2 * Copyright (C) 1996, 97, 98, 99, 2000 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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_addpath.h"
69 #include "bgpd/bgp_mac.h"
70 #include "bgpd/bgp_flowspec.h"
72 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
75 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
76 { .val_long
= true, .match_profile
= "datacenter", },
77 { .val_long
= false },
79 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
80 { .val_long
= true, .match_profile
= "datacenter", },
81 { .val_long
= false },
83 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
84 { .val_long
= true, .match_profile
= "datacenter", },
85 { .val_long
= false },
87 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
88 { .val_long
= true, .match_profile
= "datacenter", },
89 { .val_long
= false },
91 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
92 { .val_ulong
= 10, .match_profile
= "datacenter", },
95 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
96 { .val_ulong
= 9, .match_profile
= "datacenter", },
99 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
100 { .val_ulong
= 3, .match_profile
= "datacenter", },
104 DEFINE_HOOK(bgp_inst_config_write
,
105 (struct bgp
*bgp
, struct vty
*vty
),
109 "The Graceful Restart No Operation was executed as cmd same as previous one."
111 "The Graceful Restart command used is not valid at this moment."
112 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
113 struct prefix
*range
, int exact
);
115 /* Show BGP peer's information. */
125 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
126 struct prefix
*range
, int exact
);
128 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
133 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
136 afi_t afi
, bool use_json
);
138 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
144 return BGP_IPV4_NODE
;
146 return BGP_IPV4M_NODE
;
147 case SAFI_LABELED_UNICAST
:
148 return BGP_IPV4L_NODE
;
150 return BGP_VPNV4_NODE
;
152 return BGP_FLOWSPECV4_NODE
;
155 return BGP_IPV4_NODE
;
161 return BGP_IPV6_NODE
;
163 return BGP_IPV6M_NODE
;
164 case SAFI_LABELED_UNICAST
:
165 return BGP_IPV6L_NODE
;
167 return BGP_VPNV6_NODE
;
169 return BGP_FLOWSPECV6_NODE
;
172 return BGP_IPV4_NODE
;
176 return BGP_EVPN_NODE
;
179 // We should never be here but to clarify the switch statement..
180 return BGP_IPV4_NODE
;
183 // Impossible to happen
184 return BGP_IPV4_NODE
;
187 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
189 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
190 return "IPv4 Unicast";
191 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
192 return "IPv4 Multicast";
193 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
194 return "IPv4 Labeled Unicast";
195 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
197 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
199 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
200 return "IPv4 Flowspec";
201 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
202 return "IPv6 Unicast";
203 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
204 return "IPv6 Multicast";
205 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
206 return "IPv6 Labeled Unicast";
207 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
209 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
211 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
212 return "IPv6 Flowspec";
213 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
220 * Please note that we have intentionally camelCased
221 * the return strings here. So if you want
222 * to use this function, please ensure you
223 * are doing this within json output
225 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
227 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
228 return "ipv4Unicast";
229 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
230 return "ipv4Multicast";
231 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
232 return "ipv4LabeledUnicast";
233 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
235 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
237 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
238 return "ipv4Flowspec";
239 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
240 return "ipv6Unicast";
241 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
242 return "ipv6Multicast";
243 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
244 return "ipv6LabeledUnicast";
245 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
247 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
249 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
250 return "ipv6Flowspec";
251 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
257 /* Utility function to get address family from current node. */
258 afi_t
bgp_node_afi(struct vty
*vty
)
266 case BGP_FLOWSPECV6_NODE
:
279 /* Utility function to get subsequent address family from current
281 safi_t
bgp_node_safi(struct vty
*vty
)
287 safi
= SAFI_MPLS_VPN
;
291 safi
= SAFI_MULTICAST
;
298 safi
= SAFI_LABELED_UNICAST
;
300 case BGP_FLOWSPECV4_NODE
:
301 case BGP_FLOWSPECV6_NODE
:
302 safi
= SAFI_FLOWSPEC
;
312 * Converts an AFI in string form to afi_t
314 * @param afi string, one of
318 * @return the corresponding afi_t
320 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
322 afi_t afi
= AFI_MAX
; /* unknown */
323 if (strmatch(afi_str
, "ipv4"))
325 else if (strmatch(afi_str
, "ipv6"))
327 else if (strmatch(afi_str
, "l2vpn"))
332 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
336 if (argv_find(argv
, argc
, "ipv4", index
)) {
340 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
344 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
352 /* supports <unicast|multicast|vpn|labeled-unicast> */
353 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
355 safi_t safi
= SAFI_MAX
; /* unknown */
356 if (strmatch(safi_str
, "multicast"))
357 safi
= SAFI_MULTICAST
;
358 else if (strmatch(safi_str
, "unicast"))
360 else if (strmatch(safi_str
, "vpn"))
361 safi
= SAFI_MPLS_VPN
;
362 else if (strmatch(safi_str
, "evpn"))
364 else if (strmatch(safi_str
, "labeled-unicast"))
365 safi
= SAFI_LABELED_UNICAST
;
366 else if (strmatch(safi_str
, "flowspec"))
367 safi
= SAFI_FLOWSPEC
;
371 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
375 if (argv_find(argv
, argc
, "unicast", index
)) {
378 *safi
= SAFI_UNICAST
;
379 } else if (argv_find(argv
, argc
, "multicast", index
)) {
382 *safi
= SAFI_MULTICAST
;
383 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
386 *safi
= SAFI_LABELED_UNICAST
;
387 } else if (argv_find(argv
, argc
, "vpn", index
)) {
390 *safi
= SAFI_MPLS_VPN
;
391 } else if (argv_find(argv
, argc
, "evpn", index
)) {
395 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
398 *safi
= SAFI_FLOWSPEC
;
403 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
404 enum bgp_instance_type inst_type
)
406 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
408 if (ret
== BGP_CREATED
) {
409 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
410 DFLT_BGP_CONNECT_RETRY
);
412 if (DFLT_BGP_IMPORT_CHECK
)
413 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
414 if (DFLT_BGP_SHOW_HOSTNAME
)
415 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
416 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
417 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
418 if (DFLT_BGP_DETERMINISTIC_MED
)
419 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
427 * bgp_vty_find_and_parse_afi_safi_bgp
429 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
430 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
431 * to appropriate values for the calling function. This is to allow the
432 * calling function to make decisions appropriate for the show command
433 * that is being parsed.
435 * The show commands are generally of the form:
436 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
437 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
439 * Since we use argv_find if the show command in particular doesn't have:
441 * [<view|vrf> VIEWVRFNAME]
442 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
443 * The command parsing should still be ok.
445 * vty -> The vty for the command so we can output some useful data in
446 * the event of a parse error in the vrf.
447 * argv -> The command tokens
448 * argc -> How many command tokens we have
449 * idx -> The current place in the command, generally should be 0 for this
451 * afi -> The parsed afi if it was included in the show command, returned here
452 * safi -> The parsed safi if it was included in the show command, returned here
453 * bgp -> Pointer to the bgp data structure we need to fill in.
454 * use_json -> json is configured or not
456 * The function returns the correct location in the parse tree for the
459 * Returns 0 for failure to parse correctly, else the idx position of where
460 * it found the last token.
462 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
463 struct cmd_token
**argv
, int argc
,
464 int *idx
, afi_t
*afi
, safi_t
*safi
,
465 struct bgp
**bgp
, bool use_json
)
467 char *vrf_name
= NULL
;
473 if (argv_find(argv
, argc
, "ip", idx
))
476 if (argv_find(argv
, argc
, "view", idx
))
477 vrf_name
= argv
[*idx
+ 1]->arg
;
478 else if (argv_find(argv
, argc
, "vrf", idx
)) {
479 vrf_name
= argv
[*idx
+ 1]->arg
;
480 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
484 if (strmatch(vrf_name
, "all"))
487 *bgp
= bgp_lookup_by_name(vrf_name
);
490 json_object
*json
= NULL
;
491 json
= json_object_new_object();
492 json_object_string_add(
494 "View/Vrf is unknown");
496 json_object_to_json_string_ext(json
,
497 JSON_C_TO_STRING_PRETTY
));
498 json_object_free(json
);
501 vty_out(vty
, "View/Vrf %s is unknown\n",
508 *bgp
= bgp_get_default();
511 json_object
*json
= NULL
;
512 json
= json_object_new_object();
513 json_object_string_add(
515 "Default BGP instance not found");
517 json_object_to_json_string_ext(json
,
518 JSON_C_TO_STRING_PRETTY
));
519 json_object_free(json
);
523 "Default BGP instance not found\n");
529 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
530 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
536 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
538 struct interface
*ifp
= NULL
;
540 if (su
->sa
.sa_family
== AF_INET
)
541 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
542 else if (su
->sa
.sa_family
== AF_INET6
)
543 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
544 su
->sin6
.sin6_scope_id
,
553 /* Utility function for looking up peer from VTY. */
554 /* This is used only for configuration, so disallow if attempted on
555 * a dynamic neighbor.
557 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
559 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
568 ret
= str2sockunion(ip_str
, &su
);
570 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
572 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
575 "%% Malformed address or name: %s\n",
581 peer
= peer_lookup(bgp
, &su
);
584 "%% Specify remote-as or peer-group commands first\n");
587 if (peer_dynamic_neighbor(peer
)) {
589 "%% Operation not allowed on a dynamic neighbor\n");
596 /* Utility function for looking up peer or peer group. */
597 /* This is used only for configuration, so disallow if attempted on
598 * a dynamic neighbor.
600 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
602 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
605 struct peer
*peer
= NULL
;
606 struct peer_group
*group
= NULL
;
612 ret
= str2sockunion(peer_str
, &su
);
614 /* IP address, locate peer. */
615 peer
= peer_lookup(bgp
, &su
);
617 /* Not IP, could match either peer configured on interface or a
619 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
621 group
= peer_group_lookup(bgp
, peer_str
);
625 if (peer_dynamic_neighbor(peer
)) {
627 "%% Operation not allowed on a dynamic neighbor\n");
637 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
642 int bgp_vty_return(struct vty
*vty
, int ret
)
644 const char *str
= NULL
;
647 case BGP_ERR_INVALID_VALUE
:
648 str
= "Invalid value";
650 case BGP_ERR_INVALID_FLAG
:
651 str
= "Invalid flag";
653 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
654 str
= "Peer-group has been shutdown. Activate the peer-group first";
656 case BGP_ERR_PEER_FLAG_CONFLICT
:
657 str
= "Can't set override-capability and strict-capability-match at the same time";
659 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
660 str
= "Specify remote-as or peer-group remote AS first";
662 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
663 str
= "Cannot change the peer-group. Deconfigure first";
665 case BGP_ERR_PEER_GROUP_MISMATCH
:
666 str
= "Peer is not a member of this peer-group";
668 case BGP_ERR_PEER_FILTER_CONFLICT
:
669 str
= "Prefix/distribute list can not co-exist";
671 case BGP_ERR_NOT_INTERNAL_PEER
:
672 str
= "Invalid command. Not an internal neighbor";
674 case BGP_ERR_REMOVE_PRIVATE_AS
:
675 str
= "remove-private-AS cannot be configured for IBGP peers";
677 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
678 str
= "Local-AS allowed only for EBGP peers";
680 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
681 str
= "Cannot have local-as same as BGP AS number";
683 case BGP_ERR_TCPSIG_FAILED
:
684 str
= "Error while applying TCP-Sig to session(s)";
686 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
687 str
= "ebgp-multihop and ttl-security cannot be configured together";
689 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
690 str
= "ttl-security only allowed for EBGP peers";
692 case BGP_ERR_AS_OVERRIDE
:
693 str
= "as-override cannot be configured for IBGP peers";
695 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
696 str
= "Invalid limit for number of dynamic neighbors";
698 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
699 str
= "Dynamic neighbor listen range already exists";
701 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
702 str
= "Operation not allowed on a dynamic neighbor";
704 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
705 str
= "Operation not allowed on a directly connected neighbor";
707 case BGP_ERR_PEER_SAFI_CONFLICT
:
710 case BGP_ERR_GR_INVALID_CMD
:
711 str
= "The Graceful Restart command used is not valid at this moment.";
713 case BGP_ERR_GR_OPERATION_FAILED
:
714 str
= "The Graceful Restart Operation failed due to an err.";
716 case BGP_GR_NO_OPERATION
:
721 vty_out(vty
, "%% %s\n", str
);
722 return CMD_WARNING_CONFIG_FAILED
;
727 /* BGP clear sort. */
736 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
737 safi_t safi
, int error
)
740 case BGP_ERR_AF_UNCONFIGURED
:
742 "%%BGP: Enable %s address family for the neighbor %s\n",
743 get_afi_safi_str(afi
, safi
, false), peer
->host
);
745 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
747 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
755 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
756 struct listnode
**nnode
, enum bgp_clear_type stype
)
760 /* if afi/.safi not specified, spin thru all of them */
761 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
765 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
766 if (!peer
->afc
[tmp_afi
][tmp_safi
])
769 if (stype
== BGP_CLEAR_SOFT_NONE
)
770 ret
= peer_clear(peer
, nnode
);
772 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
775 /* if afi specified and safi not, spin thru safis on this afi */
776 } else if (safi
== SAFI_UNSPEC
) {
779 for (tmp_safi
= SAFI_UNICAST
;
780 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
781 if (!peer
->afc
[afi
][tmp_safi
])
784 if (stype
== BGP_CLEAR_SOFT_NONE
)
785 ret
= peer_clear(peer
, nnode
);
787 ret
= peer_clear_soft(peer
, afi
,
790 /* both afi/safi specified, let the caller know if not defined */
792 if (!peer
->afc
[afi
][safi
])
795 if (stype
== BGP_CLEAR_SOFT_NONE
)
796 ret
= peer_clear(peer
, nnode
);
798 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
804 /* `clear ip bgp' functions. */
805 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
806 enum clear_sort sort
, enum bgp_clear_type stype
,
813 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
815 /* Clear all neighbors. */
817 * Pass along pointer to next node to peer_clear() when walking all
818 * nodes on the BGP instance as that may get freed if it is a
821 if (sort
== clear_all
) {
822 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
824 bgp_peer_gr_flags_update(peer
);
826 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
827 gr_router_detected
= true;
829 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
833 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
836 if (gr_router_detected
837 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
838 bgp_zebra_send_capabilities(bgp
, false);
839 } else if (!gr_router_detected
840 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
841 bgp_zebra_send_capabilities(bgp
, true);
844 /* This is to apply read-only mode on this clear. */
845 if (stype
== BGP_CLEAR_SOFT_NONE
)
846 bgp
->update_delay_over
= 0;
851 /* Clear specified neighbor. */
852 if (sort
== clear_peer
) {
855 /* Make sockunion for lookup. */
856 ret
= str2sockunion(arg
, &su
);
858 peer
= peer_lookup_by_conf_if(bgp
, arg
);
860 peer
= peer_lookup_by_hostname(bgp
, arg
);
863 "Malformed address or name: %s\n",
869 peer
= peer_lookup(bgp
, &su
);
872 "%%BGP: Unknown neighbor - \"%s\"\n",
878 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
879 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
881 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
883 /* if afi/safi not defined for this peer, let caller know */
885 ret
= BGP_ERR_AF_UNCONFIGURED
;
888 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
893 /* Clear all neighbors belonging to a specific peer-group. */
894 if (sort
== clear_group
) {
895 struct peer_group
*group
;
897 group
= peer_group_lookup(bgp
, arg
);
899 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
903 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
904 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
907 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
914 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
915 get_afi_safi_str(afi
, safi
, false), arg
);
920 /* Clear all external (eBGP) neighbors. */
921 if (sort
== clear_external
) {
922 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
923 if (peer
->sort
== BGP_PEER_IBGP
)
926 bgp_peer_gr_flags_update(peer
);
928 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
929 gr_router_detected
= true;
931 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
934 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
939 if (gr_router_detected
940 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
941 bgp_zebra_send_capabilities(bgp
, false);
942 } else if (!gr_router_detected
943 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
944 bgp_zebra_send_capabilities(bgp
, true);
949 "%%BGP: No external %s peer is configured\n",
950 get_afi_safi_str(afi
, safi
, false));
955 /* Clear all neighbors belonging to a specific AS. */
956 if (sort
== clear_as
) {
957 as_t as
= strtoul(arg
, NULL
, 10);
959 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
963 bgp_peer_gr_flags_update(peer
);
965 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
966 gr_router_detected
= true;
968 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
971 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
976 if (gr_router_detected
977 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
978 bgp_zebra_send_capabilities(bgp
, false);
979 } else if (!gr_router_detected
980 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
981 bgp_zebra_send_capabilities(bgp
, true);
986 "%%BGP: No %s peer is configured with AS %s\n",
987 get_afi_safi_str(afi
, safi
, false), arg
);
995 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
996 safi_t safi
, enum clear_sort sort
,
997 enum bgp_clear_type stype
, const char *arg
)
1001 /* BGP structure lookup. */
1003 bgp
= bgp_lookup_by_name(name
);
1005 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1009 bgp
= bgp_get_default();
1011 vty_out(vty
, "No BGP process is configured\n");
1016 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1019 /* clear soft inbound */
1020 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1025 FOREACH_AFI_SAFI (afi
, safi
)
1026 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1027 BGP_CLEAR_SOFT_IN
, NULL
);
1030 /* clear soft outbound */
1031 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1036 FOREACH_AFI_SAFI (afi
, safi
)
1037 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1038 BGP_CLEAR_SOFT_OUT
, NULL
);
1042 #ifndef VTYSH_EXTRACT_PL
1043 #include "bgpd/bgp_vty_clippy.c"
1046 DEFUN_HIDDEN (bgp_local_mac
,
1048 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1050 "Local MAC config\n"
1051 "VxLAN Network Identifier\n"
1055 "mac-mobility sequence\n"
1065 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1066 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1067 vty_out(vty
, "%% Malformed MAC address\n");
1070 memset(&ip
, 0, sizeof(ip
));
1071 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1073 bgp
= bgp_get_default();
1075 vty_out(vty
, "Default BGP instance is not there\n");
1079 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
1081 vty_out(vty
, "Internal error\n");
1088 DEFUN_HIDDEN (no_bgp_local_mac
,
1089 no_bgp_local_mac_cmd
,
1090 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1093 "Local MAC config\n"
1094 "VxLAN Network Identifier\n"
1105 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1106 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1107 vty_out(vty
, "%% Malformed MAC address\n");
1110 memset(&ip
, 0, sizeof(ip
));
1112 bgp
= bgp_get_default();
1114 vty_out(vty
, "Default BGP instance is not there\n");
1118 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1120 vty_out(vty
, "Internal error\n");
1127 DEFUN (no_synchronization
,
1128 no_synchronization_cmd
,
1129 "no synchronization",
1131 "Perform IGP synchronization\n")
1136 DEFUN (no_auto_summary
,
1137 no_auto_summary_cmd
,
1140 "Enable automatic network number summarization\n")
1145 /* "router bgp" commands. */
1146 DEFUN_NOSH (router_bgp
,
1148 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1152 BGP_INSTANCE_HELP_STR
)
1155 int idx_view_vrf
= 3;
1161 const char *name
= NULL
;
1162 enum bgp_instance_type inst_type
;
1164 // "router bgp" without an ASN
1166 // Pending: Make VRF option available for ASN less config
1167 bgp
= bgp_get_default();
1170 vty_out(vty
, "%% No BGP process is configured\n");
1171 return CMD_WARNING_CONFIG_FAILED
;
1174 if (listcount(bm
->bgp
) > 1) {
1175 vty_out(vty
, "%% Please specify ASN and VRF\n");
1176 return CMD_WARNING_CONFIG_FAILED
;
1182 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1184 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1186 name
= argv
[idx_vrf
]->arg
;
1188 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1189 if (strmatch(name
, VRF_DEFAULT_NAME
))
1192 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1193 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1194 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1197 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1198 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1200 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1202 case BGP_ERR_AS_MISMATCH
:
1203 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1204 return CMD_WARNING_CONFIG_FAILED
;
1205 case BGP_ERR_INSTANCE_MISMATCH
:
1207 "BGP instance name and AS number mismatch\n");
1209 "BGP instance is already running; AS is %u\n",
1211 return CMD_WARNING_CONFIG_FAILED
;
1215 * If we just instantiated the default instance, complete
1216 * any pending VRF-VPN leaking that was configured via
1217 * earlier "router bgp X vrf FOO" blocks.
1219 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1220 vpn_leak_postchange_all();
1222 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1223 bgp_vpn_leak_export(bgp
);
1224 /* Pending: handle when user tries to change a view to vrf n vv.
1228 /* unset the auto created flag as the user config is now present */
1229 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1230 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1235 /* "no router bgp" commands. */
1236 DEFUN (no_router_bgp
,
1238 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1243 BGP_INSTANCE_HELP_STR
)
1249 const char *name
= NULL
;
1251 // "no router bgp" without an ASN
1253 // Pending: Make VRF option available for ASN less config
1254 bgp
= bgp_get_default();
1257 vty_out(vty
, "%% No BGP process is configured\n");
1258 return CMD_WARNING_CONFIG_FAILED
;
1261 if (listcount(bm
->bgp
) > 1) {
1262 vty_out(vty
, "%% Please specify ASN and VRF\n");
1263 return CMD_WARNING_CONFIG_FAILED
;
1267 vty_out(vty
, "%% Please unconfigure l3vni %u",
1269 return CMD_WARNING_CONFIG_FAILED
;
1272 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1275 name
= argv
[idx_vrf
]->arg
;
1277 /* Lookup bgp structure. */
1278 bgp
= bgp_lookup(as
, name
);
1280 vty_out(vty
, "%% Can't find BGP instance\n");
1281 return CMD_WARNING_CONFIG_FAILED
;
1285 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1287 return CMD_WARNING_CONFIG_FAILED
;
1290 /* Cannot delete default instance if vrf instances exist */
1291 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1292 struct listnode
*node
;
1293 struct bgp
*tmp_bgp
;
1295 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1296 if (tmp_bgp
->inst_type
1297 == BGP_INSTANCE_TYPE_VRF
) {
1299 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1300 return CMD_WARNING_CONFIG_FAILED
;
1306 if (bgp_vpn_leak_unimport(bgp
, vty
))
1307 return CMD_WARNING_CONFIG_FAILED
;
1315 /* BGP router-id. */
1317 DEFPY (bgp_router_id
,
1319 "bgp router-id A.B.C.D",
1321 "Override configured router identifier\n"
1322 "Manually configured router identifier\n")
1324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1325 bgp_router_id_static_set(bgp
, router_id
);
1329 DEFPY (no_bgp_router_id
,
1330 no_bgp_router_id_cmd
,
1331 "no bgp router-id [A.B.C.D]",
1334 "Override configured router identifier\n"
1335 "Manually configured router identifier\n")
1337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1339 if (router_id_str
) {
1340 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1341 vty_out(vty
, "%% BGP router-id doesn't match\n");
1342 return CMD_WARNING_CONFIG_FAILED
;
1346 router_id
.s_addr
= 0;
1347 bgp_router_id_static_set(bgp
, router_id
);
1353 /* BGP Cluster ID. */
1354 DEFUN (bgp_cluster_id
,
1356 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1358 "Configure Route-Reflector Cluster-id\n"
1359 "Route-Reflector Cluster-id in IP address format\n"
1360 "Route-Reflector Cluster-id as 32 bit quantity\n")
1362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1365 struct in_addr cluster
;
1367 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1369 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1370 return CMD_WARNING_CONFIG_FAILED
;
1373 bgp_cluster_id_set(bgp
, &cluster
);
1374 bgp_clear_star_soft_out(vty
, bgp
->name
);
1379 DEFUN (no_bgp_cluster_id
,
1380 no_bgp_cluster_id_cmd
,
1381 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1384 "Configure Route-Reflector Cluster-id\n"
1385 "Route-Reflector Cluster-id in IP address format\n"
1386 "Route-Reflector Cluster-id as 32 bit quantity\n")
1388 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1389 bgp_cluster_id_unset(bgp
);
1390 bgp_clear_star_soft_out(vty
, bgp
->name
);
1395 DEFUN (bgp_confederation_identifier
,
1396 bgp_confederation_identifier_cmd
,
1397 "bgp confederation identifier (1-4294967295)",
1398 "BGP specific commands\n"
1399 "AS confederation parameters\n"
1401 "Set routing domain confederation AS\n")
1403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1407 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1409 bgp_confederation_id_set(bgp
, as
);
1414 DEFUN (no_bgp_confederation_identifier
,
1415 no_bgp_confederation_identifier_cmd
,
1416 "no bgp confederation identifier [(1-4294967295)]",
1418 "BGP specific commands\n"
1419 "AS confederation parameters\n"
1421 "Set routing domain confederation AS\n")
1423 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1424 bgp_confederation_id_unset(bgp
);
1429 DEFUN (bgp_confederation_peers
,
1430 bgp_confederation_peers_cmd
,
1431 "bgp confederation peers (1-4294967295)...",
1432 "BGP specific commands\n"
1433 "AS confederation parameters\n"
1434 "Peer ASs in BGP confederation\n"
1437 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1442 for (i
= idx_asn
; i
< argc
; i
++) {
1443 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1445 if (bgp
->as
== as
) {
1447 "%% Local member-AS not allowed in confed peer list\n");
1451 bgp_confederation_peers_add(bgp
, as
);
1456 DEFUN (no_bgp_confederation_peers
,
1457 no_bgp_confederation_peers_cmd
,
1458 "no bgp confederation peers (1-4294967295)...",
1460 "BGP specific commands\n"
1461 "AS confederation parameters\n"
1462 "Peer ASs in BGP confederation\n"
1465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1470 for (i
= idx_asn
; i
< argc
; i
++) {
1471 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1473 bgp_confederation_peers_remove(bgp
, as
);
1479 * Central routine for maximum-paths configuration.
1480 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1481 * @set: 1 for setting values, 0 for removing the max-paths config.
1483 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1484 const char *mpaths
, uint16_t options
,
1487 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1488 uint16_t maxpaths
= 0;
1493 afi
= bgp_node_afi(vty
);
1494 safi
= bgp_node_safi(vty
);
1497 maxpaths
= strtol(mpaths
, NULL
, 10);
1498 if (maxpaths
> multipath_num
) {
1500 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1501 maxpaths
, multipath_num
);
1502 return CMD_WARNING_CONFIG_FAILED
;
1504 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1507 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1511 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1512 (set
== 1) ? "" : "un",
1513 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1514 maxpaths
, afi
, safi
);
1515 return CMD_WARNING_CONFIG_FAILED
;
1518 bgp_recalculate_all_bestpaths(bgp
);
1523 DEFUN (bgp_maxmed_admin
,
1524 bgp_maxmed_admin_cmd
,
1525 "bgp max-med administrative ",
1527 "Advertise routes with max-med\n"
1528 "Administratively applied, for an indefinite period\n")
1530 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1532 bgp
->v_maxmed_admin
= 1;
1533 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1535 bgp_maxmed_update(bgp
);
1540 DEFUN (bgp_maxmed_admin_medv
,
1541 bgp_maxmed_admin_medv_cmd
,
1542 "bgp max-med administrative (0-4294967295)",
1544 "Advertise routes with max-med\n"
1545 "Administratively applied, for an indefinite period\n"
1546 "Max MED value to be used\n")
1548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1551 bgp
->v_maxmed_admin
= 1;
1552 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1554 bgp_maxmed_update(bgp
);
1559 DEFUN (no_bgp_maxmed_admin
,
1560 no_bgp_maxmed_admin_cmd
,
1561 "no bgp max-med administrative [(0-4294967295)]",
1564 "Advertise routes with max-med\n"
1565 "Administratively applied, for an indefinite period\n"
1566 "Max MED value to be used\n")
1568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1569 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1570 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1571 bgp_maxmed_update(bgp
);
1576 DEFUN (bgp_maxmed_onstartup
,
1577 bgp_maxmed_onstartup_cmd
,
1578 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1580 "Advertise routes with max-med\n"
1581 "Effective on a startup\n"
1582 "Time (seconds) period for max-med\n"
1583 "Max MED value to be used\n")
1585 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1588 argv_find(argv
, argc
, "(5-86400)", &idx
);
1589 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1590 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1591 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1593 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1595 bgp_maxmed_update(bgp
);
1600 DEFUN (no_bgp_maxmed_onstartup
,
1601 no_bgp_maxmed_onstartup_cmd
,
1602 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1605 "Advertise routes with max-med\n"
1606 "Effective on a startup\n"
1607 "Time (seconds) period for max-med\n"
1608 "Max MED value to be used\n")
1610 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1612 /* Cancel max-med onstartup if its on */
1613 if (bgp
->t_maxmed_onstartup
) {
1614 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1615 bgp
->maxmed_onstartup_over
= 1;
1618 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1619 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1621 bgp_maxmed_update(bgp
);
1626 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1630 uint16_t update_delay
;
1631 uint16_t establish_wait
;
1633 update_delay
= strtoul(delay
, NULL
, 10);
1635 if (!wait
) /* update-delay <delay> */
1637 bgp
->v_update_delay
= update_delay
;
1638 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1642 /* update-delay <delay> <establish-wait> */
1643 establish_wait
= atoi(wait
);
1644 if (update_delay
< establish_wait
) {
1646 "%%Failed: update-delay less than the establish-wait!\n");
1647 return CMD_WARNING_CONFIG_FAILED
;
1650 bgp
->v_update_delay
= update_delay
;
1651 bgp
->v_establish_wait
= establish_wait
;
1656 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1660 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1661 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1666 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1668 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1669 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1670 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1671 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1677 /* Update-delay configuration */
1678 DEFUN (bgp_update_delay
,
1679 bgp_update_delay_cmd
,
1680 "update-delay (0-3600)",
1681 "Force initial delay for best-path and updates\n"
1685 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1688 DEFUN (bgp_update_delay_establish_wait
,
1689 bgp_update_delay_establish_wait_cmd
,
1690 "update-delay (0-3600) (1-3600)",
1691 "Force initial delay for best-path and updates\n"
1696 int idx_number_2
= 2;
1697 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1698 argv
[idx_number_2
]->arg
);
1701 /* Update-delay deconfiguration */
1702 DEFUN (no_bgp_update_delay
,
1703 no_bgp_update_delay_cmd
,
1704 "no update-delay [(0-3600) [(1-3600)]]",
1706 "Force initial delay for best-path and updates\n"
1710 return bgp_update_delay_deconfig_vty(vty
);
1714 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1719 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1720 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1725 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1730 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1731 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1736 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1739 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1740 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1741 vty_out(vty
, " write-quanta %d\n", quanta
);
1744 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1747 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1748 if (quanta
!= BGP_READ_PACKET_MAX
)
1749 vty_out(vty
, " read-quanta %d\n", quanta
);
1752 /* Packet quanta configuration
1754 * XXX: The value set here controls the size of a stack buffer in the IO
1755 * thread. When changing these limits be careful to prevent stack overflow.
1757 * Furthermore, the maximums used here should correspond to
1758 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1760 DEFPY (bgp_wpkt_quanta
,
1761 bgp_wpkt_quanta_cmd
,
1762 "[no] write-quanta (1-64)$quanta",
1764 "How many packets to write to peer socket per run\n"
1765 "Number of packets\n")
1767 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1770 DEFPY (bgp_rpkt_quanta
,
1771 bgp_rpkt_quanta_cmd
,
1772 "[no] read-quanta (1-10)$quanta",
1774 "How many packets to read from peer socket per I/O cycle\n"
1775 "Number of packets\n")
1777 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1780 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1782 if (!bgp
->heuristic_coalesce
)
1783 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1787 DEFUN (bgp_coalesce_time
,
1788 bgp_coalesce_time_cmd
,
1789 "coalesce-time (0-4294967295)",
1790 "Subgroup coalesce timer\n"
1791 "Subgroup coalesce timer value (in ms)\n")
1793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1796 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1797 bgp
->heuristic_coalesce
= false;
1798 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1802 DEFUN (no_bgp_coalesce_time
,
1803 no_bgp_coalesce_time_cmd
,
1804 "no coalesce-time (0-4294967295)",
1806 "Subgroup coalesce timer\n"
1807 "Subgroup coalesce timer value (in ms)\n")
1809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1811 bgp
->heuristic_coalesce
= true;
1812 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1816 /* Maximum-paths configuration */
1817 DEFUN (bgp_maxpaths
,
1819 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1820 "Forward packets over multiple paths\n"
1821 "Number of paths\n")
1824 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1825 argv
[idx_number
]->arg
, 0, 1);
1828 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1829 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1830 "Forward packets over multiple paths\n"
1831 "Number of paths\n")
1833 DEFUN (bgp_maxpaths_ibgp
,
1834 bgp_maxpaths_ibgp_cmd
,
1835 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1836 "Forward packets over multiple paths\n"
1838 "Number of paths\n")
1841 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1842 argv
[idx_number
]->arg
, 0, 1);
1845 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1846 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1847 "Forward packets over multiple paths\n"
1849 "Number of paths\n")
1851 DEFUN (bgp_maxpaths_ibgp_cluster
,
1852 bgp_maxpaths_ibgp_cluster_cmd
,
1853 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1854 "Forward packets over multiple paths\n"
1857 "Match the cluster length\n")
1860 return bgp_maxpaths_config_vty(
1861 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1862 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1865 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1866 "maximum-paths ibgp " CMD_RANGE_STR(
1867 1, MULTIPATH_NUM
) " equal-cluster-length",
1868 "Forward packets over multiple paths\n"
1871 "Match the cluster length\n")
1873 DEFUN (no_bgp_maxpaths
,
1874 no_bgp_maxpaths_cmd
,
1875 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1877 "Forward packets over multiple paths\n"
1878 "Number of paths\n")
1880 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1883 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1884 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1885 "Forward packets over multiple paths\n"
1886 "Number of paths\n")
1888 DEFUN (no_bgp_maxpaths_ibgp
,
1889 no_bgp_maxpaths_ibgp_cmd
,
1890 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1892 "Forward packets over multiple paths\n"
1895 "Match the cluster length\n")
1897 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1900 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1901 "no maximum-paths ibgp [" CMD_RANGE_STR(
1902 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1904 "Forward packets over multiple paths\n"
1907 "Match the cluster length\n")
1909 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
1910 afi_t afi
, safi_t safi
)
1912 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1913 vty_out(vty
, " maximum-paths %d\n",
1914 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1917 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1918 vty_out(vty
, " maximum-paths ibgp %d",
1919 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1920 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1921 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1922 vty_out(vty
, " equal-cluster-length");
1931 "timers bgp (0-65535) (0-65535)",
1932 "Adjust routing timers\n"
1934 "Keepalive interval\n"
1937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1939 int idx_number_2
= 3;
1940 unsigned long keepalive
= 0;
1941 unsigned long holdtime
= 0;
1943 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1944 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1946 /* Holdtime value check. */
1947 if (holdtime
< 3 && holdtime
!= 0) {
1949 "%% hold time value must be either 0 or greater than 3\n");
1950 return CMD_WARNING_CONFIG_FAILED
;
1953 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
);
1958 DEFUN (no_bgp_timers
,
1960 "no timers bgp [(0-65535) (0-65535)]",
1962 "Adjust routing timers\n"
1964 "Keepalive interval\n"
1967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1968 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
1969 DFLT_BGP_CONNECT_RETRY
);
1975 DEFUN (bgp_client_to_client_reflection
,
1976 bgp_client_to_client_reflection_cmd
,
1977 "bgp client-to-client reflection",
1978 "BGP specific commands\n"
1979 "Configure client to client route reflection\n"
1980 "reflection of routes allowed\n")
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1983 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1984 bgp_clear_star_soft_out(vty
, bgp
->name
);
1989 DEFUN (no_bgp_client_to_client_reflection
,
1990 no_bgp_client_to_client_reflection_cmd
,
1991 "no bgp client-to-client reflection",
1993 "BGP specific commands\n"
1994 "Configure client to client route reflection\n"
1995 "reflection of routes allowed\n")
1997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1999 bgp_clear_star_soft_out(vty
, bgp
->name
);
2004 /* "bgp always-compare-med" configuration. */
2005 DEFUN (bgp_always_compare_med
,
2006 bgp_always_compare_med_cmd
,
2007 "bgp always-compare-med",
2008 "BGP specific commands\n"
2009 "Allow comparing MED from different neighbors\n")
2011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2012 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2013 bgp_recalculate_all_bestpaths(bgp
);
2018 DEFUN (no_bgp_always_compare_med
,
2019 no_bgp_always_compare_med_cmd
,
2020 "no bgp always-compare-med",
2022 "BGP specific commands\n"
2023 "Allow comparing MED from different neighbors\n")
2025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2026 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2027 bgp_recalculate_all_bestpaths(bgp
);
2033 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2034 "bgp ebgp-requires-policy",
2035 "BGP specific commands\n"
2036 "Require in and out policy for eBGP peers (RFC8212)\n")
2038 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2039 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
2043 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2044 "no bgp ebgp-requires-policy",
2046 "BGP specific commands\n"
2047 "Require in and out policy for eBGP peers (RFC8212)\n")
2049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2050 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
2054 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2055 "bgp reject-as-sets",
2056 "BGP specific commands\n"
2057 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 struct listnode
*node
, *nnode
;
2063 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_ENABLED
;
2065 /* Reset existing BGP sessions to reject routes
2066 * with aspath containing AS_SET or AS_CONFED_SET.
2068 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2069 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2070 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2071 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2072 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2079 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2080 "no bgp reject-as-sets",
2082 "BGP specific commands\n"
2083 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2086 struct listnode
*node
, *nnode
;
2089 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_DISABLED
;
2091 /* Reset existing BGP sessions to reject routes
2092 * with aspath containing AS_SET or AS_CONFED_SET.
2094 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2095 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2096 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2097 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2098 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2105 /* "bgp deterministic-med" configuration. */
2106 DEFUN (bgp_deterministic_med
,
2107 bgp_deterministic_med_cmd
,
2108 "bgp deterministic-med",
2109 "BGP specific commands\n"
2110 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2114 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2115 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2116 bgp_recalculate_all_bestpaths(bgp
);
2122 DEFUN (no_bgp_deterministic_med
,
2123 no_bgp_deterministic_med_cmd
,
2124 "no bgp deterministic-med",
2126 "BGP specific commands\n"
2127 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2130 int bestpath_per_as_used
;
2134 struct listnode
*node
, *nnode
;
2136 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2137 bestpath_per_as_used
= 0;
2139 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2140 FOREACH_AFI_SAFI (afi
, safi
)
2141 if (bgp_addpath_dmed_required(
2142 peer
->addpath_type
[afi
][safi
])) {
2143 bestpath_per_as_used
= 1;
2147 if (bestpath_per_as_used
)
2151 if (bestpath_per_as_used
) {
2153 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2154 return CMD_WARNING_CONFIG_FAILED
;
2156 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2157 bgp_recalculate_all_bestpaths(bgp
);
2164 /* "bgp graceful-restart mode" configuration. */
2165 DEFUN (bgp_graceful_restart
,
2166 bgp_graceful_restart_cmd
,
2167 "bgp graceful-restart",
2168 "BGP specific commands\n"
2172 int ret
= BGP_GR_FAILURE
;
2174 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2175 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2179 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2181 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2184 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2185 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2187 "Graceful restart configuration changed, reset all peers to take effect\n");
2188 return bgp_vty_return(vty
, ret
);
2191 DEFUN (no_bgp_graceful_restart
,
2192 no_bgp_graceful_restart_cmd
,
2193 "no bgp graceful-restart",
2195 "BGP specific commands\n"
2199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2201 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2202 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2204 int ret
= BGP_GR_FAILURE
;
2206 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2208 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2211 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2212 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2214 "Graceful restart configuration changed, reset all peers to take effect\n");
2216 return bgp_vty_return(vty
, ret
);
2219 DEFUN (bgp_graceful_restart_stalepath_time
,
2220 bgp_graceful_restart_stalepath_time_cmd
,
2221 "bgp graceful-restart stalepath-time (1-4095)",
2222 "BGP specific commands\n"
2223 "Graceful restart capability parameters\n"
2224 "Set the max time to hold onto restarting peer's stale paths\n"
2225 "Delay value (seconds)\n")
2227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2231 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2232 bgp
->stalepath_time
= stalepath
;
2236 DEFUN (bgp_graceful_restart_restart_time
,
2237 bgp_graceful_restart_restart_time_cmd
,
2238 "bgp graceful-restart restart-time (1-4095)",
2239 "BGP specific commands\n"
2240 "Graceful restart capability parameters\n"
2241 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2242 "Delay value (seconds)\n")
2244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2248 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2249 bgp
->restart_time
= restart
;
2253 DEFUN (bgp_graceful_restart_select_defer_time
,
2254 bgp_graceful_restart_select_defer_time_cmd
,
2255 "bgp graceful-restart select-defer-time (0-3600)",
2256 "BGP specific commands\n"
2257 "Graceful restart capability parameters\n"
2258 "Set the time to defer the BGP route selection after restart\n"
2259 "Delay value (seconds, 0 - disable)\n")
2261 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2263 uint32_t defer_time
;
2265 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2266 bgp
->select_defer_time
= defer_time
;
2267 if (defer_time
== 0)
2268 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2270 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2275 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2276 no_bgp_graceful_restart_stalepath_time_cmd
,
2277 "no bgp graceful-restart stalepath-time [(1-4095)]",
2279 "BGP specific commands\n"
2280 "Graceful restart capability parameters\n"
2281 "Set the max time to hold onto restarting peer's stale paths\n"
2282 "Delay value (seconds)\n")
2284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2286 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2290 DEFUN (no_bgp_graceful_restart_restart_time
,
2291 no_bgp_graceful_restart_restart_time_cmd
,
2292 "no bgp graceful-restart restart-time [(1-4095)]",
2294 "BGP specific commands\n"
2295 "Graceful restart capability parameters\n"
2296 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2297 "Delay value (seconds)\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2305 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2306 no_bgp_graceful_restart_select_defer_time_cmd
,
2307 "no bgp graceful-restart select-defer-time [(0-3600)]",
2309 "BGP specific commands\n"
2310 "Graceful restart capability parameters\n"
2311 "Set the time to defer the BGP route selection after restart\n"
2312 "Delay value (seconds)\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2316 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2317 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2322 DEFUN (bgp_graceful_restart_preserve_fw
,
2323 bgp_graceful_restart_preserve_fw_cmd
,
2324 "bgp graceful-restart preserve-fw-state",
2325 "BGP specific commands\n"
2326 "Graceful restart capability parameters\n"
2327 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2330 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2334 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2335 no_bgp_graceful_restart_preserve_fw_cmd
,
2336 "no bgp graceful-restart preserve-fw-state",
2338 "BGP specific commands\n"
2339 "Graceful restart capability parameters\n"
2340 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2343 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2347 DEFUN (bgp_graceful_restart_disable
,
2348 bgp_graceful_restart_disable_cmd
,
2349 "bgp graceful-restart-disable",
2350 "BGP specific commands\n"
2353 int ret
= BGP_GR_FAILURE
;
2355 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2357 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2359 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2361 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2363 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2366 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2368 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2370 "Graceful restart configuration changed, reset all peers to take effect\n");
2372 return bgp_vty_return(vty
, ret
);
2375 DEFUN (no_bgp_graceful_restart_disable
,
2376 no_bgp_graceful_restart_disable_cmd
,
2377 "no bgp graceful-restart-disable",
2379 "BGP specific commands\n"
2383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2385 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2387 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2389 int ret
= BGP_GR_FAILURE
;
2391 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2393 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2396 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2398 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2400 "Graceful restart configuration changed, reset all peers to take effect\n");
2402 return bgp_vty_return(vty
, ret
);
2405 DEFUN (bgp_neighbor_graceful_restart_set
,
2406 bgp_neighbor_graceful_restart_set_cmd
,
2407 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2415 int ret
= BGP_GR_FAILURE
;
2417 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2419 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2421 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2423 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2425 return CMD_WARNING_CONFIG_FAILED
;
2427 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2429 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2430 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2432 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2434 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2436 "Graceful restart configuration changed, reset this peer to take effect\n");
2438 return bgp_vty_return(vty
, ret
);
2441 DEFUN (no_bgp_neighbor_graceful_restart
,
2442 no_bgp_neighbor_graceful_restart_set_cmd
,
2443 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2451 int ret
= BGP_GR_FAILURE
;
2454 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2456 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2458 return CMD_WARNING_CONFIG_FAILED
;
2460 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2462 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2464 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2466 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2467 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2469 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2471 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2473 "Graceful restart configuration changed, reset this peer to take effect\n");
2475 return bgp_vty_return(vty
, ret
);
2478 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2479 bgp_neighbor_graceful_restart_helper_set_cmd
,
2480 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2483 GR_NEIGHBOR_HELPER_CMD
2488 int ret
= BGP_GR_FAILURE
;
2490 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2492 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2494 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2496 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2499 return CMD_WARNING_CONFIG_FAILED
;
2502 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2504 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2505 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2507 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2509 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2511 "Graceful restart configuration changed, reset this peer to take effect\n");
2513 return bgp_vty_return(vty
, ret
);
2516 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2517 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2518 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2522 NO_GR_NEIGHBOR_HELPER_CMD
2526 int ret
= BGP_GR_FAILURE
;
2529 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2531 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2533 return CMD_WARNING_CONFIG_FAILED
;
2535 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2537 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2539 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
2541 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2542 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2544 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2546 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2548 "Graceful restart configuration changed, reset this peer to take effect\n");
2550 return bgp_vty_return(vty
, ret
);
2553 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
2554 bgp_neighbor_graceful_restart_disable_set_cmd
,
2555 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2558 GR_NEIGHBOR_DISABLE_CMD
2563 int ret
= BGP_GR_FAILURE
;
2565 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2567 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2569 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2571 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2573 return CMD_WARNING_CONFIG_FAILED
;
2575 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
2577 if (peer
->bgp
->t_startup
)
2578 bgp_peer_gr_flags_update(peer
);
2580 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2581 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2583 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2585 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2587 "Graceful restart configuration changed, reset this peer to take effect\n");
2589 return bgp_vty_return(vty
, ret
);
2592 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
2593 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
2594 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2598 NO_GR_NEIGHBOR_DISABLE_CMD
2602 int ret
= BGP_GR_FAILURE
;
2605 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2607 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2609 return CMD_WARNING_CONFIG_FAILED
;
2611 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2613 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2615 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
2617 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2618 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2620 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2622 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2624 "Graceful restart configuration changed, reset this peer to take effect\n");
2626 return bgp_vty_return(vty
, ret
);
2629 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
2630 bgp_graceful_restart_disable_eor_cmd
,
2631 "bgp graceful-restart disable-eor",
2632 "BGP specific commands\n"
2633 "Graceful restart configuration parameters\n"
2634 "Disable EOR Check\n")
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2637 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2642 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
2643 no_bgp_graceful_restart_disable_eor_cmd
,
2644 "no bgp graceful-restart disable-eor",
2646 "BGP specific commands\n"
2647 "Graceful restart configuration parameters\n"
2648 "Disable EOR Check\n")
2650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2651 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2656 DEFUN (bgp_graceful_restart_rib_stale_time
,
2657 bgp_graceful_restart_rib_stale_time_cmd
,
2658 "bgp graceful-restart rib-stale-time (1-3600)",
2659 "BGP specific commands\n"
2660 "Graceful restart configuration parameters\n"
2661 "Specify the stale route removal timer in rib\n"
2662 "Delay value (seconds)\n")
2664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2666 uint32_t stale_time
;
2668 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2669 bgp
->rib_stale_time
= stale_time
;
2670 /* Send the stale timer update message to RIB */
2671 if (bgp_zebra_stale_timer_update(bgp
))
2677 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
2678 no_bgp_graceful_restart_rib_stale_time_cmd
,
2679 "no bgp graceful-restart rib-stale-time [(1-3600)]",
2681 "BGP specific commands\n"
2682 "Graceful restart configuration parameters\n"
2683 "Specify the stale route removal timer in rib\n"
2684 "Delay value (seconds)\n")
2686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2688 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
2689 /* Send the stale timer update message to RIB */
2690 if (bgp_zebra_stale_timer_update(bgp
))
2696 /* "bgp graceful-shutdown" configuration */
2697 DEFUN (bgp_graceful_shutdown
,
2698 bgp_graceful_shutdown_cmd
,
2699 "bgp graceful-shutdown",
2701 "Graceful shutdown parameters\n")
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2705 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2706 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2707 bgp_static_redo_import_check(bgp
);
2708 bgp_redistribute_redo(bgp
);
2709 bgp_clear_star_soft_out(vty
, bgp
->name
);
2710 bgp_clear_star_soft_in(vty
, bgp
->name
);
2716 DEFUN (no_bgp_graceful_shutdown
,
2717 no_bgp_graceful_shutdown_cmd
,
2718 "no bgp graceful-shutdown",
2721 "Graceful shutdown parameters\n")
2723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2726 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2727 bgp_static_redo_import_check(bgp
);
2728 bgp_redistribute_redo(bgp
);
2729 bgp_clear_star_soft_out(vty
, bgp
->name
);
2730 bgp_clear_star_soft_in(vty
, bgp
->name
);
2736 /* "bgp fast-external-failover" configuration. */
2737 DEFUN (bgp_fast_external_failover
,
2738 bgp_fast_external_failover_cmd
,
2739 "bgp fast-external-failover",
2741 "Immediately reset session if a link to a directly connected external peer goes down\n")
2743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2744 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2748 DEFUN (no_bgp_fast_external_failover
,
2749 no_bgp_fast_external_failover_cmd
,
2750 "no bgp fast-external-failover",
2753 "Immediately reset session if a link to a directly connected external peer goes down\n")
2755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2756 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2760 /* "bgp bestpath compare-routerid" configuration. */
2761 DEFUN (bgp_bestpath_compare_router_id
,
2762 bgp_bestpath_compare_router_id_cmd
,
2763 "bgp bestpath compare-routerid",
2764 "BGP specific commands\n"
2765 "Change the default bestpath selection\n"
2766 "Compare router-id for identical EBGP paths\n")
2768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2769 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2770 bgp_recalculate_all_bestpaths(bgp
);
2775 DEFUN (no_bgp_bestpath_compare_router_id
,
2776 no_bgp_bestpath_compare_router_id_cmd
,
2777 "no bgp bestpath compare-routerid",
2779 "BGP specific commands\n"
2780 "Change the default bestpath selection\n"
2781 "Compare router-id for identical EBGP paths\n")
2783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2784 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2785 bgp_recalculate_all_bestpaths(bgp
);
2790 /* "bgp bestpath as-path ignore" configuration. */
2791 DEFUN (bgp_bestpath_aspath_ignore
,
2792 bgp_bestpath_aspath_ignore_cmd
,
2793 "bgp bestpath as-path ignore",
2794 "BGP specific commands\n"
2795 "Change the default bestpath selection\n"
2796 "AS-path attribute\n"
2797 "Ignore as-path length in selecting a route\n")
2799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2800 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2801 bgp_recalculate_all_bestpaths(bgp
);
2806 DEFUN (no_bgp_bestpath_aspath_ignore
,
2807 no_bgp_bestpath_aspath_ignore_cmd
,
2808 "no bgp bestpath as-path ignore",
2810 "BGP specific commands\n"
2811 "Change the default bestpath selection\n"
2812 "AS-path attribute\n"
2813 "Ignore as-path length in selecting a route\n")
2815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2816 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2817 bgp_recalculate_all_bestpaths(bgp
);
2822 /* "bgp bestpath as-path confed" configuration. */
2823 DEFUN (bgp_bestpath_aspath_confed
,
2824 bgp_bestpath_aspath_confed_cmd
,
2825 "bgp bestpath as-path confed",
2826 "BGP specific commands\n"
2827 "Change the default bestpath selection\n"
2828 "AS-path attribute\n"
2829 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2832 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2833 bgp_recalculate_all_bestpaths(bgp
);
2838 DEFUN (no_bgp_bestpath_aspath_confed
,
2839 no_bgp_bestpath_aspath_confed_cmd
,
2840 "no bgp bestpath as-path confed",
2842 "BGP specific commands\n"
2843 "Change the default bestpath selection\n"
2844 "AS-path attribute\n"
2845 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2848 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2849 bgp_recalculate_all_bestpaths(bgp
);
2854 /* "bgp bestpath as-path multipath-relax" configuration. */
2855 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2856 bgp_bestpath_aspath_multipath_relax_cmd
,
2857 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2858 "BGP specific commands\n"
2859 "Change the default bestpath selection\n"
2860 "AS-path attribute\n"
2861 "Allow load sharing across routes that have different AS paths (but same length)\n"
2862 "Generate an AS_SET\n"
2863 "Do not generate an AS_SET\n")
2865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2867 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2869 /* no-as-set is now the default behavior so we can silently
2871 if (argv_find(argv
, argc
, "as-set", &idx
))
2872 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2874 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2876 bgp_recalculate_all_bestpaths(bgp
);
2881 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2882 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2883 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2885 "BGP specific commands\n"
2886 "Change the default bestpath selection\n"
2887 "AS-path attribute\n"
2888 "Allow load sharing across routes that have different AS paths (but same length)\n"
2889 "Generate an AS_SET\n"
2890 "Do not generate an AS_SET\n")
2892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2893 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2894 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2895 bgp_recalculate_all_bestpaths(bgp
);
2900 /* "bgp log-neighbor-changes" configuration. */
2901 DEFUN (bgp_log_neighbor_changes
,
2902 bgp_log_neighbor_changes_cmd
,
2903 "bgp log-neighbor-changes",
2904 "BGP specific commands\n"
2905 "Log neighbor up/down and reset reason\n")
2907 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2908 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2912 DEFUN (no_bgp_log_neighbor_changes
,
2913 no_bgp_log_neighbor_changes_cmd
,
2914 "no bgp log-neighbor-changes",
2916 "BGP specific commands\n"
2917 "Log neighbor up/down and reset reason\n")
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2920 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2924 /* "bgp bestpath med" configuration. */
2925 DEFUN (bgp_bestpath_med
,
2926 bgp_bestpath_med_cmd
,
2927 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2928 "BGP specific commands\n"
2929 "Change the default bestpath selection\n"
2931 "Compare MED among confederation paths\n"
2932 "Treat missing MED as the least preferred one\n"
2933 "Treat missing MED as the least preferred one\n"
2934 "Compare MED among confederation paths\n")
2936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2939 if (argv_find(argv
, argc
, "confed", &idx
))
2940 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2942 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2943 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2945 bgp_recalculate_all_bestpaths(bgp
);
2950 DEFUN (no_bgp_bestpath_med
,
2951 no_bgp_bestpath_med_cmd
,
2952 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2954 "BGP specific commands\n"
2955 "Change the default bestpath selection\n"
2957 "Compare MED among confederation paths\n"
2958 "Treat missing MED as the least preferred one\n"
2959 "Treat missing MED as the least preferred one\n"
2960 "Compare MED among confederation paths\n")
2962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2965 if (argv_find(argv
, argc
, "confed", &idx
))
2966 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2968 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2969 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2971 bgp_recalculate_all_bestpaths(bgp
);
2976 /* "no bgp default ipv4-unicast". */
2977 DEFUN (no_bgp_default_ipv4_unicast
,
2978 no_bgp_default_ipv4_unicast_cmd
,
2979 "no bgp default ipv4-unicast",
2981 "BGP specific commands\n"
2982 "Configure BGP defaults\n"
2983 "Activate ipv4-unicast for a peer by default\n")
2985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2986 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
2990 DEFUN (bgp_default_ipv4_unicast
,
2991 bgp_default_ipv4_unicast_cmd
,
2992 "bgp default ipv4-unicast",
2993 "BGP specific commands\n"
2994 "Configure BGP defaults\n"
2995 "Activate ipv4-unicast for a peer by default\n")
2997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2998 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3002 /* Display hostname in certain command outputs */
3003 DEFUN (bgp_default_show_hostname
,
3004 bgp_default_show_hostname_cmd
,
3005 "bgp default show-hostname",
3006 "BGP specific commands\n"
3007 "Configure BGP defaults\n"
3008 "Show hostname in certain command outputs\n")
3010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3011 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3015 DEFUN (no_bgp_default_show_hostname
,
3016 no_bgp_default_show_hostname_cmd
,
3017 "no bgp default show-hostname",
3019 "BGP specific commands\n"
3020 "Configure BGP defaults\n"
3021 "Show hostname in certain command outputs\n")
3023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3024 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3028 /* "bgp network import-check" configuration. */
3029 DEFUN (bgp_network_import_check
,
3030 bgp_network_import_check_cmd
,
3031 "bgp network import-check",
3032 "BGP specific commands\n"
3033 "BGP network command\n"
3034 "Check BGP network route exists in IGP\n")
3036 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3037 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3038 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3039 bgp_static_redo_import_check(bgp
);
3045 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3046 "bgp network import-check exact",
3047 "BGP specific commands\n"
3048 "BGP network command\n"
3049 "Check BGP network route exists in IGP\n"
3050 "Match route precisely\n")
3052 DEFUN (no_bgp_network_import_check
,
3053 no_bgp_network_import_check_cmd
,
3054 "no bgp network import-check",
3056 "BGP specific commands\n"
3057 "BGP network command\n"
3058 "Check BGP network route exists in IGP\n")
3060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3061 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3062 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3063 bgp_static_redo_import_check(bgp
);
3069 DEFUN (bgp_default_local_preference
,
3070 bgp_default_local_preference_cmd
,
3071 "bgp default local-preference (0-4294967295)",
3072 "BGP specific commands\n"
3073 "Configure BGP defaults\n"
3074 "local preference (higher=more preferred)\n"
3075 "Configure default local preference value\n")
3077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3079 uint32_t local_pref
;
3081 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3083 bgp_default_local_preference_set(bgp
, local_pref
);
3084 bgp_clear_star_soft_in(vty
, bgp
->name
);
3089 DEFUN (no_bgp_default_local_preference
,
3090 no_bgp_default_local_preference_cmd
,
3091 "no bgp default local-preference [(0-4294967295)]",
3093 "BGP specific commands\n"
3094 "Configure BGP defaults\n"
3095 "local preference (higher=more preferred)\n"
3096 "Configure default local preference value\n")
3098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3099 bgp_default_local_preference_unset(bgp
);
3100 bgp_clear_star_soft_in(vty
, bgp
->name
);
3106 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3107 bgp_default_subgroup_pkt_queue_max_cmd
,
3108 "bgp default subgroup-pkt-queue-max (20-100)",
3109 "BGP specific commands\n"
3110 "Configure BGP defaults\n"
3111 "subgroup-pkt-queue-max\n"
3112 "Configure subgroup packet queue max\n")
3114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3118 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3120 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3125 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3126 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3127 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3129 "BGP specific commands\n"
3130 "Configure BGP defaults\n"
3131 "subgroup-pkt-queue-max\n"
3132 "Configure subgroup packet queue max\n")
3134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3135 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3140 DEFUN (bgp_rr_allow_outbound_policy
,
3141 bgp_rr_allow_outbound_policy_cmd
,
3142 "bgp route-reflector allow-outbound-policy",
3143 "BGP specific commands\n"
3144 "Allow modifications made by out route-map\n"
3145 "on ibgp neighbors\n")
3147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3149 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3150 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3151 update_group_announce_rrclients(bgp
);
3152 bgp_clear_star_soft_out(vty
, bgp
->name
);
3158 DEFUN (no_bgp_rr_allow_outbound_policy
,
3159 no_bgp_rr_allow_outbound_policy_cmd
,
3160 "no bgp route-reflector allow-outbound-policy",
3162 "BGP specific commands\n"
3163 "Allow modifications made by out route-map\n"
3164 "on ibgp neighbors\n")
3166 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3168 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3169 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3170 update_group_announce_rrclients(bgp
);
3171 bgp_clear_star_soft_out(vty
, bgp
->name
);
3177 DEFUN (bgp_listen_limit
,
3178 bgp_listen_limit_cmd
,
3179 "bgp listen limit (1-5000)",
3180 "BGP specific commands\n"
3181 "BGP Dynamic Neighbors listen commands\n"
3182 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3183 "Configure Dynamic Neighbors listen limit value\n")
3185 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3189 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3191 bgp_listen_limit_set(bgp
, listen_limit
);
3196 DEFUN (no_bgp_listen_limit
,
3197 no_bgp_listen_limit_cmd
,
3198 "no bgp listen limit [(1-5000)]",
3200 "BGP specific commands\n"
3201 "BGP Dynamic Neighbors listen commands\n"
3202 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3203 "Configure Dynamic Neighbors listen limit value\n")
3205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3206 bgp_listen_limit_unset(bgp
);
3212 * Check if this listen range is already configured. Check for exact
3213 * match or overlap based on input.
3215 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3216 struct prefix
*range
, int exact
)
3218 struct listnode
*node
, *nnode
;
3219 struct listnode
*node1
, *nnode1
;
3220 struct peer_group
*group
;
3225 afi
= family2afi(range
->family
);
3226 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3227 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3230 match
= prefix_same(range
, lr
);
3232 match
= (prefix_match(range
, lr
)
3233 || prefix_match(lr
, range
));
3242 DEFUN (bgp_listen_range
,
3243 bgp_listen_range_cmd
,
3244 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3245 "BGP specific commands\n"
3246 "Configure BGP dynamic neighbors listen range\n"
3247 "Configure BGP dynamic neighbors listen range\n"
3249 "Member of the peer-group\n"
3250 "Peer-group name\n")
3252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct prefix range
;
3254 struct peer_group
*group
, *existing_group
;
3259 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3260 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3261 char *prefix
= argv
[idx
]->arg
;
3262 argv_find(argv
, argc
, "PGNAME", &idx
);
3263 char *peergroup
= argv
[idx
]->arg
;
3265 /* Convert IP prefix string to struct prefix. */
3266 ret
= str2prefix(prefix
, &range
);
3268 vty_out(vty
, "%% Malformed listen range\n");
3269 return CMD_WARNING_CONFIG_FAILED
;
3272 afi
= family2afi(range
.family
);
3274 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3276 "%% Malformed listen range (link-local address)\n");
3277 return CMD_WARNING_CONFIG_FAILED
;
3282 /* Check if same listen range is already configured. */
3283 existing_group
= listen_range_exists(bgp
, &range
, 1);
3284 if (existing_group
) {
3285 if (strcmp(existing_group
->name
, peergroup
) == 0)
3289 "%% Same listen range is attached to peer-group %s\n",
3290 existing_group
->name
);
3291 return CMD_WARNING_CONFIG_FAILED
;
3295 /* Check if an overlapping listen range exists. */
3296 if (listen_range_exists(bgp
, &range
, 0)) {
3298 "%% Listen range overlaps with existing listen range\n");
3299 return CMD_WARNING_CONFIG_FAILED
;
3302 group
= peer_group_lookup(bgp
, peergroup
);
3304 vty_out(vty
, "%% Configure the peer-group first\n");
3305 return CMD_WARNING_CONFIG_FAILED
;
3308 ret
= peer_group_listen_range_add(group
, &range
);
3309 return bgp_vty_return(vty
, ret
);
3312 DEFUN (no_bgp_listen_range
,
3313 no_bgp_listen_range_cmd
,
3314 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3316 "BGP specific commands\n"
3317 "Unconfigure BGP dynamic neighbors listen range\n"
3318 "Unconfigure BGP dynamic neighbors listen range\n"
3320 "Member of the peer-group\n"
3321 "Peer-group name\n")
3323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3324 struct prefix range
;
3325 struct peer_group
*group
;
3330 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3331 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3332 char *prefix
= argv
[idx
]->arg
;
3333 argv_find(argv
, argc
, "PGNAME", &idx
);
3334 char *peergroup
= argv
[idx
]->arg
;
3336 /* Convert IP prefix string to struct prefix. */
3337 ret
= str2prefix(prefix
, &range
);
3339 vty_out(vty
, "%% Malformed listen range\n");
3340 return CMD_WARNING_CONFIG_FAILED
;
3343 afi
= family2afi(range
.family
);
3345 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3347 "%% Malformed listen range (link-local address)\n");
3348 return CMD_WARNING_CONFIG_FAILED
;
3353 group
= peer_group_lookup(bgp
, peergroup
);
3355 vty_out(vty
, "%% Peer-group does not exist\n");
3356 return CMD_WARNING_CONFIG_FAILED
;
3359 ret
= peer_group_listen_range_del(group
, &range
);
3360 return bgp_vty_return(vty
, ret
);
3363 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
3365 struct peer_group
*group
;
3366 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
3367 struct prefix
*range
;
3369 char buf
[PREFIX2STR_BUFFER
];
3371 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
3372 vty_out(vty
, " bgp listen limit %d\n",
3373 bgp
->dynamic_neighbors_limit
);
3375 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3376 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
3377 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
3379 prefix2str(range
, buf
, sizeof(buf
));
3381 " bgp listen range %s peer-group %s\n",
3389 DEFUN (bgp_disable_connected_route_check
,
3390 bgp_disable_connected_route_check_cmd
,
3391 "bgp disable-ebgp-connected-route-check",
3392 "BGP specific commands\n"
3393 "Disable checking if nexthop is connected on ebgp sessions\n")
3395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3396 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3397 bgp_clear_star_soft_in(vty
, bgp
->name
);
3402 DEFUN (no_bgp_disable_connected_route_check
,
3403 no_bgp_disable_connected_route_check_cmd
,
3404 "no bgp disable-ebgp-connected-route-check",
3406 "BGP specific commands\n"
3407 "Disable checking if nexthop is connected on ebgp sessions\n")
3409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3410 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3411 bgp_clear_star_soft_in(vty
, bgp
->name
);
3417 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
3418 const char *as_str
, afi_t afi
, safi_t safi
)
3420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3423 int as_type
= AS_SPECIFIED
;
3426 if (as_str
[0] == 'i') {
3428 as_type
= AS_INTERNAL
;
3429 } else if (as_str
[0] == 'e') {
3431 as_type
= AS_EXTERNAL
;
3433 /* Get AS number. */
3434 as
= strtoul(as_str
, NULL
, 10);
3437 /* If peer is peer group or interface peer, call proper function. */
3438 ret
= str2sockunion(peer_str
, &su
);
3442 /* Check if existing interface peer */
3443 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
3445 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
3448 /* if not interface peer, check peer-group settings */
3449 if (ret
< 0 && !peer
) {
3450 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
3453 "%% Create the peer-group or interface first\n");
3454 return CMD_WARNING_CONFIG_FAILED
;
3459 if (peer_address_self_check(bgp
, &su
)) {
3461 "%% Can not configure the local system as neighbor\n");
3462 return CMD_WARNING_CONFIG_FAILED
;
3464 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
3467 /* This peer belongs to peer group. */
3469 case BGP_ERR_PEER_GROUP_MEMBER
:
3471 "%% Peer-group member cannot override remote-as of peer-group\n");
3472 return CMD_WARNING_CONFIG_FAILED
;
3473 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
3475 "%% Peer-group members must be all internal or all external\n");
3476 return CMD_WARNING_CONFIG_FAILED
;
3478 return bgp_vty_return(vty
, ret
);
3481 DEFUN (bgp_default_shutdown
,
3482 bgp_default_shutdown_cmd
,
3483 "[no] bgp default shutdown",
3486 "Configure BGP defaults\n"
3487 "Apply administrative shutdown to newly configured peers\n")
3489 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3490 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
3494 DEFUN (neighbor_remote_as
,
3495 neighbor_remote_as_cmd
,
3496 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
3499 "Specify a BGP neighbor\n"
3501 "Internal BGP peer\n"
3502 "External BGP peer\n")
3505 int idx_remote_as
= 3;
3506 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
3507 argv
[idx_remote_as
]->arg
, AFI_IP
,
3511 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
3512 afi_t afi
, safi_t safi
, int v6only
,
3513 const char *peer_group_name
,
3516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3518 int as_type
= AS_UNSPECIFIED
;
3520 struct peer_group
*group
;
3524 group
= peer_group_lookup(bgp
, conf_if
);
3527 vty_out(vty
, "%% Name conflict with peer-group \n");
3528 return CMD_WARNING_CONFIG_FAILED
;
3532 if (as_str
[0] == 'i') {
3533 as_type
= AS_INTERNAL
;
3534 } else if (as_str
[0] == 'e') {
3535 as_type
= AS_EXTERNAL
;
3537 /* Get AS number. */
3538 as
= strtoul(as_str
, NULL
, 10);
3539 as_type
= AS_SPECIFIED
;
3543 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
3546 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3549 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
3550 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3551 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3552 as_type
, 0, 0, NULL
);
3554 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3555 as_type
, afi
, safi
, NULL
);
3558 vty_out(vty
, "%% BGP failed to create peer\n");
3559 return CMD_WARNING_CONFIG_FAILED
;
3563 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3565 /* Request zebra to initiate IPv6 RAs on this interface. We do
3567 * any unnumbered peer in order to not worry about run-time
3569 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3571 * gets deleted later etc.)
3574 bgp_zebra_initiate_radv(bgp
, peer
);
3577 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3578 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3580 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3582 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3584 /* v6only flag changed. Reset bgp seesion */
3585 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3586 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3587 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3588 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3590 bgp_session_reset(peer
);
3593 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3594 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3595 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3596 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3599 if (peer_group_name
) {
3600 group
= peer_group_lookup(bgp
, peer_group_name
);
3602 vty_out(vty
, "%% Configure the peer-group first\n");
3603 return CMD_WARNING_CONFIG_FAILED
;
3606 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3609 return bgp_vty_return(vty
, ret
);
3612 DEFUN (neighbor_interface_config
,
3613 neighbor_interface_config_cmd
,
3614 "neighbor WORD interface [peer-group PGNAME]",
3616 "Interface name or neighbor tag\n"
3617 "Enable BGP on interface\n"
3618 "Member of the peer-group\n"
3619 "Peer-group name\n")
3622 int idx_peer_group_word
= 4;
3624 if (argc
> idx_peer_group_word
)
3625 return peer_conf_interface_get(
3626 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3627 argv
[idx_peer_group_word
]->arg
, NULL
);
3629 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3630 SAFI_UNICAST
, 0, NULL
, NULL
);
3633 DEFUN (neighbor_interface_config_v6only
,
3634 neighbor_interface_config_v6only_cmd
,
3635 "neighbor WORD interface v6only [peer-group PGNAME]",
3637 "Interface name or neighbor tag\n"
3638 "Enable BGP on interface\n"
3639 "Enable BGP with v6 link-local only\n"
3640 "Member of the peer-group\n"
3641 "Peer-group name\n")
3644 int idx_peer_group_word
= 5;
3646 if (argc
> idx_peer_group_word
)
3647 return peer_conf_interface_get(
3648 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3649 argv
[idx_peer_group_word
]->arg
, NULL
);
3651 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3652 SAFI_UNICAST
, 1, NULL
, NULL
);
3656 DEFUN (neighbor_interface_config_remote_as
,
3657 neighbor_interface_config_remote_as_cmd
,
3658 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3660 "Interface name or neighbor tag\n"
3661 "Enable BGP on interface\n"
3662 "Specify a BGP neighbor\n"
3664 "Internal BGP peer\n"
3665 "External BGP peer\n")
3668 int idx_remote_as
= 4;
3669 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3670 SAFI_UNICAST
, 0, NULL
,
3671 argv
[idx_remote_as
]->arg
);
3674 DEFUN (neighbor_interface_v6only_config_remote_as
,
3675 neighbor_interface_v6only_config_remote_as_cmd
,
3676 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3678 "Interface name or neighbor tag\n"
3679 "Enable BGP with v6 link-local only\n"
3680 "Enable BGP on interface\n"
3681 "Specify a BGP neighbor\n"
3683 "Internal BGP peer\n"
3684 "External BGP peer\n")
3687 int idx_remote_as
= 5;
3688 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3689 SAFI_UNICAST
, 1, NULL
,
3690 argv
[idx_remote_as
]->arg
);
3693 DEFUN (neighbor_peer_group
,
3694 neighbor_peer_group_cmd
,
3695 "neighbor WORD peer-group",
3697 "Interface name or neighbor tag\n"
3698 "Configure peer-group\n")
3700 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3703 struct peer_group
*group
;
3705 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3707 vty_out(vty
, "%% Name conflict with interface: \n");
3708 return CMD_WARNING_CONFIG_FAILED
;
3711 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3713 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3714 return CMD_WARNING_CONFIG_FAILED
;
3722 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3726 "Specify a BGP neighbor\n"
3728 "Internal BGP peer\n"
3729 "External BGP peer\n")
3731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3735 struct peer_group
*group
;
3739 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3741 /* look up for neighbor by interface name config. */
3742 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3744 /* Request zebra to terminate IPv6 RAs on this
3747 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3748 peer_notify_unconfig(peer
);
3753 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3755 peer_group_notify_unconfig(group
);
3756 peer_group_delete(group
);
3758 vty_out(vty
, "%% Create the peer-group first\n");
3759 return CMD_WARNING_CONFIG_FAILED
;
3762 peer
= peer_lookup(bgp
, &su
);
3764 if (peer_dynamic_neighbor(peer
)) {
3766 "%% Operation not allowed on a dynamic neighbor\n");
3767 return CMD_WARNING_CONFIG_FAILED
;
3770 other
= peer
->doppelganger
;
3771 peer_notify_unconfig(peer
);
3773 if (other
&& other
->status
!= Deleted
) {
3774 peer_notify_unconfig(other
);
3783 DEFUN (no_neighbor_interface_config
,
3784 no_neighbor_interface_config_cmd
,
3785 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3789 "Configure BGP on interface\n"
3790 "Enable BGP with v6 link-local only\n"
3791 "Member of the peer-group\n"
3793 "Specify a BGP neighbor\n"
3795 "Internal BGP peer\n"
3796 "External BGP peer\n")
3798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3802 /* look up for neighbor by interface name config. */
3803 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3805 /* Request zebra to terminate IPv6 RAs on this interface. */
3807 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3808 peer_notify_unconfig(peer
);
3811 vty_out(vty
, "%% Create the bgp interface first\n");
3812 return CMD_WARNING_CONFIG_FAILED
;
3817 DEFUN (no_neighbor_peer_group
,
3818 no_neighbor_peer_group_cmd
,
3819 "no neighbor WORD peer-group",
3823 "Configure peer-group\n")
3825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3827 struct peer_group
*group
;
3829 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3831 peer_group_notify_unconfig(group
);
3832 peer_group_delete(group
);
3834 vty_out(vty
, "%% Create the peer-group first\n");
3835 return CMD_WARNING_CONFIG_FAILED
;
3840 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3841 no_neighbor_interface_peer_group_remote_as_cmd
,
3842 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3845 "Interface name or neighbor tag\n"
3846 "Specify a BGP neighbor\n"
3848 "Internal BGP peer\n"
3849 "External BGP peer\n")
3851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3853 struct peer_group
*group
;
3856 /* look up for neighbor by interface name config. */
3857 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3859 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3863 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3865 peer_group_remote_as_delete(group
);
3867 vty_out(vty
, "%% Create the peer-group or interface first\n");
3868 return CMD_WARNING_CONFIG_FAILED
;
3873 DEFUN (neighbor_local_as
,
3874 neighbor_local_as_cmd
,
3875 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3878 "Specify a local-as number\n"
3879 "AS number used as local AS\n")
3887 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3889 return CMD_WARNING_CONFIG_FAILED
;
3891 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3892 ret
= peer_local_as_set(peer
, as
, 0, 0);
3893 return bgp_vty_return(vty
, ret
);
3896 DEFUN (neighbor_local_as_no_prepend
,
3897 neighbor_local_as_no_prepend_cmd
,
3898 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3901 "Specify a local-as number\n"
3902 "AS number used as local AS\n"
3903 "Do not prepend local-as to updates from ebgp peers\n")
3911 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3913 return CMD_WARNING_CONFIG_FAILED
;
3915 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3916 ret
= peer_local_as_set(peer
, as
, 1, 0);
3917 return bgp_vty_return(vty
, ret
);
3920 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3921 neighbor_local_as_no_prepend_replace_as_cmd
,
3922 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3925 "Specify a local-as number\n"
3926 "AS number used as local AS\n"
3927 "Do not prepend local-as to updates from ebgp peers\n"
3928 "Do not prepend local-as to updates from ibgp peers\n")
3936 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3938 return CMD_WARNING_CONFIG_FAILED
;
3940 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3941 ret
= peer_local_as_set(peer
, as
, 1, 1);
3942 return bgp_vty_return(vty
, ret
);
3945 DEFUN (no_neighbor_local_as
,
3946 no_neighbor_local_as_cmd
,
3947 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3951 "Specify a local-as number\n"
3952 "AS number used as local AS\n"
3953 "Do not prepend local-as to updates from ebgp peers\n"
3954 "Do not prepend local-as to updates from ibgp peers\n")
3960 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3962 return CMD_WARNING_CONFIG_FAILED
;
3964 ret
= peer_local_as_unset(peer
);
3965 return bgp_vty_return(vty
, ret
);
3969 DEFUN (neighbor_solo
,
3971 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3974 "Solo peer - part of its own update group\n")
3980 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3982 return CMD_WARNING_CONFIG_FAILED
;
3984 ret
= update_group_adjust_soloness(peer
, 1);
3985 return bgp_vty_return(vty
, ret
);
3988 DEFUN (no_neighbor_solo
,
3989 no_neighbor_solo_cmd
,
3990 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3994 "Solo peer - part of its own update group\n")
4000 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4002 return CMD_WARNING_CONFIG_FAILED
;
4004 ret
= update_group_adjust_soloness(peer
, 0);
4005 return bgp_vty_return(vty
, ret
);
4008 DEFUN (neighbor_password
,
4009 neighbor_password_cmd
,
4010 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4021 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4023 return CMD_WARNING_CONFIG_FAILED
;
4025 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4026 return bgp_vty_return(vty
, ret
);
4029 DEFUN (no_neighbor_password
,
4030 no_neighbor_password_cmd
,
4031 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4042 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4044 return CMD_WARNING_CONFIG_FAILED
;
4046 ret
= peer_password_unset(peer
);
4047 return bgp_vty_return(vty
, ret
);
4050 DEFUN (neighbor_activate
,
4051 neighbor_activate_cmd
,
4052 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4055 "Enable the Address Family for this Neighbor\n")
4061 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4063 return CMD_WARNING_CONFIG_FAILED
;
4065 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4066 return bgp_vty_return(vty
, ret
);
4069 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4070 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4071 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4072 "Enable the Address Family for this Neighbor\n")
4074 DEFUN (no_neighbor_activate
,
4075 no_neighbor_activate_cmd
,
4076 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4080 "Enable the Address Family for this Neighbor\n")
4087 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4089 return CMD_WARNING_CONFIG_FAILED
;
4091 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4092 return bgp_vty_return(vty
, ret
);
4095 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4096 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4097 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4098 "Enable the Address Family for this Neighbor\n")
4100 DEFUN (neighbor_set_peer_group
,
4101 neighbor_set_peer_group_cmd
,
4102 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4105 "Member of the peer-group\n"
4106 "Peer-group name\n")
4108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4115 struct peer_group
*group
;
4117 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4119 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4121 vty_out(vty
, "%% Malformed address or name: %s\n",
4122 argv
[idx_peer
]->arg
);
4123 return CMD_WARNING_CONFIG_FAILED
;
4126 if (peer_address_self_check(bgp
, &su
)) {
4128 "%% Can not configure the local system as neighbor\n");
4129 return CMD_WARNING_CONFIG_FAILED
;
4132 /* Disallow for dynamic neighbor. */
4133 peer
= peer_lookup(bgp
, &su
);
4134 if (peer
&& peer_dynamic_neighbor(peer
)) {
4136 "%% Operation not allowed on a dynamic neighbor\n");
4137 return CMD_WARNING_CONFIG_FAILED
;
4141 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4143 vty_out(vty
, "%% Configure the peer-group first\n");
4144 return CMD_WARNING_CONFIG_FAILED
;
4147 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4149 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4151 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4153 return CMD_WARNING_CONFIG_FAILED
;
4156 return bgp_vty_return(vty
, ret
);
4159 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4160 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4161 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4162 "Member of the peer-group\n"
4163 "Peer-group name\n")
4165 DEFUN (no_neighbor_set_peer_group
,
4166 no_neighbor_set_peer_group_cmd
,
4167 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4171 "Member of the peer-group\n"
4172 "Peer-group name\n")
4174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4179 struct peer_group
*group
;
4181 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4183 return CMD_WARNING_CONFIG_FAILED
;
4185 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4187 vty_out(vty
, "%% Configure the peer-group first\n");
4188 return CMD_WARNING_CONFIG_FAILED
;
4191 peer_notify_unconfig(peer
);
4192 ret
= peer_delete(peer
);
4194 return bgp_vty_return(vty
, ret
);
4197 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4198 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4199 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4200 "Member of the peer-group\n"
4201 "Peer-group name\n")
4203 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4204 uint32_t flag
, int set
)
4209 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4211 return CMD_WARNING_CONFIG_FAILED
;
4214 * If 'neighbor <interface>', then this is for directly connected peers,
4215 * we should not accept disable-connected-check.
4217 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4219 "%s is directly connected peer, cannot accept disable-"
4220 "connected-check\n",
4222 return CMD_WARNING_CONFIG_FAILED
;
4225 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4226 peer_tx_shutdown_message_unset(peer
);
4229 ret
= peer_flag_set(peer
, flag
);
4231 ret
= peer_flag_unset(peer
, flag
);
4233 return bgp_vty_return(vty
, ret
);
4236 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4238 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4241 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4244 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4247 /* neighbor passive. */
4248 DEFUN (neighbor_passive
,
4249 neighbor_passive_cmd
,
4250 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4253 "Don't send open messages to this neighbor\n")
4256 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4259 DEFUN (no_neighbor_passive
,
4260 no_neighbor_passive_cmd
,
4261 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4265 "Don't send open messages to this neighbor\n")
4268 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4271 /* neighbor shutdown. */
4272 DEFUN (neighbor_shutdown_msg
,
4273 neighbor_shutdown_msg_cmd
,
4274 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4277 "Administratively shut down this neighbor\n"
4278 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
4279 "Shutdown message\n")
4285 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4289 return CMD_WARNING_CONFIG_FAILED
;
4290 message
= argv_concat(argv
, argc
, 4);
4291 peer_tx_shutdown_message_set(peer
, message
);
4292 XFREE(MTYPE_TMP
, message
);
4295 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
4298 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
4299 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4300 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4301 "Administratively shut down this neighbor\n")
4303 DEFUN (no_neighbor_shutdown_msg
,
4304 no_neighbor_shutdown_msg_cmd
,
4305 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4309 "Administratively shut down this neighbor\n"
4310 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
4311 "Shutdown message\n")
4315 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4316 PEER_FLAG_SHUTDOWN
);
4319 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
4320 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4321 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4322 "Administratively shut down this neighbor\n")
4324 /* neighbor capability dynamic. */
4325 DEFUN (neighbor_capability_dynamic
,
4326 neighbor_capability_dynamic_cmd
,
4327 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4330 "Advertise capability to the peer\n"
4331 "Advertise dynamic capability to this neighbor\n")
4334 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4335 PEER_FLAG_DYNAMIC_CAPABILITY
);
4338 DEFUN (no_neighbor_capability_dynamic
,
4339 no_neighbor_capability_dynamic_cmd
,
4340 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4344 "Advertise capability to the peer\n"
4345 "Advertise dynamic capability to this neighbor\n")
4348 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4349 PEER_FLAG_DYNAMIC_CAPABILITY
);
4352 /* neighbor dont-capability-negotiate */
4353 DEFUN (neighbor_dont_capability_negotiate
,
4354 neighbor_dont_capability_negotiate_cmd
,
4355 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4358 "Do not perform capability negotiation\n")
4361 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4362 PEER_FLAG_DONT_CAPABILITY
);
4365 DEFUN (no_neighbor_dont_capability_negotiate
,
4366 no_neighbor_dont_capability_negotiate_cmd
,
4367 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4371 "Do not perform capability negotiation\n")
4374 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4375 PEER_FLAG_DONT_CAPABILITY
);
4378 /* neighbor capability extended next hop encoding */
4379 DEFUN (neighbor_capability_enhe
,
4380 neighbor_capability_enhe_cmd
,
4381 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4384 "Advertise capability to the peer\n"
4385 "Advertise extended next-hop capability to the peer\n")
4388 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4389 PEER_FLAG_CAPABILITY_ENHE
);
4392 DEFUN (no_neighbor_capability_enhe
,
4393 no_neighbor_capability_enhe_cmd
,
4394 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4398 "Advertise capability to the peer\n"
4399 "Advertise extended next-hop capability to the peer\n")
4402 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4403 PEER_FLAG_CAPABILITY_ENHE
);
4406 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
4407 afi_t afi
, safi_t safi
, uint32_t flag
,
4413 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4415 return CMD_WARNING_CONFIG_FAILED
;
4418 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
4420 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
4422 return bgp_vty_return(vty
, ret
);
4425 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
4426 afi_t afi
, safi_t safi
, uint32_t flag
)
4428 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
4431 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
4432 afi_t afi
, safi_t safi
, uint32_t flag
)
4434 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
4437 /* neighbor capability orf prefix-list. */
4438 DEFUN (neighbor_capability_orf_prefix
,
4439 neighbor_capability_orf_prefix_cmd
,
4440 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4443 "Advertise capability to the peer\n"
4444 "Advertise ORF capability to the peer\n"
4445 "Advertise prefixlist ORF capability to this neighbor\n"
4446 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4447 "Capability to RECEIVE the ORF from this neighbor\n"
4448 "Capability to SEND the ORF to this neighbor\n")
4451 int idx_send_recv
= 5;
4454 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4455 flag
= PEER_FLAG_ORF_PREFIX_SM
;
4456 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4457 flag
= PEER_FLAG_ORF_PREFIX_RM
;
4458 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4459 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
4461 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
4462 return CMD_WARNING_CONFIG_FAILED
;
4465 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4466 bgp_node_safi(vty
), flag
);
4470 neighbor_capability_orf_prefix
,
4471 neighbor_capability_orf_prefix_hidden_cmd
,
4472 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4473 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4474 "Advertise capability to the peer\n"
4475 "Advertise ORF capability to the peer\n"
4476 "Advertise prefixlist ORF capability to this neighbor\n"
4477 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4478 "Capability to RECEIVE the ORF from this neighbor\n"
4479 "Capability to SEND the ORF to this neighbor\n")
4481 DEFUN (no_neighbor_capability_orf_prefix
,
4482 no_neighbor_capability_orf_prefix_cmd
,
4483 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4487 "Advertise capability to the peer\n"
4488 "Advertise ORF capability to the peer\n"
4489 "Advertise prefixlist ORF capability to this neighbor\n"
4490 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4491 "Capability to RECEIVE the ORF from this neighbor\n"
4492 "Capability to SEND the ORF to this neighbor\n")
4495 int idx_send_recv
= 6;
4498 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4499 flag
= PEER_FLAG_ORF_PREFIX_SM
;
4500 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4501 flag
= PEER_FLAG_ORF_PREFIX_RM
;
4502 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4503 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
4505 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
4506 return CMD_WARNING_CONFIG_FAILED
;
4509 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4510 bgp_node_afi(vty
), bgp_node_safi(vty
),
4515 no_neighbor_capability_orf_prefix
,
4516 no_neighbor_capability_orf_prefix_hidden_cmd
,
4517 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4518 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4519 "Advertise capability to the peer\n"
4520 "Advertise ORF capability to the peer\n"
4521 "Advertise prefixlist ORF capability to this neighbor\n"
4522 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4523 "Capability to RECEIVE the ORF from this neighbor\n"
4524 "Capability to SEND the ORF to this neighbor\n")
4526 /* neighbor next-hop-self. */
4527 DEFUN (neighbor_nexthop_self
,
4528 neighbor_nexthop_self_cmd
,
4529 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4532 "Disable the next hop calculation for this neighbor\n")
4535 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4536 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
4539 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
4540 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4541 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4542 "Disable the next hop calculation for this neighbor\n")
4544 /* neighbor next-hop-self. */
4545 DEFUN (neighbor_nexthop_self_force
,
4546 neighbor_nexthop_self_force_cmd
,
4547 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4550 "Disable the next hop calculation for this neighbor\n"
4551 "Set the next hop to self for reflected routes\n")
4554 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4556 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4559 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4560 neighbor_nexthop_self_force_hidden_cmd
,
4561 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4562 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4563 "Disable the next hop calculation for this neighbor\n"
4564 "Set the next hop to self for reflected routes\n")
4566 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4567 neighbor_nexthop_self_all_hidden_cmd
,
4568 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4569 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4570 "Disable the next hop calculation for this neighbor\n"
4571 "Set the next hop to self for reflected routes\n")
4573 DEFUN (no_neighbor_nexthop_self
,
4574 no_neighbor_nexthop_self_cmd
,
4575 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4579 "Disable the next hop calculation for this neighbor\n")
4582 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4583 bgp_node_afi(vty
), bgp_node_safi(vty
),
4584 PEER_FLAG_NEXTHOP_SELF
);
4587 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4588 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4589 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4590 "Disable the next hop calculation for this neighbor\n")
4592 DEFUN (no_neighbor_nexthop_self_force
,
4593 no_neighbor_nexthop_self_force_cmd
,
4594 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4598 "Disable the next hop calculation for this neighbor\n"
4599 "Set the next hop to self for reflected routes\n")
4602 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4603 bgp_node_afi(vty
), bgp_node_safi(vty
),
4604 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4607 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4608 no_neighbor_nexthop_self_force_hidden_cmd
,
4609 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4610 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4611 "Disable the next hop calculation for this neighbor\n"
4612 "Set the next hop to self for reflected routes\n")
4614 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4615 no_neighbor_nexthop_self_all_hidden_cmd
,
4616 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4617 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4618 "Disable the next hop calculation for this neighbor\n"
4619 "Set the next hop to self for reflected routes\n")
4621 /* neighbor as-override */
4622 DEFUN (neighbor_as_override
,
4623 neighbor_as_override_cmd
,
4624 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4627 "Override ASNs in outbound updates if aspath equals remote-as\n")
4630 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4631 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4634 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4635 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4636 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4637 "Override ASNs in outbound updates if aspath equals remote-as\n")
4639 DEFUN (no_neighbor_as_override
,
4640 no_neighbor_as_override_cmd
,
4641 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4645 "Override ASNs in outbound updates if aspath equals remote-as\n")
4648 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4649 bgp_node_afi(vty
), bgp_node_safi(vty
),
4650 PEER_FLAG_AS_OVERRIDE
);
4653 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4654 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4655 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4656 "Override ASNs in outbound updates if aspath equals remote-as\n")
4658 /* neighbor remove-private-AS. */
4659 DEFUN (neighbor_remove_private_as
,
4660 neighbor_remove_private_as_cmd
,
4661 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4664 "Remove private ASNs in outbound updates\n")
4667 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4669 PEER_FLAG_REMOVE_PRIVATE_AS
);
4672 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4673 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4674 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4675 "Remove private ASNs in outbound updates\n")
4677 DEFUN (neighbor_remove_private_as_all
,
4678 neighbor_remove_private_as_all_cmd
,
4679 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4682 "Remove private ASNs in outbound updates\n"
4683 "Apply to all AS numbers\n")
4686 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4688 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4691 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4692 neighbor_remove_private_as_all_hidden_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4694 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4695 "Remove private ASNs in outbound updates\n"
4696 "Apply to all AS numbers")
4698 DEFUN (neighbor_remove_private_as_replace_as
,
4699 neighbor_remove_private_as_replace_as_cmd
,
4700 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4703 "Remove private ASNs in outbound updates\n"
4704 "Replace private ASNs with our ASN in outbound updates\n")
4707 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4709 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4712 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4713 neighbor_remove_private_as_replace_as_hidden_cmd
,
4714 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4715 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4716 "Remove private ASNs in outbound updates\n"
4717 "Replace private ASNs with our ASN in outbound updates\n")
4719 DEFUN (neighbor_remove_private_as_all_replace_as
,
4720 neighbor_remove_private_as_all_replace_as_cmd
,
4721 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4724 "Remove private ASNs in outbound updates\n"
4725 "Apply to all AS numbers\n"
4726 "Replace private ASNs with our ASN in outbound updates\n")
4729 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4731 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4735 neighbor_remove_private_as_all_replace_as
,
4736 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4737 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4738 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4739 "Remove private ASNs in outbound updates\n"
4740 "Apply to all AS numbers\n"
4741 "Replace private ASNs with our ASN in outbound updates\n")
4743 DEFUN (no_neighbor_remove_private_as
,
4744 no_neighbor_remove_private_as_cmd
,
4745 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4749 "Remove private ASNs in outbound updates\n")
4752 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4753 bgp_node_afi(vty
), bgp_node_safi(vty
),
4754 PEER_FLAG_REMOVE_PRIVATE_AS
);
4757 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4758 no_neighbor_remove_private_as_hidden_cmd
,
4759 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4760 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4761 "Remove private ASNs in outbound updates\n")
4763 DEFUN (no_neighbor_remove_private_as_all
,
4764 no_neighbor_remove_private_as_all_cmd
,
4765 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4769 "Remove private ASNs in outbound updates\n"
4770 "Apply to all AS numbers\n")
4773 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4774 bgp_node_afi(vty
), bgp_node_safi(vty
),
4775 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4778 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4779 no_neighbor_remove_private_as_all_hidden_cmd
,
4780 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4781 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4782 "Remove private ASNs in outbound updates\n"
4783 "Apply to all AS numbers\n")
4785 DEFUN (no_neighbor_remove_private_as_replace_as
,
4786 no_neighbor_remove_private_as_replace_as_cmd
,
4787 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4791 "Remove private ASNs in outbound updates\n"
4792 "Replace private ASNs with our ASN in outbound updates\n")
4795 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4796 bgp_node_afi(vty
), bgp_node_safi(vty
),
4797 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4800 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4801 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4802 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4803 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4804 "Remove private ASNs in outbound updates\n"
4805 "Replace private ASNs with our ASN in outbound updates\n")
4807 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4808 no_neighbor_remove_private_as_all_replace_as_cmd
,
4809 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4813 "Remove private ASNs in outbound updates\n"
4814 "Apply to all AS numbers\n"
4815 "Replace private ASNs with our ASN in outbound updates\n")
4818 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4819 bgp_node_afi(vty
), bgp_node_safi(vty
),
4820 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4824 no_neighbor_remove_private_as_all_replace_as
,
4825 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4826 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4828 "Remove private ASNs in outbound updates\n"
4829 "Apply to all AS numbers\n"
4830 "Replace private ASNs with our ASN in outbound updates\n")
4833 /* neighbor send-community. */
4834 DEFUN (neighbor_send_community
,
4835 neighbor_send_community_cmd
,
4836 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4839 "Send Community attribute to this neighbor\n")
4843 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4845 PEER_FLAG_SEND_COMMUNITY
);
4848 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4849 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4850 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4851 "Send Community attribute to this neighbor\n")
4853 DEFUN (no_neighbor_send_community
,
4854 no_neighbor_send_community_cmd
,
4855 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4859 "Send Community attribute to this neighbor\n")
4863 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4864 bgp_node_afi(vty
), bgp_node_safi(vty
),
4865 PEER_FLAG_SEND_COMMUNITY
);
4868 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4869 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4870 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4871 "Send Community attribute to this neighbor\n")
4873 /* neighbor send-community extended. */
4874 DEFUN (neighbor_send_community_type
,
4875 neighbor_send_community_type_cmd
,
4876 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4879 "Send Community attribute to this neighbor\n"
4880 "Send Standard and Extended Community attributes\n"
4881 "Send Standard, Large and Extended Community attributes\n"
4882 "Send Extended Community attributes\n"
4883 "Send Standard Community attributes\n"
4884 "Send Large Community attributes\n")
4888 const char *type
= argv
[argc
- 1]->text
;
4890 if (strmatch(type
, "standard")) {
4891 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4892 } else if (strmatch(type
, "extended")) {
4893 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4894 } else if (strmatch(type
, "large")) {
4895 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4896 } else if (strmatch(type
, "both")) {
4897 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4898 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4899 } else { /* if (strmatch(type, "all")) */
4900 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4901 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4902 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4905 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4906 bgp_node_safi(vty
), flag
);
4910 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4911 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4912 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4913 "Send Community attribute to this neighbor\n"
4914 "Send Standard and Extended Community attributes\n"
4915 "Send Standard, Large and Extended Community attributes\n"
4916 "Send Extended Community attributes\n"
4917 "Send Standard Community attributes\n"
4918 "Send Large Community attributes\n")
4920 DEFUN (no_neighbor_send_community_type
,
4921 no_neighbor_send_community_type_cmd
,
4922 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4926 "Send Community attribute to this neighbor\n"
4927 "Send Standard and Extended Community attributes\n"
4928 "Send Standard, Large and Extended Community attributes\n"
4929 "Send Extended Community attributes\n"
4930 "Send Standard Community attributes\n"
4931 "Send Large Community attributes\n")
4935 const char *type
= argv
[argc
- 1]->text
;
4937 if (strmatch(type
, "standard")) {
4938 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4939 } else if (strmatch(type
, "extended")) {
4940 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4941 } else if (strmatch(type
, "large")) {
4942 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4943 } else if (strmatch(type
, "both")) {
4944 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4945 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4946 } else { /* if (strmatch(type, "all")) */
4947 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4948 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4949 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4952 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4953 bgp_node_afi(vty
), bgp_node_safi(vty
),
4958 no_neighbor_send_community_type
,
4959 no_neighbor_send_community_type_hidden_cmd
,
4960 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4961 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4962 "Send Community attribute to this neighbor\n"
4963 "Send Standard and Extended Community attributes\n"
4964 "Send Standard, Large and Extended Community attributes\n"
4965 "Send Extended Community attributes\n"
4966 "Send Standard Community attributes\n"
4967 "Send Large Community attributes\n")
4969 /* neighbor soft-reconfig. */
4970 DEFUN (neighbor_soft_reconfiguration
,
4971 neighbor_soft_reconfiguration_cmd
,
4972 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4975 "Per neighbor soft reconfiguration\n"
4976 "Allow inbound soft reconfiguration for this neighbor\n")
4979 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4981 PEER_FLAG_SOFT_RECONFIG
);
4984 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4985 neighbor_soft_reconfiguration_hidden_cmd
,
4986 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4987 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4988 "Per neighbor soft reconfiguration\n"
4989 "Allow inbound soft reconfiguration for this neighbor\n")
4991 DEFUN (no_neighbor_soft_reconfiguration
,
4992 no_neighbor_soft_reconfiguration_cmd
,
4993 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4997 "Per neighbor soft reconfiguration\n"
4998 "Allow inbound soft reconfiguration for this neighbor\n")
5001 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5002 bgp_node_afi(vty
), bgp_node_safi(vty
),
5003 PEER_FLAG_SOFT_RECONFIG
);
5006 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5007 no_neighbor_soft_reconfiguration_hidden_cmd
,
5008 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5009 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5010 "Per neighbor soft reconfiguration\n"
5011 "Allow inbound soft reconfiguration for this neighbor\n")
5013 DEFUN (neighbor_route_reflector_client
,
5014 neighbor_route_reflector_client_cmd
,
5015 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5018 "Configure a neighbor as Route Reflector client\n")
5024 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5026 return CMD_WARNING_CONFIG_FAILED
;
5028 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5030 PEER_FLAG_REFLECTOR_CLIENT
);
5033 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5034 neighbor_route_reflector_client_hidden_cmd
,
5035 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5036 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5037 "Configure a neighbor as Route Reflector client\n")
5039 DEFUN (no_neighbor_route_reflector_client
,
5040 no_neighbor_route_reflector_client_cmd
,
5041 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5045 "Configure a neighbor as Route Reflector client\n")
5048 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5049 bgp_node_afi(vty
), bgp_node_safi(vty
),
5050 PEER_FLAG_REFLECTOR_CLIENT
);
5053 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5054 no_neighbor_route_reflector_client_hidden_cmd
,
5055 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5056 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5057 "Configure a neighbor as Route Reflector client\n")
5059 /* neighbor route-server-client. */
5060 DEFUN (neighbor_route_server_client
,
5061 neighbor_route_server_client_cmd
,
5062 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5065 "Configure a neighbor as Route Server client\n")
5070 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5072 return CMD_WARNING_CONFIG_FAILED
;
5073 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5075 PEER_FLAG_RSERVER_CLIENT
);
5078 ALIAS_HIDDEN(neighbor_route_server_client
,
5079 neighbor_route_server_client_hidden_cmd
,
5080 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5081 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5082 "Configure a neighbor as Route Server client\n")
5084 DEFUN (no_neighbor_route_server_client
,
5085 no_neighbor_route_server_client_cmd
,
5086 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5090 "Configure a neighbor as Route Server client\n")
5093 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5094 bgp_node_afi(vty
), bgp_node_safi(vty
),
5095 PEER_FLAG_RSERVER_CLIENT
);
5098 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5099 no_neighbor_route_server_client_hidden_cmd
,
5100 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5101 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5102 "Configure a neighbor as Route Server client\n")
5104 DEFUN (neighbor_nexthop_local_unchanged
,
5105 neighbor_nexthop_local_unchanged_cmd
,
5106 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5109 "Configure treatment of outgoing link-local nexthop attribute\n"
5110 "Leave link-local nexthop unchanged for this peer\n")
5113 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5115 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5118 DEFUN (no_neighbor_nexthop_local_unchanged
,
5119 no_neighbor_nexthop_local_unchanged_cmd
,
5120 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5124 "Configure treatment of outgoing link-local-nexthop attribute\n"
5125 "Leave link-local nexthop unchanged for this peer\n")
5128 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5129 bgp_node_afi(vty
), bgp_node_safi(vty
),
5130 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5133 DEFUN (neighbor_attr_unchanged
,
5134 neighbor_attr_unchanged_cmd
,
5135 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5138 "BGP attribute is propagated unchanged to this neighbor\n"
5139 "As-path attribute\n"
5140 "Nexthop attribute\n"
5144 char *peer_str
= argv
[1]->arg
;
5147 afi_t afi
= bgp_node_afi(vty
);
5148 safi_t safi
= bgp_node_safi(vty
);
5150 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5152 return CMD_WARNING_CONFIG_FAILED
;
5154 if (argv_find(argv
, argc
, "as-path", &idx
))
5155 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5157 if (argv_find(argv
, argc
, "next-hop", &idx
))
5158 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5160 if (argv_find(argv
, argc
, "med", &idx
))
5161 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5163 /* no flags means all of them! */
5165 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5166 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5167 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5169 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
5170 && peer_af_flag_check(peer
, afi
, safi
,
5171 PEER_FLAG_AS_PATH_UNCHANGED
)) {
5172 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5173 PEER_FLAG_AS_PATH_UNCHANGED
);
5176 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
5177 && peer_af_flag_check(peer
, afi
, safi
,
5178 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
5179 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5180 PEER_FLAG_NEXTHOP_UNCHANGED
);
5183 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
5184 && peer_af_flag_check(peer
, afi
, safi
,
5185 PEER_FLAG_MED_UNCHANGED
)) {
5186 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5187 PEER_FLAG_MED_UNCHANGED
);
5191 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
5195 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
5196 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5197 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5198 "BGP attribute is propagated unchanged to this neighbor\n"
5199 "As-path attribute\n"
5200 "Nexthop attribute\n"
5203 DEFUN (no_neighbor_attr_unchanged
,
5204 no_neighbor_attr_unchanged_cmd
,
5205 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5209 "BGP attribute is propagated unchanged to this neighbor\n"
5210 "As-path attribute\n"
5211 "Nexthop attribute\n"
5215 char *peer
= argv
[2]->arg
;
5218 if (argv_find(argv
, argc
, "as-path", &idx
))
5219 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5221 if (argv_find(argv
, argc
, "next-hop", &idx
))
5222 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5224 if (argv_find(argv
, argc
, "med", &idx
))
5225 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5227 if (!flags
) // no flags means all of them!
5229 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5230 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5231 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5234 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
5235 bgp_node_safi(vty
), flags
);
5239 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
5240 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5241 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5242 "BGP attribute is propagated unchanged to this neighbor\n"
5243 "As-path attribute\n"
5244 "Nexthop attribute\n"
5247 /* EBGP multihop configuration. */
5248 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
5249 const char *ttl_str
)
5254 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5256 return CMD_WARNING_CONFIG_FAILED
;
5259 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
5264 ttl
= strtoul(ttl_str
, NULL
, 10);
5266 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
5269 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
5273 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5275 return CMD_WARNING_CONFIG_FAILED
;
5277 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
5280 /* neighbor ebgp-multihop. */
5281 DEFUN (neighbor_ebgp_multihop
,
5282 neighbor_ebgp_multihop_cmd
,
5283 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
5286 "Allow EBGP neighbors not on directly connected networks\n")
5289 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5292 DEFUN (neighbor_ebgp_multihop_ttl
,
5293 neighbor_ebgp_multihop_ttl_cmd
,
5294 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
5297 "Allow EBGP neighbors not on directly connected networks\n"
5298 "maximum hop count\n")
5302 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
5303 argv
[idx_number
]->arg
);
5306 DEFUN (no_neighbor_ebgp_multihop
,
5307 no_neighbor_ebgp_multihop_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
5312 "Allow EBGP neighbors not on directly connected networks\n"
5313 "maximum hop count\n")
5316 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
5320 /* disable-connected-check */
5321 DEFUN (neighbor_disable_connected_check
,
5322 neighbor_disable_connected_check_cmd
,
5323 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5326 "one-hop away EBGP peer using loopback address\n"
5327 "Enforce EBGP neighbors perform multihop\n")
5330 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5331 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5334 DEFUN (no_neighbor_disable_connected_check
,
5335 no_neighbor_disable_connected_check_cmd
,
5336 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5340 "one-hop away EBGP peer using loopback address\n"
5341 "Enforce EBGP neighbors perform multihop\n")
5344 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5345 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5349 /* enforce-first-as */
5350 DEFUN (neighbor_enforce_first_as
,
5351 neighbor_enforce_first_as_cmd
,
5352 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5355 "Enforce the first AS for EBGP routes\n")
5359 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5360 PEER_FLAG_ENFORCE_FIRST_AS
);
5363 DEFUN (no_neighbor_enforce_first_as
,
5364 no_neighbor_enforce_first_as_cmd
,
5365 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5369 "Enforce the first AS for EBGP routes\n")
5373 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5374 PEER_FLAG_ENFORCE_FIRST_AS
);
5378 DEFUN (neighbor_description
,
5379 neighbor_description_cmd
,
5380 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5383 "Neighbor specific description\n"
5384 "Up to 80 characters describing this neighbor\n")
5391 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5393 return CMD_WARNING_CONFIG_FAILED
;
5395 str
= argv_concat(argv
, argc
, idx_line
);
5397 peer_description_set(peer
, str
);
5399 XFREE(MTYPE_TMP
, str
);
5404 DEFUN (no_neighbor_description
,
5405 no_neighbor_description_cmd
,
5406 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
5410 "Neighbor specific description\n")
5415 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5417 return CMD_WARNING_CONFIG_FAILED
;
5419 peer_description_unset(peer
);
5424 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
5425 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5426 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5427 "Neighbor specific description\n"
5428 "Up to 80 characters describing this neighbor\n")
5430 /* Neighbor update-source. */
5431 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
5432 const char *source_str
)
5438 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5440 return CMD_WARNING_CONFIG_FAILED
;
5446 if (str2sockunion(source_str
, &su
) == 0)
5447 peer_update_source_addr_set(peer
, &su
);
5449 if (str2prefix(source_str
, &p
)) {
5451 "%% Invalid update-source, remove prefix length \n");
5452 return CMD_WARNING_CONFIG_FAILED
;
5454 peer_update_source_if_set(peer
, source_str
);
5457 peer_update_source_unset(peer
);
5462 #define BGP_UPDATE_SOURCE_HELP_STR \
5465 "Interface name (requires zebra to be running)\n"
5467 DEFUN (neighbor_update_source
,
5468 neighbor_update_source_cmd
,
5469 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
5472 "Source of routing updates\n"
5473 BGP_UPDATE_SOURCE_HELP_STR
)
5477 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
5478 argv
[idx_peer_2
]->arg
);
5481 DEFUN (no_neighbor_update_source
,
5482 no_neighbor_update_source_cmd
,
5483 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
5487 "Source of routing updates\n"
5488 BGP_UPDATE_SOURCE_HELP_STR
)
5491 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5494 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
5495 afi_t afi
, safi_t safi
,
5496 const char *rmap
, int set
)
5500 struct route_map
*route_map
= NULL
;
5502 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5508 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
5509 ret
= peer_default_originate_set(peer
, afi
, safi
,
5512 ret
= peer_default_originate_unset(peer
, afi
, safi
);
5514 return bgp_vty_return(vty
, ret
);
5517 /* neighbor default-originate. */
5518 DEFUN (neighbor_default_originate
,
5519 neighbor_default_originate_cmd
,
5520 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5523 "Originate default route to this neighbor\n")
5526 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5528 bgp_node_safi(vty
), NULL
, 1);
5531 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
5532 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5533 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5534 "Originate default route to this neighbor\n")
5536 DEFUN (neighbor_default_originate_rmap
,
5537 neighbor_default_originate_rmap_cmd
,
5538 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5541 "Originate default route to this neighbor\n"
5542 "Route-map to specify criteria to originate default\n"
5547 return peer_default_originate_set_vty(
5548 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5549 argv
[idx_word
]->arg
, 1);
5553 neighbor_default_originate_rmap
,
5554 neighbor_default_originate_rmap_hidden_cmd
,
5555 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5556 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5557 "Originate default route to this neighbor\n"
5558 "Route-map to specify criteria to originate default\n"
5561 DEFUN (no_neighbor_default_originate
,
5562 no_neighbor_default_originate_cmd
,
5563 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5567 "Originate default route to this neighbor\n"
5568 "Route-map to specify criteria to originate default\n"
5572 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5574 bgp_node_safi(vty
), NULL
, 0);
5578 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5579 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5580 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5581 "Originate default route to this neighbor\n"
5582 "Route-map to specify criteria to originate default\n"
5586 /* Set neighbor's BGP port. */
5587 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5588 const char *port_str
)
5594 peer
= peer_lookup_vty(vty
, ip_str
);
5596 return CMD_WARNING_CONFIG_FAILED
;
5599 sp
= getservbyname("bgp", "tcp");
5600 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5602 port
= strtoul(port_str
, NULL
, 10);
5605 peer_port_set(peer
, port
);
5610 /* Set specified peer's BGP port. */
5611 DEFUN (neighbor_port
,
5613 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5616 "Neighbor's BGP port\n"
5617 "TCP port number\n")
5621 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5622 argv
[idx_number
]->arg
);
5625 DEFUN (no_neighbor_port
,
5626 no_neighbor_port_cmd
,
5627 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5631 "Neighbor's BGP port\n"
5632 "TCP port number\n")
5635 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5639 /* neighbor weight. */
5640 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5641 safi_t safi
, const char *weight_str
)
5645 unsigned long weight
;
5647 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5649 return CMD_WARNING_CONFIG_FAILED
;
5651 weight
= strtoul(weight_str
, NULL
, 10);
5653 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5654 return bgp_vty_return(vty
, ret
);
5657 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5663 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5665 return CMD_WARNING_CONFIG_FAILED
;
5667 ret
= peer_weight_unset(peer
, afi
, safi
);
5668 return bgp_vty_return(vty
, ret
);
5671 DEFUN (neighbor_weight
,
5672 neighbor_weight_cmd
,
5673 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5676 "Set default weight for routes from this neighbor\n"
5681 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5682 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5685 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5686 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5687 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5688 "Set default weight for routes from this neighbor\n"
5691 DEFUN (no_neighbor_weight
,
5692 no_neighbor_weight_cmd
,
5693 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5697 "Set default weight for routes from this neighbor\n"
5701 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5702 bgp_node_afi(vty
), bgp_node_safi(vty
));
5705 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5706 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5708 "Set default weight for routes from this neighbor\n"
5712 /* Override capability negotiation. */
5713 DEFUN (neighbor_override_capability
,
5714 neighbor_override_capability_cmd
,
5715 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5718 "Override capability negotiation result\n")
5721 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5722 PEER_FLAG_OVERRIDE_CAPABILITY
);
5725 DEFUN (no_neighbor_override_capability
,
5726 no_neighbor_override_capability_cmd
,
5727 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5731 "Override capability negotiation result\n")
5734 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5735 PEER_FLAG_OVERRIDE_CAPABILITY
);
5738 DEFUN (neighbor_strict_capability
,
5739 neighbor_strict_capability_cmd
,
5740 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5743 "Strict capability negotiation match\n")
5747 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5748 PEER_FLAG_STRICT_CAP_MATCH
);
5751 DEFUN (no_neighbor_strict_capability
,
5752 no_neighbor_strict_capability_cmd
,
5753 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5757 "Strict capability negotiation match\n")
5761 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5762 PEER_FLAG_STRICT_CAP_MATCH
);
5765 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5766 const char *keep_str
, const char *hold_str
)
5773 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5775 return CMD_WARNING_CONFIG_FAILED
;
5777 keepalive
= strtoul(keep_str
, NULL
, 10);
5778 holdtime
= strtoul(hold_str
, NULL
, 10);
5780 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5782 return bgp_vty_return(vty
, ret
);
5785 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5790 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5792 return CMD_WARNING_CONFIG_FAILED
;
5794 ret
= peer_timers_unset(peer
);
5796 return bgp_vty_return(vty
, ret
);
5799 DEFUN (neighbor_timers
,
5800 neighbor_timers_cmd
,
5801 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5804 "BGP per neighbor timers\n"
5805 "Keepalive interval\n"
5810 int idx_number_2
= 4;
5811 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5812 argv
[idx_number
]->arg
,
5813 argv
[idx_number_2
]->arg
);
5816 DEFUN (no_neighbor_timers
,
5817 no_neighbor_timers_cmd
,
5818 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5822 "BGP per neighbor timers\n"
5823 "Keepalive interval\n"
5827 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5831 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5832 const char *time_str
)
5838 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5840 return CMD_WARNING_CONFIG_FAILED
;
5842 connect
= strtoul(time_str
, NULL
, 10);
5844 ret
= peer_timers_connect_set(peer
, connect
);
5846 return bgp_vty_return(vty
, ret
);
5849 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5854 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5856 return CMD_WARNING_CONFIG_FAILED
;
5858 ret
= peer_timers_connect_unset(peer
);
5860 return bgp_vty_return(vty
, ret
);
5863 DEFUN (neighbor_timers_connect
,
5864 neighbor_timers_connect_cmd
,
5865 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5868 "BGP per neighbor timers\n"
5869 "BGP connect timer\n"
5874 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5875 argv
[idx_number
]->arg
);
5878 DEFUN (no_neighbor_timers_connect
,
5879 no_neighbor_timers_connect_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5884 "BGP per neighbor timers\n"
5885 "BGP connect timer\n"
5889 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5893 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5894 const char *time_str
, int set
)
5898 uint32_t routeadv
= 0;
5900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5902 return CMD_WARNING_CONFIG_FAILED
;
5905 routeadv
= strtoul(time_str
, NULL
, 10);
5908 ret
= peer_advertise_interval_set(peer
, routeadv
);
5910 ret
= peer_advertise_interval_unset(peer
);
5912 return bgp_vty_return(vty
, ret
);
5915 DEFUN (neighbor_advertise_interval
,
5916 neighbor_advertise_interval_cmd
,
5917 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5920 "Minimum interval between sending BGP routing updates\n"
5921 "time in seconds\n")
5925 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5926 argv
[idx_number
]->arg
, 1);
5929 DEFUN (no_neighbor_advertise_interval
,
5930 no_neighbor_advertise_interval_cmd
,
5931 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5935 "Minimum interval between sending BGP routing updates\n"
5936 "time in seconds\n")
5939 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5943 /* Time to wait before processing route-map updates */
5944 DEFUN (bgp_set_route_map_delay_timer
,
5945 bgp_set_route_map_delay_timer_cmd
,
5946 "bgp route-map delay-timer (0-600)",
5948 "BGP route-map delay timer\n"
5949 "Time in secs to wait before processing route-map changes\n"
5950 "0 disables the timer, no route updates happen when route-maps change\n")
5953 uint32_t rmap_delay_timer
;
5955 if (argv
[idx_number
]->arg
) {
5956 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5957 bm
->rmap_update_timer
= rmap_delay_timer
;
5959 /* if the dynamic update handling is being disabled, and a timer
5961 * running, stop the timer and act as if the timer has already
5964 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5965 BGP_TIMER_OFF(bm
->t_rmap_update
);
5966 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5971 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5972 return CMD_WARNING_CONFIG_FAILED
;
5976 DEFUN (no_bgp_set_route_map_delay_timer
,
5977 no_bgp_set_route_map_delay_timer_cmd
,
5978 "no bgp route-map delay-timer [(0-600)]",
5981 "Default BGP route-map delay timer\n"
5982 "Reset to default time to wait for processing route-map changes\n"
5983 "0 disables the timer, no route updates happen when route-maps change\n")
5986 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5992 /* neighbor interface */
5993 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5998 peer
= peer_lookup_vty(vty
, ip_str
);
5999 if (!peer
|| peer
->conf_if
) {
6000 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
6001 return CMD_WARNING_CONFIG_FAILED
;
6005 peer_interface_set(peer
, str
);
6007 peer_interface_unset(peer
);
6012 DEFUN (neighbor_interface
,
6013 neighbor_interface_cmd
,
6014 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
6022 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
6025 DEFUN (no_neighbor_interface
,
6026 no_neighbor_interface_cmd
,
6027 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
6035 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6038 DEFUN (neighbor_distribute_list
,
6039 neighbor_distribute_list_cmd
,
6040 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6043 "Filter updates to/from this neighbor\n"
6044 "IP access-list number\n"
6045 "IP access-list number (expanded range)\n"
6046 "IP Access-list name\n"
6047 "Filter incoming updates\n"
6048 "Filter outgoing updates\n")
6055 const char *pstr
= argv
[idx_peer
]->arg
;
6056 const char *acl
= argv
[idx_acl
]->arg
;
6057 const char *inout
= argv
[argc
- 1]->text
;
6059 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6061 return CMD_WARNING_CONFIG_FAILED
;
6063 /* Check filter direction. */
6064 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6065 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6068 return bgp_vty_return(vty
, ret
);
6072 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
6073 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6074 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6075 "Filter updates to/from this neighbor\n"
6076 "IP access-list number\n"
6077 "IP access-list number (expanded range)\n"
6078 "IP Access-list name\n"
6079 "Filter incoming updates\n"
6080 "Filter outgoing updates\n")
6082 DEFUN (no_neighbor_distribute_list
,
6083 no_neighbor_distribute_list_cmd
,
6084 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6088 "Filter updates to/from this neighbor\n"
6089 "IP access-list number\n"
6090 "IP access-list number (expanded range)\n"
6091 "IP Access-list name\n"
6092 "Filter incoming updates\n"
6093 "Filter outgoing updates\n")
6099 const char *pstr
= argv
[idx_peer
]->arg
;
6100 const char *inout
= argv
[argc
- 1]->text
;
6102 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6104 return CMD_WARNING_CONFIG_FAILED
;
6106 /* Check filter direction. */
6107 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6108 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6111 return bgp_vty_return(vty
, ret
);
6115 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
6116 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6117 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6118 "Filter updates to/from this neighbor\n"
6119 "IP access-list number\n"
6120 "IP access-list number (expanded range)\n"
6121 "IP Access-list name\n"
6122 "Filter incoming updates\n"
6123 "Filter outgoing updates\n")
6125 /* Set prefix list to the peer. */
6126 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
6127 afi_t afi
, safi_t safi
,
6128 const char *name_str
,
6129 const char *direct_str
)
6132 int direct
= FILTER_IN
;
6135 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6137 return CMD_WARNING_CONFIG_FAILED
;
6139 /* Check filter direction. */
6140 if (strncmp(direct_str
, "i", 1) == 0)
6142 else if (strncmp(direct_str
, "o", 1) == 0)
6143 direct
= FILTER_OUT
;
6145 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
6147 return bgp_vty_return(vty
, ret
);
6150 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
6151 afi_t afi
, safi_t safi
,
6152 const char *direct_str
)
6156 int direct
= FILTER_IN
;
6158 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6160 return CMD_WARNING_CONFIG_FAILED
;
6162 /* Check filter direction. */
6163 if (strncmp(direct_str
, "i", 1) == 0)
6165 else if (strncmp(direct_str
, "o", 1) == 0)
6166 direct
= FILTER_OUT
;
6168 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
6170 return bgp_vty_return(vty
, ret
);
6173 DEFUN (neighbor_prefix_list
,
6174 neighbor_prefix_list_cmd
,
6175 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6178 "Filter updates to/from this neighbor\n"
6179 "Name of a prefix list\n"
6180 "Filter incoming updates\n"
6181 "Filter outgoing updates\n")
6186 return peer_prefix_list_set_vty(
6187 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6188 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6191 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
6192 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6193 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6194 "Filter updates to/from this neighbor\n"
6195 "Name of a prefix list\n"
6196 "Filter incoming updates\n"
6197 "Filter outgoing updates\n")
6199 DEFUN (no_neighbor_prefix_list
,
6200 no_neighbor_prefix_list_cmd
,
6201 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6205 "Filter updates to/from this neighbor\n"
6206 "Name of a prefix list\n"
6207 "Filter incoming updates\n"
6208 "Filter outgoing updates\n")
6212 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
6213 bgp_node_afi(vty
), bgp_node_safi(vty
),
6214 argv
[idx_in_out
]->arg
);
6217 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
6218 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6219 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6220 "Filter updates to/from this neighbor\n"
6221 "Name of a prefix list\n"
6222 "Filter incoming updates\n"
6223 "Filter outgoing updates\n")
6225 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6226 safi_t safi
, const char *name_str
,
6227 const char *direct_str
)
6231 int direct
= FILTER_IN
;
6233 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6235 return CMD_WARNING_CONFIG_FAILED
;
6237 /* Check filter direction. */
6238 if (strncmp(direct_str
, "i", 1) == 0)
6240 else if (strncmp(direct_str
, "o", 1) == 0)
6241 direct
= FILTER_OUT
;
6243 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
6245 return bgp_vty_return(vty
, ret
);
6248 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6249 safi_t safi
, const char *direct_str
)
6253 int direct
= FILTER_IN
;
6255 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6257 return CMD_WARNING_CONFIG_FAILED
;
6259 /* Check filter direction. */
6260 if (strncmp(direct_str
, "i", 1) == 0)
6262 else if (strncmp(direct_str
, "o", 1) == 0)
6263 direct
= FILTER_OUT
;
6265 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
6267 return bgp_vty_return(vty
, ret
);
6270 DEFUN (neighbor_filter_list
,
6271 neighbor_filter_list_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6275 "Establish BGP filters\n"
6276 "AS path access-list name\n"
6277 "Filter incoming routes\n"
6278 "Filter outgoing routes\n")
6283 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6284 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
6285 argv
[idx_in_out
]->arg
);
6288 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
6289 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6291 "Establish BGP filters\n"
6292 "AS path access-list name\n"
6293 "Filter incoming routes\n"
6294 "Filter outgoing routes\n")
6296 DEFUN (no_neighbor_filter_list
,
6297 no_neighbor_filter_list_cmd
,
6298 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6302 "Establish BGP filters\n"
6303 "AS path access-list name\n"
6304 "Filter incoming routes\n"
6305 "Filter outgoing routes\n")
6309 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
6310 bgp_node_afi(vty
), bgp_node_safi(vty
),
6311 argv
[idx_in_out
]->arg
);
6314 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
6315 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6316 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6317 "Establish BGP filters\n"
6318 "AS path access-list name\n"
6319 "Filter incoming routes\n"
6320 "Filter outgoing routes\n")
6322 /* Set route-map to the peer. */
6323 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
6324 afi_t afi
, safi_t safi
, const char *name_str
,
6325 const char *direct_str
)
6329 int direct
= RMAP_IN
;
6330 struct route_map
*route_map
;
6332 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6334 return CMD_WARNING_CONFIG_FAILED
;
6336 /* Check filter direction. */
6337 if (strncmp(direct_str
, "in", 2) == 0)
6339 else if (strncmp(direct_str
, "o", 1) == 0)
6342 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6343 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
6345 return bgp_vty_return(vty
, ret
);
6348 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6349 afi_t afi
, safi_t safi
,
6350 const char *direct_str
)
6354 int direct
= RMAP_IN
;
6356 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6358 return CMD_WARNING_CONFIG_FAILED
;
6360 /* Check filter direction. */
6361 if (strncmp(direct_str
, "in", 2) == 0)
6363 else if (strncmp(direct_str
, "o", 1) == 0)
6366 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
6368 return bgp_vty_return(vty
, ret
);
6371 DEFUN (neighbor_route_map
,
6372 neighbor_route_map_cmd
,
6373 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6376 "Apply route map to neighbor\n"
6377 "Name of route map\n"
6378 "Apply map to incoming routes\n"
6379 "Apply map to outbound routes\n")
6384 return peer_route_map_set_vty(
6385 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6386 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6389 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
6390 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6391 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6392 "Apply route map to neighbor\n"
6393 "Name of route map\n"
6394 "Apply map to incoming routes\n"
6395 "Apply map to outbound routes\n")
6397 DEFUN (no_neighbor_route_map
,
6398 no_neighbor_route_map_cmd
,
6399 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6403 "Apply route map to neighbor\n"
6404 "Name of route map\n"
6405 "Apply map to incoming routes\n"
6406 "Apply map to outbound routes\n")
6410 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6411 bgp_node_afi(vty
), bgp_node_safi(vty
),
6412 argv
[idx_in_out
]->arg
);
6415 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
6416 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6417 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6418 "Apply route map to neighbor\n"
6419 "Name of route map\n"
6420 "Apply map to incoming routes\n"
6421 "Apply map to outbound routes\n")
6423 /* Set unsuppress-map to the peer. */
6424 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
6425 afi_t afi
, safi_t safi
,
6426 const char *name_str
)
6430 struct route_map
*route_map
;
6432 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6434 return CMD_WARNING_CONFIG_FAILED
;
6436 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6437 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
6439 return bgp_vty_return(vty
, ret
);
6442 /* Unset route-map from the peer. */
6443 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6444 afi_t afi
, safi_t safi
)
6449 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6451 return CMD_WARNING_CONFIG_FAILED
;
6453 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
6455 return bgp_vty_return(vty
, ret
);
6458 DEFUN (neighbor_unsuppress_map
,
6459 neighbor_unsuppress_map_cmd
,
6460 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6463 "Route-map to selectively unsuppress suppressed routes\n"
6464 "Name of route map\n")
6468 return peer_unsuppress_map_set_vty(
6469 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6470 argv
[idx_word
]->arg
);
6473 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
6474 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6475 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6476 "Route-map to selectively unsuppress suppressed routes\n"
6477 "Name of route map\n")
6479 DEFUN (no_neighbor_unsuppress_map
,
6480 no_neighbor_unsuppress_map_cmd
,
6481 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6485 "Route-map to selectively unsuppress suppressed routes\n"
6486 "Name of route map\n")
6489 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6491 bgp_node_safi(vty
));
6494 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
6495 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6496 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6497 "Route-map to selectively unsuppress suppressed routes\n"
6498 "Name of route map\n")
6500 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
6501 afi_t afi
, safi_t safi
,
6502 const char *num_str
,
6503 const char *threshold_str
, int warning
,
6504 const char *restart_str
)
6512 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6514 return CMD_WARNING_CONFIG_FAILED
;
6516 max
= strtoul(num_str
, NULL
, 10);
6518 threshold
= atoi(threshold_str
);
6520 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
6523 restart
= atoi(restart_str
);
6527 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
6530 return bgp_vty_return(vty
, ret
);
6533 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
6534 afi_t afi
, safi_t safi
)
6539 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6541 return CMD_WARNING_CONFIG_FAILED
;
6543 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
6545 return bgp_vty_return(vty
, ret
);
6548 /* Maximum number of prefix to be sent to the neighbor. */
6549 DEFUN(neighbor_maximum_prefix_out
,
6550 neighbor_maximum_prefix_out_cmd
,
6551 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
6554 "Maximum number of prefixes to be sent to this peer\n"
6555 "Maximum no. of prefix limit\n")
6561 afi_t afi
= bgp_node_afi(vty
);
6562 safi_t safi
= bgp_node_safi(vty
);
6564 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6566 return CMD_WARNING_CONFIG_FAILED
;
6568 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6570 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
6571 peer
->pmax_out
[afi
][safi
] = max
;
6576 DEFUN(no_neighbor_maximum_prefix_out
,
6577 no_neighbor_maximum_prefix_out_cmd
,
6578 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
6582 "Maximum number of prefixes to be sent to this peer\n")
6586 afi_t afi
= bgp_node_afi(vty
);
6587 safi_t safi
= bgp_node_safi(vty
);
6589 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6591 return CMD_WARNING_CONFIG_FAILED
;
6593 peer
->pmax_out
[afi
][safi
] = 0;
6598 /* Maximum number of prefix configuration. prefix count is different
6599 for each peer configuration. So this configuration can be set for
6600 each peer configuration. */
6601 DEFUN (neighbor_maximum_prefix
,
6602 neighbor_maximum_prefix_cmd
,
6603 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6606 "Maximum number of prefix accept from this peer\n"
6607 "maximum no. of prefix limit\n")
6611 return peer_maximum_prefix_set_vty(
6612 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6613 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6616 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6617 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6618 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6619 "Maximum number of prefix accept from this peer\n"
6620 "maximum no. of prefix limit\n")
6622 DEFUN (neighbor_maximum_prefix_threshold
,
6623 neighbor_maximum_prefix_threshold_cmd
,
6624 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6627 "Maximum number of prefix accept from this peer\n"
6628 "maximum no. of prefix limit\n"
6629 "Threshold value (%) at which to generate a warning msg\n")
6633 int idx_number_2
= 4;
6634 return peer_maximum_prefix_set_vty(
6635 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6636 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6640 neighbor_maximum_prefix_threshold
,
6641 neighbor_maximum_prefix_threshold_hidden_cmd
,
6642 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6643 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6644 "Maximum number of prefix accept from this peer\n"
6645 "maximum no. of prefix limit\n"
6646 "Threshold value (%) at which to generate a warning msg\n")
6648 DEFUN (neighbor_maximum_prefix_warning
,
6649 neighbor_maximum_prefix_warning_cmd
,
6650 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6653 "Maximum number of prefix accept from this peer\n"
6654 "maximum no. of prefix limit\n"
6655 "Only give warning message when limit is exceeded\n")
6659 return peer_maximum_prefix_set_vty(
6660 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6661 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6665 neighbor_maximum_prefix_warning
,
6666 neighbor_maximum_prefix_warning_hidden_cmd
,
6667 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6668 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6669 "Maximum number of prefix accept from this peer\n"
6670 "maximum no. of prefix limit\n"
6671 "Only give warning message when limit is exceeded\n")
6673 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6674 neighbor_maximum_prefix_threshold_warning_cmd
,
6675 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6678 "Maximum number of prefix accept from this peer\n"
6679 "maximum no. of prefix limit\n"
6680 "Threshold value (%) at which to generate a warning msg\n"
6681 "Only give warning message when limit is exceeded\n")
6685 int idx_number_2
= 4;
6686 return peer_maximum_prefix_set_vty(
6687 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6688 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6692 neighbor_maximum_prefix_threshold_warning
,
6693 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6694 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6695 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6696 "Maximum number of prefix accept from this peer\n"
6697 "maximum no. of prefix limit\n"
6698 "Threshold value (%) at which to generate a warning msg\n"
6699 "Only give warning message when limit is exceeded\n")
6701 DEFUN (neighbor_maximum_prefix_restart
,
6702 neighbor_maximum_prefix_restart_cmd
,
6703 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6706 "Maximum number of prefix accept from this peer\n"
6707 "maximum no. of prefix limit\n"
6708 "Restart bgp connection after limit is exceeded\n"
6709 "Restart interval in minutes\n")
6713 int idx_number_2
= 5;
6714 return peer_maximum_prefix_set_vty(
6715 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6716 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6720 neighbor_maximum_prefix_restart
,
6721 neighbor_maximum_prefix_restart_hidden_cmd
,
6722 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6723 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6724 "Maximum number of prefix accept from this peer\n"
6725 "maximum no. of prefix limit\n"
6726 "Restart bgp connection after limit is exceeded\n"
6727 "Restart interval in minutes\n")
6729 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6730 neighbor_maximum_prefix_threshold_restart_cmd
,
6731 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6734 "Maximum number of prefixes to accept from this peer\n"
6735 "maximum no. of prefix limit\n"
6736 "Threshold value (%) at which to generate a warning msg\n"
6737 "Restart bgp connection after limit is exceeded\n"
6738 "Restart interval in minutes\n")
6742 int idx_number_2
= 4;
6743 int idx_number_3
= 6;
6744 return peer_maximum_prefix_set_vty(
6745 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6746 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6747 argv
[idx_number_3
]->arg
);
6751 neighbor_maximum_prefix_threshold_restart
,
6752 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6753 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6754 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6755 "Maximum number of prefixes to accept from this peer\n"
6756 "maximum no. of prefix limit\n"
6757 "Threshold value (%) at which to generate a warning msg\n"
6758 "Restart bgp connection after limit is exceeded\n"
6759 "Restart interval in minutes\n")
6761 DEFUN (no_neighbor_maximum_prefix
,
6762 no_neighbor_maximum_prefix_cmd
,
6763 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6767 "Maximum number of prefixes to accept from this peer\n"
6768 "maximum no. of prefix limit\n"
6769 "Threshold value (%) at which to generate a warning msg\n"
6770 "Restart bgp connection after limit is exceeded\n"
6771 "Restart interval in minutes\n"
6772 "Only give warning message when limit is exceeded\n")
6775 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6777 bgp_node_safi(vty
));
6781 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6782 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6783 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6784 "Maximum number of prefixes to accept from this peer\n"
6785 "maximum no. of prefix limit\n"
6786 "Threshold value (%) at which to generate a warning msg\n"
6787 "Restart bgp connection after limit is exceeded\n"
6788 "Restart interval in minutes\n"
6789 "Only give warning message when limit is exceeded\n")
6792 /* "neighbor allowas-in" */
6793 DEFUN (neighbor_allowas_in
,
6794 neighbor_allowas_in_cmd
,
6795 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6798 "Accept as-path with my AS present in it\n"
6799 "Number of occurrences of AS number\n"
6800 "Only accept my AS in the as-path if the route was originated in my AS\n")
6803 int idx_number_origin
= 3;
6809 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6811 return CMD_WARNING_CONFIG_FAILED
;
6813 if (argc
<= idx_number_origin
)
6816 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6819 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6822 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6825 return bgp_vty_return(vty
, ret
);
6829 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6830 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6831 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6832 "Accept as-path with my AS present in it\n"
6833 "Number of occurrences of AS number\n"
6834 "Only accept my AS in the as-path if the route was originated in my AS\n")
6836 DEFUN (no_neighbor_allowas_in
,
6837 no_neighbor_allowas_in_cmd
,
6838 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6842 "allow local ASN appears in aspath attribute\n"
6843 "Number of occurrences of AS number\n"
6844 "Only accept my AS in the as-path if the route was originated in my AS\n")
6850 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6852 return CMD_WARNING_CONFIG_FAILED
;
6854 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6855 bgp_node_safi(vty
));
6857 return bgp_vty_return(vty
, ret
);
6861 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6862 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6863 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6864 "allow local ASN appears in aspath attribute\n"
6865 "Number of occurrences of AS number\n"
6866 "Only accept my AS in the as-path if the route was originated in my AS\n")
6868 DEFUN (neighbor_ttl_security
,
6869 neighbor_ttl_security_cmd
,
6870 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6873 "BGP ttl-security parameters\n"
6874 "Specify the maximum number of hops to the BGP peer\n"
6875 "Number of hops to BGP peer\n")
6882 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6884 return CMD_WARNING_CONFIG_FAILED
;
6886 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6889 * If 'neighbor swpX', then this is for directly connected peers,
6890 * we should not accept a ttl-security hops value greater than 1.
6892 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
6894 "%s is directly connected peer, hops cannot exceed 1\n",
6895 argv
[idx_peer
]->arg
);
6896 return CMD_WARNING_CONFIG_FAILED
;
6899 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6902 DEFUN (no_neighbor_ttl_security
,
6903 no_neighbor_ttl_security_cmd
,
6904 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6908 "BGP ttl-security parameters\n"
6909 "Specify the maximum number of hops to the BGP peer\n"
6910 "Number of hops to BGP peer\n")
6915 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6917 return CMD_WARNING_CONFIG_FAILED
;
6919 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6922 DEFUN (neighbor_addpath_tx_all_paths
,
6923 neighbor_addpath_tx_all_paths_cmd
,
6924 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6927 "Use addpath to advertise all paths to a neighbor\n")
6932 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6934 return CMD_WARNING_CONFIG_FAILED
;
6936 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6941 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6942 neighbor_addpath_tx_all_paths_hidden_cmd
,
6943 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6944 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6945 "Use addpath to advertise all paths to a neighbor\n")
6947 DEFUN (no_neighbor_addpath_tx_all_paths
,
6948 no_neighbor_addpath_tx_all_paths_cmd
,
6949 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6953 "Use addpath to advertise all paths to a neighbor\n")
6958 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6960 return CMD_WARNING_CONFIG_FAILED
;
6962 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6963 != BGP_ADDPATH_ALL
) {
6965 "%% Peer not currently configured to transmit all paths.");
6966 return CMD_WARNING_CONFIG_FAILED
;
6969 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6975 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6976 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6977 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6978 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6979 "Use addpath to advertise all paths to a neighbor\n")
6981 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6982 neighbor_addpath_tx_bestpath_per_as_cmd
,
6983 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6986 "Use addpath to advertise the bestpath per each neighboring AS\n")
6991 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6993 return CMD_WARNING_CONFIG_FAILED
;
6995 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6996 BGP_ADDPATH_BEST_PER_AS
);
7001 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
7002 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7003 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7004 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7005 "Use addpath to advertise the bestpath per each neighboring AS\n")
7007 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
7008 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
7009 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7013 "Use addpath to advertise the bestpath per each neighboring AS\n")
7018 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7020 return CMD_WARNING_CONFIG_FAILED
;
7022 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7023 != BGP_ADDPATH_BEST_PER_AS
) {
7025 "%% Peer not currently configured to transmit all best path per as.");
7026 return CMD_WARNING_CONFIG_FAILED
;
7029 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7035 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
7036 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7037 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7038 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7039 "Use addpath to advertise the bestpath per each neighboring AS\n")
7042 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
7043 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7046 "Detect AS loops before sending to neighbor\n")
7050 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7052 return CMD_WARNING_CONFIG_FAILED
;
7054 peer
->as_path_loop_detection
= true;
7060 no_neighbor_aspath_loop_detection
,
7061 no_neighbor_aspath_loop_detection_cmd
,
7062 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7066 "Detect AS loops before sending to neighbor\n")
7070 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7072 return CMD_WARNING_CONFIG_FAILED
;
7074 peer
->as_path_loop_detection
= false;
7079 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
7080 struct ecommunity
**list
)
7082 struct ecommunity
*ecom
= NULL
;
7083 struct ecommunity
*ecomadd
;
7085 for (; argc
; --argc
, ++argv
) {
7087 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
7088 ECOMMUNITY_ROUTE_TARGET
, 0);
7090 vty_out(vty
, "Malformed community-list value\n");
7092 ecommunity_free(&ecom
);
7093 return CMD_WARNING_CONFIG_FAILED
;
7097 ecommunity_merge(ecom
, ecomadd
);
7098 ecommunity_free(&ecomadd
);
7105 ecommunity_free(&*list
);
7113 * v2vimport is true if we are handling a `import vrf ...` command
7115 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
7119 switch (vty
->node
) {
7128 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
7133 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7134 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
7135 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7136 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
7138 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
7142 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7143 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
7144 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7145 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
7147 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
7154 DEFPY (af_rd_vpn_export
,
7155 af_rd_vpn_export_cmd
,
7156 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
7158 "Specify route distinguisher\n"
7159 "Between current address-family and vpn\n"
7160 "For routes leaked from current address-family to vpn\n"
7161 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
7163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7164 struct prefix_rd prd
;
7170 if (argv_find(argv
, argc
, "no", &idx
))
7174 ret
= str2prefix_rd(rd_str
, &prd
);
7176 vty_out(vty
, "%% Malformed rd\n");
7177 return CMD_WARNING_CONFIG_FAILED
;
7181 afi
= vpn_policy_getafi(vty
, bgp
, false);
7183 return CMD_WARNING_CONFIG_FAILED
;
7186 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7188 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7189 bgp_get_default(), bgp
);
7192 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
7193 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7194 BGP_VPN_POLICY_TOVPN_RD_SET
);
7196 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7197 BGP_VPN_POLICY_TOVPN_RD_SET
);
7200 /* post-change: re-export vpn routes */
7201 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7202 bgp_get_default(), bgp
);
7207 ALIAS (af_rd_vpn_export
,
7208 af_no_rd_vpn_export_cmd
,
7211 "Specify route distinguisher\n"
7212 "Between current address-family and vpn\n"
7213 "For routes leaked from current address-family to vpn\n")
7215 DEFPY (af_label_vpn_export
,
7216 af_label_vpn_export_cmd
,
7217 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
7219 "label value for VRF\n"
7220 "Between current address-family and vpn\n"
7221 "For routes leaked from current address-family to vpn\n"
7222 "Label Value <0-1048575>\n"
7223 "Automatically assign a label\n")
7225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7226 mpls_label_t label
= MPLS_LABEL_NONE
;
7231 if (argv_find(argv
, argc
, "no", &idx
))
7234 /* If "no ...", squash trailing parameter */
7240 label
= label_val
; /* parser should force unsigned */
7243 afi
= vpn_policy_getafi(vty
, bgp
, false);
7245 return CMD_WARNING_CONFIG_FAILED
;
7248 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7249 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
7254 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7256 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7257 bgp_get_default(), bgp
);
7259 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7260 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
7262 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
7265 * label has previously been automatically
7266 * assigned by labelpool: release it
7268 * NB if tovpn_label == MPLS_LABEL_NONE it
7269 * means the automatic assignment is in flight
7270 * and therefore the labelpool callback must
7271 * detect that the auto label is not needed.
7274 bgp_lp_release(LP_TYPE_VRF
,
7275 &bgp
->vpn_policy
[afi
],
7276 bgp
->vpn_policy
[afi
].tovpn_label
);
7278 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7279 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7282 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
7284 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7285 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7286 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
7287 vpn_leak_label_callback
);
7290 /* post-change: re-export vpn routes */
7291 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7292 bgp_get_default(), bgp
);
7297 ALIAS (af_label_vpn_export
,
7298 af_no_label_vpn_export_cmd
,
7299 "no label vpn export",
7301 "label value for VRF\n"
7302 "Between current address-family and vpn\n"
7303 "For routes leaked from current address-family to vpn\n")
7305 DEFPY (af_nexthop_vpn_export
,
7306 af_nexthop_vpn_export_cmd
,
7307 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
7309 "Specify next hop to use for VRF advertised prefixes\n"
7310 "Between current address-family and vpn\n"
7311 "For routes leaked from current address-family to vpn\n"
7315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7321 if (argv_find(argv
, argc
, "no", &idx
))
7325 if (!sockunion2hostprefix(nexthop_str
, &p
))
7326 return CMD_WARNING_CONFIG_FAILED
;
7329 afi
= vpn_policy_getafi(vty
, bgp
, false);
7331 return CMD_WARNING_CONFIG_FAILED
;
7334 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7336 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7337 bgp_get_default(), bgp
);
7340 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
7341 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7342 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7344 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7345 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7348 /* post-change: re-export vpn routes */
7349 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7350 bgp_get_default(), bgp
);
7355 ALIAS (af_nexthop_vpn_export
,
7356 af_no_nexthop_vpn_export_cmd
,
7357 "no nexthop vpn export",
7359 "Specify next hop to use for VRF advertised prefixes\n"
7360 "Between current address-family and vpn\n"
7361 "For routes leaked from current address-family to vpn\n")
7363 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
7365 if (!strcmp(dstr
, "import")) {
7366 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7367 } else if (!strcmp(dstr
, "export")) {
7368 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7369 } else if (!strcmp(dstr
, "both")) {
7370 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7371 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7373 vty_out(vty
, "%% direction parse error\n");
7374 return CMD_WARNING_CONFIG_FAILED
;
7379 DEFPY (af_rt_vpn_imexport
,
7380 af_rt_vpn_imexport_cmd
,
7381 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
7383 "Specify route target list\n"
7384 "Specify route target list\n"
7385 "Between current address-family and vpn\n"
7386 "For routes leaked from vpn to current address-family: match any\n"
7387 "For routes leaked from current address-family to vpn: set\n"
7388 "both import: match any and export: set\n"
7389 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7393 struct ecommunity
*ecom
= NULL
;
7394 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7395 vpn_policy_direction_t dir
;
7400 if (argv_find(argv
, argc
, "no", &idx
))
7403 afi
= vpn_policy_getafi(vty
, bgp
, false);
7405 return CMD_WARNING_CONFIG_FAILED
;
7407 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7408 if (ret
!= CMD_SUCCESS
)
7412 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7413 vty_out(vty
, "%% Missing RTLIST\n");
7414 return CMD_WARNING_CONFIG_FAILED
;
7416 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7417 if (ret
!= CMD_SUCCESS
) {
7422 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7426 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7429 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7431 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7432 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
7433 ecommunity_dup(ecom
);
7435 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7437 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7438 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
7441 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7445 ecommunity_free(&ecom
);
7450 ALIAS (af_rt_vpn_imexport
,
7451 af_no_rt_vpn_imexport_cmd
,
7452 "no <rt|route-target> vpn <import|export|both>$direction_str",
7454 "Specify route target list\n"
7455 "Specify route target list\n"
7456 "Between current address-family and vpn\n"
7457 "For routes leaked from vpn to current address-family\n"
7458 "For routes leaked from current address-family to vpn\n"
7459 "both import and export\n")
7461 DEFPY (af_route_map_vpn_imexport
,
7462 af_route_map_vpn_imexport_cmd
,
7463 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
7464 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
7466 "Specify route map\n"
7467 "Between current address-family and vpn\n"
7468 "For routes leaked from vpn to current address-family\n"
7469 "For routes leaked from current address-family to vpn\n"
7470 "name of route-map\n")
7472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7474 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7475 vpn_policy_direction_t dir
;
7480 if (argv_find(argv
, argc
, "no", &idx
))
7483 afi
= vpn_policy_getafi(vty
, bgp
, false);
7485 return CMD_WARNING_CONFIG_FAILED
;
7487 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7488 if (ret
!= CMD_SUCCESS
)
7491 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7495 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7498 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7499 XFREE(MTYPE_ROUTE_MAP_NAME
,
7500 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7501 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
7502 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7503 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7504 route_map_lookup_warn_noexist(vty
, rmap_str
);
7505 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7508 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7509 XFREE(MTYPE_ROUTE_MAP_NAME
,
7510 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7511 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7512 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7515 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7521 ALIAS (af_route_map_vpn_imexport
,
7522 af_no_route_map_vpn_imexport_cmd
,
7523 "no route-map vpn <import|export>$direction_str",
7525 "Specify route map\n"
7526 "Between current address-family and vpn\n"
7527 "For routes leaked from vpn to current address-family\n"
7528 "For routes leaked from current address-family to vpn\n")
7530 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
7531 "[no] import vrf route-map RMAP$rmap_str",
7533 "Import routes from another VRF\n"
7534 "Vrf routes being filtered\n"
7535 "Specify route map\n"
7536 "name of route-map\n")
7538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7539 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7543 struct bgp
*bgp_default
;
7545 if (argv_find(argv
, argc
, "no", &idx
))
7548 afi
= vpn_policy_getafi(vty
, bgp
, true);
7550 return CMD_WARNING_CONFIG_FAILED
;
7552 bgp_default
= bgp_get_default();
7557 /* Auto-create assuming the same AS */
7558 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7559 BGP_INSTANCE_TYPE_DEFAULT
);
7563 "VRF default is not configured as a bgp instance\n");
7568 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7571 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7572 XFREE(MTYPE_ROUTE_MAP_NAME
,
7573 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7574 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
7575 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7576 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7577 route_map_lookup_warn_noexist(vty
, rmap_str
);
7578 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7581 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7582 XFREE(MTYPE_ROUTE_MAP_NAME
,
7583 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7584 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7585 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7588 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7593 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
7594 "no import vrf route-map",
7596 "Import routes from another VRF\n"
7597 "Vrf routes being filtered\n"
7598 "Specify route map\n")
7600 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7601 "[no] import vrf VIEWVRFNAME$import_name",
7603 "Import routes from another VRF\n"
7604 "VRF to import from\n"
7605 "The name of the VRF\n")
7607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7608 struct listnode
*node
;
7609 struct bgp
*vrf_bgp
, *bgp_default
;
7612 bool remove
= false;
7615 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7619 if (import_name
== NULL
) {
7620 vty_out(vty
, "%% Missing import name\n");
7624 if (argv_find(argv
, argc
, "no", &idx
))
7627 afi
= vpn_policy_getafi(vty
, bgp
, true);
7629 return CMD_WARNING_CONFIG_FAILED
;
7631 safi
= bgp_node_safi(vty
);
7633 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7634 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7635 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7636 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7637 remove
? "unimport" : "import", import_name
);
7641 bgp_default
= bgp_get_default();
7643 /* Auto-create assuming the same AS */
7644 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7645 BGP_INSTANCE_TYPE_DEFAULT
);
7649 "VRF default is not configured as a bgp instance\n");
7654 vrf_bgp
= bgp_lookup_by_name(import_name
);
7656 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7657 vrf_bgp
= bgp_default
;
7659 /* Auto-create assuming the same AS */
7660 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
7664 "VRF %s is not configured as a bgp instance\n",
7671 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7673 /* Already importing from "import_vrf"? */
7674 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7676 if (strcmp(vname
, import_name
) == 0)
7680 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7686 /* This command is valid only in a bgp vrf instance or the default instance */
7687 DEFPY (bgp_imexport_vpn
,
7688 bgp_imexport_vpn_cmd
,
7689 "[no] <import|export>$direction_str vpn",
7691 "Import routes to this address-family\n"
7692 "Export routes from this address-family\n"
7693 "to/from default instance VPN RIB\n")
7695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7702 vpn_policy_direction_t dir
;
7704 if (argv_find(argv
, argc
, "no", &idx
))
7707 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7708 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7710 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7711 return CMD_WARNING_CONFIG_FAILED
;
7714 afi
= bgp_node_afi(vty
);
7715 safi
= bgp_node_safi(vty
);
7716 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7717 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7718 return CMD_WARNING_CONFIG_FAILED
;
7721 if (!strcmp(direction_str
, "import")) {
7722 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7723 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7724 } else if (!strcmp(direction_str
, "export")) {
7725 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7726 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7728 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7729 return CMD_WARNING_CONFIG_FAILED
;
7732 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7735 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7736 if (!previous_state
) {
7737 /* trigger export current vrf */
7738 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7741 if (previous_state
) {
7742 /* trigger un-export current vrf */
7743 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7745 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7751 DEFPY (af_routetarget_import
,
7752 af_routetarget_import_cmd
,
7753 "[no] <rt|route-target> redirect import RTLIST...",
7755 "Specify route target list\n"
7756 "Specify route target list\n"
7757 "Flow-spec redirect type route target\n"
7758 "Import routes to this address-family\n"
7759 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7763 struct ecommunity
*ecom
= NULL
;
7768 if (argv_find(argv
, argc
, "no", &idx
))
7771 afi
= vpn_policy_getafi(vty
, bgp
, false);
7773 return CMD_WARNING_CONFIG_FAILED
;
7776 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7777 vty_out(vty
, "%% Missing RTLIST\n");
7778 return CMD_WARNING_CONFIG_FAILED
;
7780 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7781 if (ret
!= CMD_SUCCESS
)
7786 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7787 ecommunity_free(&bgp
->vpn_policy
[afi
]
7788 .import_redirect_rtlist
);
7789 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7790 ecommunity_dup(ecom
);
7792 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7793 ecommunity_free(&bgp
->vpn_policy
[afi
]
7794 .import_redirect_rtlist
);
7795 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7799 ecommunity_free(&ecom
);
7804 DEFUN_NOSH (address_family_ipv4_safi
,
7805 address_family_ipv4_safi_cmd
,
7806 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7807 "Enter Address Family command mode\n"
7809 BGP_SAFI_WITH_LABEL_HELP_STR
)
7813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7814 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7815 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7816 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7817 && safi
!= SAFI_EVPN
) {
7819 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7820 return CMD_WARNING_CONFIG_FAILED
;
7822 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7824 vty
->node
= BGP_IPV4_NODE
;
7829 DEFUN_NOSH (address_family_ipv6_safi
,
7830 address_family_ipv6_safi_cmd
,
7831 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7832 "Enter Address Family command mode\n"
7834 BGP_SAFI_WITH_LABEL_HELP_STR
)
7837 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7838 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7839 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7840 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7841 && safi
!= SAFI_EVPN
) {
7843 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7844 return CMD_WARNING_CONFIG_FAILED
;
7846 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7848 vty
->node
= BGP_IPV6_NODE
;
7853 #ifdef KEEP_OLD_VPN_COMMANDS
7854 DEFUN_NOSH (address_family_vpnv4
,
7855 address_family_vpnv4_cmd
,
7856 "address-family vpnv4 [unicast]",
7857 "Enter Address Family command mode\n"
7859 "Address Family modifier\n")
7861 vty
->node
= BGP_VPNV4_NODE
;
7865 DEFUN_NOSH (address_family_vpnv6
,
7866 address_family_vpnv6_cmd
,
7867 "address-family vpnv6 [unicast]",
7868 "Enter Address Family command mode\n"
7870 "Address Family modifier\n")
7872 vty
->node
= BGP_VPNV6_NODE
;
7875 #endif /* KEEP_OLD_VPN_COMMANDS */
7877 DEFUN_NOSH (address_family_evpn
,
7878 address_family_evpn_cmd
,
7879 "address-family l2vpn evpn",
7880 "Enter Address Family command mode\n"
7882 "Address Family modifier\n")
7884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7885 vty
->node
= BGP_EVPN_NODE
;
7889 DEFUN_NOSH (exit_address_family
,
7890 exit_address_family_cmd
,
7891 "exit-address-family",
7892 "Exit from Address Family configuration mode\n")
7894 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7895 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7896 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7897 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7898 || vty
->node
== BGP_EVPN_NODE
7899 || vty
->node
== BGP_FLOWSPECV4_NODE
7900 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7901 vty
->node
= BGP_NODE
;
7905 /* Recalculate bestpath and re-advertise a prefix */
7906 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7907 const char *ip_str
, afi_t afi
, safi_t safi
,
7908 struct prefix_rd
*prd
)
7911 struct prefix match
;
7912 struct bgp_node
*rn
;
7913 struct bgp_node
*rm
;
7915 struct bgp_table
*table
;
7916 struct bgp_table
*rib
;
7918 /* BGP structure lookup. */
7920 bgp
= bgp_lookup_by_name(view_name
);
7922 vty_out(vty
, "%% Can't find BGP instance %s\n",
7927 bgp
= bgp_get_default();
7929 vty_out(vty
, "%% No BGP process is configured\n");
7934 /* Check IP address argument. */
7935 ret
= str2prefix(ip_str
, &match
);
7937 vty_out(vty
, "%% address is malformed\n");
7941 match
.family
= afi2family(afi
);
7942 rib
= bgp
->rib
[afi
][safi
];
7944 if (safi
== SAFI_MPLS_VPN
) {
7945 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7946 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7949 table
= bgp_node_get_bgp_table_info(rn
);
7950 if (table
!= NULL
) {
7952 if ((rm
= bgp_node_match(table
, &match
))
7955 == match
.prefixlen
) {
7957 BGP_NODE_USER_CLEAR
);
7958 bgp_process(bgp
, rm
, afi
, safi
);
7960 bgp_unlock_node(rm
);
7965 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7966 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7967 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7968 bgp_process(bgp
, rn
, afi
, safi
);
7970 bgp_unlock_node(rn
);
7977 /* one clear bgp command to rule them all */
7978 DEFUN (clear_ip_bgp_all
,
7979 clear_ip_bgp_all_cmd
,
7980 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7984 BGP_INSTANCE_HELP_STR
7987 BGP_SAFI_WITH_LABEL_HELP_STR
7988 "Address Family modifier\n"
7990 "BGP IPv4 neighbor to clear\n"
7991 "BGP IPv6 neighbor to clear\n"
7992 "BGP neighbor on interface to clear\n"
7993 "Clear peers with the AS number\n"
7994 "Clear all external peers\n"
7995 "Clear all members of peer-group\n"
7996 "BGP peer-group name\n"
8001 "Push out prefix-list ORF and do inbound soft reconfig\n"
8006 afi_t afi
= AFI_UNSPEC
;
8007 safi_t safi
= SAFI_UNSPEC
;
8008 enum clear_sort clr_sort
= clear_peer
;
8009 enum bgp_clear_type clr_type
;
8010 char *clr_arg
= NULL
;
8014 /* clear [ip] bgp */
8015 if (argv_find(argv
, argc
, "ip", &idx
))
8018 /* [<vrf> VIEWVRFNAME] */
8019 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8020 vrf
= argv
[idx
+ 1]->arg
;
8022 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8024 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8025 /* [<view> VIEWVRFNAME] */
8026 vrf
= argv
[idx
+ 1]->arg
;
8029 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8030 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
8031 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8033 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
8034 if (argv_find(argv
, argc
, "*", &idx
)) {
8035 clr_sort
= clear_all
;
8036 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8037 clr_sort
= clear_peer
;
8038 clr_arg
= argv
[idx
]->arg
;
8039 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
8040 clr_sort
= clear_peer
;
8041 clr_arg
= argv
[idx
]->arg
;
8042 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
8043 clr_sort
= clear_group
;
8045 clr_arg
= argv
[idx
]->arg
;
8046 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
8047 clr_sort
= clear_peer
;
8048 clr_arg
= argv
[idx
]->arg
;
8049 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8050 clr_sort
= clear_peer
;
8051 clr_arg
= argv
[idx
]->arg
;
8052 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
8053 clr_sort
= clear_as
;
8054 clr_arg
= argv
[idx
]->arg
;
8055 } else if (argv_find(argv
, argc
, "external", &idx
)) {
8056 clr_sort
= clear_external
;
8059 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
8060 if (argv_find(argv
, argc
, "soft", &idx
)) {
8061 if (argv_find(argv
, argc
, "in", &idx
)
8062 || argv_find(argv
, argc
, "out", &idx
))
8063 clr_type
= strmatch(argv
[idx
]->text
, "in")
8065 : BGP_CLEAR_SOFT_OUT
;
8067 clr_type
= BGP_CLEAR_SOFT_BOTH
;
8068 } else if (argv_find(argv
, argc
, "in", &idx
)) {
8069 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
8070 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
8071 : BGP_CLEAR_SOFT_IN
;
8072 } else if (argv_find(argv
, argc
, "out", &idx
)) {
8073 clr_type
= BGP_CLEAR_SOFT_OUT
;
8075 clr_type
= BGP_CLEAR_SOFT_NONE
;
8077 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
8080 DEFUN (clear_ip_bgp_prefix
,
8081 clear_ip_bgp_prefix_cmd
,
8082 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
8086 BGP_INSTANCE_HELP_STR
8087 "Clear bestpath and re-advertise\n"
8091 char *prefix
= NULL
;
8095 /* [<view|vrf> VIEWVRFNAME] */
8096 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8097 vrf
= argv
[idx
+ 1]->arg
;
8099 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8101 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8102 /* [<view> VIEWVRFNAME] */
8103 vrf
= argv
[idx
+ 1]->arg
;
8107 prefix
= argv
[argc
- 1]->arg
;
8109 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
8112 DEFUN (clear_bgp_ipv6_safi_prefix
,
8113 clear_bgp_ipv6_safi_prefix_cmd
,
8114 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8120 "Clear bestpath and re-advertise\n"
8124 int idx_ipv6_prefix
= 0;
8125 safi_t safi
= SAFI_UNICAST
;
8126 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8127 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8129 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8130 return bgp_clear_prefix(
8131 vty
, NULL
, prefix
, AFI_IP6
,
8135 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
8136 clear_bgp_instance_ipv6_safi_prefix_cmd
,
8137 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8141 BGP_INSTANCE_HELP_STR
8144 "Clear bestpath and re-advertise\n"
8148 int idx_vrfview
= 0;
8149 int idx_ipv6_prefix
= 0;
8150 safi_t safi
= SAFI_UNICAST
;
8151 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8152 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8153 char *vrfview
= NULL
;
8155 /* [<view|vrf> VIEWVRFNAME] */
8156 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
8157 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8158 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
8160 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
8161 /* [<view> VIEWVRFNAME] */
8162 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8164 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8166 return bgp_clear_prefix(
8167 vty
, vrfview
, prefix
,
8168 AFI_IP6
, safi
, NULL
);
8171 DEFUN (show_bgp_views
,
8173 "show [ip] bgp views",
8177 "Show the defined BGP views\n")
8179 struct list
*inst
= bm
->bgp
;
8180 struct listnode
*node
;
8183 vty_out(vty
, "Defined BGP views:\n");
8184 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8186 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
8188 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
8195 DEFUN (show_bgp_vrfs
,
8197 "show [ip] bgp vrfs [json]",
8204 char buf
[ETHER_ADDR_STRLEN
];
8205 struct list
*inst
= bm
->bgp
;
8206 struct listnode
*node
;
8208 bool uj
= use_json(argc
, argv
);
8209 json_object
*json
= NULL
;
8210 json_object
*json_vrfs
= NULL
;
8214 json
= json_object_new_object();
8215 json_vrfs
= json_object_new_object();
8218 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8219 const char *name
, *type
;
8221 struct listnode
*node2
, *nnode2
;
8222 int peers_cfg
, peers_estb
;
8223 json_object
*json_vrf
= NULL
;
8226 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
8230 if (!uj
&& count
== 1) {
8232 "%4s %-5s %-16s %9s %10s %-37s\n",
8233 "Type", "Id", "routerId", "#PeersCfg",
8234 "#PeersEstb", "Name");
8235 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
8236 "L3-VNI", "RouterMAC", "Interface");
8239 peers_cfg
= peers_estb
= 0;
8241 json_vrf
= json_object_new_object();
8244 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
8245 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8248 if (peer
->status
== Established
)
8252 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
8253 name
= VRF_DEFAULT_NAME
;
8262 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8264 : (int64_t)bgp
->vrf_id
;
8265 json_object_string_add(json_vrf
, "type", type
);
8266 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
8267 json_object_string_add(json_vrf
, "routerId",
8268 inet_ntoa(bgp
->router_id
));
8269 json_object_int_add(json_vrf
, "numConfiguredPeers",
8271 json_object_int_add(json_vrf
, "numEstablishedPeers",
8274 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
8275 json_object_string_add(
8277 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
8278 json_object_string_add(json_vrf
, "interface",
8279 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8281 json_object_object_add(json_vrfs
, name
, json_vrf
);
8284 "%4s %-5d %-16s %-9u %-10u %-37s\n",
8286 bgp
->vrf_id
== VRF_UNKNOWN
? -1
8288 inet_ntoa(bgp
->router_id
), peers_cfg
,
8290 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
8292 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
8293 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8299 json_object_object_add(json
, "vrfs", json_vrfs
);
8301 json_object_int_add(json
, "totalVrfs", count
);
8303 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8304 json
, JSON_C_TO_STRING_PRETTY
));
8305 json_object_free(json
);
8309 "\nTotal number of VRFs (including default): %d\n",
8316 DEFUN (show_bgp_mac_hash
,
8317 show_bgp_mac_hash_cmd
,
8318 "show bgp mac hash",
8322 "Mac Address database\n")
8324 bgp_mac_dump_table(vty
);
8329 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
8331 struct vty
*vty
= (struct vty
*)args
;
8332 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
8334 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
8338 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
8340 vty_out(vty
, "self nexthop database:\n");
8341 bgp_nexthop_show_address_hash(vty
, bgp
);
8343 vty_out(vty
, "Tunnel-ip database:\n");
8344 hash_iterate(bgp
->tip_hash
,
8345 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
8349 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
8350 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
8351 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
8352 "martian next-hops\n"
8353 "martian next-hop database\n")
8355 struct bgp
*bgp
= NULL
;
8359 /* [<vrf> VIEWVRFNAME] */
8360 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8361 name
= argv
[idx
+ 1]->arg
;
8362 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
8364 } else if (argv_find(argv
, argc
, "view", &idx
))
8365 /* [<view> VIEWVRFNAME] */
8366 name
= argv
[idx
+ 1]->arg
;
8368 bgp
= bgp_lookup_by_name(name
);
8370 bgp
= bgp_get_default();
8373 vty_out(vty
, "%% No BGP process is configured\n");
8376 bgp_show_martian_nexthops(vty
, bgp
);
8381 DEFUN (show_bgp_memory
,
8382 show_bgp_memory_cmd
,
8383 "show [ip] bgp memory",
8387 "Global BGP memory statistics\n")
8389 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8390 unsigned long count
;
8392 /* RIB related usage stats */
8393 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
8394 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
8395 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8396 count
* sizeof(struct bgp_node
)));
8398 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
8399 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
8400 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8401 count
* sizeof(struct bgp_path_info
)));
8402 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
8403 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
8406 memstrbuf
, sizeof(memstrbuf
),
8407 count
* sizeof(struct bgp_path_info_extra
)));
8409 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
8410 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
8411 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8412 count
* sizeof(struct bgp_static
)));
8414 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
8415 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
8416 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8417 count
* sizeof(struct bpacket
)));
8420 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
8421 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
8422 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8423 count
* sizeof(struct bgp_adj_in
)));
8424 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
8425 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
8426 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8427 count
* sizeof(struct bgp_adj_out
)));
8429 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
8430 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
8432 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8433 count
* sizeof(struct bgp_nexthop_cache
)));
8435 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
8436 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
8438 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8439 count
* sizeof(struct bgp_damp_info
)));
8442 count
= attr_count();
8443 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
8444 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8445 count
* sizeof(struct attr
)));
8447 if ((count
= attr_unknown_count()))
8448 vty_out(vty
, "%ld unknown attributes\n", count
);
8450 /* AS_PATH attributes */
8451 count
= aspath_count();
8452 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
8453 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8454 count
* sizeof(struct aspath
)));
8456 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
8457 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
8458 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8459 count
* sizeof(struct assegment
)));
8461 /* Other attributes */
8462 if ((count
= community_count()))
8463 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8464 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8465 count
* sizeof(struct community
)));
8466 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
8467 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8468 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8469 count
* sizeof(struct ecommunity
)));
8470 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
8472 "%ld BGP large-community entries, using %s of memory\n",
8473 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8474 count
* sizeof(struct lcommunity
)));
8476 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
8477 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
8478 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8479 count
* sizeof(struct cluster_list
)));
8481 /* Peer related usage */
8482 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
8483 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
8484 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8485 count
* sizeof(struct peer
)));
8487 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
8488 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
8489 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8490 count
* sizeof(struct peer_group
)));
8493 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
8494 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
8495 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8496 count
* sizeof(regex_t
)));
8500 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
8502 json_object
*bestpath
= json_object_new_object();
8504 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
8505 json_object_string_add(bestpath
, "asPath", "ignore");
8507 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
8508 json_object_string_add(bestpath
, "asPath", "confed");
8510 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
8511 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
8512 json_object_string_add(bestpath
, "multiPathRelax",
8515 json_object_string_add(bestpath
, "multiPathRelax",
8518 json_object_string_add(bestpath
, "multiPathRelax", "false");
8520 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
8521 json_object_string_add(bestpath
, "compareRouterId", "true");
8522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
8523 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
8524 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
8525 json_object_string_add(bestpath
, "med", "confed");
8526 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
8527 json_object_string_add(bestpath
, "med",
8528 "missing-as-worst");
8530 json_object_string_add(bestpath
, "med", "true");
8533 json_object_object_add(json
, "bestPath", bestpath
);
8536 /* Print the error code/subcode for why the peer is down */
8537 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
8538 json_object
*json_peer
, bool use_json
)
8540 const char *code_str
;
8541 const char *subcode_str
;
8544 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8545 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8546 char errorcodesubcode_hexstr
[5];
8547 char errorcodesubcode_str
[256];
8549 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8550 subcode_str
= bgp_notify_subcode_str(
8552 peer
->notify
.subcode
);
8554 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
8555 peer
->notify
.code
, peer
->notify
.subcode
);
8556 json_object_string_add(json_peer
,
8557 "lastErrorCodeSubcode",
8558 errorcodesubcode_hexstr
);
8559 snprintf(errorcodesubcode_str
, 255, "%s%s",
8560 code_str
, subcode_str
);
8561 json_object_string_add(json_peer
,
8562 "lastNotificationReason",
8563 errorcodesubcode_str
);
8564 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
8565 && peer
->notify
.code
== BGP_NOTIFY_CEASE
8566 && (peer
->notify
.subcode
8567 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
8568 || peer
->notify
.subcode
8569 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
8570 && peer
->notify
.length
) {
8572 const char *msg_str
;
8574 msg_str
= bgp_notify_admin_message(
8575 msgbuf
, sizeof(msgbuf
),
8576 (uint8_t *)peer
->notify
.data
,
8577 peer
->notify
.length
);
8579 json_object_string_add(
8581 "lastShutdownDescription",
8586 json_object_string_add(json_peer
, "lastResetDueTo",
8587 peer_down_str
[(int)peer
->last_reset
]);
8588 json_object_int_add(json_peer
, "lastResetCode",
8591 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8592 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8593 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8595 bgp_notify_subcode_str(peer
->notify
.code
,
8596 peer
->notify
.subcode
);
8597 vty_out(vty
, " Notification %s (%s%s)\n",
8598 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8601 code_str
, subcode_str
);
8603 vty_out(vty
, " %s\n",
8604 peer_down_str
[(int)peer
->last_reset
]);
8609 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8612 return ((peer
->status
!= Established
) ||
8613 !peer
->afc_recv
[afi
][safi
]);
8616 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8617 struct peer
*peer
, json_object
*json_peer
,
8618 int max_neighbor_width
, bool use_json
)
8620 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8624 if (peer_dynamic_neighbor(peer
))
8625 json_object_boolean_true_add(json_peer
,
8628 json_object_string_add(json_peer
, "hostname",
8631 if (peer
->domainname
)
8632 json_object_string_add(json_peer
, "domainname",
8634 json_object_int_add(json_peer
, "connectionsEstablished",
8636 json_object_int_add(json_peer
, "connectionsDropped",
8638 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8639 use_json
, json_peer
);
8640 if (peer
->status
== Established
)
8641 json_object_string_add(json_peer
, "lastResetDueTo",
8642 "AFI/SAFI Not Negotiated");
8644 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8647 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8649 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
8650 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8651 peer
->hostname
, peer
->host
);
8653 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8655 /* pad the neighbor column with spaces */
8656 if (len
< max_neighbor_width
)
8657 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8659 vty_out(vty
, "%7d %7d %9s", peer
->established
,
8661 peer_uptime(peer
->uptime
, timebuf
,
8662 BGP_UPTIME_LEN
, 0, NULL
));
8663 if (peer
->status
== Established
)
8664 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8666 bgp_show_peer_reset(vty
, peer
, NULL
,
8672 /* Show BGP peer's summary information. */
8673 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8674 bool show_failed
, bool use_json
)
8677 struct listnode
*node
, *nnode
;
8678 unsigned int count
= 0, dn_count
= 0;
8679 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8680 char neighbor_buf
[VTY_BUFSIZ
];
8681 int neighbor_col_default_width
= 16;
8682 int len
, failed_count
= 0;
8683 int max_neighbor_width
= 0;
8685 json_object
*json
= NULL
;
8686 json_object
*json_peer
= NULL
;
8687 json_object
*json_peers
= NULL
;
8688 struct peer_af
*paf
;
8690 /* labeled-unicast routes are installed in the unicast table so in order
8692 * display the correct PfxRcd value we must look at SAFI_UNICAST
8695 if (safi
== SAFI_LABELED_UNICAST
)
8696 pfx_rcd_safi
= SAFI_UNICAST
;
8698 pfx_rcd_safi
= safi
;
8701 json
= json_object_new_object();
8702 json_peers
= json_object_new_object();
8703 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8704 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8707 if (peer
->afc
[afi
][safi
]) {
8708 /* See if we have at least a single failed peer */
8709 if (bgp_has_peer_failed(peer
, afi
, safi
))
8713 if (peer_dynamic_neighbor(peer
))
8718 /* Loop over all neighbors that will be displayed to determine
8720 * characters are needed for the Neighbor column
8722 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8723 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8726 if (peer
->afc
[afi
][safi
]) {
8727 memset(dn_flag
, '\0', sizeof(dn_flag
));
8728 if (peer_dynamic_neighbor(peer
))
8732 && CHECK_FLAG(bgp
->flags
,
8733 BGP_FLAG_SHOW_HOSTNAME
))
8734 sprintf(neighbor_buf
, "%s%s(%s) ",
8735 dn_flag
, peer
->hostname
,
8738 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8741 len
= strlen(neighbor_buf
);
8743 if (len
> max_neighbor_width
)
8744 max_neighbor_width
= len
;
8746 /* See if we have at least a single failed peer */
8747 if (bgp_has_peer_failed(peer
, afi
, safi
))
8753 /* Originally we displayed the Neighbor column as 16
8754 * characters wide so make that the default
8756 if (max_neighbor_width
< neighbor_col_default_width
)
8757 max_neighbor_width
= neighbor_col_default_width
;
8760 if (show_failed
&& !failed_count
) {
8762 json_object_int_add(json
, "failedPeersCount", 0);
8763 json_object_int_add(json
, "dynamicPeers", dn_count
);
8764 json_object_int_add(json
, "totalPeers", count
);
8766 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8767 json
, JSON_C_TO_STRING_PRETTY
));
8768 json_object_free(json
);
8770 vty_out(vty
, "%% No failed BGP neighbors found\n");
8771 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8776 count
= 0; /* Reset the value as its used again */
8777 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8778 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8781 if (!peer
->afc
[afi
][safi
])
8786 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8789 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8791 : (int64_t)bgp
->vrf_id
;
8793 /* Usage summary and header */
8795 json_object_string_add(
8797 inet_ntoa(bgp
->router_id
));
8798 json_object_int_add(json
, "as", bgp
->as
);
8799 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8800 json_object_string_add(
8803 == BGP_INSTANCE_TYPE_DEFAULT
)
8808 "BGP router identifier %s, local AS number %u vrf-id %d",
8809 inet_ntoa(bgp
->router_id
), bgp
->as
,
8810 bgp
->vrf_id
== VRF_UNKNOWN
8812 : (int)bgp
->vrf_id
);
8816 if (bgp_update_delay_configured(bgp
)) {
8818 json_object_int_add(
8819 json
, "updateDelayLimit",
8820 bgp
->v_update_delay
);
8822 if (bgp
->v_update_delay
8823 != bgp
->v_establish_wait
)
8824 json_object_int_add(
8826 "updateDelayEstablishWait",
8827 bgp
->v_establish_wait
);
8829 if (bgp_update_delay_active(bgp
)) {
8830 json_object_string_add(
8832 "updateDelayFirstNeighbor",
8833 bgp
->update_delay_begin_time
);
8834 json_object_boolean_true_add(
8836 "updateDelayInProgress");
8838 if (bgp
->update_delay_over
) {
8839 json_object_string_add(
8841 "updateDelayFirstNeighbor",
8842 bgp
->update_delay_begin_time
);
8843 json_object_string_add(
8845 "updateDelayBestpathResumed",
8846 bgp
->update_delay_end_time
);
8847 json_object_string_add(
8849 "updateDelayZebraUpdateResume",
8850 bgp
->update_delay_zebra_resume_time
);
8851 json_object_string_add(
8853 "updateDelayPeerUpdateResume",
8854 bgp
->update_delay_peers_resume_time
);
8859 "Read-only mode update-delay limit: %d seconds\n",
8860 bgp
->v_update_delay
);
8861 if (bgp
->v_update_delay
8862 != bgp
->v_establish_wait
)
8864 " Establish wait: %d seconds\n",
8865 bgp
->v_establish_wait
);
8867 if (bgp_update_delay_active(bgp
)) {
8869 " First neighbor established: %s\n",
8870 bgp
->update_delay_begin_time
);
8872 " Delay in progress\n");
8874 if (bgp
->update_delay_over
) {
8876 " First neighbor established: %s\n",
8877 bgp
->update_delay_begin_time
);
8879 " Best-paths resumed: %s\n",
8880 bgp
->update_delay_end_time
);
8882 " zebra update resumed: %s\n",
8883 bgp
->update_delay_zebra_resume_time
);
8885 " peers update resumed: %s\n",
8886 bgp
->update_delay_peers_resume_time
);
8893 if (bgp_maxmed_onstartup_configured(bgp
)
8894 && bgp
->maxmed_active
)
8895 json_object_boolean_true_add(
8896 json
, "maxMedOnStartup");
8897 if (bgp
->v_maxmed_admin
)
8898 json_object_boolean_true_add(
8899 json
, "maxMedAdministrative");
8901 json_object_int_add(
8902 json
, "tableVersion",
8903 bgp_table_version(bgp
->rib
[afi
][safi
]));
8905 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8906 json_object_int_add(json
, "ribCount", ents
);
8907 json_object_int_add(
8909 ents
* sizeof(struct bgp_node
));
8911 ents
= bgp
->af_peer_count
[afi
][safi
];
8912 json_object_int_add(json
, "peerCount", ents
);
8913 json_object_int_add(json
, "peerMemory",
8914 ents
* sizeof(struct peer
));
8916 if ((ents
= listcount(bgp
->group
))) {
8917 json_object_int_add(
8918 json
, "peerGroupCount", ents
);
8919 json_object_int_add(
8920 json
, "peerGroupMemory",
8921 ents
* sizeof(struct
8925 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8926 BGP_CONFIG_DAMPENING
))
8927 json_object_boolean_true_add(
8928 json
, "dampeningEnabled");
8930 if (bgp_maxmed_onstartup_configured(bgp
)
8931 && bgp
->maxmed_active
)
8933 "Max-med on-startup active\n");
8934 if (bgp
->v_maxmed_admin
)
8936 "Max-med administrative active\n");
8938 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8939 bgp_table_version(bgp
->rib
[afi
][safi
]));
8941 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8943 "RIB entries %ld, using %s of memory\n",
8945 mtype_memstr(memstrbuf
,
8947 ents
* sizeof(struct
8950 /* Peer related usage */
8951 ents
= bgp
->af_peer_count
[afi
][safi
];
8952 vty_out(vty
, "Peers %ld, using %s of memory\n",
8955 memstrbuf
, sizeof(memstrbuf
),
8956 ents
* sizeof(struct peer
)));
8958 if ((ents
= listcount(bgp
->group
)))
8960 "Peer groups %ld, using %s of memory\n",
8965 ents
* sizeof(struct
8968 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8969 BGP_CONFIG_DAMPENING
))
8970 vty_out(vty
, "Dampening enabled.\n");
8973 /* Subtract 8 here because 'Neighbor' is
8975 vty_out(vty
, "Neighbor");
8976 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8979 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8982 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8987 /* Works for both failed & successful cases */
8988 if (peer_dynamic_neighbor(peer
))
8995 bgp_has_peer_failed(peer
, afi
, safi
)) {
8996 json_peer
= json_object_new_object();
8997 bgp_show_failed_summary(vty
, bgp
, peer
,
8998 json_peer
, 0, use_json
);
8999 } else if (!show_failed
) {
9000 json_peer
= json_object_new_object();
9001 if (peer_dynamic_neighbor(peer
)) {
9002 json_object_boolean_true_add(json_peer
,
9007 json_object_string_add(json_peer
, "hostname",
9010 if (peer
->domainname
)
9011 json_object_string_add(json_peer
, "domainname",
9014 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
9015 json_object_int_add(json_peer
, "version", 4);
9016 json_object_int_add(json_peer
, "msgRcvd",
9017 PEER_TOTAL_RX(peer
));
9018 json_object_int_add(json_peer
, "msgSent",
9019 PEER_TOTAL_TX(peer
));
9021 json_object_int_add(json_peer
, "tableVersion",
9022 peer
->version
[afi
][safi
]);
9023 json_object_int_add(json_peer
, "outq",
9025 json_object_int_add(json_peer
, "inq", 0);
9026 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9027 use_json
, json_peer
);
9030 * Adding "pfxRcd" field to match with the corresponding
9031 * CLI. "prefixReceivedCount" will be deprecated in
9034 json_object_int_add(json_peer
, "prefixReceivedCount",
9035 peer
->pcount
[afi
][pfx_rcd_safi
]);
9036 json_object_int_add(json_peer
, "pfxRcd",
9037 peer
->pcount
[afi
][pfx_rcd_safi
]);
9039 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
9040 if (paf
&& PAF_SUBGRP(paf
))
9041 json_object_int_add(json_peer
,
9043 (PAF_SUBGRP(paf
))->scount
);
9044 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
9045 json_object_string_add(json_peer
, "state",
9047 else if (peer
->afc_recv
[afi
][safi
])
9048 json_object_string_add(
9050 lookup_msg(bgp_status_msg
, peer
->status
,
9052 else if (CHECK_FLAG(peer
->sflags
,
9053 PEER_STATUS_PREFIX_OVERFLOW
))
9054 json_object_string_add(json_peer
, "state",
9057 json_object_string_add(
9059 lookup_msg(bgp_status_msg
, peer
->status
,
9061 json_object_int_add(json_peer
, "connectionsEstablished",
9063 json_object_int_add(json_peer
, "connectionsDropped",
9066 /* Avoid creating empty peer dicts in JSON */
9067 if (json_peer
== NULL
)
9071 json_object_string_add(json_peer
, "idType",
9073 else if (peer
->su
.sa
.sa_family
== AF_INET
)
9074 json_object_string_add(json_peer
, "idType",
9076 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
9077 json_object_string_add(json_peer
, "idType",
9079 json_object_object_add(json_peers
, peer
->host
,
9083 bgp_has_peer_failed(peer
, afi
, safi
)) {
9084 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
9087 } else if (!show_failed
) {
9088 memset(dn_flag
, '\0', sizeof(dn_flag
));
9089 if (peer_dynamic_neighbor(peer
)) {
9094 && CHECK_FLAG(bgp
->flags
,
9095 BGP_FLAG_SHOW_HOSTNAME
))
9096 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9100 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9102 /* pad the neighbor column with spaces */
9103 if (len
< max_neighbor_width
)
9104 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9107 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
" %4d %4zd %8s",
9108 peer
->as
, PEER_TOTAL_RX(peer
),
9109 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
9110 0, peer
->obuf
->count
,
9111 peer_uptime(peer
->uptime
, timebuf
,
9112 BGP_UPTIME_LEN
, 0, NULL
));
9114 if (peer
->status
== Established
)
9115 if (peer
->afc_recv
[afi
][safi
])
9116 vty_out(vty
, " %12" PRIu32
,
9121 vty_out(vty
, " NoNeg");
9123 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
9124 vty_out(vty
, " Idle (Admin)");
9125 else if (CHECK_FLAG(
9127 PEER_STATUS_PREFIX_OVERFLOW
))
9128 vty_out(vty
, " Idle (PfxCt)");
9130 vty_out(vty
, " %12s",
9131 lookup_msg(bgp_status_msg
,
9132 peer
->status
, NULL
));
9141 json_object_object_add(json
, "peers", json_peers
);
9142 json_object_int_add(json
, "failedPeers", failed_count
);
9143 json_object_int_add(json
, "totalPeers", count
);
9144 json_object_int_add(json
, "dynamicPeers", dn_count
);
9147 bgp_show_bestpath_json(bgp
, json
);
9149 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9150 json
, JSON_C_TO_STRING_PRETTY
));
9151 json_object_free(json
);
9154 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
9156 vty_out(vty
, "No %s neighbor is configured\n",
9157 get_afi_safi_str(afi
, safi
, false));
9161 vty_out(vty
, "* - dynamic neighbor\n");
9162 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
9163 dn_count
, bgp
->dynamic_neighbors_limit
);
9170 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
9171 int safi
, bool show_failed
, bool use_json
)
9174 int afi_wildcard
= (afi
== AFI_MAX
);
9175 int safi_wildcard
= (safi
== SAFI_MAX
);
9176 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
9177 bool nbr_output
= false;
9179 if (use_json
&& is_wildcard
)
9180 vty_out(vty
, "{\n");
9182 afi
= 1; /* AFI_IP */
9183 while (afi
< AFI_MAX
) {
9185 safi
= 1; /* SAFI_UNICAST */
9186 while (safi
< SAFI_MAX
) {
9187 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
9192 * So limit output to those afi/safi
9194 * actualy have something interesting in
9199 vty_out(vty
, ",\n");
9203 vty_out(vty
, "\"%s\":",
9204 get_afi_safi_str(afi
,
9208 vty_out(vty
, "\n%s Summary:\n",
9209 get_afi_safi_str(afi
,
9214 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
9226 if (use_json
&& is_wildcard
)
9227 vty_out(vty
, "}\n");
9228 else if (!nbr_output
) {
9230 vty_out(vty
, "{}\n");
9232 vty_out(vty
, "%% No BGP neighbors found\n");
9236 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
9237 safi_t safi
, bool show_failed
,
9240 struct listnode
*node
, *nnode
;
9243 bool nbr_output
= false;
9246 vty_out(vty
, "{\n");
9248 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9252 vty_out(vty
, ",\n");
9256 vty_out(vty
, "\"%s\":",
9257 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9261 vty_out(vty
, "\nInstance %s:\n",
9262 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9266 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9271 vty_out(vty
, "}\n");
9272 else if (!nbr_output
)
9273 vty_out(vty
, "%% BGP instance not found\n");
9276 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
9277 safi_t safi
, bool show_failed
, bool use_json
)
9282 if (strmatch(name
, "all")) {
9283 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
9288 bgp
= bgp_lookup_by_name(name
);
9292 vty_out(vty
, "{}\n");
9295 "%% BGP instance not found\n");
9299 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
9300 show_failed
, use_json
);
9305 bgp
= bgp_get_default();
9308 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9312 vty_out(vty
, "{}\n");
9314 vty_out(vty
, "%% BGP instance not found\n");
9321 /* `show [ip] bgp summary' commands. */
9322 DEFUN (show_ip_bgp_summary
,
9323 show_ip_bgp_summary_cmd
,
9324 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
9328 BGP_INSTANCE_HELP_STR
9330 BGP_SAFI_WITH_LABEL_HELP_STR
9331 "Summary of BGP neighbor status\n"
9332 "Show only sessions not in Established state\n"
9336 afi_t afi
= AFI_MAX
;
9337 safi_t safi
= SAFI_MAX
;
9338 bool show_failed
= false;
9343 if (argv_find(argv
, argc
, "ip", &idx
))
9345 /* [<vrf> VIEWVRFNAME] */
9346 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9347 vrf
= argv
[idx
+ 1]->arg
;
9348 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9350 } else if (argv_find(argv
, argc
, "view", &idx
))
9351 /* [<view> VIEWVRFNAME] */
9352 vrf
= argv
[idx
+ 1]->arg
;
9353 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9354 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
9355 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9358 if (argv_find(argv
, argc
, "failed", &idx
))
9361 bool uj
= use_json(argc
, argv
);
9363 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
9366 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
9369 return get_afi_safi_json_str(afi
, safi
);
9371 return get_afi_safi_vty_str(afi
, safi
);
9375 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
9376 afi_t afi
, safi_t safi
,
9377 uint16_t adv_smcap
, uint16_t adv_rmcap
,
9378 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
9379 bool use_json
, json_object
*json_pref
)
9382 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9383 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
9385 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9386 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9387 json_object_string_add(json_pref
, "sendMode",
9388 "advertisedAndReceived");
9389 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9390 json_object_string_add(json_pref
, "sendMode",
9392 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9393 json_object_string_add(json_pref
, "sendMode",
9396 vty_out(vty
, " Send-mode: ");
9397 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9398 vty_out(vty
, "advertised");
9399 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9400 vty_out(vty
, "%sreceived",
9401 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9410 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9411 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
9413 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9414 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9415 json_object_string_add(json_pref
, "recvMode",
9416 "advertisedAndReceived");
9417 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9418 json_object_string_add(json_pref
, "recvMode",
9420 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9421 json_object_string_add(json_pref
, "recvMode",
9424 vty_out(vty
, " Receive-mode: ");
9425 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9426 vty_out(vty
, "advertised");
9427 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9428 vty_out(vty
, "%sreceived",
9429 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9438 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
9443 bool rbit_status
= false;
9446 vty_out(vty
, "\n R bit: ");
9448 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
9449 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
9450 && (p
->status
== Established
)) {
9452 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
9455 rbit_status
= false;
9460 json_object_boolean_true_add(json
, "rBit");
9462 vty_out(vty
, "True\n");
9465 json_object_boolean_false_add(json
, "rBit");
9467 vty_out(vty
, "False\n");
9471 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
9476 const char *mode
= "NotApplicable";
9479 vty_out(vty
, "\n Remote GR Mode: ");
9481 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9482 && (peer
->status
== Established
)) {
9484 if ((peer
->nsf_af_count
== 0)
9485 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9489 } else if (peer
->nsf_af_count
== 0
9490 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9494 } else if (peer
->nsf_af_count
!= 0
9495 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9502 json_object_string_add(json
, "remoteGrMode", mode
);
9504 vty_out(vty
, mode
, "\n");
9507 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
9512 const char *mode
= "Invalid";
9515 vty_out(vty
, " Local GR Mode: ");
9517 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
9519 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
9521 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
9523 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
9524 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
9526 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
9528 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
9535 json_object_string_add(json
, "localGrMode", mode
);
9537 vty_out(vty
, mode
, "\n");
9541 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
9542 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
9546 json_object
*json_afi_safi
= NULL
;
9547 json_object
*json_timer
= NULL
;
9548 json_object
*json_endofrib_status
= NULL
;
9549 bool eor_flag
= false;
9551 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9552 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
9553 if (!peer
->afc
[afi
][safi
])
9556 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9557 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
9561 json_afi_safi
= json_object_new_object();
9562 json_endofrib_status
= json_object_new_object();
9563 json_timer
= json_object_new_object();
9566 if (peer
->eor_stime
[afi
][safi
]
9567 >= peer
->pkt_stime
[afi
][safi
])
9573 vty_out(vty
, " %s:\n",
9574 get_afi_safi_str(afi
, safi
, false));
9576 vty_out(vty
, " F bit: ");
9579 if (peer
->nsf
[afi
][safi
]
9580 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
9581 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
9584 json_object_boolean_true_add(
9585 json_afi_safi
, "fBit");
9587 vty_out(vty
, "True\n");
9590 json_object_boolean_false_add(
9591 json_afi_safi
, "fBit");
9593 vty_out(vty
, "False\n");
9597 vty_out(vty
, " End-of-RIB sent: ");
9599 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
9600 PEER_STATUS_EOR_SEND
)) {
9602 json_object_boolean_true_add(
9603 json_endofrib_status
,
9606 PRINT_EOR_JSON(eor_flag
);
9608 vty_out(vty
, "Yes\n");
9610 " End-of-RIB sent after update: ");
9612 PRINT_EOR(eor_flag
);
9616 json_object_boolean_false_add(
9617 json_endofrib_status
,
9619 json_object_boolean_false_add(
9620 json_endofrib_status
,
9621 "endOfRibSentAfterUpdate");
9623 vty_out(vty
, "No\n");
9625 " End-of-RIB sent after update: ");
9626 vty_out(vty
, "No\n");
9631 vty_out(vty
, " End-of-RIB received: ");
9633 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
9634 PEER_STATUS_EOR_RECEIVED
)) {
9636 json_object_boolean_true_add(
9637 json_endofrib_status
,
9640 vty_out(vty
, "Yes\n");
9643 json_object_boolean_false_add(
9644 json_endofrib_status
,
9647 vty_out(vty
, "No\n");
9651 json_object_int_add(json_timer
,
9653 peer
->bgp
->stalepath_time
);
9655 if (peer
->t_gr_stale
!= NULL
) {
9656 json_object_int_add(
9658 "stalePathTimerRemaining",
9659 thread_timer_remain_second(
9663 /* Display Configured Selection
9664 * Deferral only when when
9665 * Gr mode is enabled.
9667 if (CHECK_FLAG(peer
->flags
,
9668 PEER_FLAG_GRACEFUL_RESTART
)) {
9669 json_object_int_add(
9671 "selectionDeferralTimer",
9672 peer
->bgp
->stalepath_time
);
9675 if (peer
->bgp
->gr_info
[afi
][safi
]
9679 json_object_int_add(
9681 "selectionDeferralTimerRemaining",
9682 thread_timer_remain_second(
9686 .t_select_deferral
));
9689 vty_out(vty
, " Timers:\n");
9691 " Configured Stale Path Time(sec): %u\n",
9692 peer
->bgp
->stalepath_time
);
9694 if (peer
->t_gr_stale
!= NULL
)
9696 " Stale Path Remaining(sec): %ld\n",
9697 thread_timer_remain_second(
9699 /* Display Configured Selection
9700 * Deferral only when when
9701 * Gr mode is enabled.
9703 if (CHECK_FLAG(peer
->flags
,
9704 PEER_FLAG_GRACEFUL_RESTART
))
9706 " Configured Selection Deferral Time(sec): %u\n",
9707 peer
->bgp
->select_defer_time
);
9709 if (peer
->bgp
->gr_info
[afi
][safi
]
9713 " Selection Deferral Time Remaining(sec): %ld\n",
9714 thread_timer_remain_second(
9718 .t_select_deferral
));
9721 json_object_object_add(json_afi_safi
,
9723 json_endofrib_status
);
9724 json_object_object_add(json_afi_safi
, "timers",
9726 json_object_object_add(
9727 json
, get_afi_safi_str(afi
, safi
, true),
9734 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
9740 json_object
*json_timer
= NULL
;
9742 json_timer
= json_object_new_object();
9744 json_object_int_add(json_timer
, "configuredRestartTimer",
9745 p
->bgp
->restart_time
);
9747 json_object_int_add(json_timer
, "receivedRestartTimer",
9750 if (p
->t_gr_restart
!= NULL
)
9751 json_object_int_add(
9752 json_timer
, "restartTimerRemaining",
9753 thread_timer_remain_second(p
->t_gr_restart
));
9755 json_object_object_add(json
, "timers", json_timer
);
9758 vty_out(vty
, " Timers:\n");
9759 vty_out(vty
, " Configured Restart Time(sec): %u\n",
9760 p
->bgp
->restart_time
);
9762 vty_out(vty
, " Received Restart Time(sec): %u\n",
9764 if (p
->t_gr_restart
!= NULL
)
9765 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
9766 thread_timer_remain_second(p
->t_gr_restart
));
9767 if (p
->t_gr_restart
!= NULL
) {
9768 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
9769 thread_timer_remain_second(p
->t_gr_restart
));
9774 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
9775 bool use_json
, json_object
*json
)
9777 char buf
[SU_ADDRSTRLEN
] = {0};
9778 char dn_flag
[2] = {0};
9779 char neighborAddr
[INET6_ADDRSTRLEN
] = {0};
9781 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9786 json_object_string_add(
9787 json
, "neighborAddr",
9788 BGP_PEER_SU_UNSPEC(p
)
9790 : sockunion2str(&p
->su
, buf
,
9793 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
9794 BGP_PEER_SU_UNSPEC(p
)
9796 : sockunion2str(&p
->su
, buf
,
9799 sprintf(neighborAddr
, "%s%s", dn_flag
, p
->host
);
9802 json_object_string_add(json
, "neighborAddr",
9805 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
9808 /* more gr info in new format */
9809 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
9812 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
9813 safi_t safi
, bool use_json
,
9814 json_object
*json_neigh
)
9816 struct bgp_filter
*filter
;
9817 struct peer_af
*paf
;
9818 char orf_pfx_name
[BUFSIZ
];
9820 json_object
*json_af
= NULL
;
9821 json_object
*json_prefA
= NULL
;
9822 json_object
*json_prefB
= NULL
;
9823 json_object
*json_addr
= NULL
;
9826 json_addr
= json_object_new_object();
9827 json_af
= json_object_new_object();
9828 filter
= &p
->filter
[afi
][safi
];
9830 if (peer_group_active(p
))
9831 json_object_string_add(json_addr
, "peerGroupMember",
9834 paf
= peer_af_find(p
, afi
, safi
);
9835 if (paf
&& PAF_SUBGRP(paf
)) {
9836 json_object_int_add(json_addr
, "updateGroupId",
9837 PAF_UPDGRP(paf
)->id
);
9838 json_object_int_add(json_addr
, "subGroupId",
9839 PAF_SUBGRP(paf
)->id
);
9840 json_object_int_add(json_addr
, "packetQueueLength",
9841 bpacket_queue_virtual_length(paf
));
9844 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9845 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9846 PEER_CAP_ORF_PREFIX_SM_RCV
)
9847 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9848 PEER_CAP_ORF_PREFIX_RM_ADV
)
9849 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9850 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9851 json_object_int_add(json_af
, "orfType",
9853 json_prefA
= json_object_new_object();
9854 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
9855 PEER_CAP_ORF_PREFIX_SM_ADV
,
9856 PEER_CAP_ORF_PREFIX_RM_ADV
,
9857 PEER_CAP_ORF_PREFIX_SM_RCV
,
9858 PEER_CAP_ORF_PREFIX_RM_RCV
,
9859 use_json
, json_prefA
);
9860 json_object_object_add(json_af
, "orfPrefixList",
9864 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9865 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9866 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9867 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9868 PEER_CAP_ORF_PREFIX_RM_ADV
)
9869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9870 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9871 json_object_int_add(json_af
, "orfOldType",
9872 ORF_TYPE_PREFIX_OLD
);
9873 json_prefB
= json_object_new_object();
9874 bgp_show_peer_afi_orf_cap(
9875 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9876 PEER_CAP_ORF_PREFIX_RM_ADV
,
9877 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9878 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
9880 json_object_object_add(json_af
, "orfOldPrefixList",
9884 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9885 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9886 PEER_CAP_ORF_PREFIX_SM_RCV
)
9887 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9888 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9890 PEER_CAP_ORF_PREFIX_RM_ADV
)
9891 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9892 PEER_CAP_ORF_PREFIX_RM_RCV
)
9893 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9894 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9895 json_object_object_add(json_addr
, "afDependentCap",
9898 json_object_free(json_af
);
9900 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9901 orf_pfx_count
= prefix_bgp_show_prefix_list(
9902 NULL
, afi
, orf_pfx_name
, use_json
);
9904 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9905 PEER_STATUS_ORF_PREFIX_SEND
)
9907 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9908 PEER_STATUS_ORF_PREFIX_SEND
))
9909 json_object_boolean_true_add(json_neigh
,
9912 json_object_int_add(json_addr
, "orfRecvCounter",
9915 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9916 PEER_STATUS_ORF_WAIT_REFRESH
))
9917 json_object_string_add(
9918 json_addr
, "orfFirstUpdate",
9919 "deferredUntilORFOrRouteRefreshRecvd");
9921 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9922 PEER_FLAG_REFLECTOR_CLIENT
))
9923 json_object_boolean_true_add(json_addr
,
9924 "routeReflectorClient");
9925 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9926 PEER_FLAG_RSERVER_CLIENT
))
9927 json_object_boolean_true_add(json_addr
,
9928 "routeServerClient");
9929 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9930 json_object_boolean_true_add(json_addr
,
9931 "inboundSoftConfigPermit");
9933 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9934 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9935 json_object_boolean_true_add(
9937 "privateAsNumsAllReplacedInUpdatesToNbr");
9938 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9939 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9940 json_object_boolean_true_add(
9942 "privateAsNumsReplacedInUpdatesToNbr");
9943 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9944 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9945 json_object_boolean_true_add(
9947 "privateAsNumsAllRemovedInUpdatesToNbr");
9948 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9949 PEER_FLAG_REMOVE_PRIVATE_AS
))
9950 json_object_boolean_true_add(
9952 "privateAsNumsRemovedInUpdatesToNbr");
9954 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9955 json_object_boolean_true_add(
9957 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9960 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9961 json_object_string_add(json_addr
,
9962 "overrideASNsInOutboundUpdates",
9963 "ifAspathEqualRemoteAs");
9965 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9966 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9967 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9968 json_object_boolean_true_add(json_addr
,
9969 "routerAlwaysNextHop");
9970 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9971 PEER_FLAG_AS_PATH_UNCHANGED
))
9972 json_object_boolean_true_add(
9973 json_addr
, "unchangedAsPathPropogatedToNbr");
9974 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9975 PEER_FLAG_NEXTHOP_UNCHANGED
))
9976 json_object_boolean_true_add(
9977 json_addr
, "unchangedNextHopPropogatedToNbr");
9978 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9979 json_object_boolean_true_add(
9980 json_addr
, "unchangedMedPropogatedToNbr");
9981 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9982 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9983 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
9984 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9985 PEER_FLAG_SEND_COMMUNITY
)
9986 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9987 PEER_FLAG_SEND_EXT_COMMUNITY
))
9988 json_object_string_add(json_addr
,
9989 "commAttriSentToNbr",
9990 "extendedAndStandard");
9991 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9992 PEER_FLAG_SEND_EXT_COMMUNITY
))
9993 json_object_string_add(json_addr
,
9994 "commAttriSentToNbr",
9997 json_object_string_add(json_addr
,
9998 "commAttriSentToNbr",
10001 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10002 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10003 if (p
->default_rmap
[afi
][safi
].name
)
10004 json_object_string_add(
10005 json_addr
, "defaultRouteMap",
10006 p
->default_rmap
[afi
][safi
].name
);
10008 if (paf
&& PAF_SUBGRP(paf
)
10009 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10010 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10011 json_object_boolean_true_add(json_addr
,
10014 json_object_boolean_true_add(json_addr
,
10018 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10019 if (is_evpn_enabled())
10020 json_object_boolean_true_add(
10021 json_addr
, "advertiseAllVnis");
10024 if (filter
->plist
[FILTER_IN
].name
10025 || filter
->dlist
[FILTER_IN
].name
10026 || filter
->aslist
[FILTER_IN
].name
10027 || filter
->map
[RMAP_IN
].name
)
10028 json_object_boolean_true_add(json_addr
,
10029 "inboundPathPolicyConfig");
10030 if (filter
->plist
[FILTER_OUT
].name
10031 || filter
->dlist
[FILTER_OUT
].name
10032 || filter
->aslist
[FILTER_OUT
].name
10033 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10034 json_object_boolean_true_add(
10035 json_addr
, "outboundPathPolicyConfig");
10038 if (filter
->plist
[FILTER_IN
].name
)
10039 json_object_string_add(json_addr
,
10040 "incomingUpdatePrefixFilterList",
10041 filter
->plist
[FILTER_IN
].name
);
10042 if (filter
->plist
[FILTER_OUT
].name
)
10043 json_object_string_add(json_addr
,
10044 "outgoingUpdatePrefixFilterList",
10045 filter
->plist
[FILTER_OUT
].name
);
10047 /* distribute-list */
10048 if (filter
->dlist
[FILTER_IN
].name
)
10049 json_object_string_add(
10050 json_addr
, "incomingUpdateNetworkFilterList",
10051 filter
->dlist
[FILTER_IN
].name
);
10052 if (filter
->dlist
[FILTER_OUT
].name
)
10053 json_object_string_add(
10054 json_addr
, "outgoingUpdateNetworkFilterList",
10055 filter
->dlist
[FILTER_OUT
].name
);
10058 if (filter
->aslist
[FILTER_IN
].name
)
10059 json_object_string_add(json_addr
,
10060 "incomingUpdateAsPathFilterList",
10061 filter
->aslist
[FILTER_IN
].name
);
10062 if (filter
->aslist
[FILTER_OUT
].name
)
10063 json_object_string_add(json_addr
,
10064 "outgoingUpdateAsPathFilterList",
10065 filter
->aslist
[FILTER_OUT
].name
);
10068 if (filter
->map
[RMAP_IN
].name
)
10069 json_object_string_add(
10070 json_addr
, "routeMapForIncomingAdvertisements",
10071 filter
->map
[RMAP_IN
].name
);
10072 if (filter
->map
[RMAP_OUT
].name
)
10073 json_object_string_add(
10074 json_addr
, "routeMapForOutgoingAdvertisements",
10075 filter
->map
[RMAP_OUT
].name
);
10077 /* ebgp-requires-policy (inbound) */
10078 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10079 && !bgp_inbound_policy_exists(p
, filter
))
10080 json_object_string_add(
10081 json_addr
, "inboundEbgpRequiresPolicy",
10082 "Inbound updates discarded due to missing policy");
10084 /* ebgp-requires-policy (outbound) */
10085 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10086 && (!bgp_outbound_policy_exists(p
, filter
)))
10087 json_object_string_add(
10088 json_addr
, "outboundEbgpRequiresPolicy",
10089 "Outbound updates discarded due to missing policy");
10091 /* unsuppress-map */
10092 if (filter
->usmap
.name
)
10093 json_object_string_add(json_addr
,
10094 "selectiveUnsuppressRouteMap",
10095 filter
->usmap
.name
);
10097 /* Receive prefix count */
10098 json_object_int_add(json_addr
, "acceptedPrefixCounter",
10099 p
->pcount
[afi
][safi
]);
10100 if (paf
&& PAF_SUBGRP(paf
))
10101 json_object_int_add(json_addr
, "sentPrefixCounter",
10102 (PAF_SUBGRP(paf
))->scount
);
10104 /* Maximum prefix */
10105 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
10106 json_object_int_add(json_addr
, "prefixOutAllowedMax",
10107 p
->pmax_out
[afi
][safi
]);
10109 /* Maximum prefix */
10110 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10111 json_object_int_add(json_addr
, "prefixAllowedMax",
10112 p
->pmax
[afi
][safi
]);
10113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10114 PEER_FLAG_MAX_PREFIX_WARNING
))
10115 json_object_boolean_true_add(
10116 json_addr
, "prefixAllowedMaxWarning");
10117 json_object_int_add(json_addr
,
10118 "prefixAllowedWarningThresh",
10119 p
->pmax_threshold
[afi
][safi
]);
10120 if (p
->pmax_restart
[afi
][safi
])
10121 json_object_int_add(
10123 "prefixAllowedRestartIntervalMsecs",
10124 p
->pmax_restart
[afi
][safi
] * 60000);
10126 json_object_object_add(json_neigh
,
10127 get_afi_safi_str(afi
, safi
, true),
10131 filter
= &p
->filter
[afi
][safi
];
10133 vty_out(vty
, " For address family: %s\n",
10134 get_afi_safi_str(afi
, safi
, false));
10136 if (peer_group_active(p
))
10137 vty_out(vty
, " %s peer-group member\n",
10140 paf
= peer_af_find(p
, afi
, safi
);
10141 if (paf
&& PAF_SUBGRP(paf
)) {
10142 vty_out(vty
, " Update group %" PRIu64
10143 ", subgroup %" PRIu64
"\n",
10144 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
10145 vty_out(vty
, " Packet Queue length %d\n",
10146 bpacket_queue_virtual_length(paf
));
10148 vty_out(vty
, " Not part of any update group\n");
10150 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10151 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10152 PEER_CAP_ORF_PREFIX_SM_RCV
)
10153 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10154 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10155 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10156 PEER_CAP_ORF_PREFIX_RM_ADV
)
10157 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10158 PEER_CAP_ORF_PREFIX_RM_RCV
)
10159 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10160 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
10161 vty_out(vty
, " AF-dependant capabilities:\n");
10163 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10164 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10165 PEER_CAP_ORF_PREFIX_SM_RCV
)
10166 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10167 PEER_CAP_ORF_PREFIX_RM_ADV
)
10168 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10169 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
10171 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10173 bgp_show_peer_afi_orf_cap(
10174 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10175 PEER_CAP_ORF_PREFIX_RM_ADV
,
10176 PEER_CAP_ORF_PREFIX_SM_RCV
,
10177 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
10179 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10180 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10181 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10182 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10183 PEER_CAP_ORF_PREFIX_RM_ADV
)
10184 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10185 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
10187 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10188 ORF_TYPE_PREFIX_OLD
);
10189 bgp_show_peer_afi_orf_cap(
10190 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10191 PEER_CAP_ORF_PREFIX_RM_ADV
,
10192 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
10193 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
10196 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
10197 orf_pfx_count
= prefix_bgp_show_prefix_list(
10198 NULL
, afi
, orf_pfx_name
, use_json
);
10200 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10201 PEER_STATUS_ORF_PREFIX_SEND
)
10202 || orf_pfx_count
) {
10203 vty_out(vty
, " Outbound Route Filter (ORF):");
10204 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10205 PEER_STATUS_ORF_PREFIX_SEND
))
10206 vty_out(vty
, " sent;");
10208 vty_out(vty
, " received (%d entries)",
10210 vty_out(vty
, "\n");
10212 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10213 PEER_STATUS_ORF_WAIT_REFRESH
))
10215 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
10217 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10218 PEER_FLAG_REFLECTOR_CLIENT
))
10219 vty_out(vty
, " Route-Reflector Client\n");
10220 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10221 PEER_FLAG_RSERVER_CLIENT
))
10222 vty_out(vty
, " Route-Server Client\n");
10223 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
10225 " Inbound soft reconfiguration allowed\n");
10227 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10228 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
10230 " Private AS numbers (all) replaced in updates to this neighbor\n");
10231 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10232 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
10234 " Private AS numbers replaced in updates to this neighbor\n");
10235 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10236 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
10238 " Private AS numbers (all) removed in updates to this neighbor\n");
10239 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10240 PEER_FLAG_REMOVE_PRIVATE_AS
))
10242 " Private AS numbers removed in updates to this neighbor\n");
10244 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
10245 vty_out(vty
, " %s\n",
10246 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
10247 ->human_description
);
10249 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
10251 " Override ASNs in outbound updates if aspath equals remote-as\n");
10253 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
10254 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10255 PEER_FLAG_FORCE_NEXTHOP_SELF
))
10256 vty_out(vty
, " NEXT_HOP is always this router\n");
10257 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10258 PEER_FLAG_AS_PATH_UNCHANGED
))
10260 " AS_PATH is propagated unchanged to this neighbor\n");
10261 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10262 PEER_FLAG_NEXTHOP_UNCHANGED
))
10264 " NEXT_HOP is propagated unchanged to this neighbor\n");
10265 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10267 " MED is propagated unchanged to this neighbor\n");
10268 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10269 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10270 PEER_FLAG_SEND_EXT_COMMUNITY
)
10271 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10272 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
10274 " Community attribute sent to this neighbor");
10275 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10276 PEER_FLAG_SEND_COMMUNITY
)
10277 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10278 PEER_FLAG_SEND_EXT_COMMUNITY
)
10279 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10280 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10281 vty_out(vty
, "(all)\n");
10282 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10283 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10284 vty_out(vty
, "(large)\n");
10285 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10286 PEER_FLAG_SEND_EXT_COMMUNITY
))
10287 vty_out(vty
, "(extended)\n");
10289 vty_out(vty
, "(standard)\n");
10291 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10292 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10293 vty_out(vty
, " Default information originate,");
10295 if (p
->default_rmap
[afi
][safi
].name
)
10296 vty_out(vty
, " default route-map %s%s,",
10297 p
->default_rmap
[afi
][safi
].map
? "*"
10299 p
->default_rmap
[afi
][safi
].name
);
10300 if (paf
&& PAF_SUBGRP(paf
)
10301 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10302 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10303 vty_out(vty
, " default sent\n");
10305 vty_out(vty
, " default not sent\n");
10308 /* advertise-vni-all */
10309 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10310 if (is_evpn_enabled())
10311 vty_out(vty
, " advertise-all-vni\n");
10314 if (filter
->plist
[FILTER_IN
].name
10315 || filter
->dlist
[FILTER_IN
].name
10316 || filter
->aslist
[FILTER_IN
].name
10317 || filter
->map
[RMAP_IN
].name
)
10318 vty_out(vty
, " Inbound path policy configured\n");
10319 if (filter
->plist
[FILTER_OUT
].name
10320 || filter
->dlist
[FILTER_OUT
].name
10321 || filter
->aslist
[FILTER_OUT
].name
10322 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10323 vty_out(vty
, " Outbound path policy configured\n");
10326 if (filter
->plist
[FILTER_IN
].name
)
10328 " Incoming update prefix filter list is %s%s\n",
10329 filter
->plist
[FILTER_IN
].plist
? "*" : "",
10330 filter
->plist
[FILTER_IN
].name
);
10331 if (filter
->plist
[FILTER_OUT
].name
)
10333 " Outgoing update prefix filter list is %s%s\n",
10334 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
10335 filter
->plist
[FILTER_OUT
].name
);
10337 /* distribute-list */
10338 if (filter
->dlist
[FILTER_IN
].name
)
10340 " Incoming update network filter list is %s%s\n",
10341 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
10342 filter
->dlist
[FILTER_IN
].name
);
10343 if (filter
->dlist
[FILTER_OUT
].name
)
10345 " Outgoing update network filter list is %s%s\n",
10346 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
10347 filter
->dlist
[FILTER_OUT
].name
);
10350 if (filter
->aslist
[FILTER_IN
].name
)
10352 " Incoming update AS path filter list is %s%s\n",
10353 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
10354 filter
->aslist
[FILTER_IN
].name
);
10355 if (filter
->aslist
[FILTER_OUT
].name
)
10357 " Outgoing update AS path filter list is %s%s\n",
10358 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
10359 filter
->aslist
[FILTER_OUT
].name
);
10362 if (filter
->map
[RMAP_IN
].name
)
10364 " Route map for incoming advertisements is %s%s\n",
10365 filter
->map
[RMAP_IN
].map
? "*" : "",
10366 filter
->map
[RMAP_IN
].name
);
10367 if (filter
->map
[RMAP_OUT
].name
)
10369 " Route map for outgoing advertisements is %s%s\n",
10370 filter
->map
[RMAP_OUT
].map
? "*" : "",
10371 filter
->map
[RMAP_OUT
].name
);
10373 /* ebgp-requires-policy (inbound) */
10374 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10375 && !bgp_inbound_policy_exists(p
, filter
))
10377 " Inbound updates discarded due to missing policy\n");
10379 /* ebgp-requires-policy (outbound) */
10380 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10381 && !bgp_outbound_policy_exists(p
, filter
))
10383 " Outbound updates discarded due to missing policy\n");
10385 /* unsuppress-map */
10386 if (filter
->usmap
.name
)
10388 " Route map for selective unsuppress is %s%s\n",
10389 filter
->usmap
.map
? "*" : "",
10390 filter
->usmap
.name
);
10392 /* Receive prefix count */
10393 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
10394 p
->pcount
[afi
][safi
]);
10396 /* maximum-prefix-out */
10397 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10398 PEER_FLAG_MAX_PREFIX_OUT
))
10400 " Maximum allowed prefixes sent %" PRIu32
"\n",
10401 p
->pmax_out
[afi
][safi
]);
10403 /* Maximum prefix */
10404 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10406 " Maximum prefixes allowed %" PRIu32
"%s\n",
10407 p
->pmax
[afi
][safi
],
10408 CHECK_FLAG(p
->af_flags
[afi
][safi
],
10409 PEER_FLAG_MAX_PREFIX_WARNING
)
10410 ? " (warning-only)"
10412 vty_out(vty
, " Threshold for warning message %d%%",
10413 p
->pmax_threshold
[afi
][safi
]);
10414 if (p
->pmax_restart
[afi
][safi
])
10415 vty_out(vty
, ", restart interval %d min",
10416 p
->pmax_restart
[afi
][safi
]);
10417 vty_out(vty
, "\n");
10420 vty_out(vty
, "\n");
10424 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
10428 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
10429 char timebuf
[BGP_UPTIME_LEN
];
10435 json_object
*json_neigh
= NULL
;
10441 json_neigh
= json_object_new_object();
10443 memset(dn_flag
, '\0', sizeof(dn_flag
));
10444 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
10448 if (p
->conf_if
) /* Configured interface name. */
10449 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
10450 BGP_PEER_SU_UNSPEC(p
)
10452 : sockunion2str(&p
->su
, buf
,
10454 else /* Configured IP address. */
10455 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
10460 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
10461 json_object_string_add(json_neigh
, "bgpNeighborAddr",
10463 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
10464 json_object_string_add(
10465 json_neigh
, "bgpNeighborAddr",
10466 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
10468 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
10470 if (p
->change_local_as
)
10471 json_object_int_add(json_neigh
, "localAs",
10472 p
->change_local_as
);
10474 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
10476 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
10477 json_object_boolean_true_add(json_neigh
,
10478 "localAsNoPrepend");
10480 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
10481 json_object_boolean_true_add(json_neigh
,
10482 "localAsReplaceAs");
10484 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
10485 || (p
->as_type
== AS_INTERNAL
))
10486 vty_out(vty
, "remote AS %u, ", p
->as
);
10488 vty_out(vty
, "remote AS Unspecified, ");
10489 vty_out(vty
, "local AS %u%s%s, ",
10490 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
10491 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
10494 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
10498 /* peer type internal or confed-internal */
10499 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
10501 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10502 json_object_boolean_true_add(
10503 json_neigh
, "nbrConfedInternalLink");
10505 json_object_boolean_true_add(json_neigh
,
10506 "nbrInternalLink");
10508 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10509 vty_out(vty
, "confed-internal link\n");
10511 vty_out(vty
, "internal link\n");
10513 /* peer type external or confed-external */
10514 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
10516 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10517 json_object_boolean_true_add(
10518 json_neigh
, "nbrConfedExternalLink");
10520 json_object_boolean_true_add(json_neigh
,
10521 "nbrExternalLink");
10523 if (bgp_confederation_peers_check(bgp
, p
->as
))
10524 vty_out(vty
, "confed-external link\n");
10526 vty_out(vty
, "external link\n");
10530 json_object_boolean_true_add(json_neigh
,
10531 "nbrUnspecifiedLink");
10533 vty_out(vty
, "unspecified link\n");
10539 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
10541 vty_out(vty
, " Description: %s\n", p
->desc
);
10547 json_object_string_add(json_neigh
, "hostname",
10551 json_object_string_add(json_neigh
, "domainname",
10554 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
10555 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
10558 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
10565 json_object_string_add(json_neigh
, "peerGroup",
10569 struct prefix prefix
, *range
= NULL
;
10571 sockunion2hostprefix(&(p
->su
), &prefix
);
10572 range
= peer_group_lookup_dynamic_neighbor_range(
10573 p
->group
, &prefix
);
10576 prefix2str(range
, buf1
, sizeof(buf1
));
10577 json_object_string_add(
10579 "peerSubnetRangeGroup", buf1
);
10584 " Member of peer-group %s for session parameters\n",
10588 struct prefix prefix
, *range
= NULL
;
10590 sockunion2hostprefix(&(p
->su
), &prefix
);
10591 range
= peer_group_lookup_dynamic_neighbor_range(
10592 p
->group
, &prefix
);
10595 prefix2str(range
, buf1
, sizeof(buf1
));
10597 " Belongs to the subnet range group: %s\n",
10605 /* Administrative shutdown. */
10606 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
10607 json_object_boolean_true_add(json_neigh
,
10611 json_object_int_add(json_neigh
, "bgpVersion", 4);
10612 json_object_string_add(
10613 json_neigh
, "remoteRouterId",
10614 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
10615 json_object_string_add(
10616 json_neigh
, "localRouterId",
10617 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
10620 /* Confederation */
10621 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
10622 && bgp_confederation_peers_check(bgp
, p
->as
))
10623 json_object_boolean_true_add(json_neigh
,
10627 json_object_string_add(
10628 json_neigh
, "bgpState",
10629 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
10631 if (p
->status
== Established
) {
10634 uptime
= bgp_clock();
10635 uptime
-= p
->uptime
;
10636 epoch_tbuf
= time(NULL
) - uptime
;
10638 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
10640 json_object_string_add(json_neigh
, "bgpTimerUpString",
10641 peer_uptime(p
->uptime
, timebuf
,
10644 json_object_int_add(json_neigh
,
10645 "bgpTimerUpEstablishedEpoch",
10649 else if (p
->status
== Active
) {
10650 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
10651 json_object_string_add(json_neigh
, "bgpStateIs",
10653 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
10654 json_object_string_add(json_neigh
, "bgpStateIs",
10662 uptime
= bgp_clock();
10663 uptime
-= p
->readtime
;
10664 tm
= gmtime(&uptime
);
10665 json_object_int_add(json_neigh
, "bgpTimerLastRead",
10666 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10667 + (tm
->tm_hour
* 3600000));
10669 uptime
= bgp_clock();
10670 uptime
-= p
->last_write
;
10671 tm
= gmtime(&uptime
);
10672 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
10673 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10674 + (tm
->tm_hour
* 3600000));
10676 uptime
= bgp_clock();
10677 uptime
-= p
->update_time
;
10678 tm
= gmtime(&uptime
);
10679 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
10680 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10681 + (tm
->tm_hour
* 3600000));
10683 /* Configured timer values. */
10684 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
10685 p
->v_holdtime
* 1000);
10686 json_object_int_add(json_neigh
,
10687 "bgpTimerKeepAliveIntervalMsecs",
10688 p
->v_keepalive
* 1000);
10689 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
10690 json_object_int_add(json_neigh
,
10691 "bgpTimerConfiguredHoldTimeMsecs",
10692 p
->holdtime
* 1000);
10693 json_object_int_add(
10695 "bgpTimerConfiguredKeepAliveIntervalMsecs",
10696 p
->keepalive
* 1000);
10697 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
10698 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
10699 json_object_int_add(json_neigh
,
10700 "bgpTimerConfiguredHoldTimeMsecs",
10701 bgp
->default_holdtime
);
10702 json_object_int_add(
10704 "bgpTimerConfiguredKeepAliveIntervalMsecs",
10705 bgp
->default_keepalive
);
10708 /* Administrative shutdown. */
10709 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
10710 vty_out(vty
, " Administratively shut down\n");
10713 vty_out(vty
, " BGP version 4");
10714 vty_out(vty
, ", remote router ID %s",
10715 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
10716 vty_out(vty
, ", local router ID %s\n",
10717 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
10720 /* Confederation */
10721 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
10722 && bgp_confederation_peers_check(bgp
, p
->as
))
10724 " Neighbor under common administration\n");
10727 vty_out(vty
, " BGP state = %s",
10728 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
10730 if (p
->status
== Established
)
10731 vty_out(vty
, ", up for %8s",
10732 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10735 else if (p
->status
== Active
) {
10736 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
10737 vty_out(vty
, " (passive)");
10738 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
10739 vty_out(vty
, " (NSF passive)");
10741 vty_out(vty
, "\n");
10744 vty_out(vty
, " Last read %s",
10745 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
10747 vty_out(vty
, ", Last write %s\n",
10748 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
10751 /* Configured timer values. */
10753 " Hold time is %d, keepalive interval is %d seconds\n",
10754 p
->v_holdtime
, p
->v_keepalive
);
10755 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
10756 vty_out(vty
, " Configured hold time is %d",
10758 vty_out(vty
, ", keepalive interval is %d seconds\n",
10760 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
10761 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
10762 vty_out(vty
, " Configured hold time is %d",
10763 bgp
->default_holdtime
);
10764 vty_out(vty
, ", keepalive interval is %d seconds\n",
10765 bgp
->default_keepalive
);
10769 if (p
->status
== Established
) {
10770 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
10771 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
10772 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
10773 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
10774 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
10775 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
10776 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
10777 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
10778 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
10779 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
10780 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
10781 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
10782 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
10783 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
10784 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
10785 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
10786 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
10787 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
10788 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
10789 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
10791 json_object
*json_cap
= NULL
;
10793 json_cap
= json_object_new_object();
10796 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10797 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10798 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
10799 && CHECK_FLAG(p
->cap
,
10801 json_object_string_add(
10802 json_cap
, "4byteAs",
10803 "advertisedAndReceived");
10804 else if (CHECK_FLAG(p
->cap
,
10806 json_object_string_add(
10807 json_cap
, "4byteAs",
10809 else if (CHECK_FLAG(p
->cap
,
10811 json_object_string_add(
10812 json_cap
, "4byteAs",
10817 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10818 || CHECK_FLAG(p
->cap
,
10819 PEER_CAP_ADDPATH_ADV
)) {
10820 json_object
*json_add
= NULL
;
10821 const char *print_store
;
10823 json_add
= json_object_new_object();
10825 FOREACH_AFI_SAFI (afi
, safi
) {
10826 json_object
*json_sub
= NULL
;
10828 json_object_new_object();
10829 print_store
= get_afi_safi_str(
10835 PEER_CAP_ADDPATH_AF_TX_ADV
)
10839 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10844 PEER_CAP_ADDPATH_AF_TX_ADV
)
10849 PEER_CAP_ADDPATH_AF_TX_RCV
))
10850 json_object_boolean_true_add(
10852 "txAdvertisedAndReceived");
10858 PEER_CAP_ADDPATH_AF_TX_ADV
))
10859 json_object_boolean_true_add(
10867 PEER_CAP_ADDPATH_AF_TX_RCV
))
10868 json_object_boolean_true_add(
10876 PEER_CAP_ADDPATH_AF_RX_ADV
)
10880 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10885 PEER_CAP_ADDPATH_AF_RX_ADV
)
10890 PEER_CAP_ADDPATH_AF_RX_RCV
))
10891 json_object_boolean_true_add(
10893 "rxAdvertisedAndReceived");
10899 PEER_CAP_ADDPATH_AF_RX_ADV
))
10900 json_object_boolean_true_add(
10908 PEER_CAP_ADDPATH_AF_RX_RCV
))
10909 json_object_boolean_true_add(
10917 PEER_CAP_ADDPATH_AF_TX_ADV
)
10921 PEER_CAP_ADDPATH_AF_TX_RCV
)
10925 PEER_CAP_ADDPATH_AF_RX_ADV
)
10929 PEER_CAP_ADDPATH_AF_RX_RCV
))
10930 json_object_object_add(
10939 json_object_object_add(
10940 json_cap
, "addPath", json_add
);
10944 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10945 || CHECK_FLAG(p
->cap
,
10946 PEER_CAP_DYNAMIC_ADV
)) {
10947 if (CHECK_FLAG(p
->cap
,
10948 PEER_CAP_DYNAMIC_ADV
)
10949 && CHECK_FLAG(p
->cap
,
10950 PEER_CAP_DYNAMIC_RCV
))
10951 json_object_string_add(
10952 json_cap
, "dynamic",
10953 "advertisedAndReceived");
10954 else if (CHECK_FLAG(
10956 PEER_CAP_DYNAMIC_ADV
))
10957 json_object_string_add(
10958 json_cap
, "dynamic",
10960 else if (CHECK_FLAG(
10962 PEER_CAP_DYNAMIC_RCV
))
10963 json_object_string_add(
10964 json_cap
, "dynamic",
10968 /* Extended nexthop */
10969 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10970 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10971 json_object
*json_nxt
= NULL
;
10972 const char *print_store
;
10975 if (CHECK_FLAG(p
->cap
,
10977 && CHECK_FLAG(p
->cap
,
10978 PEER_CAP_ENHE_RCV
))
10979 json_object_string_add(
10982 "advertisedAndReceived");
10983 else if (CHECK_FLAG(p
->cap
,
10984 PEER_CAP_ENHE_ADV
))
10985 json_object_string_add(
10989 else if (CHECK_FLAG(p
->cap
,
10990 PEER_CAP_ENHE_RCV
))
10991 json_object_string_add(
10996 if (CHECK_FLAG(p
->cap
,
10997 PEER_CAP_ENHE_RCV
)) {
10999 json_object_new_object();
11001 for (safi
= SAFI_UNICAST
;
11002 safi
< SAFI_MAX
; safi
++) {
11007 PEER_CAP_ENHE_AF_RCV
)) {
11008 print_store
= get_afi_safi_str(
11011 json_object_string_add(
11014 "recieved"); /* misspelled for compatibility */
11017 json_object_object_add(
11019 "extendedNexthopFamililesByPeer",
11024 /* Route Refresh */
11025 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11026 || CHECK_FLAG(p
->cap
,
11027 PEER_CAP_REFRESH_NEW_RCV
)
11028 || CHECK_FLAG(p
->cap
,
11029 PEER_CAP_REFRESH_OLD_RCV
)) {
11030 if (CHECK_FLAG(p
->cap
,
11031 PEER_CAP_REFRESH_ADV
)
11034 PEER_CAP_REFRESH_NEW_RCV
)
11037 PEER_CAP_REFRESH_OLD_RCV
))) {
11040 PEER_CAP_REFRESH_OLD_RCV
)
11043 PEER_CAP_REFRESH_NEW_RCV
))
11044 json_object_string_add(
11047 "advertisedAndReceivedOldNew");
11051 PEER_CAP_REFRESH_OLD_RCV
))
11052 json_object_string_add(
11055 "advertisedAndReceivedOld");
11057 json_object_string_add(
11060 "advertisedAndReceivedNew");
11065 PEER_CAP_REFRESH_ADV
))
11066 json_object_string_add(
11073 PEER_CAP_REFRESH_NEW_RCV
)
11076 PEER_CAP_REFRESH_OLD_RCV
))
11077 json_object_string_add(
11083 /* Multiprotocol Extensions */
11084 json_object
*json_multi
= NULL
;
11085 json_multi
= json_object_new_object();
11087 FOREACH_AFI_SAFI (afi
, safi
) {
11088 if (p
->afc_adv
[afi
][safi
]
11089 || p
->afc_recv
[afi
][safi
]) {
11090 json_object
*json_exten
= NULL
;
11092 json_object_new_object();
11094 if (p
->afc_adv
[afi
][safi
]
11095 && p
->afc_recv
[afi
][safi
])
11096 json_object_boolean_true_add(
11098 "advertisedAndReceived");
11099 else if (p
->afc_adv
[afi
][safi
])
11100 json_object_boolean_true_add(
11103 else if (p
->afc_recv
[afi
][safi
])
11104 json_object_boolean_true_add(
11108 json_object_object_add(
11110 get_afi_safi_str(afi
,
11116 json_object_object_add(
11117 json_cap
, "multiprotocolExtensions",
11120 /* Hostname capabilities */
11121 json_object
*json_hname
= NULL
;
11123 json_hname
= json_object_new_object();
11125 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11126 json_object_string_add(
11127 json_hname
, "advHostName",
11128 bgp
->peer_self
->hostname
11132 json_object_string_add(
11133 json_hname
, "advDomainName",
11134 bgp
->peer_self
->domainname
11141 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11142 json_object_string_add(
11143 json_hname
, "rcvHostName",
11144 p
->hostname
? p
->hostname
11146 json_object_string_add(
11147 json_hname
, "rcvDomainName",
11148 p
->domainname
? p
->domainname
11152 json_object_object_add(json_cap
, "hostName",
11155 /* Gracefull Restart */
11156 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11157 || CHECK_FLAG(p
->cap
,
11158 PEER_CAP_RESTART_ADV
)) {
11159 if (CHECK_FLAG(p
->cap
,
11160 PEER_CAP_RESTART_ADV
)
11161 && CHECK_FLAG(p
->cap
,
11162 PEER_CAP_RESTART_RCV
))
11163 json_object_string_add(
11166 "advertisedAndReceived");
11167 else if (CHECK_FLAG(
11169 PEER_CAP_RESTART_ADV
))
11170 json_object_string_add(
11172 "gracefulRestartCapability",
11174 else if (CHECK_FLAG(
11176 PEER_CAP_RESTART_RCV
))
11177 json_object_string_add(
11179 "gracefulRestartCapability",
11182 if (CHECK_FLAG(p
->cap
,
11183 PEER_CAP_RESTART_RCV
)) {
11184 int restart_af_count
= 0;
11185 json_object
*json_restart
=
11188 json_object_new_object();
11190 json_object_int_add(
11192 "gracefulRestartRemoteTimerMsecs",
11193 p
->v_gr_restart
* 1000);
11195 FOREACH_AFI_SAFI (afi
, safi
) {
11200 PEER_CAP_RESTART_AF_RCV
)) {
11205 json_object_new_object();
11211 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
11212 json_object_boolean_true_add(
11215 restart_af_count
++;
11216 json_object_object_add(
11225 if (!restart_af_count
) {
11226 json_object_string_add(
11228 "addressFamiliesByPeer",
11233 json_object_object_add(
11235 "addressFamiliesByPeer",
11239 json_object_object_add(json_neigh
,
11240 "neighborCapabilities",
11243 vty_out(vty
, " Neighbor capabilities:\n");
11246 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
11247 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
11248 vty_out(vty
, " 4 Byte AS:");
11249 if (CHECK_FLAG(p
->cap
,
11251 vty_out(vty
, " advertised");
11252 if (CHECK_FLAG(p
->cap
,
11254 vty_out(vty
, " %sreceived",
11260 vty_out(vty
, "\n");
11264 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
11265 || CHECK_FLAG(p
->cap
,
11266 PEER_CAP_ADDPATH_ADV
)) {
11267 vty_out(vty
, " AddPath:\n");
11269 FOREACH_AFI_SAFI (afi
, safi
) {
11273 PEER_CAP_ADDPATH_AF_TX_ADV
)
11277 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
11289 PEER_CAP_ADDPATH_AF_TX_ADV
))
11301 PEER_CAP_ADDPATH_AF_TX_RCV
))
11308 PEER_CAP_ADDPATH_AF_TX_ADV
)
11312 vty_out(vty
, "\n");
11318 PEER_CAP_ADDPATH_AF_RX_ADV
)
11322 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
11334 PEER_CAP_ADDPATH_AF_RX_ADV
))
11346 PEER_CAP_ADDPATH_AF_RX_RCV
))
11353 PEER_CAP_ADDPATH_AF_RX_ADV
)
11357 vty_out(vty
, "\n");
11363 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
11364 || CHECK_FLAG(p
->cap
,
11365 PEER_CAP_DYNAMIC_ADV
)) {
11366 vty_out(vty
, " Dynamic:");
11367 if (CHECK_FLAG(p
->cap
,
11368 PEER_CAP_DYNAMIC_ADV
))
11369 vty_out(vty
, " advertised");
11370 if (CHECK_FLAG(p
->cap
,
11371 PEER_CAP_DYNAMIC_RCV
))
11372 vty_out(vty
, " %sreceived",
11375 PEER_CAP_DYNAMIC_ADV
)
11378 vty_out(vty
, "\n");
11381 /* Extended nexthop */
11382 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
11383 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
11384 vty_out(vty
, " Extended nexthop:");
11385 if (CHECK_FLAG(p
->cap
,
11386 PEER_CAP_ENHE_ADV
))
11387 vty_out(vty
, " advertised");
11388 if (CHECK_FLAG(p
->cap
,
11389 PEER_CAP_ENHE_RCV
))
11390 vty_out(vty
, " %sreceived",
11396 vty_out(vty
, "\n");
11398 if (CHECK_FLAG(p
->cap
,
11399 PEER_CAP_ENHE_RCV
)) {
11401 " Address families by peer:\n ");
11402 for (safi
= SAFI_UNICAST
;
11403 safi
< SAFI_MAX
; safi
++)
11408 PEER_CAP_ENHE_AF_RCV
))
11418 /* Route Refresh */
11419 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11420 || CHECK_FLAG(p
->cap
,
11421 PEER_CAP_REFRESH_NEW_RCV
)
11422 || CHECK_FLAG(p
->cap
,
11423 PEER_CAP_REFRESH_OLD_RCV
)) {
11424 vty_out(vty
, " Route refresh:");
11425 if (CHECK_FLAG(p
->cap
,
11426 PEER_CAP_REFRESH_ADV
))
11427 vty_out(vty
, " advertised");
11428 if (CHECK_FLAG(p
->cap
,
11429 PEER_CAP_REFRESH_NEW_RCV
)
11432 PEER_CAP_REFRESH_OLD_RCV
))
11433 vty_out(vty
, " %sreceived(%s)",
11436 PEER_CAP_REFRESH_ADV
)
11441 PEER_CAP_REFRESH_OLD_RCV
)
11444 PEER_CAP_REFRESH_NEW_RCV
))
11448 PEER_CAP_REFRESH_OLD_RCV
)
11452 vty_out(vty
, "\n");
11455 /* Multiprotocol Extensions */
11456 FOREACH_AFI_SAFI (afi
, safi
)
11457 if (p
->afc_adv
[afi
][safi
]
11458 || p
->afc_recv
[afi
][safi
]) {
11460 " Address Family %s:",
11465 if (p
->afc_adv
[afi
][safi
])
11468 if (p
->afc_recv
[afi
][safi
])
11475 vty_out(vty
, "\n");
11478 /* Hostname capability */
11479 vty_out(vty
, " Hostname Capability:");
11481 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11483 " advertised (name: %s,domain name: %s)",
11484 bgp
->peer_self
->hostname
11488 bgp
->peer_self
->domainname
11493 vty_out(vty
, " not advertised");
11496 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11498 " received (name: %s,domain name: %s)",
11499 p
->hostname
? p
->hostname
11501 p
->domainname
? p
->domainname
11504 vty_out(vty
, " not received");
11507 vty_out(vty
, "\n");
11509 /* Graceful Restart */
11510 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11511 || CHECK_FLAG(p
->cap
,
11512 PEER_CAP_RESTART_ADV
)) {
11514 " Graceful Restart Capability:");
11515 if (CHECK_FLAG(p
->cap
,
11516 PEER_CAP_RESTART_ADV
))
11517 vty_out(vty
, " advertised");
11518 if (CHECK_FLAG(p
->cap
,
11519 PEER_CAP_RESTART_RCV
))
11520 vty_out(vty
, " %sreceived",
11523 PEER_CAP_RESTART_ADV
)
11526 vty_out(vty
, "\n");
11528 if (CHECK_FLAG(p
->cap
,
11529 PEER_CAP_RESTART_RCV
)) {
11530 int restart_af_count
= 0;
11533 " Remote Restart timer is %d seconds\n",
11536 " Address families by peer:\n ");
11538 FOREACH_AFI_SAFI (afi
, safi
)
11543 PEER_CAP_RESTART_AF_RCV
)) {
11557 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
11559 : "not preserved");
11560 restart_af_count
++;
11562 if (!restart_af_count
)
11563 vty_out(vty
, "none");
11564 vty_out(vty
, "\n");
11566 } /* Gracefull Restart */
11571 /* graceful restart information */
11572 json_object
*json_grace
= NULL
;
11573 json_object
*json_grace_send
= NULL
;
11574 json_object
*json_grace_recv
= NULL
;
11575 int eor_send_af_count
= 0;
11576 int eor_receive_af_count
= 0;
11579 json_grace
= json_object_new_object();
11580 json_grace_send
= json_object_new_object();
11581 json_grace_recv
= json_object_new_object();
11583 if ((p
->status
== Established
)
11584 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
11585 FOREACH_AFI_SAFI (afi
, safi
) {
11586 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11587 PEER_STATUS_EOR_SEND
)) {
11588 json_object_boolean_true_add(
11590 get_afi_safi_str(afi
,
11593 eor_send_af_count
++;
11596 FOREACH_AFI_SAFI (afi
, safi
) {
11598 p
->af_sflags
[afi
][safi
],
11599 PEER_STATUS_EOR_RECEIVED
)) {
11600 json_object_boolean_true_add(
11602 get_afi_safi_str(afi
,
11605 eor_receive_af_count
++;
11609 json_object_object_add(json_grace
, "endOfRibSend",
11611 json_object_object_add(json_grace
, "endOfRibRecv",
11615 if (p
->t_gr_restart
)
11616 json_object_int_add(json_grace
,
11617 "gracefulRestartTimerMsecs",
11618 thread_timer_remain_second(
11623 json_object_int_add(
11625 "gracefulStalepathTimerMsecs",
11626 thread_timer_remain_second(
11629 /* more gr info in new format */
11630 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
11632 json_object_object_add(
11633 json_neigh
, "gracefulRestartInfo", json_grace
);
11635 vty_out(vty
, " Graceful restart informations:\n");
11636 if ((p
->status
== Established
)
11637 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
11639 vty_out(vty
, " End-of-RIB send: ");
11640 FOREACH_AFI_SAFI (afi
, safi
) {
11641 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11642 PEER_STATUS_EOR_SEND
)) {
11643 vty_out(vty
, "%s%s",
11644 eor_send_af_count
? ", "
11649 eor_send_af_count
++;
11652 vty_out(vty
, "\n");
11653 vty_out(vty
, " End-of-RIB received: ");
11654 FOREACH_AFI_SAFI (afi
, safi
) {
11656 p
->af_sflags
[afi
][safi
],
11657 PEER_STATUS_EOR_RECEIVED
)) {
11658 vty_out(vty
, "%s%s",
11659 eor_receive_af_count
11662 get_afi_safi_str(afi
,
11665 eor_receive_af_count
++;
11668 vty_out(vty
, "\n");
11671 if (p
->t_gr_restart
)
11673 " The remaining time of restart timer is %ld\n",
11674 thread_timer_remain_second(
11679 " The remaining time of stalepath timer is %ld\n",
11680 thread_timer_remain_second(
11683 /* more gr info in new format */
11684 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
11688 json_object
*json_stat
= NULL
;
11689 json_stat
= json_object_new_object();
11690 /* Packet counts. */
11691 json_object_int_add(json_stat
, "depthInq", 0);
11692 json_object_int_add(json_stat
, "depthOutq",
11693 (unsigned long)p
->obuf
->count
);
11694 json_object_int_add(json_stat
, "opensSent",
11695 atomic_load_explicit(&p
->open_out
,
11696 memory_order_relaxed
));
11697 json_object_int_add(json_stat
, "opensRecv",
11698 atomic_load_explicit(&p
->open_in
,
11699 memory_order_relaxed
));
11700 json_object_int_add(json_stat
, "notificationsSent",
11701 atomic_load_explicit(&p
->notify_out
,
11702 memory_order_relaxed
));
11703 json_object_int_add(json_stat
, "notificationsRecv",
11704 atomic_load_explicit(&p
->notify_in
,
11705 memory_order_relaxed
));
11706 json_object_int_add(json_stat
, "updatesSent",
11707 atomic_load_explicit(&p
->update_out
,
11708 memory_order_relaxed
));
11709 json_object_int_add(json_stat
, "updatesRecv",
11710 atomic_load_explicit(&p
->update_in
,
11711 memory_order_relaxed
));
11712 json_object_int_add(json_stat
, "keepalivesSent",
11713 atomic_load_explicit(&p
->keepalive_out
,
11714 memory_order_relaxed
));
11715 json_object_int_add(json_stat
, "keepalivesRecv",
11716 atomic_load_explicit(&p
->keepalive_in
,
11717 memory_order_relaxed
));
11718 json_object_int_add(json_stat
, "routeRefreshSent",
11719 atomic_load_explicit(&p
->refresh_out
,
11720 memory_order_relaxed
));
11721 json_object_int_add(json_stat
, "routeRefreshRecv",
11722 atomic_load_explicit(&p
->refresh_in
,
11723 memory_order_relaxed
));
11724 json_object_int_add(json_stat
, "capabilitySent",
11725 atomic_load_explicit(&p
->dynamic_cap_out
,
11726 memory_order_relaxed
));
11727 json_object_int_add(json_stat
, "capabilityRecv",
11728 atomic_load_explicit(&p
->dynamic_cap_in
,
11729 memory_order_relaxed
));
11730 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
11731 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
11732 json_object_object_add(json_neigh
, "messageStats", json_stat
);
11734 /* Packet counts. */
11735 vty_out(vty
, " Message statistics:\n");
11736 vty_out(vty
, " Inq depth is 0\n");
11737 vty_out(vty
, " Outq depth is %lu\n",
11738 (unsigned long)p
->obuf
->count
);
11739 vty_out(vty
, " Sent Rcvd\n");
11740 vty_out(vty
, " Opens: %10d %10d\n",
11741 atomic_load_explicit(&p
->open_out
,
11742 memory_order_relaxed
),
11743 atomic_load_explicit(&p
->open_in
,
11744 memory_order_relaxed
));
11745 vty_out(vty
, " Notifications: %10d %10d\n",
11746 atomic_load_explicit(&p
->notify_out
,
11747 memory_order_relaxed
),
11748 atomic_load_explicit(&p
->notify_in
,
11749 memory_order_relaxed
));
11750 vty_out(vty
, " Updates: %10d %10d\n",
11751 atomic_load_explicit(&p
->update_out
,
11752 memory_order_relaxed
),
11753 atomic_load_explicit(&p
->update_in
,
11754 memory_order_relaxed
));
11755 vty_out(vty
, " Keepalives: %10d %10d\n",
11756 atomic_load_explicit(&p
->keepalive_out
,
11757 memory_order_relaxed
),
11758 atomic_load_explicit(&p
->keepalive_in
,
11759 memory_order_relaxed
));
11760 vty_out(vty
, " Route Refresh: %10d %10d\n",
11761 atomic_load_explicit(&p
->refresh_out
,
11762 memory_order_relaxed
),
11763 atomic_load_explicit(&p
->refresh_in
,
11764 memory_order_relaxed
));
11765 vty_out(vty
, " Capability: %10d %10d\n",
11766 atomic_load_explicit(&p
->dynamic_cap_out
,
11767 memory_order_relaxed
),
11768 atomic_load_explicit(&p
->dynamic_cap_in
,
11769 memory_order_relaxed
));
11770 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
11775 /* advertisement-interval */
11776 json_object_int_add(json_neigh
,
11777 "minBtwnAdvertisementRunsTimerMsecs",
11778 p
->v_routeadv
* 1000);
11780 /* Update-source. */
11781 if (p
->update_if
|| p
->update_source
) {
11783 json_object_string_add(json_neigh
,
11786 else if (p
->update_source
)
11787 json_object_string_add(
11788 json_neigh
, "updateSource",
11789 sockunion2str(p
->update_source
, buf1
,
11793 /* advertisement-interval */
11795 " Minimum time between advertisement runs is %d seconds\n",
11798 /* Update-source. */
11799 if (p
->update_if
|| p
->update_source
) {
11800 vty_out(vty
, " Update source is ");
11802 vty_out(vty
, "%s", p
->update_if
);
11803 else if (p
->update_source
)
11805 sockunion2str(p
->update_source
, buf1
,
11807 vty_out(vty
, "\n");
11810 vty_out(vty
, "\n");
11813 /* Address Family Information */
11814 json_object
*json_hold
= NULL
;
11817 json_hold
= json_object_new_object();
11819 FOREACH_AFI_SAFI (afi
, safi
)
11820 if (p
->afc
[afi
][safi
])
11821 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
11825 json_object_object_add(json_neigh
, "addressFamilyInfo",
11827 json_object_int_add(json_neigh
, "connectionsEstablished",
11829 json_object_int_add(json_neigh
, "connectionsDropped",
11832 vty_out(vty
, " Connections established %d; dropped %d\n",
11833 p
->established
, p
->dropped
);
11835 if (!p
->last_reset
) {
11837 json_object_string_add(json_neigh
, "lastReset",
11840 vty_out(vty
, " Last reset never\n");
11846 uptime
= bgp_clock();
11847 uptime
-= p
->resettime
;
11848 tm
= gmtime(&uptime
);
11849 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
11850 (tm
->tm_sec
* 1000)
11851 + (tm
->tm_min
* 60000)
11852 + (tm
->tm_hour
* 3600000));
11853 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
11855 vty_out(vty
, " Last reset %s, ",
11856 peer_uptime(p
->resettime
, timebuf
,
11857 BGP_UPTIME_LEN
, 0, NULL
));
11859 bgp_show_peer_reset(vty
, p
, NULL
, false);
11860 if (p
->last_reset_cause_size
) {
11861 msg
= p
->last_reset_cause
;
11863 " Message received that caused BGP to send a NOTIFICATION:\n ");
11864 for (i
= 1; i
<= p
->last_reset_cause_size
;
11866 vty_out(vty
, "%02X", *msg
++);
11868 if (i
!= p
->last_reset_cause_size
) {
11870 vty_out(vty
, "\n ");
11871 } else if (i
% 4 == 0) {
11876 vty_out(vty
, "\n");
11881 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
11883 json_object_boolean_true_add(json_neigh
,
11884 "prefixesConfigExceedMax");
11887 " Peer had exceeded the max. no. of prefixes configured.\n");
11889 if (p
->t_pmax_restart
) {
11891 json_object_boolean_true_add(
11892 json_neigh
, "reducePrefixNumFrom");
11893 json_object_int_add(json_neigh
,
11894 "restartInTimerMsec",
11895 thread_timer_remain_second(
11900 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
11901 p
->host
, thread_timer_remain_second(
11902 p
->t_pmax_restart
));
11905 json_object_boolean_true_add(
11907 "reducePrefixNumAndClearIpBgp");
11910 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
11915 /* EBGP Multihop and GTSM */
11916 if (p
->sort
!= BGP_PEER_IBGP
) {
11918 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
11919 json_object_int_add(json_neigh
,
11920 "externalBgpNbrMaxHopsAway",
11922 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11923 json_object_int_add(json_neigh
,
11924 "externalBgpNbrMaxHopsAway",
11927 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
11929 " External BGP neighbor may be up to %d hops away.\n",
11931 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11933 " External BGP neighbor may be up to %d hops away.\n",
11937 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
11939 json_object_int_add(json_neigh
,
11940 "internalBgpNbrMaxHopsAway",
11944 " Internal BGP neighbor may be up to %d hops away.\n",
11949 /* Local address. */
11952 json_object_string_add(json_neigh
, "hostLocal",
11953 sockunion2str(p
->su_local
, buf1
,
11955 json_object_int_add(json_neigh
, "portLocal",
11956 ntohs(p
->su_local
->sin
.sin_port
));
11958 vty_out(vty
, "Local host: %s, Local port: %d\n",
11959 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
11960 ntohs(p
->su_local
->sin
.sin_port
));
11963 /* Remote address. */
11964 if (p
->su_remote
) {
11966 json_object_string_add(json_neigh
, "hostForeign",
11967 sockunion2str(p
->su_remote
, buf1
,
11969 json_object_int_add(json_neigh
, "portForeign",
11970 ntohs(p
->su_remote
->sin
.sin_port
));
11972 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
11973 sockunion2str(p
->su_remote
, buf1
,
11975 ntohs(p
->su_remote
->sin
.sin_port
));
11978 /* Nexthop display. */
11981 json_object_string_add(json_neigh
, "nexthop",
11983 &p
->nexthop
.v4
, buf1
,
11985 json_object_string_add(json_neigh
, "nexthopGlobal",
11986 inet_ntop(AF_INET6
,
11987 &p
->nexthop
.v6_global
,
11988 buf1
, sizeof(buf1
)));
11989 json_object_string_add(json_neigh
, "nexthopLocal",
11990 inet_ntop(AF_INET6
,
11991 &p
->nexthop
.v6_local
,
11992 buf1
, sizeof(buf1
)));
11993 if (p
->shared_network
)
11994 json_object_string_add(json_neigh
,
11998 json_object_string_add(json_neigh
,
12000 "nonSharedNetwork");
12002 vty_out(vty
, "Nexthop: %s\n",
12003 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
12005 vty_out(vty
, "Nexthop global: %s\n",
12006 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
12008 vty_out(vty
, "Nexthop local: %s\n",
12009 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
12011 vty_out(vty
, "BGP connection: %s\n",
12012 p
->shared_network
? "shared network"
12013 : "non shared network");
12017 /* Timer information. */
12019 json_object_int_add(json_neigh
, "connectRetryTimer",
12021 if (p
->status
== Established
&& p
->rtt
)
12022 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
12025 json_object_int_add(
12026 json_neigh
, "nextStartTimerDueInMsecs",
12027 thread_timer_remain_second(p
->t_start
) * 1000);
12029 json_object_int_add(
12030 json_neigh
, "nextConnectTimerDueInMsecs",
12031 thread_timer_remain_second(p
->t_connect
)
12033 if (p
->t_routeadv
) {
12034 json_object_int_add(json_neigh
, "mraiInterval",
12036 json_object_int_add(
12037 json_neigh
, "mraiTimerExpireInMsecs",
12038 thread_timer_remain_second(p
->t_routeadv
)
12042 json_object_int_add(json_neigh
, "authenticationEnabled",
12046 json_object_string_add(json_neigh
, "readThread", "on");
12048 json_object_string_add(json_neigh
, "readThread", "off");
12050 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
12051 json_object_string_add(json_neigh
, "writeThread", "on");
12053 json_object_string_add(json_neigh
, "writeThread",
12056 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
12058 if (p
->status
== Established
&& p
->rtt
)
12059 vty_out(vty
, "Estimated round trip time: %d ms\n",
12062 vty_out(vty
, "Next start timer due in %ld seconds\n",
12063 thread_timer_remain_second(p
->t_start
));
12065 vty_out(vty
, "Next connect timer due in %ld seconds\n",
12066 thread_timer_remain_second(p
->t_connect
));
12069 "MRAI (interval %u) timer expires in %ld seconds\n",
12071 thread_timer_remain_second(p
->t_routeadv
));
12073 vty_out(vty
, "Peer Authentication Enabled\n");
12075 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
12076 p
->t_read
? "on" : "off",
12077 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
12082 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
12083 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
12084 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
12087 vty_out(vty
, "\n");
12089 /* BFD information. */
12090 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
12093 if (p
->conf_if
) /* Configured interface name. */
12094 json_object_object_add(json
, p
->conf_if
, json_neigh
);
12095 else /* Configured IP address. */
12096 json_object_object_add(json
, p
->host
, json_neigh
);
12100 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
12101 enum show_type type
,
12102 union sockunion
*su
,
12103 const char *conf_if
, afi_t afi
,
12104 bool use_json
, json_object
*json
)
12106 struct listnode
*node
, *nnode
;
12109 safi_t safi
= SAFI_UNICAST
;
12110 json_object
*json_neighbor
= NULL
;
12112 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12114 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12117 if ((peer
->afc
[afi
][safi
]) == 0)
12121 json_neighbor
= json_object_new_object();
12123 if (type
== show_all
) {
12124 bgp_show_peer_gr_status(vty
, peer
, use_json
,
12128 json_object_object_add(json
, peer
->host
,
12131 } else if (type
== show_peer
) {
12134 && !strcmp(peer
->conf_if
, conf_if
))
12136 && !strcmp(peer
->hostname
, conf_if
))) {
12138 bgp_show_peer_gr_status(vty
, peer
,
12143 if (sockunion_same(&peer
->su
, su
)) {
12145 bgp_show_peer_gr_status(vty
, peer
,
12150 if (use_json
&& find
)
12151 json_object_object_add(json
, peer
->host
,
12159 if (type
== show_peer
&& !find
) {
12161 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12163 vty_out(vty
, "%% No such neighbor\n");
12166 vty_out(vty
, "%s\n",
12167 json_object_to_json_string_ext(
12168 json
, JSON_C_TO_STRING_PRETTY
));
12170 vty_out(vty
, "\n");
12173 return CMD_SUCCESS
;
12176 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
12177 enum show_type type
, union sockunion
*su
,
12178 const char *conf_if
, bool use_json
,
12181 struct listnode
*node
, *nnode
;
12184 bool nbr_output
= false;
12185 afi_t afi
= AFI_MAX
;
12186 safi_t safi
= SAFI_MAX
;
12188 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
12190 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
12194 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12195 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12200 bgp_show_peer(vty
, peer
, use_json
, json
);
12206 && !strcmp(peer
->conf_if
, conf_if
))
12208 && !strcmp(peer
->hostname
, conf_if
))) {
12210 bgp_show_peer(vty
, peer
, use_json
,
12214 if (sockunion_same(&peer
->su
, su
)) {
12216 bgp_show_peer(vty
, peer
, use_json
,
12221 case show_ipv4_peer
:
12222 case show_ipv6_peer
:
12223 FOREACH_SAFI (safi
) {
12224 if (peer
->afc
[afi
][safi
]) {
12227 && !strcmp(peer
->conf_if
, conf_if
))
12229 && !strcmp(peer
->hostname
, conf_if
))) {
12231 bgp_show_peer(vty
, peer
, use_json
,
12236 if (sockunion_same(&peer
->su
, su
)) {
12238 bgp_show_peer(vty
, peer
, use_json
,
12246 case show_ipv4_all
:
12247 case show_ipv6_all
:
12248 FOREACH_SAFI (safi
) {
12249 if (peer
->afc
[afi
][safi
]) {
12250 bgp_show_peer(vty
, peer
, use_json
, json
);
12259 if ((type
== show_peer
|| type
== show_ipv4_peer
||
12260 type
== show_ipv6_peer
) && !find
) {
12262 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12264 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
12267 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
12268 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
12269 vty_out(vty
, "%% No BGP neighbors found\n");
12272 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
12273 json
, JSON_C_TO_STRING_PRETTY
));
12275 vty_out(vty
, "\n");
12278 return CMD_SUCCESS
;
12281 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
12282 enum show_type type
,
12283 const char *ip_str
,
12284 afi_t afi
, bool use_json
)
12289 union sockunion su
;
12290 json_object
*json
= NULL
;
12292 bgp
= bgp_get_default();
12298 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
12301 json
= json_object_new_object();
12303 ret
= str2sockunion(ip_str
, &su
);
12305 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
12309 bgp_show_neighbor_graceful_restart(
12310 vty
, bgp
, type
, &su
, NULL
, afi
, use_json
, json
);
12312 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
12313 afi
, use_json
, json
);
12314 json_object_free(json
);
12317 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
12318 enum show_type type
,
12319 const char *ip_str
,
12322 struct listnode
*node
, *nnode
;
12324 union sockunion su
;
12325 json_object
*json
= NULL
;
12326 int ret
, is_first
= 1;
12327 bool nbr_output
= false;
12330 vty_out(vty
, "{\n");
12332 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12335 if (!(json
= json_object_new_object())) {
12337 EC_BGP_JSON_MEM_ERROR
,
12338 "Unable to allocate memory for JSON object");
12340 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
12344 json_object_int_add(json
, "vrfId",
12345 (bgp
->vrf_id
== VRF_UNKNOWN
)
12347 : (int64_t)bgp
->vrf_id
);
12348 json_object_string_add(
12350 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12355 vty_out(vty
, ",\n");
12359 vty_out(vty
, "\"%s\":",
12360 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12364 vty_out(vty
, "\nInstance %s:\n",
12365 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12370 if (type
== show_peer
|| type
== show_ipv4_peer
||
12371 type
== show_ipv6_peer
) {
12372 ret
= str2sockunion(ip_str
, &su
);
12374 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12377 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12380 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
12383 json_object_free(json
);
12387 vty_out(vty
, "}\n");
12388 json_object_free(json
);
12390 else if (!nbr_output
)
12391 vty_out(vty
, "%% BGP instance not found\n");
12394 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
12395 enum show_type type
, const char *ip_str
,
12400 union sockunion su
;
12401 json_object
*json
= NULL
;
12404 if (strmatch(name
, "all")) {
12405 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
12407 return CMD_SUCCESS
;
12409 bgp
= bgp_lookup_by_name(name
);
12412 json
= json_object_new_object();
12413 vty_out(vty
, "%s\n",
12414 json_object_to_json_string_ext(
12416 JSON_C_TO_STRING_PRETTY
));
12417 json_object_free(json
);
12420 "%% BGP instance not found\n");
12422 return CMD_WARNING
;
12426 bgp
= bgp_get_default();
12430 json
= json_object_new_object();
12432 ret
= str2sockunion(ip_str
, &su
);
12434 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12437 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12440 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
12443 json_object_free(json
);
12446 vty_out(vty
, "{}\n");
12448 vty_out(vty
, "%% BGP instance not found\n");
12451 return CMD_SUCCESS
;
12456 /* "show [ip] bgp neighbors graceful-restart" commands. */
12457 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
12458 show_ip_bgp_neighbors_graceful_restart_cmd
,
12459 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
12465 "Neighbor to display information about\n"
12466 "Neighbor to display information about\n"
12467 "Neighbor on BGP configured interface\n"
12471 char *sh_arg
= NULL
;
12472 enum show_type sh_type
;
12474 afi_t afi
= AFI_MAX
;
12475 bool uj
= use_json(argc
, argv
);
12477 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
12482 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12483 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12484 || argv_find(argv
, argc
, "WORD", &idx
)) {
12485 sh_type
= show_peer
;
12486 sh_arg
= argv
[idx
]->arg
;
12488 sh_type
= show_all
;
12490 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
12491 return CMD_SUCCESS
;
12494 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
12498 /* "show [ip] bgp neighbors" commands. */
12499 DEFUN (show_ip_bgp_neighbors
,
12500 show_ip_bgp_neighbors_cmd
,
12501 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
12505 BGP_INSTANCE_HELP_STR
12508 "Detailed information on TCP and BGP neighbor connections\n"
12509 "Neighbor to display information about\n"
12510 "Neighbor to display information about\n"
12511 "Neighbor on BGP configured interface\n"
12515 char *sh_arg
= NULL
;
12516 enum show_type sh_type
;
12517 afi_t afi
= AFI_MAX
;
12519 bool uj
= use_json(argc
, argv
);
12523 /* [<vrf> VIEWVRFNAME] */
12524 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12525 vrf
= argv
[idx
+ 1]->arg
;
12526 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12528 } else if (argv_find(argv
, argc
, "view", &idx
))
12529 /* [<view> VIEWVRFNAME] */
12530 vrf
= argv
[idx
+ 1]->arg
;
12534 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
12535 sh_type
= show_ipv4_all
;
12537 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
12538 sh_type
= show_ipv6_all
;
12541 sh_type
= show_all
;
12544 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12545 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12546 || argv_find(argv
, argc
, "WORD", &idx
)) {
12547 sh_type
= show_peer
;
12548 sh_arg
= argv
[idx
]->arg
;
12551 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
12552 sh_type
= show_ipv4_peer
;
12553 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
12554 sh_type
= show_ipv6_peer
;
12557 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
12560 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
12561 paths' and `show ip mbgp paths'. Those functions results are the
12563 DEFUN (show_ip_bgp_paths
,
12564 show_ip_bgp_paths_cmd
,
12565 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
12570 "Path information\n")
12572 vty_out(vty
, "Address Refcnt Path\n");
12573 aspath_print_all_vty(vty
);
12574 return CMD_SUCCESS
;
12579 static void community_show_all_iterator(struct hash_bucket
*bucket
,
12582 struct community
*com
;
12584 com
= (struct community
*)bucket
->data
;
12585 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
12586 community_str(com
, false));
12589 /* Show BGP's community internal data. */
12590 DEFUN (show_ip_bgp_community_info
,
12591 show_ip_bgp_community_info_cmd
,
12592 "show [ip] bgp community-info",
12596 "List all bgp community information\n")
12598 vty_out(vty
, "Address Refcnt Community\n");
12600 hash_iterate(community_hash(),
12601 (void (*)(struct hash_bucket
*,
12602 void *))community_show_all_iterator
,
12605 return CMD_SUCCESS
;
12608 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
12611 struct lcommunity
*lcom
;
12613 lcom
= (struct lcommunity
*)bucket
->data
;
12614 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
12615 lcommunity_str(lcom
, false));
12618 /* Show BGP's community internal data. */
12619 DEFUN (show_ip_bgp_lcommunity_info
,
12620 show_ip_bgp_lcommunity_info_cmd
,
12621 "show ip bgp large-community-info",
12625 "List all bgp large-community information\n")
12627 vty_out(vty
, "Address Refcnt Large-community\n");
12629 hash_iterate(lcommunity_hash(),
12630 (void (*)(struct hash_bucket
*,
12631 void *))lcommunity_show_all_iterator
,
12634 return CMD_SUCCESS
;
12636 /* Graceful Restart */
12638 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
12645 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
12647 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
12649 switch (bgp_global_gr_mode
) {
12651 case GLOBAL_HELPER
:
12652 vty_out(vty
, "Global BGP GR Mode : Helper\n");
12656 vty_out(vty
, "Global BGP GR Mode : Restart\n");
12659 case GLOBAL_DISABLE
:
12660 vty_out(vty
, "Global BGP GR Mode : Disable\n");
12663 case GLOBAL_INVALID
:
12665 "Global BGP GR Mode Invalid\n");
12668 vty_out(vty
, "\n");
12671 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
12672 enum show_type type
,
12673 const char *ip_str
,
12674 afi_t afi
, bool use_json
)
12676 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
12679 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
12681 bgp_show_neighbor_graceful_restart_vty(
12682 vty
, type
, ip_str
, afi
, use_json
);
12685 } else if (afi
!= AFI_MAX
) {
12686 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
12689 return CMD_ERR_INCOMPLETE
;
12692 return CMD_SUCCESS
;
12694 /* Graceful Restart */
12696 DEFUN (show_ip_bgp_attr_info
,
12697 show_ip_bgp_attr_info_cmd
,
12698 "show [ip] bgp attribute-info",
12702 "List all bgp attribute information\n")
12704 attr_show_all(vty
);
12705 return CMD_SUCCESS
;
12708 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
12709 afi_t afi
, safi_t safi
,
12710 bool use_json
, json_object
*json
)
12713 struct listnode
*node
;
12715 char buf1
[INET6_ADDRSTRLEN
];
12717 vpn_policy_direction_t dir
;
12720 json_object
*json_import_vrfs
= NULL
;
12721 json_object
*json_export_vrfs
= NULL
;
12723 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12726 vty_out(vty
, "%s\n",
12727 json_object_to_json_string_ext(
12729 JSON_C_TO_STRING_PRETTY
));
12730 json_object_free(json
);
12732 return CMD_WARNING
;
12735 /* Provide context for the block */
12736 json_object_string_add(json
, "vrf", name
? name
: "default");
12737 json_object_string_add(json
, "afiSafi",
12738 get_afi_safi_str(afi
, safi
, true));
12740 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12741 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
12742 json_object_string_add(json
, "importFromVrfs", "none");
12743 json_object_string_add(json
, "importRts", "none");
12745 json_import_vrfs
= json_object_new_array();
12747 for (ALL_LIST_ELEMENTS_RO(
12748 bgp
->vpn_policy
[afi
].import_vrf
,
12750 json_object_array_add(json_import_vrfs
,
12751 json_object_new_string(vname
));
12753 json_object_object_add(json
, "importFromVrfs",
12755 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
12756 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12757 ecom_str
= ecommunity_ecom2str(
12758 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12759 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12760 json_object_string_add(json
, "importRts",
12762 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12764 json_object_string_add(json
, "importRts",
12768 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12769 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
12770 json_object_string_add(json
, "exportToVrfs", "none");
12771 json_object_string_add(json
, "routeDistinguisher",
12773 json_object_string_add(json
, "exportRts", "none");
12775 json_export_vrfs
= json_object_new_array();
12777 for (ALL_LIST_ELEMENTS_RO(
12778 bgp
->vpn_policy
[afi
].export_vrf
,
12780 json_object_array_add(json_export_vrfs
,
12781 json_object_new_string(vname
));
12782 json_object_object_add(json
, "exportToVrfs",
12784 json_object_string_add(json
, "routeDistinguisher",
12785 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
12786 buf1
, RD_ADDRSTRLEN
));
12788 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
12789 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12790 ecom_str
= ecommunity_ecom2str(
12791 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12792 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12793 json_object_string_add(json
, "exportRts",
12795 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12797 json_object_string_add(json
, "exportRts",
12802 vty_out(vty
, "%s\n",
12803 json_object_to_json_string_ext(json
,
12804 JSON_C_TO_STRING_PRETTY
));
12805 json_object_free(json
);
12808 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12811 vty_out(vty
, "%% No such BGP instance exist\n");
12812 return CMD_WARNING
;
12815 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12816 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
12818 "This VRF is not importing %s routes from any other VRF\n",
12819 get_afi_safi_str(afi
, safi
, false));
12822 "This VRF is importing %s routes from the following VRFs:\n",
12823 get_afi_safi_str(afi
, safi
, false));
12825 for (ALL_LIST_ELEMENTS_RO(
12826 bgp
->vpn_policy
[afi
].import_vrf
,
12828 vty_out(vty
, " %s\n", vname
);
12830 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
12832 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12833 ecom_str
= ecommunity_ecom2str(
12834 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12835 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12836 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
12838 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12840 vty_out(vty
, "Import RT(s):\n");
12843 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12844 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12846 "This VRF is not exporting %s routes to any other VRF\n",
12847 get_afi_safi_str(afi
, safi
, false));
12850 "This VRF is exporting %s routes to the following VRFs:\n",
12851 get_afi_safi_str(afi
, safi
, false));
12853 for (ALL_LIST_ELEMENTS_RO(
12854 bgp
->vpn_policy
[afi
].export_vrf
,
12856 vty_out(vty
, " %s\n", vname
);
12858 vty_out(vty
, "RD: %s\n",
12859 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
12860 buf1
, RD_ADDRSTRLEN
));
12862 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
12863 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12864 ecom_str
= ecommunity_ecom2str(
12865 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12866 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12867 vty_out(vty
, "Export RT: %s\n", ecom_str
);
12868 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12870 vty_out(vty
, "Import RT(s):\n");
12874 return CMD_SUCCESS
;
12877 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
12878 safi_t safi
, bool use_json
)
12880 struct listnode
*node
, *nnode
;
12882 char *vrf_name
= NULL
;
12883 json_object
*json
= NULL
;
12884 json_object
*json_vrf
= NULL
;
12885 json_object
*json_vrfs
= NULL
;
12888 json
= json_object_new_object();
12889 json_vrfs
= json_object_new_object();
12892 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12894 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
12895 vrf_name
= bgp
->name
;
12898 json_vrf
= json_object_new_object();
12900 vty_out(vty
, "\nInstance %s:\n",
12901 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12902 ? VRF_DEFAULT_NAME
: bgp
->name
);
12904 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
12906 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12907 json_object_object_add(json_vrfs
,
12908 VRF_DEFAULT_NAME
, json_vrf
);
12910 json_object_object_add(json_vrfs
, vrf_name
,
12916 json_object_object_add(json
, "vrfs", json_vrfs
);
12917 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
12918 JSON_C_TO_STRING_PRETTY
));
12919 json_object_free(json
);
12922 return CMD_SUCCESS
;
12925 /* "show [ip] bgp route-leak" command. */
12926 DEFUN (show_ip_bgp_route_leak
,
12927 show_ip_bgp_route_leak_cmd
,
12928 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
12932 BGP_INSTANCE_HELP_STR
12935 "Route leaking information\n"
12939 afi_t afi
= AFI_MAX
;
12940 safi_t safi
= SAFI_MAX
;
12942 bool uj
= use_json(argc
, argv
);
12944 json_object
*json
= NULL
;
12946 /* show [ip] bgp */
12947 if (argv_find(argv
, argc
, "ip", &idx
)) {
12949 safi
= SAFI_UNICAST
;
12951 /* [vrf VIEWVRFNAME] */
12952 if (argv_find(argv
, argc
, "view", &idx
)) {
12954 "%% This command is not applicable to BGP views\n");
12955 return CMD_WARNING
;
12958 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12959 vrf
= argv
[idx
+ 1]->arg
;
12960 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12963 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
12964 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
12965 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
12968 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
12970 "%% This command is applicable only for unicast ipv4|ipv6\n");
12971 return CMD_WARNING
;
12974 if (vrf
&& strmatch(vrf
, "all"))
12975 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
12978 json
= json_object_new_object();
12980 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
12983 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
12986 struct listnode
*node
, *nnode
;
12989 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12990 vty_out(vty
, "\nInstance %s:\n",
12991 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12994 update_group_show(bgp
, afi
, safi
, vty
, 0);
12998 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
12999 int safi
, uint64_t subgrp_id
)
13004 if (strmatch(name
, "all")) {
13005 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
13006 return CMD_SUCCESS
;
13008 bgp
= bgp_lookup_by_name(name
);
13011 bgp
= bgp_get_default();
13015 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
13016 return CMD_SUCCESS
;
13019 DEFUN (show_ip_bgp_updgrps
,
13020 show_ip_bgp_updgrps_cmd
,
13021 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
13025 BGP_INSTANCE_HELP_STR
13027 BGP_SAFI_WITH_LABEL_HELP_STR
13028 "Detailed info about dynamic update groups\n"
13029 "Specific subgroup to display detailed info for\n")
13032 afi_t afi
= AFI_IP6
;
13033 safi_t safi
= SAFI_UNICAST
;
13034 uint64_t subgrp_id
= 0;
13038 /* show [ip] bgp */
13039 if (argv_find(argv
, argc
, "ip", &idx
))
13041 /* [<vrf> VIEWVRFNAME] */
13042 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13043 vrf
= argv
[idx
+ 1]->arg
;
13044 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13046 } else if (argv_find(argv
, argc
, "view", &idx
))
13047 /* [<view> VIEWVRFNAME] */
13048 vrf
= argv
[idx
+ 1]->arg
;
13049 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13050 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13051 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13054 /* get subgroup id, if provided */
13056 if (argv
[idx
]->type
== VARIABLE_TKN
)
13057 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
13059 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
13062 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
13063 show_bgp_instance_all_ipv6_updgrps_cmd
,
13064 "show [ip] bgp <view|vrf> all update-groups",
13068 BGP_INSTANCE_ALL_HELP_STR
13069 "Detailed info about dynamic update groups\n")
13071 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
13072 return CMD_SUCCESS
;
13075 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
13076 show_bgp_l2vpn_evpn_updgrps_cmd
,
13077 "show [ip] bgp l2vpn evpn update-groups",
13081 "l2vpn address family\n"
13082 "evpn sub-address family\n"
13083 "Detailed info about dynamic update groups\n")
13086 uint64_t subgrp_id
= 0;
13088 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
13089 return CMD_SUCCESS
;
13092 DEFUN (show_bgp_updgrps_stats
,
13093 show_bgp_updgrps_stats_cmd
,
13094 "show [ip] bgp update-groups statistics",
13098 "Detailed info about dynamic update groups\n"
13103 bgp
= bgp_get_default();
13105 update_group_show_stats(bgp
, vty
);
13107 return CMD_SUCCESS
;
13110 DEFUN (show_bgp_instance_updgrps_stats
,
13111 show_bgp_instance_updgrps_stats_cmd
,
13112 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
13116 BGP_INSTANCE_HELP_STR
13117 "Detailed info about dynamic update groups\n"
13123 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
13125 update_group_show_stats(bgp
, vty
);
13127 return CMD_SUCCESS
;
13130 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
13131 afi_t afi
, safi_t safi
,
13132 const char *what
, uint64_t subgrp_id
)
13137 bgp
= bgp_lookup_by_name(name
);
13139 bgp
= bgp_get_default();
13142 if (!strcmp(what
, "advertise-queue"))
13143 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
13145 else if (!strcmp(what
, "advertised-routes"))
13146 update_group_show_advertised(bgp
, afi
, safi
, vty
,
13148 else if (!strcmp(what
, "packet-queue"))
13149 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
13154 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
13155 show_ip_bgp_instance_updgrps_adj_s_cmd
,
13156 "show [ip]$ip bgp [<view|vrf> VIEWVRFNAME$vrf] [<ipv4|ipv6>$afi <unicast|multicast|vpn>$safi] update-groups [SUBGROUP-ID]$sgid <advertise-queue|advertised-routes|packet-queue>$rtq",
13157 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
13159 "Detailed info about dynamic update groups\n"
13160 "Specific subgroup to display info for\n"
13161 "Advertisement queue\n"
13162 "Announced routes\n"
13165 uint64_t subgrp_id
= 0;
13169 subgrp_id
= strtoull(sgid
, NULL
, 10);
13174 afiz
= bgp_vty_afi_from_str(afi
);
13178 afiz
= bgp_vty_afi_from_str(afi
);
13179 if (afiz
!= AFI_IP
)
13181 "%% Cannot specify both 'ip' and 'ipv6'\n");
13182 return CMD_WARNING
;
13185 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
13187 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
13188 return CMD_SUCCESS
;
13191 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
13193 struct listnode
*node
, *nnode
;
13194 struct prefix
*range
;
13197 char buf
[PREFIX2STR_BUFFER
];
13200 const char *peer_status
;
13201 const char *af_str
;
13206 conf
= group
->conf
;
13208 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
13209 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
13210 group
->name
, conf
->as
);
13211 } else if (conf
->as_type
== AS_INTERNAL
) {
13212 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
13213 group
->name
, group
->bgp
->as
);
13215 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
13218 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
13219 vty_out(vty
, " Peer-group type is internal\n");
13221 vty_out(vty
, " Peer-group type is external\n");
13223 /* Display AFs configured. */
13224 vty_out(vty
, " Configured address-families:");
13225 FOREACH_AFI_SAFI (afi
, safi
) {
13226 if (conf
->afc
[afi
][safi
]) {
13228 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
13232 vty_out(vty
, " none\n");
13234 vty_out(vty
, "\n");
13236 /* Display listen ranges (for dynamic neighbors), if any */
13237 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
13240 else if (afi
== AFI_IP6
)
13244 lr_count
= listcount(group
->listen_range
[afi
]);
13246 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
13250 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
13252 prefix2str(range
, buf
, sizeof(buf
));
13253 vty_out(vty
, " %s\n", buf
);
13258 /* Display group members and their status */
13259 if (listcount(group
->peer
)) {
13260 vty_out(vty
, " Peer-group members:\n");
13261 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
13262 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
13263 peer_status
= "Idle (Admin)";
13264 else if (CHECK_FLAG(peer
->sflags
,
13265 PEER_STATUS_PREFIX_OVERFLOW
))
13266 peer_status
= "Idle (PfxCt)";
13268 peer_status
= lookup_msg(bgp_status_msg
,
13269 peer
->status
, NULL
);
13271 dynamic
= peer_dynamic_neighbor(peer
);
13272 vty_out(vty
, " %s %s %s \n", peer
->host
,
13273 dynamic
? "(dynamic)" : "", peer_status
);
13277 return CMD_SUCCESS
;
13280 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
13281 const char *group_name
)
13284 struct listnode
*node
, *nnode
;
13285 struct peer_group
*group
;
13286 bool found
= false;
13288 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13291 vty_out(vty
, "%% BGP instance not found\n");
13292 return CMD_WARNING
;
13295 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
13297 if (strmatch(group
->name
, group_name
)) {
13298 bgp_show_one_peer_group(vty
, group
);
13303 bgp_show_one_peer_group(vty
, group
);
13307 if (group_name
&& !found
)
13308 vty_out(vty
, "%% No such peer-group\n");
13310 return CMD_SUCCESS
;
13313 DEFUN (show_ip_bgp_peer_groups
,
13314 show_ip_bgp_peer_groups_cmd
,
13315 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
13319 BGP_INSTANCE_HELP_STR
13320 "Detailed information on BGP peer groups\n"
13321 "Peer group name\n")
13326 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
13328 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
13330 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
13334 /* Redistribute VTY commands. */
13336 DEFUN (bgp_redistribute_ipv4
,
13337 bgp_redistribute_ipv4_cmd
,
13338 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13339 "Redistribute information from another routing protocol\n"
13340 FRR_IP_REDIST_HELP_STR_BGPD
)
13342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13343 int idx_protocol
= 1;
13346 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13348 vty_out(vty
, "%% Invalid route type\n");
13349 return CMD_WARNING_CONFIG_FAILED
;
13352 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13353 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
13357 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
13358 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13359 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
13361 DEFUN (bgp_redistribute_ipv4_rmap
,
13362 bgp_redistribute_ipv4_rmap_cmd
,
13363 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13364 "Redistribute information from another routing protocol\n"
13365 FRR_IP_REDIST_HELP_STR_BGPD
13366 "Route map reference\n"
13367 "Pointer to route-map entries\n")
13369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13370 int idx_protocol
= 1;
13373 struct bgp_redist
*red
;
13375 struct route_map
*route_map
= route_map_lookup_warn_noexist(
13376 vty
, argv
[idx_word
]->arg
);
13378 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13380 vty_out(vty
, "%% Invalid route type\n");
13381 return CMD_WARNING_CONFIG_FAILED
;
13384 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13386 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13387 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13391 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
13392 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13393 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13394 "Route map reference\n"
13395 "Pointer to route-map entries\n")
13397 DEFUN (bgp_redistribute_ipv4_metric
,
13398 bgp_redistribute_ipv4_metric_cmd
,
13399 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13400 "Redistribute information from another routing protocol\n"
13401 FRR_IP_REDIST_HELP_STR_BGPD
13402 "Metric for redistributed routes\n"
13403 "Default metric\n")
13405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13406 int idx_protocol
= 1;
13407 int idx_number
= 3;
13410 struct bgp_redist
*red
;
13413 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13415 vty_out(vty
, "%% Invalid route type\n");
13416 return CMD_WARNING_CONFIG_FAILED
;
13418 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13420 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13421 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13422 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13426 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
13427 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13428 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13429 "Metric for redistributed routes\n"
13430 "Default metric\n")
13432 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
13433 bgp_redistribute_ipv4_rmap_metric_cmd
,
13434 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
13435 "Redistribute information from another routing protocol\n"
13436 FRR_IP_REDIST_HELP_STR_BGPD
13437 "Route map reference\n"
13438 "Pointer to route-map entries\n"
13439 "Metric for redistributed routes\n"
13440 "Default metric\n")
13442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13443 int idx_protocol
= 1;
13445 int idx_number
= 5;
13448 struct bgp_redist
*red
;
13450 struct route_map
*route_map
=
13451 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13453 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13455 vty_out(vty
, "%% Invalid route type\n");
13456 return CMD_WARNING_CONFIG_FAILED
;
13458 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13460 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13462 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13463 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13464 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13468 bgp_redistribute_ipv4_rmap_metric
,
13469 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
13470 "redistribute " FRR_IP_REDIST_STR_BGPD
13471 " route-map WORD metric (0-4294967295)",
13472 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13473 "Route map reference\n"
13474 "Pointer to route-map entries\n"
13475 "Metric for redistributed routes\n"
13476 "Default metric\n")
13478 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
13479 bgp_redistribute_ipv4_metric_rmap_cmd
,
13480 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
13481 "Redistribute information from another routing protocol\n"
13482 FRR_IP_REDIST_HELP_STR_BGPD
13483 "Metric for redistributed routes\n"
13485 "Route map reference\n"
13486 "Pointer to route-map entries\n")
13488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13489 int idx_protocol
= 1;
13490 int idx_number
= 3;
13494 struct bgp_redist
*red
;
13496 struct route_map
*route_map
=
13497 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13499 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13501 vty_out(vty
, "%% Invalid route type\n");
13502 return CMD_WARNING_CONFIG_FAILED
;
13504 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13506 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13507 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13509 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13510 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13514 bgp_redistribute_ipv4_metric_rmap
,
13515 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
13516 "redistribute " FRR_IP_REDIST_STR_BGPD
13517 " metric (0-4294967295) route-map WORD",
13518 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13519 "Metric for redistributed routes\n"
13521 "Route map reference\n"
13522 "Pointer to route-map entries\n")
13524 DEFUN (bgp_redistribute_ipv4_ospf
,
13525 bgp_redistribute_ipv4_ospf_cmd
,
13526 "redistribute <ospf|table> (1-65535)",
13527 "Redistribute information from another routing protocol\n"
13528 "Open Shortest Path First (OSPFv2)\n"
13529 "Non-main Kernel Routing Table\n"
13530 "Instance ID/Table ID\n")
13532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13533 int idx_ospf_table
= 1;
13534 int idx_number
= 2;
13535 unsigned short instance
;
13536 unsigned short protocol
;
13538 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13540 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13541 protocol
= ZEBRA_ROUTE_OSPF
;
13543 protocol
= ZEBRA_ROUTE_TABLE
;
13545 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13546 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
13549 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
13550 "redistribute <ospf|table> (1-65535)",
13551 "Redistribute information from another routing protocol\n"
13552 "Open Shortest Path First (OSPFv2)\n"
13553 "Non-main Kernel Routing Table\n"
13554 "Instance ID/Table ID\n")
13556 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
13557 bgp_redistribute_ipv4_ospf_rmap_cmd
,
13558 "redistribute <ospf|table> (1-65535) route-map WORD",
13559 "Redistribute information from another routing protocol\n"
13560 "Open Shortest Path First (OSPFv2)\n"
13561 "Non-main Kernel Routing Table\n"
13562 "Instance ID/Table ID\n"
13563 "Route map reference\n"
13564 "Pointer to route-map entries\n")
13566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13567 int idx_ospf_table
= 1;
13568 int idx_number
= 2;
13570 struct bgp_redist
*red
;
13571 unsigned short instance
;
13574 struct route_map
*route_map
=
13575 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13577 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13578 protocol
= ZEBRA_ROUTE_OSPF
;
13580 protocol
= ZEBRA_ROUTE_TABLE
;
13582 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13583 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13585 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13586 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13589 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
13590 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
13591 "redistribute <ospf|table> (1-65535) route-map WORD",
13592 "Redistribute information from another routing protocol\n"
13593 "Open Shortest Path First (OSPFv2)\n"
13594 "Non-main Kernel Routing Table\n"
13595 "Instance ID/Table ID\n"
13596 "Route map reference\n"
13597 "Pointer to route-map entries\n")
13599 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
13600 bgp_redistribute_ipv4_ospf_metric_cmd
,
13601 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
13602 "Redistribute information from another routing protocol\n"
13603 "Open Shortest Path First (OSPFv2)\n"
13604 "Non-main Kernel Routing Table\n"
13605 "Instance ID/Table ID\n"
13606 "Metric for redistributed routes\n"
13607 "Default metric\n")
13609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13610 int idx_ospf_table
= 1;
13611 int idx_number
= 2;
13612 int idx_number_2
= 4;
13614 struct bgp_redist
*red
;
13615 unsigned short instance
;
13619 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13620 protocol
= ZEBRA_ROUTE_OSPF
;
13622 protocol
= ZEBRA_ROUTE_TABLE
;
13624 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13625 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13627 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13628 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13630 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13633 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
13634 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
13635 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
13636 "Redistribute information from another routing protocol\n"
13637 "Open Shortest Path First (OSPFv2)\n"
13638 "Non-main Kernel Routing Table\n"
13639 "Instance ID/Table ID\n"
13640 "Metric for redistributed routes\n"
13641 "Default metric\n")
13643 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
13644 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
13645 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
13646 "Redistribute information from another routing protocol\n"
13647 "Open Shortest Path First (OSPFv2)\n"
13648 "Non-main Kernel Routing Table\n"
13649 "Instance ID/Table ID\n"
13650 "Route map reference\n"
13651 "Pointer to route-map entries\n"
13652 "Metric for redistributed routes\n"
13653 "Default metric\n")
13655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13656 int idx_ospf_table
= 1;
13657 int idx_number
= 2;
13659 int idx_number_2
= 6;
13661 struct bgp_redist
*red
;
13662 unsigned short instance
;
13665 struct route_map
*route_map
=
13666 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13668 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13669 protocol
= ZEBRA_ROUTE_OSPF
;
13671 protocol
= ZEBRA_ROUTE_TABLE
;
13673 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13674 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13676 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13678 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13679 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13681 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13685 bgp_redistribute_ipv4_ospf_rmap_metric
,
13686 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
13687 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
13688 "Redistribute information from another routing protocol\n"
13689 "Open Shortest Path First (OSPFv2)\n"
13690 "Non-main Kernel Routing Table\n"
13691 "Instance ID/Table ID\n"
13692 "Route map reference\n"
13693 "Pointer to route-map entries\n"
13694 "Metric for redistributed routes\n"
13695 "Default metric\n")
13697 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
13698 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
13699 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
13700 "Redistribute information from another routing protocol\n"
13701 "Open Shortest Path First (OSPFv2)\n"
13702 "Non-main Kernel Routing Table\n"
13703 "Instance ID/Table ID\n"
13704 "Metric for redistributed routes\n"
13706 "Route map reference\n"
13707 "Pointer to route-map entries\n")
13709 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13710 int idx_ospf_table
= 1;
13711 int idx_number
= 2;
13712 int idx_number_2
= 4;
13715 struct bgp_redist
*red
;
13716 unsigned short instance
;
13719 struct route_map
*route_map
=
13720 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13722 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13723 protocol
= ZEBRA_ROUTE_OSPF
;
13725 protocol
= ZEBRA_ROUTE_TABLE
;
13727 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13728 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13730 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13731 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13734 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13735 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13739 bgp_redistribute_ipv4_ospf_metric_rmap
,
13740 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
13741 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
13742 "Redistribute information from another routing protocol\n"
13743 "Open Shortest Path First (OSPFv2)\n"
13744 "Non-main Kernel Routing Table\n"
13745 "Instance ID/Table ID\n"
13746 "Metric for redistributed routes\n"
13748 "Route map reference\n"
13749 "Pointer to route-map entries\n")
13751 DEFUN (no_bgp_redistribute_ipv4_ospf
,
13752 no_bgp_redistribute_ipv4_ospf_cmd
,
13753 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
13755 "Redistribute information from another routing protocol\n"
13756 "Open Shortest Path First (OSPFv2)\n"
13757 "Non-main Kernel Routing Table\n"
13758 "Instance ID/Table ID\n"
13759 "Metric for redistributed routes\n"
13761 "Route map reference\n"
13762 "Pointer to route-map entries\n")
13764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13765 int idx_ospf_table
= 2;
13766 int idx_number
= 3;
13767 unsigned short instance
;
13770 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13771 protocol
= ZEBRA_ROUTE_OSPF
;
13773 protocol
= ZEBRA_ROUTE_TABLE
;
13775 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13776 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
13780 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
13781 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
13783 "Redistribute information from another routing protocol\n"
13784 "Open Shortest Path First (OSPFv2)\n"
13785 "Non-main Kernel Routing Table\n"
13786 "Instance ID/Table ID\n"
13787 "Metric for redistributed routes\n"
13789 "Route map reference\n"
13790 "Pointer to route-map entries\n")
13792 DEFUN (no_bgp_redistribute_ipv4
,
13793 no_bgp_redistribute_ipv4_cmd
,
13794 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
13796 "Redistribute information from another routing protocol\n"
13797 FRR_IP_REDIST_HELP_STR_BGPD
13798 "Metric for redistributed routes\n"
13800 "Route map reference\n"
13801 "Pointer to route-map entries\n")
13803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13804 int idx_protocol
= 2;
13807 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13809 vty_out(vty
, "%% Invalid route type\n");
13810 return CMD_WARNING_CONFIG_FAILED
;
13812 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
13816 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
13817 "no redistribute " FRR_IP_REDIST_STR_BGPD
13818 " [{metric (0-4294967295)|route-map WORD}]",
13820 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13821 "Metric for redistributed routes\n"
13823 "Route map reference\n"
13824 "Pointer to route-map entries\n")
13826 DEFUN (bgp_redistribute_ipv6
,
13827 bgp_redistribute_ipv6_cmd
,
13828 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
13829 "Redistribute information from another routing protocol\n"
13830 FRR_IP6_REDIST_HELP_STR_BGPD
)
13832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13833 int idx_protocol
= 1;
13836 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13838 vty_out(vty
, "%% Invalid route type\n");
13839 return CMD_WARNING_CONFIG_FAILED
;
13842 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13843 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
13846 DEFUN (bgp_redistribute_ipv6_rmap
,
13847 bgp_redistribute_ipv6_rmap_cmd
,
13848 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
13849 "Redistribute information from another routing protocol\n"
13850 FRR_IP6_REDIST_HELP_STR_BGPD
13851 "Route map reference\n"
13852 "Pointer to route-map entries\n")
13854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13855 int idx_protocol
= 1;
13858 struct bgp_redist
*red
;
13860 struct route_map
*route_map
=
13861 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13863 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13865 vty_out(vty
, "%% Invalid route type\n");
13866 return CMD_WARNING_CONFIG_FAILED
;
13869 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13871 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13872 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13875 DEFUN (bgp_redistribute_ipv6_metric
,
13876 bgp_redistribute_ipv6_metric_cmd
,
13877 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
13878 "Redistribute information from another routing protocol\n"
13879 FRR_IP6_REDIST_HELP_STR_BGPD
13880 "Metric for redistributed routes\n"
13881 "Default metric\n")
13883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13884 int idx_protocol
= 1;
13885 int idx_number
= 3;
13888 struct bgp_redist
*red
;
13891 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13893 vty_out(vty
, "%% Invalid route type\n");
13894 return CMD_WARNING_CONFIG_FAILED
;
13896 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13898 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13899 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
13900 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13903 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
13904 bgp_redistribute_ipv6_rmap_metric_cmd
,
13905 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
13906 "Redistribute information from another routing protocol\n"
13907 FRR_IP6_REDIST_HELP_STR_BGPD
13908 "Route map reference\n"
13909 "Pointer to route-map entries\n"
13910 "Metric for redistributed routes\n"
13911 "Default metric\n")
13913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13914 int idx_protocol
= 1;
13916 int idx_number
= 5;
13919 struct bgp_redist
*red
;
13921 struct route_map
*route_map
=
13922 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13924 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13926 vty_out(vty
, "%% Invalid route type\n");
13927 return CMD_WARNING_CONFIG_FAILED
;
13929 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13931 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13933 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13934 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
13936 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13939 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
13940 bgp_redistribute_ipv6_metric_rmap_cmd
,
13941 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
13942 "Redistribute information from another routing protocol\n"
13943 FRR_IP6_REDIST_HELP_STR_BGPD
13944 "Metric for redistributed routes\n"
13946 "Route map reference\n"
13947 "Pointer to route-map entries\n")
13949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13950 int idx_protocol
= 1;
13951 int idx_number
= 3;
13955 struct bgp_redist
*red
;
13957 struct route_map
*route_map
=
13958 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13960 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13962 vty_out(vty
, "%% Invalid route type\n");
13963 return CMD_WARNING_CONFIG_FAILED
;
13965 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13967 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13968 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
13971 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13972 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13975 DEFUN (no_bgp_redistribute_ipv6
,
13976 no_bgp_redistribute_ipv6_cmd
,
13977 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
13979 "Redistribute information from another routing protocol\n"
13980 FRR_IP6_REDIST_HELP_STR_BGPD
13981 "Metric for redistributed routes\n"
13983 "Route map reference\n"
13984 "Pointer to route-map entries\n")
13986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13987 int idx_protocol
= 2;
13990 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13992 vty_out(vty
, "%% Invalid route type\n");
13993 return CMD_WARNING_CONFIG_FAILED
;
13996 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
13999 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
14000 afi_t afi
, safi_t safi
)
14004 /* Unicast redistribution only. */
14005 if (safi
!= SAFI_UNICAST
)
14008 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
14009 /* Redistribute BGP does not make sense. */
14010 if (i
!= ZEBRA_ROUTE_BGP
) {
14011 struct list
*red_list
;
14012 struct listnode
*node
;
14013 struct bgp_redist
*red
;
14015 red_list
= bgp
->redist
[afi
][i
];
14019 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
14020 /* "redistribute" configuration. */
14021 vty_out(vty
, " redistribute %s",
14022 zebra_route_string(i
));
14024 vty_out(vty
, " %d", red
->instance
);
14025 if (red
->redist_metric_flag
)
14026 vty_out(vty
, " metric %u",
14027 red
->redist_metric
);
14028 if (red
->rmap
.name
)
14029 vty_out(vty
, " route-map %s",
14031 vty_out(vty
, "\n");
14037 /* peer-group helpers for config-write */
14039 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
14041 if (!peer_group_active(peer
)) {
14042 if (CHECK_FLAG(peer
->flags_invert
, flag
))
14043 return !CHECK_FLAG(peer
->flags
, flag
);
14045 return !!CHECK_FLAG(peer
->flags
, flag
);
14048 return !!CHECK_FLAG(peer
->flags_override
, flag
);
14051 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14054 if (!peer_group_active(peer
)) {
14055 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
14056 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
14058 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
14061 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
14064 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14065 uint8_t type
, int direct
)
14067 struct bgp_filter
*filter
;
14069 if (peer_group_active(peer
))
14070 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
14073 filter
= &peer
->filter
[afi
][safi
];
14075 case PEER_FT_DISTRIBUTE_LIST
:
14076 return !!(filter
->dlist
[direct
].name
);
14077 case PEER_FT_FILTER_LIST
:
14078 return !!(filter
->aslist
[direct
].name
);
14079 case PEER_FT_PREFIX_LIST
:
14080 return !!(filter
->plist
[direct
].name
);
14081 case PEER_FT_ROUTE_MAP
:
14082 return !!(filter
->map
[direct
].name
);
14083 case PEER_FT_UNSUPPRESS_MAP
:
14084 return !!(filter
->usmap
.name
);
14090 /* Return true if the addpath type is set for peer and different from
14093 static int peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
, safi_t safi
)
14095 enum bgp_addpath_strat type
, g_type
;
14097 type
= peer
->addpath_type
[afi
][safi
];
14099 if (type
!= BGP_ADDPATH_NONE
) {
14100 if (peer_group_active(peer
)) {
14101 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
14103 if (type
!= g_type
)
14115 /* This is part of the address-family block (unicast only) */
14116 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
14121 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14122 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
14123 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
14124 bgp
->vpn_policy
[afi
]
14125 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14127 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
14128 bgp
->vpn_policy
[afi
]
14129 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14131 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14132 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
14133 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14134 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14137 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14138 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
14140 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
14143 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
14144 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
14145 bgp
->vpn_policy
[afi
].tovpn_label
);
14148 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14149 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
14150 char buf
[RD_ADDRSTRLEN
];
14151 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
14152 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
14155 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14156 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
14158 char buf
[PREFIX_STRLEN
];
14159 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
14160 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
14163 vty_out(vty
, "%*snexthop vpn export %s\n",
14167 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
14168 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
14170 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14171 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
14173 char *b
= ecommunity_ecom2str(
14174 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14175 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
14176 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
14177 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14179 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14180 char *b
= ecommunity_ecom2str(
14181 bgp
->vpn_policy
[afi
]
14182 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14183 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14184 ECOMMUNITY_ROUTE_TARGET
);
14185 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
14186 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14188 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
14189 char *b
= ecommunity_ecom2str(
14190 bgp
->vpn_policy
[afi
]
14191 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14192 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14193 ECOMMUNITY_ROUTE_TARGET
);
14194 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
14195 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14199 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
14200 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
14201 bgp
->vpn_policy
[afi
]
14202 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
14204 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
14205 char *b
= ecommunity_ecom2str(
14206 bgp
->vpn_policy
[afi
]
14207 .import_redirect_rtlist
,
14208 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14209 ECOMMUNITY_ROUTE_TARGET
);
14211 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
14212 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14216 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
14217 afi_t afi
, safi_t safi
)
14219 struct bgp_filter
*filter
;
14223 filter
= &peer
->filter
[afi
][safi
];
14225 /* distribute-list. */
14226 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14228 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
14229 filter
->dlist
[FILTER_IN
].name
);
14231 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14233 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
14234 filter
->dlist
[FILTER_OUT
].name
);
14237 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14239 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
14240 filter
->plist
[FILTER_IN
].name
);
14242 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14244 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
14245 filter
->plist
[FILTER_OUT
].name
);
14248 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
14249 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
14250 filter
->map
[RMAP_IN
].name
);
14252 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
14254 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
14255 filter
->map
[RMAP_OUT
].name
);
14257 /* unsuppress-map */
14258 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
14259 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
14260 filter
->usmap
.name
);
14263 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14265 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
14266 filter
->aslist
[FILTER_IN
].name
);
14268 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14270 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
14271 filter
->aslist
[FILTER_OUT
].name
);
14274 /* BGP peer configuration display function. */
14275 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
14278 struct peer
*g_peer
= NULL
;
14279 char buf
[SU_ADDRSTRLEN
];
14281 int if_pg_printed
= false;
14282 int if_ras_printed
= false;
14284 /* Skip dynamic neighbors. */
14285 if (peer_dynamic_neighbor(peer
))
14289 addr
= peer
->conf_if
;
14293 /************************************
14294 ****** Global to the neighbor ******
14295 ************************************/
14296 if (peer
->conf_if
) {
14297 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
14298 vty_out(vty
, " neighbor %s interface v6only", addr
);
14300 vty_out(vty
, " neighbor %s interface", addr
);
14302 if (peer_group_active(peer
)) {
14303 vty_out(vty
, " peer-group %s", peer
->group
->name
);
14304 if_pg_printed
= true;
14305 } else if (peer
->as_type
== AS_SPECIFIED
) {
14306 vty_out(vty
, " remote-as %u", peer
->as
);
14307 if_ras_printed
= true;
14308 } else if (peer
->as_type
== AS_INTERNAL
) {
14309 vty_out(vty
, " remote-as internal");
14310 if_ras_printed
= true;
14311 } else if (peer
->as_type
== AS_EXTERNAL
) {
14312 vty_out(vty
, " remote-as external");
14313 if_ras_printed
= true;
14316 vty_out(vty
, "\n");
14319 /* remote-as and peer-group */
14320 /* peer is a member of a peer-group */
14321 if (peer_group_active(peer
)) {
14322 g_peer
= peer
->group
->conf
;
14324 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
14325 if (peer
->as_type
== AS_SPECIFIED
) {
14326 vty_out(vty
, " neighbor %s remote-as %u\n",
14328 } else if (peer
->as_type
== AS_INTERNAL
) {
14330 " neighbor %s remote-as internal\n",
14332 } else if (peer
->as_type
== AS_EXTERNAL
) {
14334 " neighbor %s remote-as external\n",
14339 /* For swpX peers we displayed the peer-group
14340 * via 'neighbor swpX interface peer-group PGNAME' */
14341 if (!if_pg_printed
)
14342 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
14343 peer
->group
->name
);
14346 /* peer is NOT a member of a peer-group */
14348 /* peer is a peer-group, declare the peer-group */
14349 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
14350 vty_out(vty
, " neighbor %s peer-group\n", addr
);
14353 if (!if_ras_printed
) {
14354 if (peer
->as_type
== AS_SPECIFIED
) {
14355 vty_out(vty
, " neighbor %s remote-as %u\n",
14357 } else if (peer
->as_type
== AS_INTERNAL
) {
14359 " neighbor %s remote-as internal\n",
14361 } else if (peer
->as_type
== AS_EXTERNAL
) {
14363 " neighbor %s remote-as external\n",
14370 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
14371 vty_out(vty
, " neighbor %s local-as %u", addr
,
14372 peer
->change_local_as
);
14373 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
14374 vty_out(vty
, " no-prepend");
14375 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
14376 vty_out(vty
, " replace-as");
14377 vty_out(vty
, "\n");
14382 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
14386 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
14387 if (peer
->tx_shutdown_message
)
14388 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
14389 peer
->tx_shutdown_message
);
14391 vty_out(vty
, " neighbor %s shutdown\n", addr
);
14395 if (peer
->bfd_info
) {
14396 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
14397 bgp_bfd_peer_config_write(vty
, peer
, addr
);
14402 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
14403 vty_out(vty
, " neighbor %s password %s\n", addr
,
14406 /* neighbor solo */
14407 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
14408 if (!peer_group_active(peer
)) {
14409 vty_out(vty
, " neighbor %s solo\n", addr
);
14414 if (peer
->port
!= BGP_PORT_DEFAULT
) {
14415 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
14418 /* Local interface name */
14419 if (peer
->ifname
) {
14420 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
14424 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
14425 vty_out(vty
, " neighbor %s passive\n", addr
);
14427 /* ebgp-multihop */
14428 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
14429 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
14430 && peer
->ttl
== MAXTTL
)) {
14431 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
14432 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
14437 /* ttl-security hops */
14438 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
14439 if (!peer_group_active(peer
)
14440 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
14441 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
14442 addr
, peer
->gtsm_hops
);
14446 /* disable-connected-check */
14447 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
14448 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
14450 /* enforce-first-as */
14451 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
14452 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
14454 /* update-source */
14455 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
14456 if (peer
->update_source
)
14457 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14458 sockunion2str(peer
->update_source
, buf
,
14460 else if (peer
->update_if
)
14461 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14465 /* advertisement-interval */
14466 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
14467 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
14471 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
14472 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
14473 peer
->keepalive
, peer
->holdtime
);
14475 /* timers connect */
14476 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
14477 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14479 /* need special-case handling for changed default values due to
14480 * config profile / version (because there is no "timers bgp connect"
14481 * command, we need to save this per-peer :/)
14483 else if (!peer_group_active(peer
) && !peer
->connect
&&
14484 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
14485 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14486 peer
->bgp
->default_connect_retry
);
14488 /* capability dynamic */
14489 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
14490 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
14492 /* capability extended-nexthop */
14493 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
14494 if (!peer
->conf_if
) {
14495 if (CHECK_FLAG(peer
->flags_invert
,
14496 PEER_FLAG_CAPABILITY_ENHE
))
14498 " no neighbor %s capability extended-nexthop\n",
14502 " neighbor %s capability extended-nexthop\n",
14507 /* dont-capability-negotiation */
14508 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
14509 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
14511 /* override-capability */
14512 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
14513 vty_out(vty
, " neighbor %s override-capability\n", addr
);
14515 /* strict-capability-match */
14516 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
14517 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
14519 /* Sender side AS path loop detection. */
14520 if (peer
->as_path_loop_detection
)
14521 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
14524 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14525 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
14527 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14528 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
14530 " neighbor %s graceful-restart-helper\n", addr
);
14531 } else if (CHECK_FLAG(
14532 peer
->peer_gr_new_status_flag
,
14533 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
14535 " neighbor %s graceful-restart\n", addr
);
14537 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14538 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
14540 peer
->peer_gr_new_status_flag
,
14541 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
14542 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
14548 /* BGP peer configuration display function. */
14549 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
14550 struct peer
*peer
, afi_t afi
, safi_t safi
)
14552 struct peer
*g_peer
= NULL
;
14554 bool flag_scomm
, flag_secomm
, flag_slcomm
;
14556 /* Skip dynamic neighbors. */
14557 if (peer_dynamic_neighbor(peer
))
14561 addr
= peer
->conf_if
;
14565 /************************************
14566 ****** Per AF to the neighbor ******
14567 ************************************/
14568 if (peer_group_active(peer
)) {
14569 g_peer
= peer
->group
->conf
;
14571 /* If the peer-group is active but peer is not, print a 'no
14573 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
14574 vty_out(vty
, " no neighbor %s activate\n", addr
);
14577 /* If the peer-group is not active but peer is, print an
14579 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
14580 vty_out(vty
, " neighbor %s activate\n", addr
);
14583 if (peer
->afc
[afi
][safi
]) {
14584 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
14585 if (CHECK_FLAG(bgp
->flags
,
14586 BGP_FLAG_NO_DEFAULT_IPV4
)) {
14587 vty_out(vty
, " neighbor %s activate\n",
14591 vty_out(vty
, " neighbor %s activate\n", addr
);
14593 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
14594 if (!CHECK_FLAG(bgp
->flags
,
14595 BGP_FLAG_NO_DEFAULT_IPV4
)) {
14597 " no neighbor %s activate\n",
14604 /* addpath TX knobs */
14605 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
14606 switch (peer
->addpath_type
[afi
][safi
]) {
14607 case BGP_ADDPATH_ALL
:
14608 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
14611 case BGP_ADDPATH_BEST_PER_AS
:
14613 " neighbor %s addpath-tx-bestpath-per-AS\n",
14616 case BGP_ADDPATH_MAX
:
14617 case BGP_ADDPATH_NONE
:
14622 /* ORF capability. */
14623 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
14624 || peergroup_af_flag_check(peer
, afi
, safi
,
14625 PEER_FLAG_ORF_PREFIX_RM
)) {
14626 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
14628 if (peergroup_af_flag_check(peer
, afi
, safi
,
14629 PEER_FLAG_ORF_PREFIX_SM
)
14630 && peergroup_af_flag_check(peer
, afi
, safi
,
14631 PEER_FLAG_ORF_PREFIX_RM
))
14632 vty_out(vty
, " both");
14633 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14634 PEER_FLAG_ORF_PREFIX_SM
))
14635 vty_out(vty
, " send");
14637 vty_out(vty
, " receive");
14638 vty_out(vty
, "\n");
14641 /* BGP flag dampening. */
14642 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14643 BGP_CONFIG_DAMPENING
))
14644 bgp_config_write_damp(vty
, afi
, safi
);
14646 /* Route reflector client. */
14647 if (peergroup_af_flag_check(peer
, afi
, safi
,
14648 PEER_FLAG_REFLECTOR_CLIENT
)) {
14649 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
14652 /* next-hop-self force */
14653 if (peergroup_af_flag_check(peer
, afi
, safi
,
14654 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
14655 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
14658 /* next-hop-self */
14659 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
14660 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
14663 /* remove-private-AS */
14664 if (peergroup_af_flag_check(peer
, afi
, safi
,
14665 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
14666 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
14670 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14671 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
14672 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
14676 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14677 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
14678 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
14681 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14682 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
14683 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
14687 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
14688 vty_out(vty
, " neighbor %s as-override\n", addr
);
14691 /* send-community print. */
14692 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14693 PEER_FLAG_SEND_COMMUNITY
);
14694 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14695 PEER_FLAG_SEND_EXT_COMMUNITY
);
14696 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14697 PEER_FLAG_SEND_LARGE_COMMUNITY
);
14699 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
14700 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
14703 vty_out(vty
, " no neighbor %s send-community\n", addr
);
14706 " no neighbor %s send-community extended\n",
14710 vty_out(vty
, " no neighbor %s send-community large\n",
14714 /* Default information */
14715 if (peergroup_af_flag_check(peer
, afi
, safi
,
14716 PEER_FLAG_DEFAULT_ORIGINATE
)) {
14717 vty_out(vty
, " neighbor %s default-originate", addr
);
14719 if (peer
->default_rmap
[afi
][safi
].name
)
14720 vty_out(vty
, " route-map %s",
14721 peer
->default_rmap
[afi
][safi
].name
);
14723 vty_out(vty
, "\n");
14726 /* Soft reconfiguration inbound. */
14727 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
14728 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
14732 /* maximum-prefix. */
14733 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
14734 vty_out(vty
, " neighbor %s maximum-prefix %" PRIu32
, addr
,
14735 peer
->pmax
[afi
][safi
]);
14737 if (peer
->pmax_threshold
[afi
][safi
]
14738 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
14739 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
14740 if (peer_af_flag_check(peer
, afi
, safi
,
14741 PEER_FLAG_MAX_PREFIX_WARNING
))
14742 vty_out(vty
, " warning-only");
14743 if (peer
->pmax_restart
[afi
][safi
])
14744 vty_out(vty
, " restart %u",
14745 peer
->pmax_restart
[afi
][safi
]);
14747 vty_out(vty
, "\n");
14750 /* maximum-prefix-out */
14751 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
14752 vty_out(vty
, " neighbor %s maximum-prefix-out %" PRIu32
"\n",
14753 addr
, peer
->pmax_out
[afi
][safi
]);
14755 /* Route server client. */
14756 if (peergroup_af_flag_check(peer
, afi
, safi
,
14757 PEER_FLAG_RSERVER_CLIENT
)) {
14758 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
14761 /* Nexthop-local unchanged. */
14762 if (peergroup_af_flag_check(peer
, afi
, safi
,
14763 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
14764 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
14767 /* allowas-in <1-10> */
14768 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
14769 if (peer_af_flag_check(peer
, afi
, safi
,
14770 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
14771 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
14772 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
14773 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
14775 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
14776 peer
->allowas_in
[afi
][safi
]);
14781 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
14782 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
14783 peer
->weight
[afi
][safi
]);
14786 bgp_config_write_filter(vty
, peer
, afi
, safi
);
14788 /* atribute-unchanged. */
14789 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
14790 || (safi
!= SAFI_EVPN
14791 && peer_af_flag_check(peer
, afi
, safi
,
14792 PEER_FLAG_NEXTHOP_UNCHANGED
))
14793 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
14795 if (!peer_group_active(peer
)
14796 || peergroup_af_flag_check(peer
, afi
, safi
,
14797 PEER_FLAG_AS_PATH_UNCHANGED
)
14798 || peergroup_af_flag_check(peer
, afi
, safi
,
14799 PEER_FLAG_NEXTHOP_UNCHANGED
)
14800 || peergroup_af_flag_check(peer
, afi
, safi
,
14801 PEER_FLAG_MED_UNCHANGED
)) {
14804 " neighbor %s attribute-unchanged%s%s%s\n",
14806 peer_af_flag_check(peer
, afi
, safi
,
14807 PEER_FLAG_AS_PATH_UNCHANGED
)
14810 peer_af_flag_check(peer
, afi
, safi
,
14811 PEER_FLAG_NEXTHOP_UNCHANGED
)
14814 peer_af_flag_check(peer
, afi
, safi
,
14815 PEER_FLAG_MED_UNCHANGED
)
14822 /* Address family based peer configuration display. */
14823 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14827 struct peer_group
*group
;
14828 struct listnode
*node
, *nnode
;
14831 vty_frame(vty
, " !\n address-family ");
14832 if (afi
== AFI_IP
) {
14833 if (safi
== SAFI_UNICAST
)
14834 vty_frame(vty
, "ipv4 unicast");
14835 else if (safi
== SAFI_LABELED_UNICAST
)
14836 vty_frame(vty
, "ipv4 labeled-unicast");
14837 else if (safi
== SAFI_MULTICAST
)
14838 vty_frame(vty
, "ipv4 multicast");
14839 else if (safi
== SAFI_MPLS_VPN
)
14840 vty_frame(vty
, "ipv4 vpn");
14841 else if (safi
== SAFI_ENCAP
)
14842 vty_frame(vty
, "ipv4 encap");
14843 else if (safi
== SAFI_FLOWSPEC
)
14844 vty_frame(vty
, "ipv4 flowspec");
14845 } else if (afi
== AFI_IP6
) {
14846 if (safi
== SAFI_UNICAST
)
14847 vty_frame(vty
, "ipv6 unicast");
14848 else if (safi
== SAFI_LABELED_UNICAST
)
14849 vty_frame(vty
, "ipv6 labeled-unicast");
14850 else if (safi
== SAFI_MULTICAST
)
14851 vty_frame(vty
, "ipv6 multicast");
14852 else if (safi
== SAFI_MPLS_VPN
)
14853 vty_frame(vty
, "ipv6 vpn");
14854 else if (safi
== SAFI_ENCAP
)
14855 vty_frame(vty
, "ipv6 encap");
14856 else if (safi
== SAFI_FLOWSPEC
)
14857 vty_frame(vty
, "ipv6 flowspec");
14858 } else if (afi
== AFI_L2VPN
) {
14859 if (safi
== SAFI_EVPN
)
14860 vty_frame(vty
, "l2vpn evpn");
14862 vty_frame(vty
, "\n");
14864 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
14866 bgp_config_write_network(vty
, bgp
, afi
, safi
);
14868 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
14870 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
14871 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
14873 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14874 /* Skip dynamic neighbors. */
14875 if (peer_dynamic_neighbor(peer
))
14878 /* Do not display doppelganger peers */
14879 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14880 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
14883 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
14884 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
14886 if (safi
== SAFI_EVPN
)
14887 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
14889 if (safi
== SAFI_FLOWSPEC
)
14890 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
14892 if (safi
== SAFI_UNICAST
) {
14893 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
14894 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14895 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
14897 vty_out(vty
, " export vpn\n");
14899 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14900 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
14902 vty_out(vty
, " import vpn\n");
14904 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14905 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14908 for (ALL_LIST_ELEMENTS_RO(
14909 bgp
->vpn_policy
[afi
].import_vrf
, node
,
14911 vty_out(vty
, " import vrf %s\n", name
);
14915 vty_endframe(vty
, " exit-address-family\n");
14918 int bgp_config_write(struct vty
*vty
)
14921 struct peer_group
*group
;
14923 struct listnode
*node
, *nnode
;
14924 struct listnode
*mnode
, *mnnode
;
14926 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
14927 vty_out(vty
, "bgp route-map delay-timer %u\n",
14928 bm
->rmap_update_timer
);
14930 /* BGP configuration. */
14931 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
14933 /* skip all auto created vrf as they dont have user config */
14934 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
14937 /* Router bgp ASN */
14938 vty_out(vty
, "router bgp %u", bgp
->as
);
14941 vty_out(vty
, " %s %s",
14942 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
14943 ? "view" : "vrf", bgp
->name
);
14944 vty_out(vty
, "\n");
14946 /* BGP fast-external-failover. */
14947 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
14948 vty_out(vty
, " no bgp fast-external-failover\n");
14950 /* BGP router ID. */
14951 if (bgp
->router_id_static
.s_addr
!= 0)
14952 vty_out(vty
, " bgp router-id %s\n",
14953 inet_ntoa(bgp
->router_id_static
));
14955 /* BGP log-neighbor-changes. */
14956 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
14957 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
14958 vty_out(vty
, " %sbgp log-neighbor-changes\n",
14959 CHECK_FLAG(bgp
->flags
,
14960 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
14964 /* BGP configuration. */
14965 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
14966 vty_out(vty
, " bgp always-compare-med\n");
14968 /* RFC8212 default eBGP policy. */
14969 if (bgp
->ebgp_requires_policy
14970 == DEFAULT_EBGP_POLICY_ENABLED
)
14971 vty_out(vty
, " bgp ebgp-requires-policy\n");
14973 /* draft-ietf-idr-deprecate-as-set-confed-set */
14974 if (bgp
->reject_as_sets
== BGP_REJECT_AS_SETS_ENABLED
)
14975 vty_out(vty
, " bgp reject-as-sets\n");
14977 /* BGP default ipv4-unicast. */
14978 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
14979 vty_out(vty
, " no bgp default ipv4-unicast\n");
14981 /* BGP default local-preference. */
14982 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
14983 vty_out(vty
, " bgp default local-preference %u\n",
14984 bgp
->default_local_pref
);
14986 /* BGP default show-hostname */
14987 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
14988 != SAVE_BGP_SHOW_HOSTNAME
)
14989 vty_out(vty
, " %sbgp default show-hostname\n",
14990 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
14994 /* BGP default subgroup-pkt-queue-max. */
14995 if (bgp
->default_subgroup_pkt_queue_max
14996 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
14997 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
14998 bgp
->default_subgroup_pkt_queue_max
);
15000 /* BGP client-to-client reflection. */
15001 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
15002 vty_out(vty
, " no bgp client-to-client reflection\n");
15004 /* BGP cluster ID. */
15005 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
15006 vty_out(vty
, " bgp cluster-id %s\n",
15007 inet_ntoa(bgp
->cluster_id
));
15009 /* Disable ebgp connected nexthop check */
15010 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
15012 " bgp disable-ebgp-connected-route-check\n");
15014 /* Confederation identifier*/
15015 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
15016 vty_out(vty
, " bgp confederation identifier %u\n",
15019 /* Confederation peer */
15020 if (bgp
->confed_peers_cnt
> 0) {
15023 vty_out(vty
, " bgp confederation peers");
15025 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
15026 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
15028 vty_out(vty
, "\n");
15031 /* BGP deterministic-med. */
15032 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
15033 != SAVE_BGP_DETERMINISTIC_MED
)
15034 vty_out(vty
, " %sbgp deterministic-med\n",
15035 CHECK_FLAG(bgp
->flags
,
15036 BGP_FLAG_DETERMINISTIC_MED
)
15040 /* BGP update-delay. */
15041 bgp_config_write_update_delay(vty
, bgp
);
15043 if (bgp
->v_maxmed_onstartup
15044 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
15045 vty_out(vty
, " bgp max-med on-startup %u",
15046 bgp
->v_maxmed_onstartup
);
15047 if (bgp
->maxmed_onstartup_value
15048 != BGP_MAXMED_VALUE_DEFAULT
)
15049 vty_out(vty
, " %u",
15050 bgp
->maxmed_onstartup_value
);
15051 vty_out(vty
, "\n");
15053 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
15054 vty_out(vty
, " bgp max-med administrative");
15055 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
15056 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
15057 vty_out(vty
, "\n");
15061 bgp_config_write_wpkt_quanta(vty
, bgp
);
15063 bgp_config_write_rpkt_quanta(vty
, bgp
);
15065 /* coalesce time */
15066 bgp_config_write_coalesce_time(vty
, bgp
);
15068 /* BGP graceful-restart. */
15069 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
15071 " bgp graceful-restart stalepath-time %u\n",
15072 bgp
->stalepath_time
);
15074 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
15075 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
15076 bgp
->restart_time
);
15078 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
15080 " bgp graceful-restart select-defer-time %u\n",
15081 bgp
->select_defer_time
);
15083 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
15084 vty_out(vty
, " bgp graceful-restart\n");
15086 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
15087 vty_out(vty
, " bgp graceful-restart-disable\n");
15089 /* BGP graceful-shutdown */
15090 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
15091 vty_out(vty
, " bgp graceful-shutdown\n");
15093 /* BGP graceful-restart Preserve State F bit. */
15094 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
15096 " bgp graceful-restart preserve-fw-state\n");
15098 /* Stale timer for RIB */
15099 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
15101 " bgp graceful-restart rib-stale-time %u\n",
15102 bgp
->rib_stale_time
);
15104 /* BGP bestpath method. */
15105 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
15106 vty_out(vty
, " bgp bestpath as-path ignore\n");
15107 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
15108 vty_out(vty
, " bgp bestpath as-path confed\n");
15110 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
15111 if (CHECK_FLAG(bgp
->flags
,
15112 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
15114 " bgp bestpath as-path multipath-relax as-set\n");
15117 " bgp bestpath as-path multipath-relax\n");
15121 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
15123 " bgp route-reflector allow-outbound-policy\n");
15125 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
15126 vty_out(vty
, " bgp bestpath compare-routerid\n");
15127 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
15128 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
15129 vty_out(vty
, " bgp bestpath med");
15130 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
15131 vty_out(vty
, " confed");
15132 if (CHECK_FLAG(bgp
->flags
,
15133 BGP_FLAG_MED_MISSING_AS_WORST
))
15134 vty_out(vty
, " missing-as-worst");
15135 vty_out(vty
, "\n");
15138 /* BGP network import check. */
15139 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15140 != SAVE_BGP_IMPORT_CHECK
)
15141 vty_out(vty
, " %sbgp network import-check\n",
15142 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15146 /* BGP timers configuration. */
15147 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
15148 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
15149 vty_out(vty
, " timers bgp %u %u\n",
15150 bgp
->default_keepalive
, bgp
->default_holdtime
);
15153 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15154 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
15157 /* Normal neighbor configuration. */
15158 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15159 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15160 bgp_config_write_peer_global(vty
, bgp
, peer
);
15163 /* listen range and limit for dynamic BGP neighbors */
15164 bgp_config_write_listen(vty
, bgp
);
15167 * BGP default autoshutdown neighbors
15169 * This must be placed after any peer and peer-group
15170 * configuration, to avoid setting all peers to shutdown after
15171 * a daemon restart, which is undesired behavior. (see #2286)
15173 if (bgp
->autoshutdown
)
15174 vty_out(vty
, " bgp default shutdown\n");
15176 /* IPv4 unicast configuration. */
15177 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
15179 /* IPv4 multicast configuration. */
15180 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
15182 /* IPv4 labeled-unicast configuration. */
15183 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
15185 /* IPv4 VPN configuration. */
15186 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
15188 /* ENCAPv4 configuration. */
15189 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
15191 /* FLOWSPEC v4 configuration. */
15192 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
15194 /* IPv6 unicast configuration. */
15195 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
15197 /* IPv6 multicast configuration. */
15198 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
15200 /* IPv6 labeled-unicast configuration. */
15201 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
15202 SAFI_LABELED_UNICAST
);
15204 /* IPv6 VPN configuration. */
15205 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
15207 /* ENCAPv6 configuration. */
15208 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
15210 /* FLOWSPEC v6 configuration. */
15211 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
15213 /* EVPN configuration. */
15214 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
15216 hook_call(bgp_inst_config_write
, bgp
, vty
);
15219 bgp_rfapi_cfg_write(vty
, bgp
);
15222 vty_out(vty
, "!\n");
15228 /* BGP node structure. */
15229 static struct cmd_node bgp_node
= {
15230 BGP_NODE
, "%s(config-router)# ", 1,
15233 static struct cmd_node bgp_ipv4_unicast_node
= {
15234 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
15237 static struct cmd_node bgp_ipv4_multicast_node
= {
15238 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
15241 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
15242 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
15245 static struct cmd_node bgp_ipv6_unicast_node
= {
15246 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
15249 static struct cmd_node bgp_ipv6_multicast_node
= {
15250 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
15253 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
15254 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
15257 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
15258 "%s(config-router-af)# ", 1};
15260 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
15261 "%s(config-router-af-vpnv6)# ", 1};
15263 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
15264 "%s(config-router-evpn)# ", 1};
15266 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
15267 "%s(config-router-af-vni)# ", 1};
15269 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
15270 "%s(config-router-af)# ", 1};
15272 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
15273 "%s(config-router-af-vpnv6)# ", 1};
15275 static void community_list_vty(void);
15277 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
15281 struct listnode
*lnbgp
, *lnpeer
;
15283 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15284 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
15285 /* only provide suggestions on the appropriate input
15287 * they'll otherwise show up multiple times */
15288 enum cmd_token_type match_type
;
15289 char *name
= peer
->host
;
15291 if (peer
->conf_if
) {
15292 match_type
= VARIABLE_TKN
;
15293 name
= peer
->conf_if
;
15294 } else if (strchr(peer
->host
, ':'))
15295 match_type
= IPV6_TKN
;
15297 match_type
= IPV4_TKN
;
15299 if (token
->type
!= match_type
)
15302 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
15307 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
15308 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
15309 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
15310 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
15311 {.completions
= NULL
}};
15313 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
15316 struct peer_group
*group
;
15317 struct listnode
*lnbgp
, *lnpeer
;
15319 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15320 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
15321 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
15326 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
15327 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
15328 {.completions
= NULL
} };
15330 void bgp_vty_init(void)
15332 cmd_variable_handler_register(bgp_var_neighbor
);
15333 cmd_variable_handler_register(bgp_var_peergroup
);
15335 /* Install bgp top node. */
15336 install_node(&bgp_node
, bgp_config_write
);
15337 install_node(&bgp_ipv4_unicast_node
, NULL
);
15338 install_node(&bgp_ipv4_multicast_node
, NULL
);
15339 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
15340 install_node(&bgp_ipv6_unicast_node
, NULL
);
15341 install_node(&bgp_ipv6_multicast_node
, NULL
);
15342 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
15343 install_node(&bgp_vpnv4_node
, NULL
);
15344 install_node(&bgp_vpnv6_node
, NULL
);
15345 install_node(&bgp_evpn_node
, NULL
);
15346 install_node(&bgp_evpn_vni_node
, NULL
);
15347 install_node(&bgp_flowspecv4_node
, NULL
);
15348 install_node(&bgp_flowspecv6_node
, NULL
);
15350 /* Install default VTY commands to new nodes. */
15351 install_default(BGP_NODE
);
15352 install_default(BGP_IPV4_NODE
);
15353 install_default(BGP_IPV4M_NODE
);
15354 install_default(BGP_IPV4L_NODE
);
15355 install_default(BGP_IPV6_NODE
);
15356 install_default(BGP_IPV6M_NODE
);
15357 install_default(BGP_IPV6L_NODE
);
15358 install_default(BGP_VPNV4_NODE
);
15359 install_default(BGP_VPNV6_NODE
);
15360 install_default(BGP_FLOWSPECV4_NODE
);
15361 install_default(BGP_FLOWSPECV6_NODE
);
15362 install_default(BGP_EVPN_NODE
);
15363 install_default(BGP_EVPN_VNI_NODE
);
15365 /* "bgp local-mac" hidden commands. */
15366 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
15367 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
15369 /* bgp route-map delay-timer commands. */
15370 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15371 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15373 /* Dummy commands (Currently not supported) */
15374 install_element(BGP_NODE
, &no_synchronization_cmd
);
15375 install_element(BGP_NODE
, &no_auto_summary_cmd
);
15377 /* "router bgp" commands. */
15378 install_element(CONFIG_NODE
, &router_bgp_cmd
);
15380 /* "no router bgp" commands. */
15381 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
15383 /* "bgp router-id" commands. */
15384 install_element(BGP_NODE
, &bgp_router_id_cmd
);
15385 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
15387 /* "bgp cluster-id" commands. */
15388 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
15389 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
15391 /* "bgp confederation" commands. */
15392 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
15393 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
15395 /* "bgp confederation peers" commands. */
15396 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
15397 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
15399 /* bgp max-med command */
15400 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
15401 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
15402 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
15403 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
15404 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
15406 /* bgp disable-ebgp-connected-nh-check */
15407 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
15408 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
15410 /* bgp update-delay command */
15411 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
15412 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
15413 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
15415 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
15416 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
15418 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
15419 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
15421 /* "maximum-paths" commands. */
15422 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
15423 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
15424 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
15425 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
15426 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
15427 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
15428 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
15429 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
15430 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
15431 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
15432 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15433 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15434 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
15435 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15436 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15438 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
15439 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
15440 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
15441 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15442 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15444 /* "timers bgp" commands. */
15445 install_element(BGP_NODE
, &bgp_timers_cmd
);
15446 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
15448 /* route-map delay-timer commands - per instance for backwards compat.
15450 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15451 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15453 /* "bgp client-to-client reflection" commands */
15454 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
15455 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
15457 /* "bgp always-compare-med" commands */
15458 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
15459 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
15461 /* bgp ebgp-requires-policy */
15462 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
15463 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
15465 /* bgp reject-as-sets */
15466 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
15467 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
15469 /* "bgp deterministic-med" commands */
15470 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
15471 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
15473 /* "bgp graceful-restart" command */
15474 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
15475 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
15477 /* "bgp graceful-restart-disable" command */
15478 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
15479 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
15481 /* "neighbor a:b:c:d graceful-restart" command */
15482 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
15483 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
15485 /* "neighbor a:b:c:d graceful-restart-disable" command */
15486 install_element(BGP_NODE
,
15487 &bgp_neighbor_graceful_restart_disable_set_cmd
);
15488 install_element(BGP_NODE
,
15489 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
15491 /* "neighbor a:b:c:d graceful-restart-helper" command */
15492 install_element(BGP_NODE
,
15493 &bgp_neighbor_graceful_restart_helper_set_cmd
);
15494 install_element(BGP_NODE
,
15495 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
15497 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
15498 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
15499 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
15500 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
15501 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
15502 install_element(BGP_NODE
,
15503 &no_bgp_graceful_restart_select_defer_time_cmd
);
15504 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
15505 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
15507 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
15508 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
15509 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
15510 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
15512 /* "bgp graceful-shutdown" commands */
15513 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
15514 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
15516 /* "bgp fast-external-failover" commands */
15517 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
15518 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
15520 /* "bgp bestpath compare-routerid" commands */
15521 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
15522 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
15524 /* "bgp bestpath as-path ignore" commands */
15525 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
15526 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
15528 /* "bgp bestpath as-path confed" commands */
15529 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
15530 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
15532 /* "bgp bestpath as-path multipath-relax" commands */
15533 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
15534 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
15536 /* "bgp log-neighbor-changes" commands */
15537 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
15538 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
15540 /* "bgp bestpath med" commands */
15541 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
15542 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
15544 /* "no bgp default ipv4-unicast" commands. */
15545 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
15546 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
15548 /* "bgp network import-check" commands. */
15549 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
15550 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
15551 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
15553 /* "bgp default local-preference" commands. */
15554 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
15555 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
15557 /* bgp default show-hostname */
15558 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
15559 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
15561 /* "bgp default subgroup-pkt-queue-max" commands. */
15562 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
15563 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
15565 /* bgp ibgp-allow-policy-mods command */
15566 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
15567 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
15569 /* "bgp listen limit" commands. */
15570 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
15571 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
15573 /* "bgp listen range" commands. */
15574 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
15575 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
15577 /* "bgp default shutdown" command */
15578 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
15580 /* "neighbor remote-as" commands. */
15581 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
15582 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
15583 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
15584 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
15585 install_element(BGP_NODE
,
15586 &neighbor_interface_v6only_config_remote_as_cmd
);
15587 install_element(BGP_NODE
, &no_neighbor_cmd
);
15588 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
15590 /* "neighbor peer-group" commands. */
15591 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
15592 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
15593 install_element(BGP_NODE
,
15594 &no_neighbor_interface_peer_group_remote_as_cmd
);
15596 /* "neighbor local-as" commands. */
15597 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
15598 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
15599 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
15600 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
15602 /* "neighbor solo" commands. */
15603 install_element(BGP_NODE
, &neighbor_solo_cmd
);
15604 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
15606 /* "neighbor password" commands. */
15607 install_element(BGP_NODE
, &neighbor_password_cmd
);
15608 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
15610 /* "neighbor activate" commands. */
15611 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
15612 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
15613 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
15614 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
15615 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
15616 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
15617 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
15618 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
15619 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
15620 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
15621 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
15622 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
15624 /* "no neighbor activate" commands. */
15625 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
15626 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
15627 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
15628 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
15629 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
15630 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
15631 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
15632 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
15633 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
15634 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
15635 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
15636 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
15638 /* "neighbor peer-group" set commands. */
15639 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
15640 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15641 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15642 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15643 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15644 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15645 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15646 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15647 install_element(BGP_FLOWSPECV4_NODE
,
15648 &neighbor_set_peer_group_hidden_cmd
);
15649 install_element(BGP_FLOWSPECV6_NODE
,
15650 &neighbor_set_peer_group_hidden_cmd
);
15652 /* "no neighbor peer-group unset" commands. */
15653 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
15654 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15655 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15656 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15657 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15658 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15659 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15660 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15661 install_element(BGP_FLOWSPECV4_NODE
,
15662 &no_neighbor_set_peer_group_hidden_cmd
);
15663 install_element(BGP_FLOWSPECV6_NODE
,
15664 &no_neighbor_set_peer_group_hidden_cmd
);
15666 /* "neighbor softreconfiguration inbound" commands.*/
15667 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
15668 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
15669 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
15670 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15671 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
15672 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15673 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
15674 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15675 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
15676 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15677 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
15678 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15679 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
15680 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15681 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
15682 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15683 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
15684 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15685 install_element(BGP_FLOWSPECV4_NODE
,
15686 &neighbor_soft_reconfiguration_cmd
);
15687 install_element(BGP_FLOWSPECV4_NODE
,
15688 &no_neighbor_soft_reconfiguration_cmd
);
15689 install_element(BGP_FLOWSPECV6_NODE
,
15690 &neighbor_soft_reconfiguration_cmd
);
15691 install_element(BGP_FLOWSPECV6_NODE
,
15692 &no_neighbor_soft_reconfiguration_cmd
);
15693 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
15694 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15696 /* "neighbor attribute-unchanged" commands. */
15697 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
15698 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
15699 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
15700 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
15701 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
15702 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
15703 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
15704 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
15705 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
15706 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
15707 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
15708 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
15709 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
15710 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
15711 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
15712 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
15713 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
15714 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
15716 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
15717 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
15719 /* "nexthop-local unchanged" commands */
15720 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
15721 install_element(BGP_IPV6_NODE
,
15722 &no_neighbor_nexthop_local_unchanged_cmd
);
15724 /* "neighbor next-hop-self" commands. */
15725 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
15726 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
15727 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
15728 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
15729 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
15730 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
15731 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
15732 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
15733 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
15734 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
15735 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
15736 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
15737 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
15738 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
15739 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
15740 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
15741 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
15742 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
15743 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
15744 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
15746 /* "neighbor next-hop-self force" commands. */
15747 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
15748 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
15749 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15750 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
15751 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
15752 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15753 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15754 install_element(BGP_IPV4_NODE
,
15755 &no_neighbor_nexthop_self_all_hidden_cmd
);
15756 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
15757 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15758 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15759 install_element(BGP_IPV4M_NODE
,
15760 &no_neighbor_nexthop_self_all_hidden_cmd
);
15761 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
15762 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15763 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15764 install_element(BGP_IPV4L_NODE
,
15765 &no_neighbor_nexthop_self_all_hidden_cmd
);
15766 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
15767 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15768 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15769 install_element(BGP_IPV6_NODE
,
15770 &no_neighbor_nexthop_self_all_hidden_cmd
);
15771 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
15772 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15773 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15774 install_element(BGP_IPV6M_NODE
,
15775 &no_neighbor_nexthop_self_all_hidden_cmd
);
15776 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
15777 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15778 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15779 install_element(BGP_IPV6L_NODE
,
15780 &no_neighbor_nexthop_self_all_hidden_cmd
);
15781 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
15782 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15783 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15784 install_element(BGP_VPNV4_NODE
,
15785 &no_neighbor_nexthop_self_all_hidden_cmd
);
15786 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
15787 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15788 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15789 install_element(BGP_VPNV6_NODE
,
15790 &no_neighbor_nexthop_self_all_hidden_cmd
);
15792 /* "neighbor as-override" commands. */
15793 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
15794 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
15795 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
15796 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
15797 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
15798 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
15799 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
15800 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
15801 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
15802 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
15803 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
15804 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
15805 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
15806 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
15807 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
15808 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
15809 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
15810 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
15812 /* "neighbor remove-private-AS" commands. */
15813 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
15814 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
15815 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
15816 install_element(BGP_NODE
,
15817 &no_neighbor_remove_private_as_all_hidden_cmd
);
15818 install_element(BGP_NODE
,
15819 &neighbor_remove_private_as_replace_as_hidden_cmd
);
15820 install_element(BGP_NODE
,
15821 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
15822 install_element(BGP_NODE
,
15823 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
15826 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
15827 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
15828 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
15829 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
15830 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15831 install_element(BGP_IPV4_NODE
,
15832 &neighbor_remove_private_as_replace_as_cmd
);
15833 install_element(BGP_IPV4_NODE
,
15834 &no_neighbor_remove_private_as_replace_as_cmd
);
15835 install_element(BGP_IPV4_NODE
,
15836 &neighbor_remove_private_as_all_replace_as_cmd
);
15837 install_element(BGP_IPV4_NODE
,
15838 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15839 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
15840 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
15841 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
15842 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15843 install_element(BGP_IPV4M_NODE
,
15844 &neighbor_remove_private_as_replace_as_cmd
);
15845 install_element(BGP_IPV4M_NODE
,
15846 &no_neighbor_remove_private_as_replace_as_cmd
);
15847 install_element(BGP_IPV4M_NODE
,
15848 &neighbor_remove_private_as_all_replace_as_cmd
);
15849 install_element(BGP_IPV4M_NODE
,
15850 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15851 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
15852 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
15853 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
15854 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15855 install_element(BGP_IPV4L_NODE
,
15856 &neighbor_remove_private_as_replace_as_cmd
);
15857 install_element(BGP_IPV4L_NODE
,
15858 &no_neighbor_remove_private_as_replace_as_cmd
);
15859 install_element(BGP_IPV4L_NODE
,
15860 &neighbor_remove_private_as_all_replace_as_cmd
);
15861 install_element(BGP_IPV4L_NODE
,
15862 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15863 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
15864 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
15865 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
15866 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15867 install_element(BGP_IPV6_NODE
,
15868 &neighbor_remove_private_as_replace_as_cmd
);
15869 install_element(BGP_IPV6_NODE
,
15870 &no_neighbor_remove_private_as_replace_as_cmd
);
15871 install_element(BGP_IPV6_NODE
,
15872 &neighbor_remove_private_as_all_replace_as_cmd
);
15873 install_element(BGP_IPV6_NODE
,
15874 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15875 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
15876 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
15877 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
15878 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15879 install_element(BGP_IPV6M_NODE
,
15880 &neighbor_remove_private_as_replace_as_cmd
);
15881 install_element(BGP_IPV6M_NODE
,
15882 &no_neighbor_remove_private_as_replace_as_cmd
);
15883 install_element(BGP_IPV6M_NODE
,
15884 &neighbor_remove_private_as_all_replace_as_cmd
);
15885 install_element(BGP_IPV6M_NODE
,
15886 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15887 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
15888 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
15889 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
15890 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15891 install_element(BGP_IPV6L_NODE
,
15892 &neighbor_remove_private_as_replace_as_cmd
);
15893 install_element(BGP_IPV6L_NODE
,
15894 &no_neighbor_remove_private_as_replace_as_cmd
);
15895 install_element(BGP_IPV6L_NODE
,
15896 &neighbor_remove_private_as_all_replace_as_cmd
);
15897 install_element(BGP_IPV6L_NODE
,
15898 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15899 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
15900 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
15901 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
15902 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15903 install_element(BGP_VPNV4_NODE
,
15904 &neighbor_remove_private_as_replace_as_cmd
);
15905 install_element(BGP_VPNV4_NODE
,
15906 &no_neighbor_remove_private_as_replace_as_cmd
);
15907 install_element(BGP_VPNV4_NODE
,
15908 &neighbor_remove_private_as_all_replace_as_cmd
);
15909 install_element(BGP_VPNV4_NODE
,
15910 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15911 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
15912 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
15913 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
15914 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15915 install_element(BGP_VPNV6_NODE
,
15916 &neighbor_remove_private_as_replace_as_cmd
);
15917 install_element(BGP_VPNV6_NODE
,
15918 &no_neighbor_remove_private_as_replace_as_cmd
);
15919 install_element(BGP_VPNV6_NODE
,
15920 &neighbor_remove_private_as_all_replace_as_cmd
);
15921 install_element(BGP_VPNV6_NODE
,
15922 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15924 /* "neighbor send-community" commands.*/
15925 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
15926 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
15927 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
15928 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
15929 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
15930 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
15931 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
15932 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
15933 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
15934 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
15935 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
15936 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
15937 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
15938 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
15939 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
15940 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
15941 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
15942 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
15943 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
15944 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
15945 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
15946 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
15947 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
15948 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
15949 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
15950 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
15951 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
15952 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
15953 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
15954 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
15955 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
15956 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
15957 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
15958 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
15959 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
15960 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
15962 /* "neighbor route-reflector" commands.*/
15963 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
15964 install_element(BGP_NODE
,
15965 &no_neighbor_route_reflector_client_hidden_cmd
);
15966 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
15967 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
15968 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
15969 install_element(BGP_IPV4M_NODE
,
15970 &no_neighbor_route_reflector_client_cmd
);
15971 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
15972 install_element(BGP_IPV4L_NODE
,
15973 &no_neighbor_route_reflector_client_cmd
);
15974 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
15975 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
15976 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
15977 install_element(BGP_IPV6M_NODE
,
15978 &no_neighbor_route_reflector_client_cmd
);
15979 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
15980 install_element(BGP_IPV6L_NODE
,
15981 &no_neighbor_route_reflector_client_cmd
);
15982 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
15983 install_element(BGP_VPNV4_NODE
,
15984 &no_neighbor_route_reflector_client_cmd
);
15985 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
15986 install_element(BGP_VPNV6_NODE
,
15987 &no_neighbor_route_reflector_client_cmd
);
15988 install_element(BGP_FLOWSPECV4_NODE
,
15989 &neighbor_route_reflector_client_cmd
);
15990 install_element(BGP_FLOWSPECV4_NODE
,
15991 &no_neighbor_route_reflector_client_cmd
);
15992 install_element(BGP_FLOWSPECV6_NODE
,
15993 &neighbor_route_reflector_client_cmd
);
15994 install_element(BGP_FLOWSPECV6_NODE
,
15995 &no_neighbor_route_reflector_client_cmd
);
15996 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
15997 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
15999 /* "neighbor route-server" commands.*/
16000 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
16001 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
16002 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
16003 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
16004 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
16005 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
16006 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
16007 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
16008 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
16009 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
16010 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
16011 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
16012 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
16013 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
16014 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
16015 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
16016 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
16017 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
16018 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
16019 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
16020 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
16021 install_element(BGP_FLOWSPECV4_NODE
,
16022 &no_neighbor_route_server_client_cmd
);
16023 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
16024 install_element(BGP_FLOWSPECV6_NODE
,
16025 &no_neighbor_route_server_client_cmd
);
16027 /* "neighbor addpath-tx-all-paths" commands.*/
16028 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
16029 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
16030 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16031 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16032 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16033 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16034 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16035 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16036 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16037 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16038 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16039 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16040 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16041 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16042 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16043 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16044 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16045 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16047 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
16048 install_element(BGP_NODE
,
16049 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16050 install_element(BGP_NODE
,
16051 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16052 install_element(BGP_IPV4_NODE
,
16053 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16054 install_element(BGP_IPV4_NODE
,
16055 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16056 install_element(BGP_IPV4M_NODE
,
16057 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16058 install_element(BGP_IPV4M_NODE
,
16059 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16060 install_element(BGP_IPV4L_NODE
,
16061 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16062 install_element(BGP_IPV4L_NODE
,
16063 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16064 install_element(BGP_IPV6_NODE
,
16065 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16066 install_element(BGP_IPV6_NODE
,
16067 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16068 install_element(BGP_IPV6M_NODE
,
16069 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16070 install_element(BGP_IPV6M_NODE
,
16071 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16072 install_element(BGP_IPV6L_NODE
,
16073 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16074 install_element(BGP_IPV6L_NODE
,
16075 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16076 install_element(BGP_VPNV4_NODE
,
16077 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16078 install_element(BGP_VPNV4_NODE
,
16079 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16080 install_element(BGP_VPNV6_NODE
,
16081 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16082 install_element(BGP_VPNV6_NODE
,
16083 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16085 /* "neighbor sender-as-path-loop-detection" commands. */
16086 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
16087 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
16089 /* "neighbor passive" commands. */
16090 install_element(BGP_NODE
, &neighbor_passive_cmd
);
16091 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
16094 /* "neighbor shutdown" commands. */
16095 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
16096 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
16097 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
16098 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
16100 /* "neighbor capability extended-nexthop" commands.*/
16101 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
16102 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
16104 /* "neighbor capability orf prefix-list" commands.*/
16105 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
16106 install_element(BGP_NODE
,
16107 &no_neighbor_capability_orf_prefix_hidden_cmd
);
16108 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
16109 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16110 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16111 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16112 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16113 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16114 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
16115 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16116 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16117 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16118 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16119 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16121 /* "neighbor capability dynamic" commands.*/
16122 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
16123 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
16125 /* "neighbor dont-capability-negotiate" commands. */
16126 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
16127 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
16129 /* "neighbor ebgp-multihop" commands. */
16130 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
16131 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
16132 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
16134 /* "neighbor disable-connected-check" commands. */
16135 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
16136 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
16138 /* "neighbor enforce-first-as" commands. */
16139 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
16140 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
16142 /* "neighbor description" commands. */
16143 install_element(BGP_NODE
, &neighbor_description_cmd
);
16144 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
16145 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
16147 /* "neighbor update-source" commands. "*/
16148 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
16149 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
16151 /* "neighbor default-originate" commands. */
16152 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
16153 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
16154 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
16155 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
16156 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
16157 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
16158 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
16159 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
16160 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
16161 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
16162 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
16163 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
16164 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
16165 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
16166 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
16167 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
16168 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
16169 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
16170 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
16171 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
16172 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
16174 /* "neighbor port" commands. */
16175 install_element(BGP_NODE
, &neighbor_port_cmd
);
16176 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
16178 /* "neighbor weight" commands. */
16179 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
16180 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
16182 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
16183 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
16184 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
16185 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
16186 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
16187 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
16188 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
16189 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
16190 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
16191 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
16192 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
16193 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
16194 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
16195 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
16196 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
16197 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
16199 /* "neighbor override-capability" commands. */
16200 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
16201 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
16203 /* "neighbor strict-capability-match" commands. */
16204 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
16205 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
16207 /* "neighbor timers" commands. */
16208 install_element(BGP_NODE
, &neighbor_timers_cmd
);
16209 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
16211 /* "neighbor timers connect" commands. */
16212 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
16213 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
16215 /* "neighbor advertisement-interval" commands. */
16216 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
16217 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
16219 /* "neighbor interface" commands. */
16220 install_element(BGP_NODE
, &neighbor_interface_cmd
);
16221 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
16223 /* "neighbor distribute" commands. */
16224 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
16225 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
16226 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
16227 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
16228 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
16229 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
16230 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
16231 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
16232 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
16233 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
16234 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
16235 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
16236 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
16237 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
16238 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
16239 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
16240 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
16241 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
16243 /* "neighbor prefix-list" commands. */
16244 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
16245 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
16246 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
16247 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
16248 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
16249 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
16250 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
16251 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
16252 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
16253 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
16254 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
16255 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
16256 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
16257 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
16258 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
16259 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
16260 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
16261 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
16262 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
16263 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
16264 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
16265 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
16267 /* "neighbor filter-list" commands. */
16268 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
16269 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
16270 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
16271 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
16272 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
16273 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
16274 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
16275 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
16276 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
16277 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
16278 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
16279 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
16280 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
16281 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
16282 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
16283 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
16284 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
16285 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
16286 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
16287 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
16288 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
16289 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
16291 /* "neighbor route-map" commands. */
16292 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
16293 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
16294 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
16295 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
16296 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
16297 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
16298 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
16299 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
16300 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
16301 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
16302 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
16303 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
16304 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
16305 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
16306 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
16307 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
16308 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
16309 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
16310 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
16311 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
16312 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
16313 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
16314 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
16315 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
16317 /* "neighbor unsuppress-map" commands. */
16318 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
16319 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
16320 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
16321 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16322 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
16323 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16324 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
16325 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16326 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
16327 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16328 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
16329 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16330 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
16331 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16332 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
16333 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16334 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
16335 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16337 /* neighbor maximum-prefix-out commands. */
16338 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
16339 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16340 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16341 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16342 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16343 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16344 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16345 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16346 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16347 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16348 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16349 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16350 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16351 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16352 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16353 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16354 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16355 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16357 /* "neighbor maximum-prefix" commands. */
16358 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
16359 install_element(BGP_NODE
,
16360 &neighbor_maximum_prefix_threshold_hidden_cmd
);
16361 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
16362 install_element(BGP_NODE
,
16363 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
16364 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
16365 install_element(BGP_NODE
,
16366 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
16367 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
16368 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
16369 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16370 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16371 install_element(BGP_IPV4_NODE
,
16372 &neighbor_maximum_prefix_threshold_warning_cmd
);
16373 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16374 install_element(BGP_IPV4_NODE
,
16375 &neighbor_maximum_prefix_threshold_restart_cmd
);
16376 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16377 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
16378 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16379 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16380 install_element(BGP_IPV4M_NODE
,
16381 &neighbor_maximum_prefix_threshold_warning_cmd
);
16382 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16383 install_element(BGP_IPV4M_NODE
,
16384 &neighbor_maximum_prefix_threshold_restart_cmd
);
16385 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16386 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
16387 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16388 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16389 install_element(BGP_IPV4L_NODE
,
16390 &neighbor_maximum_prefix_threshold_warning_cmd
);
16391 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16392 install_element(BGP_IPV4L_NODE
,
16393 &neighbor_maximum_prefix_threshold_restart_cmd
);
16394 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16395 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
16396 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16397 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16398 install_element(BGP_IPV6_NODE
,
16399 &neighbor_maximum_prefix_threshold_warning_cmd
);
16400 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16401 install_element(BGP_IPV6_NODE
,
16402 &neighbor_maximum_prefix_threshold_restart_cmd
);
16403 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16404 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
16405 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16406 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16407 install_element(BGP_IPV6M_NODE
,
16408 &neighbor_maximum_prefix_threshold_warning_cmd
);
16409 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16410 install_element(BGP_IPV6M_NODE
,
16411 &neighbor_maximum_prefix_threshold_restart_cmd
);
16412 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16413 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
16414 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16415 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16416 install_element(BGP_IPV6L_NODE
,
16417 &neighbor_maximum_prefix_threshold_warning_cmd
);
16418 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16419 install_element(BGP_IPV6L_NODE
,
16420 &neighbor_maximum_prefix_threshold_restart_cmd
);
16421 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16422 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
16423 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16424 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16425 install_element(BGP_VPNV4_NODE
,
16426 &neighbor_maximum_prefix_threshold_warning_cmd
);
16427 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16428 install_element(BGP_VPNV4_NODE
,
16429 &neighbor_maximum_prefix_threshold_restart_cmd
);
16430 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16431 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
16432 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16433 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16434 install_element(BGP_VPNV6_NODE
,
16435 &neighbor_maximum_prefix_threshold_warning_cmd
);
16436 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16437 install_element(BGP_VPNV6_NODE
,
16438 &neighbor_maximum_prefix_threshold_restart_cmd
);
16439 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16441 /* "neighbor allowas-in" */
16442 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
16443 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
16444 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
16445 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
16446 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
16447 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
16448 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
16449 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
16450 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
16451 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
16452 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
16453 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
16454 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
16455 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
16456 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
16457 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
16458 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
16459 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
16460 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
16461 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
16463 /* address-family commands. */
16464 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
16465 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
16466 #ifdef KEEP_OLD_VPN_COMMANDS
16467 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
16468 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
16469 #endif /* KEEP_OLD_VPN_COMMANDS */
16471 install_element(BGP_NODE
, &address_family_evpn_cmd
);
16473 /* "exit-address-family" command. */
16474 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
16475 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
16476 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
16477 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
16478 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
16479 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
16480 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
16481 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
16482 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
16483 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
16484 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
16486 /* "clear ip bgp commands" */
16487 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
16489 /* clear ip bgp prefix */
16490 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
16491 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
16492 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
16494 /* "show [ip] bgp summary" commands. */
16495 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
16496 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
16497 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
16498 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
16499 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
16500 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
16501 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
16503 /* "show [ip] bgp neighbors" commands. */
16504 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
16506 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
16508 /* "show [ip] bgp peer-group" commands. */
16509 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
16511 /* "show [ip] bgp paths" commands. */
16512 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
16514 /* "show [ip] bgp community" commands. */
16515 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
16517 /* "show ip bgp large-community" commands. */
16518 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
16519 /* "show [ip] bgp attribute-info" commands. */
16520 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
16521 /* "show [ip] bgp route-leak" command */
16522 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
16524 /* "redistribute" commands. */
16525 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
16526 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
16527 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
16528 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
16529 install_element(BGP_NODE
,
16530 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
16531 install_element(BGP_NODE
,
16532 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
16533 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
16534 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
16535 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
16536 install_element(BGP_NODE
,
16537 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
16538 install_element(BGP_NODE
,
16539 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
16540 install_element(BGP_NODE
,
16541 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
16542 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
16543 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
16544 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
16545 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
16546 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
16547 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
16548 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
16549 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
16550 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
16551 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
16552 install_element(BGP_IPV4_NODE
,
16553 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
16554 install_element(BGP_IPV4_NODE
,
16555 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
16556 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
16557 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
16558 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
16559 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
16560 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
16561 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
16563 /* import|export vpn [route-map WORD] */
16564 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
16565 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
16567 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
16568 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
16570 /* ttl_security commands */
16571 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
16572 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
16574 /* "show [ip] bgp memory" commands. */
16575 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
16577 /* "show bgp martian next-hop" */
16578 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
16580 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
16582 /* "show [ip] bgp views" commands. */
16583 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
16585 /* "show [ip] bgp vrfs" commands. */
16586 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
16588 /* Community-list. */
16589 community_list_vty();
16591 /* vpn-policy commands */
16592 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
16593 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
16594 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
16595 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
16596 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
16597 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
16598 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
16599 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
16600 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
16601 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
16602 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
16603 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
16605 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
16606 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
16608 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
16609 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
16610 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
16611 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
16612 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
16613 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
16614 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
16615 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
16616 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
16617 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
16618 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
16619 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
16622 #include "memory.h"
16623 #include "bgp_regex.h"
16624 #include "bgp_clist.h"
16625 #include "bgp_ecommunity.h"
16627 /* VTY functions. */
16629 /* Direction value to string conversion. */
16630 static const char *community_direct_str(int direct
)
16633 case COMMUNITY_DENY
:
16635 case COMMUNITY_PERMIT
:
16642 /* Display error string. */
16643 static void community_list_perror(struct vty
*vty
, int ret
)
16646 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
16647 vty_out(vty
, "%% Can't find community-list\n");
16649 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
16650 vty_out(vty
, "%% Malformed community-list value\n");
16652 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
16654 "%% Community name conflict, previously defined as standard community\n");
16656 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
16658 "%% Community name conflict, previously defined as expanded community\n");
16663 /* "community-list" keyword help string. */
16664 #define COMMUNITY_LIST_STR "Add a community list entry\n"
16666 /*community-list standard */
16667 DEFUN (community_list_standard
,
16668 bgp_community_list_standard_cmd
,
16669 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16672 "Community list number (standard)\n"
16673 "Add an standard community-list entry\n"
16674 "Community list name\n"
16675 "Sequence number of an entry\n"
16676 "Sequence number\n"
16677 "Specify community to reject\n"
16678 "Specify community to accept\n"
16681 char *cl_name_or_number
= NULL
;
16684 int style
= COMMUNITY_LIST_STANDARD
;
16687 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16689 seq
= argv
[idx
]->arg
;
16692 argv_find(argv
, argc
, "(1-99)", &idx
);
16693 argv_find(argv
, argc
, "WORD", &idx
);
16694 cl_name_or_number
= argv
[idx
]->arg
;
16695 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16697 argv_find(argv
, argc
, "AA:NN", &idx
);
16698 char *str
= argv_concat(argv
, argc
, idx
);
16700 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
16703 XFREE(MTYPE_TMP
, str
);
16706 /* Display error string. */
16707 community_list_perror(vty
, ret
);
16708 return CMD_WARNING_CONFIG_FAILED
;
16711 return CMD_SUCCESS
;
16714 DEFUN (no_community_list_standard_all
,
16715 no_bgp_community_list_standard_all_cmd
,
16716 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16720 "Community list number (standard)\n"
16721 "Add an standard community-list entry\n"
16722 "Community list name\n"
16723 "Sequence number of an entry\n"
16724 "Sequence number\n"
16725 "Specify community to reject\n"
16726 "Specify community to accept\n"
16729 char *cl_name_or_number
= NULL
;
16732 int style
= COMMUNITY_LIST_STANDARD
;
16736 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16738 seq
= argv
[idx
]->arg
;
16741 argv_find(argv
, argc
, "permit", &idx
);
16742 argv_find(argv
, argc
, "deny", &idx
);
16745 direct
= argv_find(argv
, argc
, "permit", &idx
)
16750 argv_find(argv
, argc
, "AA:NN", &idx
);
16751 str
= argv_concat(argv
, argc
, idx
);
16755 argv_find(argv
, argc
, "(1-99)", &idx
);
16756 argv_find(argv
, argc
, "WORD", &idx
);
16757 cl_name_or_number
= argv
[idx
]->arg
;
16759 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
16762 XFREE(MTYPE_TMP
, str
);
16765 community_list_perror(vty
, ret
);
16766 return CMD_WARNING_CONFIG_FAILED
;
16769 return CMD_SUCCESS
;
16772 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
16773 "no bgp community-list <(1-99)|standard WORD>",
16774 NO_STR BGP_STR COMMUNITY_LIST_STR
16775 "Community list number (standard)\n"
16776 "Add an standard community-list entry\n"
16777 "Community list name\n")
16779 /*community-list expanded */
16780 DEFUN (community_list_expanded_all
,
16781 bgp_community_list_expanded_all_cmd
,
16782 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16785 "Community list number (expanded)\n"
16786 "Add an expanded community-list entry\n"
16787 "Community list name\n"
16788 "Sequence number of an entry\n"
16789 "Sequence number\n"
16790 "Specify community to reject\n"
16791 "Specify community to accept\n"
16794 char *cl_name_or_number
= NULL
;
16797 int style
= COMMUNITY_LIST_EXPANDED
;
16800 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16802 seq
= argv
[idx
]->arg
;
16806 argv_find(argv
, argc
, "(100-500)", &idx
);
16807 argv_find(argv
, argc
, "WORD", &idx
);
16808 cl_name_or_number
= argv
[idx
]->arg
;
16809 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16811 argv_find(argv
, argc
, "AA:NN", &idx
);
16812 char *str
= argv_concat(argv
, argc
, idx
);
16814 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
16817 XFREE(MTYPE_TMP
, str
);
16820 /* Display error string. */
16821 community_list_perror(vty
, ret
);
16822 return CMD_WARNING_CONFIG_FAILED
;
16825 return CMD_SUCCESS
;
16828 DEFUN (no_community_list_expanded_all
,
16829 no_bgp_community_list_expanded_all_cmd
,
16830 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16834 "Community list number (expanded)\n"
16835 "Add an expanded community-list entry\n"
16836 "Community list name\n"
16837 "Sequence number of an entry\n"
16838 "Sequence number\n"
16839 "Specify community to reject\n"
16840 "Specify community to accept\n"
16843 char *cl_name_or_number
= NULL
;
16847 int style
= COMMUNITY_LIST_EXPANDED
;
16850 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16852 seq
= argv
[idx
]->arg
;
16855 argv_find(argv
, argc
, "permit", &idx
);
16856 argv_find(argv
, argc
, "deny", &idx
);
16859 direct
= argv_find(argv
, argc
, "permit", &idx
)
16864 argv_find(argv
, argc
, "AA:NN", &idx
);
16865 str
= argv_concat(argv
, argc
, idx
);
16869 argv_find(argv
, argc
, "(100-500)", &idx
);
16870 argv_find(argv
, argc
, "WORD", &idx
);
16871 cl_name_or_number
= argv
[idx
]->arg
;
16873 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
16876 XFREE(MTYPE_TMP
, str
);
16879 community_list_perror(vty
, ret
);
16880 return CMD_WARNING_CONFIG_FAILED
;
16883 return CMD_SUCCESS
;
16886 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
16887 "no bgp community-list <(100-500)|expanded WORD>",
16888 NO_STR IP_STR COMMUNITY_LIST_STR
16889 "Community list number (expanded)\n"
16890 "Add an expanded community-list entry\n"
16891 "Community list name\n")
16893 /* Return configuration string of community-list entry. */
16894 static const char *community_list_config_str(struct community_entry
*entry
)
16901 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
16902 str
= community_str(entry
->u
.com
, false);
16903 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
16904 str
= lcommunity_str(entry
->u
.lcom
, false);
16906 str
= entry
->config
;
16911 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
16913 struct community_entry
*entry
;
16915 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16916 if (entry
== list
->head
) {
16917 if (all_digit(list
->name
))
16918 vty_out(vty
, "Community %s list %s\n",
16919 entry
->style
== COMMUNITY_LIST_STANDARD
16921 : "(expanded) access",
16924 vty_out(vty
, "Named Community %s list %s\n",
16925 entry
->style
== COMMUNITY_LIST_STANDARD
16931 vty_out(vty
, " %s\n",
16932 community_direct_str(entry
->direct
));
16934 vty_out(vty
, " %s %s\n",
16935 community_direct_str(entry
->direct
),
16936 community_list_config_str(entry
));
16940 DEFUN (show_community_list
,
16941 show_bgp_community_list_cmd
,
16942 "show bgp community-list",
16945 "List community-list\n")
16947 struct community_list
*list
;
16948 struct community_list_master
*cm
;
16950 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
16952 return CMD_SUCCESS
;
16954 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16955 community_list_show(vty
, list
);
16957 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16958 community_list_show(vty
, list
);
16960 return CMD_SUCCESS
;
16963 DEFUN (show_community_list_arg
,
16964 show_bgp_community_list_arg_cmd
,
16965 "show bgp community-list <(1-500)|WORD> detail",
16968 "List community-list\n"
16969 "Community-list number\n"
16970 "Community-list name\n"
16971 "Detailed information on community-list\n")
16973 int idx_comm_list
= 3;
16974 struct community_list
*list
;
16976 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
16977 COMMUNITY_LIST_MASTER
);
16979 vty_out(vty
, "%% Can't find community-list\n");
16980 return CMD_WARNING
;
16983 community_list_show(vty
, list
);
16985 return CMD_SUCCESS
;
16989 * Large Community code.
16991 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
16992 struct cmd_token
**argv
, int style
,
16993 int reject_all_digit_name
)
17002 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17004 seq
= argv
[idx
]->arg
;
17007 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17010 /* All digit name check. */
17012 argv_find(argv
, argc
, "WORD", &idx
);
17013 argv_find(argv
, argc
, "(1-99)", &idx
);
17014 argv_find(argv
, argc
, "(100-500)", &idx
);
17015 cl_name
= argv
[idx
]->arg
;
17016 if (reject_all_digit_name
&& all_digit(cl_name
)) {
17017 vty_out(vty
, "%% Community name cannot have all digits\n");
17018 return CMD_WARNING_CONFIG_FAILED
;
17022 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
17023 argv_find(argv
, argc
, "LINE", &idx
);
17024 /* Concat community string argument. */
17026 str
= argv_concat(argv
, argc
, idx
);
17030 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
17032 /* Free temporary community list string allocated by
17034 XFREE(MTYPE_TMP
, str
);
17037 community_list_perror(vty
, ret
);
17038 return CMD_WARNING_CONFIG_FAILED
;
17040 return CMD_SUCCESS
;
17043 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
17044 struct cmd_token
**argv
, int style
)
17052 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17054 seq
= argv
[idx
]->arg
;
17057 argv_find(argv
, argc
, "permit", &idx
);
17058 argv_find(argv
, argc
, "deny", &idx
);
17061 /* Check the list direct. */
17062 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
17063 direct
= COMMUNITY_PERMIT
;
17065 direct
= COMMUNITY_DENY
;
17068 argv_find(argv
, argc
, "LINE", &idx
);
17069 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
17070 /* Concat community string argument. */
17071 str
= argv_concat(argv
, argc
, idx
);
17075 argv_find(argv
, argc
, "(1-99)", &idx
);
17076 argv_find(argv
, argc
, "(100-500)", &idx
);
17077 argv_find(argv
, argc
, "WORD", &idx
);
17079 /* Unset community list. */
17080 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
17083 /* Free temporary community list string allocated by
17085 XFREE(MTYPE_TMP
, str
);
17088 community_list_perror(vty
, ret
);
17089 return CMD_WARNING_CONFIG_FAILED
;
17092 return CMD_SUCCESS
;
17095 /* "large-community-list" keyword help string. */
17096 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
17097 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
17099 DEFUN (lcommunity_list_standard
,
17100 bgp_lcommunity_list_standard_cmd
,
17101 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17103 LCOMMUNITY_LIST_STR
17104 "Large Community list number (standard)\n"
17105 "Sequence number of an entry\n"
17106 "Sequence number\n"
17107 "Specify large community to reject\n"
17108 "Specify large community to accept\n"
17109 LCOMMUNITY_VAL_STR
)
17111 return lcommunity_list_set_vty(vty
, argc
, argv
,
17112 LARGE_COMMUNITY_LIST_STANDARD
, 0);
17115 DEFUN (lcommunity_list_expanded
,
17116 bgp_lcommunity_list_expanded_cmd
,
17117 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17119 LCOMMUNITY_LIST_STR
17120 "Large Community list number (expanded)\n"
17121 "Sequence number of an entry\n"
17122 "Sequence number\n"
17123 "Specify large community to reject\n"
17124 "Specify large community to accept\n"
17125 "An ordered list as a regular-expression\n")
17127 return lcommunity_list_set_vty(vty
, argc
, argv
,
17128 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
17131 DEFUN (lcommunity_list_name_standard
,
17132 bgp_lcommunity_list_name_standard_cmd
,
17133 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17135 LCOMMUNITY_LIST_STR
17136 "Specify standard large-community-list\n"
17137 "Large Community list name\n"
17138 "Sequence number of an entry\n"
17139 "Sequence number\n"
17140 "Specify large community to reject\n"
17141 "Specify large community to accept\n"
17142 LCOMMUNITY_VAL_STR
)
17144 return lcommunity_list_set_vty(vty
, argc
, argv
,
17145 LARGE_COMMUNITY_LIST_STANDARD
, 1);
17148 DEFUN (lcommunity_list_name_expanded
,
17149 bgp_lcommunity_list_name_expanded_cmd
,
17150 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17152 LCOMMUNITY_LIST_STR
17153 "Specify expanded large-community-list\n"
17154 "Large Community list name\n"
17155 "Sequence number of an entry\n"
17156 "Sequence number\n"
17157 "Specify large community to reject\n"
17158 "Specify large community to accept\n"
17159 "An ordered list as a regular-expression\n")
17161 return lcommunity_list_set_vty(vty
, argc
, argv
,
17162 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
17165 DEFUN (no_lcommunity_list_all
,
17166 no_bgp_lcommunity_list_all_cmd
,
17167 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
17170 LCOMMUNITY_LIST_STR
17171 "Large Community list number (standard)\n"
17172 "Large Community list number (expanded)\n"
17173 "Large Community list name\n")
17175 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17176 LARGE_COMMUNITY_LIST_STANDARD
);
17179 DEFUN (no_lcommunity_list_name_standard_all
,
17180 no_bgp_lcommunity_list_name_standard_all_cmd
,
17181 "no bgp large-community-list standard WORD",
17184 LCOMMUNITY_LIST_STR
17185 "Specify standard large-community-list\n"
17186 "Large Community list name\n")
17188 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17189 LARGE_COMMUNITY_LIST_STANDARD
);
17192 DEFUN (no_lcommunity_list_name_expanded_all
,
17193 no_bgp_lcommunity_list_name_expanded_all_cmd
,
17194 "no bgp large-community-list expanded WORD",
17197 LCOMMUNITY_LIST_STR
17198 "Specify expanded large-community-list\n"
17199 "Large Community list name\n")
17201 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17202 LARGE_COMMUNITY_LIST_EXPANDED
);
17205 DEFUN (no_lcommunity_list_standard
,
17206 no_bgp_lcommunity_list_standard_cmd
,
17207 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17210 LCOMMUNITY_LIST_STR
17211 "Large Community list number (standard)\n"
17212 "Sequence number of an entry\n"
17213 "Sequence number\n"
17214 "Specify large community to reject\n"
17215 "Specify large community to accept\n"
17216 LCOMMUNITY_VAL_STR
)
17218 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17219 LARGE_COMMUNITY_LIST_STANDARD
);
17222 DEFUN (no_lcommunity_list_expanded
,
17223 no_bgp_lcommunity_list_expanded_cmd
,
17224 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17227 LCOMMUNITY_LIST_STR
17228 "Large Community list number (expanded)\n"
17229 "Sequence number of an entry\n"
17230 "Sequence number\n"
17231 "Specify large community to reject\n"
17232 "Specify large community to accept\n"
17233 "An ordered list as a regular-expression\n")
17235 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17236 LARGE_COMMUNITY_LIST_EXPANDED
);
17239 DEFUN (no_lcommunity_list_name_standard
,
17240 no_bgp_lcommunity_list_name_standard_cmd
,
17241 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17244 LCOMMUNITY_LIST_STR
17245 "Specify standard large-community-list\n"
17246 "Large Community list name\n"
17247 "Sequence number of an entry\n"
17248 "Sequence number\n"
17249 "Specify large community to reject\n"
17250 "Specify large community to accept\n"
17251 LCOMMUNITY_VAL_STR
)
17253 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17254 LARGE_COMMUNITY_LIST_STANDARD
);
17257 DEFUN (no_lcommunity_list_name_expanded
,
17258 no_bgp_lcommunity_list_name_expanded_cmd
,
17259 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17262 LCOMMUNITY_LIST_STR
17263 "Specify expanded large-community-list\n"
17264 "Large community list name\n"
17265 "Sequence number of an entry\n"
17266 "Sequence number\n"
17267 "Specify large community to reject\n"
17268 "Specify large community to accept\n"
17269 "An ordered list as a regular-expression\n")
17271 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17272 LARGE_COMMUNITY_LIST_EXPANDED
);
17275 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
17277 struct community_entry
*entry
;
17279 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17280 if (entry
== list
->head
) {
17281 if (all_digit(list
->name
))
17282 vty_out(vty
, "Large community %s list %s\n",
17284 LARGE_COMMUNITY_LIST_STANDARD
17286 : "(expanded) access",
17290 "Named large community %s list %s\n",
17292 LARGE_COMMUNITY_LIST_STANDARD
17298 vty_out(vty
, " %s\n",
17299 community_direct_str(entry
->direct
));
17301 vty_out(vty
, " %s %s\n",
17302 community_direct_str(entry
->direct
),
17303 community_list_config_str(entry
));
17307 DEFUN (show_lcommunity_list
,
17308 show_bgp_lcommunity_list_cmd
,
17309 "show bgp large-community-list",
17312 "List large-community list\n")
17314 struct community_list
*list
;
17315 struct community_list_master
*cm
;
17317 cm
= community_list_master_lookup(bgp_clist
,
17318 LARGE_COMMUNITY_LIST_MASTER
);
17320 return CMD_SUCCESS
;
17322 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17323 lcommunity_list_show(vty
, list
);
17325 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17326 lcommunity_list_show(vty
, list
);
17328 return CMD_SUCCESS
;
17331 DEFUN (show_lcommunity_list_arg
,
17332 show_bgp_lcommunity_list_arg_cmd
,
17333 "show bgp large-community-list <(1-500)|WORD> detail",
17336 "List large-community list\n"
17337 "Large-community-list number\n"
17338 "Large-community-list name\n"
17339 "Detailed information on large-community-list\n")
17341 struct community_list
*list
;
17343 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
17344 LARGE_COMMUNITY_LIST_MASTER
);
17346 vty_out(vty
, "%% Can't find large-community-list\n");
17347 return CMD_WARNING
;
17350 lcommunity_list_show(vty
, list
);
17352 return CMD_SUCCESS
;
17355 /* "extcommunity-list" keyword help string. */
17356 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
17357 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
17359 DEFUN (extcommunity_list_standard
,
17360 bgp_extcommunity_list_standard_cmd
,
17361 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17363 EXTCOMMUNITY_LIST_STR
17364 "Extended Community list number (standard)\n"
17365 "Specify standard extcommunity-list\n"
17366 "Community list name\n"
17367 "Sequence number of an entry\n"
17368 "Sequence number\n"
17369 "Specify community to reject\n"
17370 "Specify community to accept\n"
17371 EXTCOMMUNITY_VAL_STR
)
17373 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17375 char *cl_number_or_name
= NULL
;
17380 argv_find(argv
, argc
, "(1-99)", &idx
);
17381 argv_find(argv
, argc
, "WORD", &idx
);
17382 cl_number_or_name
= argv
[idx
]->arg
;
17384 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17386 seq
= argv
[idx
]->arg
;
17388 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17390 argv_find(argv
, argc
, "AA:NN", &idx
);
17391 char *str
= argv_concat(argv
, argc
, idx
);
17393 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17396 XFREE(MTYPE_TMP
, str
);
17399 community_list_perror(vty
, ret
);
17400 return CMD_WARNING_CONFIG_FAILED
;
17403 return CMD_SUCCESS
;
17406 DEFUN (extcommunity_list_name_expanded
,
17407 bgp_extcommunity_list_name_expanded_cmd
,
17408 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
17410 EXTCOMMUNITY_LIST_STR
17411 "Extended Community list number (expanded)\n"
17412 "Specify expanded extcommunity-list\n"
17413 "Extended Community list name\n"
17414 "Sequence number of an entry\n"
17415 "Sequence number\n"
17416 "Specify community to reject\n"
17417 "Specify community to accept\n"
17418 "An ordered list as a regular-expression\n")
17420 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
17422 char *cl_number_or_name
= NULL
;
17426 argv_find(argv
, argc
, "(100-500)", &idx
);
17427 argv_find(argv
, argc
, "WORD", &idx
);
17428 cl_number_or_name
= argv
[idx
]->arg
;
17430 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17432 seq
= argv
[idx
]->arg
;
17434 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17436 argv_find(argv
, argc
, "LINE", &idx
);
17437 char *str
= argv_concat(argv
, argc
, idx
);
17439 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17442 XFREE(MTYPE_TMP
, str
);
17445 community_list_perror(vty
, ret
);
17446 return CMD_WARNING_CONFIG_FAILED
;
17449 return CMD_SUCCESS
;
17452 DEFUN (no_extcommunity_list_standard_all
,
17453 no_bgp_extcommunity_list_standard_all_cmd
,
17454 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17457 EXTCOMMUNITY_LIST_STR
17458 "Extended Community list number (standard)\n"
17459 "Specify standard extcommunity-list\n"
17460 "Community list name\n"
17461 "Sequence number of an entry\n"
17462 "Sequence number\n"
17463 "Specify community to reject\n"
17464 "Specify community to accept\n"
17465 EXTCOMMUNITY_VAL_STR
)
17467 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17469 char *cl_number_or_name
= NULL
;
17474 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17476 seq
= argv
[idx
]->arg
;
17479 argv_find(argv
, argc
, "permit", &idx
);
17480 argv_find(argv
, argc
, "deny", &idx
);
17482 direct
= argv_find(argv
, argc
, "permit", &idx
)
17487 argv_find(argv
, argc
, "AA:NN", &idx
);
17488 str
= argv_concat(argv
, argc
, idx
);
17492 argv_find(argv
, argc
, "(1-99)", &idx
);
17493 argv_find(argv
, argc
, "WORD", &idx
);
17494 cl_number_or_name
= argv
[idx
]->arg
;
17496 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
17497 seq
, direct
, style
);
17499 XFREE(MTYPE_TMP
, str
);
17502 community_list_perror(vty
, ret
);
17503 return CMD_WARNING_CONFIG_FAILED
;
17506 return CMD_SUCCESS
;
17509 ALIAS(no_extcommunity_list_standard_all
,
17510 no_bgp_extcommunity_list_standard_all_list_cmd
,
17511 "no bgp extcommunity-list <(1-99)|standard WORD>",
17512 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
17513 "Extended Community list number (standard)\n"
17514 "Specify standard extcommunity-list\n"
17515 "Community list name\n")
17517 DEFUN (no_extcommunity_list_expanded_all
,
17518 no_bgp_extcommunity_list_expanded_all_cmd
,
17519 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
17522 EXTCOMMUNITY_LIST_STR
17523 "Extended Community list number (expanded)\n"
17524 "Specify expanded extcommunity-list\n"
17525 "Extended Community list name\n"
17526 "Sequence number of an entry\n"
17527 "Sequence number\n"
17528 "Specify community to reject\n"
17529 "Specify community to accept\n"
17530 "An ordered list as a regular-expression\n")
17532 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
17534 char *cl_number_or_name
= NULL
;
17539 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17541 seq
= argv
[idx
]->arg
;
17544 argv_find(argv
, argc
, "permit", &idx
);
17545 argv_find(argv
, argc
, "deny", &idx
);
17548 direct
= argv_find(argv
, argc
, "permit", &idx
)
17553 argv_find(argv
, argc
, "LINE", &idx
);
17554 str
= argv_concat(argv
, argc
, idx
);
17558 argv_find(argv
, argc
, "(100-500)", &idx
);
17559 argv_find(argv
, argc
, "WORD", &idx
);
17560 cl_number_or_name
= argv
[idx
]->arg
;
17562 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
17563 seq
, direct
, style
);
17565 XFREE(MTYPE_TMP
, str
);
17568 community_list_perror(vty
, ret
);
17569 return CMD_WARNING_CONFIG_FAILED
;
17572 return CMD_SUCCESS
;
17575 ALIAS(no_extcommunity_list_expanded_all
,
17576 no_bgp_extcommunity_list_expanded_all_list_cmd
,
17577 "no bgp extcommunity-list <(100-500)|expanded WORD>",
17578 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
17579 "Extended Community list number (expanded)\n"
17580 "Specify expanded extcommunity-list\n"
17581 "Extended Community list name\n")
17583 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
17585 struct community_entry
*entry
;
17587 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17588 if (entry
== list
->head
) {
17589 if (all_digit(list
->name
))
17590 vty_out(vty
, "Extended community %s list %s\n",
17591 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17593 : "(expanded) access",
17597 "Named extended community %s list %s\n",
17598 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17604 vty_out(vty
, " %s\n",
17605 community_direct_str(entry
->direct
));
17607 vty_out(vty
, " %s %s\n",
17608 community_direct_str(entry
->direct
),
17609 community_list_config_str(entry
));
17613 DEFUN (show_extcommunity_list
,
17614 show_bgp_extcommunity_list_cmd
,
17615 "show bgp extcommunity-list",
17618 "List extended-community list\n")
17620 struct community_list
*list
;
17621 struct community_list_master
*cm
;
17623 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
17625 return CMD_SUCCESS
;
17627 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17628 extcommunity_list_show(vty
, list
);
17630 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17631 extcommunity_list_show(vty
, list
);
17633 return CMD_SUCCESS
;
17636 DEFUN (show_extcommunity_list_arg
,
17637 show_bgp_extcommunity_list_arg_cmd
,
17638 "show bgp extcommunity-list <(1-500)|WORD> detail",
17641 "List extended-community list\n"
17642 "Extcommunity-list number\n"
17643 "Extcommunity-list name\n"
17644 "Detailed information on extcommunity-list\n")
17646 int idx_comm_list
= 3;
17647 struct community_list
*list
;
17649 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
17650 EXTCOMMUNITY_LIST_MASTER
);
17652 vty_out(vty
, "%% Can't find extcommunity-list\n");
17653 return CMD_WARNING
;
17656 extcommunity_list_show(vty
, list
);
17658 return CMD_SUCCESS
;
17661 /* Display community-list and extcommunity-list configuration. */
17662 static int community_list_config_write(struct vty
*vty
)
17664 struct community_list
*list
;
17665 struct community_entry
*entry
;
17666 struct community_list_master
*cm
;
17669 /* Community-list. */
17670 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
17672 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17673 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17675 "bgp community-list %s seq %" PRId64
" %s %s\n",
17676 list
->name
, entry
->seq
,
17677 community_direct_str(entry
->direct
),
17678 community_list_config_str(entry
));
17681 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17682 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17684 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
17685 entry
->style
== COMMUNITY_LIST_STANDARD
17688 list
->name
, entry
->seq
,
17689 community_direct_str(entry
->direct
),
17690 community_list_config_str(entry
));
17694 /* Extcommunity-list. */
17695 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
17697 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17698 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17700 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
17701 list
->name
, entry
->seq
,
17702 community_direct_str(entry
->direct
),
17703 community_list_config_str(entry
));
17706 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17707 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17709 "bgp extcommunity-list %s %s seq %" PRId64
17711 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17714 list
->name
, entry
->seq
,
17715 community_direct_str(entry
->direct
),
17716 community_list_config_str(entry
));
17721 /* lcommunity-list. */
17722 cm
= community_list_master_lookup(bgp_clist
,
17723 LARGE_COMMUNITY_LIST_MASTER
);
17725 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17726 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17728 "bgp large-community-list %s seq %" PRId64
17730 list
->name
, entry
->seq
,
17731 community_direct_str(entry
->direct
),
17732 community_list_config_str(entry
));
17735 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17736 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17738 "bgp large-community-list %s %s seq %" PRId64
17741 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
17744 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
17745 community_list_config_str(entry
));
17752 static struct cmd_node community_list_node
= {
17753 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
17756 static void community_list_vty(void)
17758 install_node(&community_list_node
, community_list_config_write
);
17760 /* Community-list. */
17761 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
17762 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
17763 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
17764 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
17765 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
17766 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
17767 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
17768 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
17770 /* Extcommunity-list. */
17771 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
17772 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
17773 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
17774 install_element(CONFIG_NODE
,
17775 &no_bgp_extcommunity_list_standard_all_list_cmd
);
17776 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
17777 install_element(CONFIG_NODE
,
17778 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
17779 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
17780 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
17782 /* Large Community List */
17783 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
17784 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
17785 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
17786 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
17787 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
17788 install_element(CONFIG_NODE
,
17789 &no_bgp_lcommunity_list_name_standard_all_cmd
);
17790 install_element(CONFIG_NODE
,
17791 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
17792 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
17793 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
17794 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
17795 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
17796 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
17797 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);