1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
10 #include "lib/sockopt.h"
11 #include "lib_errors.h"
12 #include "lib/zclient.h"
13 #include "lib/printfrr.h"
29 #include "bgpd/bgpd.h"
30 #include "bgpd/bgp_attr_evpn.h"
31 #include "bgpd/bgp_advertise.h"
32 #include "bgpd/bgp_attr.h"
33 #include "bgpd/bgp_aspath.h"
34 #include "bgpd/bgp_community.h"
35 #include "bgpd/bgp_community_alias.h"
36 #include "bgpd/bgp_ecommunity.h"
37 #include "bgpd/bgp_lcommunity.h"
38 #include "bgpd/bgp_damp.h"
39 #include "bgpd/bgp_debug.h"
40 #include "bgpd/bgp_errors.h"
41 #include "bgpd/bgp_fsm.h"
42 #include "bgpd/bgp_nht.h"
43 #include "bgpd/bgp_nexthop.h"
44 #include "bgpd/bgp_network.h"
45 #include "bgpd/bgp_open.h"
46 #include "bgpd/bgp_regex.h"
47 #include "bgpd/bgp_route.h"
48 #include "bgpd/bgp_mplsvpn.h"
49 #include "bgpd/bgp_zebra.h"
50 #include "bgpd/bgp_table.h"
51 #include "bgpd/bgp_vty.h"
52 #include "bgpd/bgp_mpath.h"
53 #include "bgpd/bgp_packet.h"
54 #include "bgpd/bgp_updgrp.h"
55 #include "bgpd/bgp_bfd.h"
56 #include "bgpd/bgp_io.h"
57 #include "bgpd/bgp_evpn.h"
58 #include "bgpd/bgp_evpn_vty.h"
59 #include "bgpd/bgp_evpn_mh.h"
60 #include "bgpd/bgp_addpath.h"
61 #include "bgpd/bgp_mac.h"
62 #include "bgpd/bgp_flowspec.h"
63 #include "bgpd/bgp_conditional_adv.h"
65 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
68 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
71 .match_profile
= "traditional",
72 .match_version
= "< 7.4",
76 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
77 { .val_bool
= true, .match_profile
= "datacenter", },
78 { .val_bool
= false },
80 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
81 { .val_bool
= true, .match_profile
= "datacenter", },
82 { .val_bool
= false },
84 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
85 { .val_bool
= true, .match_profile
= "datacenter", },
86 { .val_bool
= false },
88 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
89 { .val_bool
= true, .match_profile
= "datacenter", },
90 { .val_bool
= false },
92 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
93 { .val_ulong
= 10, .match_profile
= "datacenter", },
96 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
97 { .val_ulong
= 9, .match_profile
= "datacenter", },
100 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
101 { .val_ulong
= 3, .match_profile
= "datacenter", },
104 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
105 { .val_bool
= false, .match_profile
= "datacenter", },
106 { .val_bool
= false, .match_version
= "< 7.4", },
107 { .val_bool
= true },
109 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
110 { .val_bool
= false, .match_version
= "< 7.6", },
111 { .val_bool
= true },
113 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
114 { .val_bool
= false, .match_version
= "< 8.3", },
115 { .val_bool
= true },
117 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
118 { .val_bool
= false, .match_version
= "< 8.3", },
119 { .val_bool
= true },
122 DEFINE_HOOK(bgp_inst_config_write
,
123 (struct bgp
*bgp
, struct vty
*vty
),
125 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
126 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
128 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
129 struct prefix
*range
, int exact
);
131 /* Show BGP peer's information. */
141 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
142 struct prefix
*range
, int exact
);
144 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
147 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
150 afi_t afi
, bool use_json
);
152 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
158 return BGP_IPV4_NODE
;
160 return BGP_IPV4M_NODE
;
161 case SAFI_LABELED_UNICAST
:
162 return BGP_IPV4L_NODE
;
164 return BGP_VPNV4_NODE
;
166 return BGP_FLOWSPECV4_NODE
;
172 return BGP_IPV4_NODE
;
178 return BGP_IPV6_NODE
;
180 return BGP_IPV6M_NODE
;
181 case SAFI_LABELED_UNICAST
:
182 return BGP_IPV6L_NODE
;
184 return BGP_VPNV6_NODE
;
186 return BGP_FLOWSPECV6_NODE
;
191 /* not expected and the return value seems wrong */
192 return BGP_IPV4_NODE
;
196 return BGP_EVPN_NODE
;
199 // We should never be here but to clarify the switch statement..
200 return BGP_IPV4_NODE
;
203 // Impossible to happen
204 return BGP_IPV4_NODE
;
207 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
210 if (safi
== SAFI_UNICAST
)
211 return "IPv4 Unicast";
212 if (safi
== SAFI_MULTICAST
)
213 return "IPv4 Multicast";
214 if (safi
== SAFI_LABELED_UNICAST
)
215 return "IPv4 Labeled Unicast";
216 if (safi
== SAFI_MPLS_VPN
)
218 if (safi
== SAFI_ENCAP
)
220 if (safi
== SAFI_FLOWSPEC
)
221 return "IPv4 Flowspec";
222 } else if (afi
== AFI_IP6
) {
223 if (safi
== SAFI_UNICAST
)
224 return "IPv6 Unicast";
225 if (safi
== SAFI_MULTICAST
)
226 return "IPv6 Multicast";
227 if (safi
== SAFI_LABELED_UNICAST
)
228 return "IPv6 Labeled Unicast";
229 if (safi
== SAFI_MPLS_VPN
)
231 if (safi
== SAFI_ENCAP
)
233 if (safi
== SAFI_FLOWSPEC
)
234 return "IPv6 Flowspec";
235 } else if (afi
== AFI_L2VPN
) {
236 if (safi
== SAFI_EVPN
)
244 * Please note that we have intentionally camelCased
245 * the return strings here. So if you want
246 * to use this function, please ensure you
247 * are doing this within json output
249 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
252 if (safi
== SAFI_UNICAST
)
253 return "ipv4Unicast";
254 if (safi
== SAFI_MULTICAST
)
255 return "ipv4Multicast";
256 if (safi
== SAFI_LABELED_UNICAST
)
257 return "ipv4LabeledUnicast";
258 if (safi
== SAFI_MPLS_VPN
)
260 if (safi
== SAFI_ENCAP
)
262 if (safi
== SAFI_FLOWSPEC
)
263 return "ipv4Flowspec";
264 } else if (afi
== AFI_IP6
) {
265 if (safi
== SAFI_UNICAST
)
266 return "ipv6Unicast";
267 if (safi
== SAFI_MULTICAST
)
268 return "ipv6Multicast";
269 if (safi
== SAFI_LABELED_UNICAST
)
270 return "ipv6LabeledUnicast";
271 if (safi
== SAFI_MPLS_VPN
)
273 if (safi
== SAFI_ENCAP
)
275 if (safi
== SAFI_FLOWSPEC
)
276 return "ipv6Flowspec";
277 } else if (afi
== AFI_L2VPN
) {
278 if (safi
== SAFI_EVPN
)
285 /* unset srv6 locator */
286 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
289 struct listnode
*node
, *nnode
;
290 struct srv6_locator_chunk
*chunk
;
291 struct bgp_srv6_function
*func
;
294 /* release chunk notification via ZAPI */
295 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
296 bgp
->srv6_locator_name
);
301 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
302 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
303 srv6_locator_chunk_free(&chunk
);
306 /* refresh functions */
307 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
308 listnode_delete(bgp
->srv6_functions
, func
);
309 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
312 /* refresh tovpn_sid */
313 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
314 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
317 /* refresh vpnv4 tovpn_sid */
318 XFREE(MTYPE_BGP_SRV6_SID
,
319 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
321 /* refresh vpnv6 tovpn_sid */
322 XFREE(MTYPE_BGP_SRV6_SID
,
323 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
325 /* refresh per-vrf tovpn_sid */
326 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
329 /* update vpn bgp processes */
330 vpn_leak_postchange_all();
332 /* refresh tovpn_sid_locator */
333 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
334 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
337 /* refresh vpnv4 tovpn_sid_locator */
338 srv6_locator_chunk_free(
339 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
341 /* refresh vpnv6 tovpn_sid_locator */
342 srv6_locator_chunk_free(
343 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
345 /* refresh per-vrf tovpn_sid_locator */
346 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
349 /* clear locator name */
350 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
355 /* Utility function to get address family from current node. */
356 afi_t
bgp_node_afi(struct vty
*vty
)
364 case BGP_FLOWSPECV6_NODE
:
377 /* Utility function to get subsequent address family from current
379 safi_t
bgp_node_safi(struct vty
*vty
)
385 safi
= SAFI_MPLS_VPN
;
389 safi
= SAFI_MULTICAST
;
396 safi
= SAFI_LABELED_UNICAST
;
398 case BGP_FLOWSPECV4_NODE
:
399 case BGP_FLOWSPECV6_NODE
:
400 safi
= SAFI_FLOWSPEC
;
410 * Converts an AFI in string form to afi_t
412 * @param afi string, one of
416 * @return the corresponding afi_t
418 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
420 afi_t afi
= AFI_MAX
; /* unknown */
421 if (strmatch(afi_str
, "ipv4"))
423 else if (strmatch(afi_str
, "ipv6"))
425 else if (strmatch(afi_str
, "l2vpn"))
430 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
434 if (argv_find(argv
, argc
, "ipv4", index
)) {
438 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
442 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
450 /* supports <unicast|multicast|vpn|labeled-unicast> */
451 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
453 safi_t safi
= SAFI_MAX
; /* unknown */
454 if (strmatch(safi_str
, "multicast"))
455 safi
= SAFI_MULTICAST
;
456 else if (strmatch(safi_str
, "unicast"))
458 else if (strmatch(safi_str
, "vpn"))
459 safi
= SAFI_MPLS_VPN
;
460 else if (strmatch(safi_str
, "evpn"))
462 else if (strmatch(safi_str
, "labeled-unicast"))
463 safi
= SAFI_LABELED_UNICAST
;
464 else if (strmatch(safi_str
, "flowspec"))
465 safi
= SAFI_FLOWSPEC
;
469 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
473 if (argv_find(argv
, argc
, "unicast", index
)) {
476 *safi
= SAFI_UNICAST
;
477 } else if (argv_find(argv
, argc
, "multicast", index
)) {
480 *safi
= SAFI_MULTICAST
;
481 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
484 *safi
= SAFI_LABELED_UNICAST
;
485 } else if (argv_find(argv
, argc
, "vpn", index
)) {
488 *safi
= SAFI_MPLS_VPN
;
489 } else if (argv_find(argv
, argc
, "evpn", index
)) {
493 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
496 *safi
= SAFI_FLOWSPEC
;
502 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
505 * address-family identifier
508 * subsequent address-family identifier
511 * default_af string corresponding to the supplied afi/safi pair.
512 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
515 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
521 return "ipv4-unicast";
523 return "ipv4-multicast";
528 case SAFI_LABELED_UNICAST
:
529 return "ipv4-labeled-unicast";
531 return "ipv4-flowspec";
535 return "unknown-afi/safi";
541 return "ipv6-unicast";
543 return "ipv6-multicast";
548 case SAFI_LABELED_UNICAST
:
549 return "ipv6-labeled-unicast";
551 return "ipv6-flowspec";
555 return "unknown-afi/safi";
566 case SAFI_LABELED_UNICAST
:
570 return "unknown-afi/safi";
575 return "unknown-afi/safi";
577 /* all AFIs are accounted for above, so this shouldn't happen */
579 assert(!"Reached end of function where we did not expect to");
582 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
583 enum bgp_instance_type inst_type
, const char *as_pretty
,
584 enum asnotation_mode asnotation
)
586 int ret
= bgp_get(bgp
, as
, name
, inst_type
, as_pretty
, asnotation
);
588 if (ret
== BGP_CREATED
) {
589 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
590 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
592 if (DFLT_BGP_IMPORT_CHECK
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
594 if (DFLT_BGP_SHOW_HOSTNAME
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
596 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
598 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
600 if (DFLT_BGP_DETERMINISTIC_MED
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
602 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
604 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
606 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
607 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
608 if (DFLT_BGP_HARD_ADMIN_RESET
)
609 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
617 * bgp_vty_find_and_parse_afi_safi_bgp
619 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
620 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
621 * to appropriate values for the calling function. This is to allow the
622 * calling function to make decisions appropriate for the show command
623 * that is being parsed.
625 * The show commands are generally of the form:
626 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
627 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
629 * Since we use argv_find if the show command in particular doesn't have:
631 * [<view|vrf> VIEWVRFNAME]
632 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
633 * The command parsing should still be ok.
635 * vty -> The vty for the command so we can output some useful data in
636 * the event of a parse error in the vrf.
637 * argv -> The command tokens
638 * argc -> How many command tokens we have
639 * idx -> The current place in the command, generally should be 0 for this
641 * afi -> The parsed afi if it was included in the show command, returned here
642 * safi -> The parsed safi if it was included in the show command, returned here
643 * bgp -> Pointer to the bgp data structure we need to fill in.
644 * use_json -> json is configured or not
646 * The function returns the correct location in the parse tree for the
649 * Returns 0 for failure to parse correctly, else the idx position of where
650 * it found the last token.
652 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
653 struct cmd_token
**argv
, int argc
,
654 int *idx
, afi_t
*afi
, safi_t
*safi
,
655 struct bgp
**bgp
, bool use_json
)
657 char *vrf_name
= NULL
;
663 if (argv_find(argv
, argc
, "ip", idx
))
666 if (argv_find(argv
, argc
, "view", idx
))
667 vrf_name
= argv
[*idx
+ 1]->arg
;
668 else if (argv_find(argv
, argc
, "vrf", idx
)) {
669 vrf_name
= argv
[*idx
+ 1]->arg
;
670 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
674 if (strmatch(vrf_name
, "all"))
677 *bgp
= bgp_lookup_by_name(vrf_name
);
680 json_object
*json
= NULL
;
681 json
= json_object_new_object();
682 json_object_string_add(
684 "View/Vrf is unknown");
688 vty_out(vty
, "View/Vrf %s is unknown\n",
695 *bgp
= bgp_get_default();
698 json_object
*json
= NULL
;
699 json
= json_object_new_object();
700 json_object_string_add(
702 "Default BGP instance not found");
707 "Default BGP instance not found\n");
713 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
714 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
720 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
722 struct interface
*ifp
= NULL
;
723 struct listnode
*node
;
724 struct bgp_listener
*listener
;
725 union sockunion all_su
;
727 if (su
->sa
.sa_family
== AF_INET
) {
728 (void)str2sockunion("0.0.0.0", &all_su
);
729 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
730 } else if (su
->sa
.sa_family
== AF_INET6
) {
731 (void)str2sockunion("::", &all_su
);
732 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
733 su
->sin6
.sin6_scope_id
,
738 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
739 if (sockunion_family(su
) !=
740 sockunion_family(&listener
->su
))
743 /* If 0.0.0.0/:: is a listener, then treat as self and
746 if (!sockunion_cmp(&listener
->su
, su
) ||
747 !sockunion_cmp(&listener
->su
, &all_su
))
755 /* Utility function for looking up peer from VTY. */
756 /* This is used only for configuration, so disallow if attempted on
757 * a dynamic neighbor.
759 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
761 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
770 ret
= str2sockunion(ip_str
, &su
);
772 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
774 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
777 "%% Malformed address or name: %s\n",
783 peer
= peer_lookup(bgp
, &su
);
786 "%% Specify remote-as or peer-group commands first\n");
789 if (peer_dynamic_neighbor(peer
)) {
791 "%% Operation not allowed on a dynamic neighbor\n");
798 /* Utility function for looking up peer or peer group. */
799 /* This is used only for configuration, so disallow if attempted on
800 * a dynamic neighbor.
802 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
804 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
807 struct peer
*peer
= NULL
;
808 struct peer_group
*group
= NULL
;
814 ret
= str2sockunion(peer_str
, &su
);
816 /* IP address, locate peer. */
817 peer
= peer_lookup(bgp
, &su
);
819 /* Not IP, could match either peer configured on interface or a
821 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
823 group
= peer_group_lookup(bgp
, peer_str
);
827 if (peer_dynamic_neighbor(peer
)) {
829 "%pBP: Operation not allowed on a dynamic neighbor",
832 "%% Operation not allowed on a dynamic neighbor\n");
842 zlog_warn("Specify remote-as or peer-group commands first before: %s",
844 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
849 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
851 const char *str
= NULL
;
856 case BGP_GR_NO_OPERATION
:
858 case BGP_ERR_INVALID_VALUE
:
859 str
= "Invalid value";
861 case BGP_ERR_INVALID_FLAG
:
862 str
= "Invalid flag";
864 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
865 str
= "Peer-group has been shutdown. Activate the peer-group first";
867 case BGP_ERR_PEER_FLAG_CONFLICT
:
868 str
= "Can't set override-capability and strict-capability-match at the same time";
870 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
871 str
= "Specify remote-as or peer-group remote AS first";
873 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
874 str
= "Cannot change the peer-group. Deconfigure first";
876 case BGP_ERR_PEER_GROUP_MISMATCH
:
877 str
= "Peer is not a member of this peer-group";
879 case BGP_ERR_PEER_FILTER_CONFLICT
:
880 str
= "Prefix/distribute list can not co-exist";
882 case BGP_ERR_NOT_INTERNAL_PEER
:
883 str
= "Invalid command. Not an internal neighbor";
885 case BGP_ERR_REMOVE_PRIVATE_AS
:
886 str
= "remove-private-AS cannot be configured for IBGP peers";
888 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
889 str
= "Cannot have local-as same as BGP AS number";
891 case BGP_ERR_TCPSIG_FAILED
:
892 str
= "Error while applying TCP-Sig to session(s)";
894 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
895 str
= "ebgp-multihop and ttl-security cannot be configured together";
897 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
898 str
= "ttl-security only allowed for EBGP peers";
900 case BGP_ERR_AS_OVERRIDE
:
901 str
= "as-override cannot be configured for IBGP peers";
903 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
904 str
= "Invalid limit for number of dynamic neighbors";
906 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
907 str
= "Dynamic neighbor listen range already exists";
909 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
910 str
= "Operation not allowed on a dynamic neighbor";
912 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
913 str
= "Operation not allowed on a directly connected neighbor";
915 case BGP_ERR_PEER_SAFI_CONFLICT
:
916 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
918 case BGP_ERR_GR_INVALID_CMD
:
919 str
= "The Graceful Restart command used is not valid at this moment.";
921 case BGP_ERR_GR_OPERATION_FAILED
:
922 str
= "The Graceful Restart Operation failed due to an err.";
924 case BGP_ERR_PEER_GROUP_MEMBER
:
925 str
= "Peer-group member cannot override remote-as of peer-group.";
927 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
928 str
= "Peer-group members must be all internal or all external.";
930 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
931 str
= "Range specified cannot be deleted because it is not part of current config.";
933 case BGP_ERR_INSTANCE_MISMATCH
:
934 str
= "Instance specified does not match the current instance.";
936 case BGP_ERR_NO_INTERFACE_CONFIG
:
937 str
= "Interface specified is not being used for interface based peer.";
939 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
940 str
= "No configuration already specified for soft reconfiguration.";
942 case BGP_ERR_AS_MISMATCH
:
943 str
= "BGP is already running.";
945 case BGP_ERR_AF_UNCONFIGURED
:
946 str
= "AFI/SAFI specified is not currently configured.";
948 case BGP_ERR_INVALID_AS
:
949 str
= "Confederation AS specified is the same AS as our AS.";
951 case BGP_ERR_INVALID_ROLE_NAME
:
952 str
= "Invalid role name";
954 case BGP_ERR_INVALID_INTERNAL_ROLE
:
955 str
= "External roles can be set only on eBGP session";
959 vty_out(vty
, "%% %s\n", str
);
960 return CMD_WARNING_CONFIG_FAILED
;
965 /* BGP clear sort. */
974 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
975 safi_t safi
, int error
)
978 case BGP_ERR_AF_UNCONFIGURED
:
981 "%% BGP: Enable %s address family for the neighbor %s\n",
982 get_afi_safi_str(afi
, safi
, false), peer
->host
);
985 "%% BGP: Enable %s address family for the neighbor %s",
986 get_afi_safi_str(afi
, safi
, false), peer
->host
);
988 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
991 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
995 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
1003 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1004 struct listnode
**nnode
, enum bgp_clear_type stype
)
1007 struct peer_af
*paf
;
1009 /* if afi/.safi not specified, spin thru all of them */
1010 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1013 enum bgp_af_index index
;
1015 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1016 paf
= peer
->peer_af_array
[index
];
1020 if (paf
&& paf
->subgroup
)
1021 SET_FLAG(paf
->subgroup
->sflags
,
1022 SUBGRP_STATUS_FORCE_UPDATES
);
1025 tmp_safi
= paf
->safi
;
1026 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1029 if (stype
== BGP_CLEAR_SOFT_NONE
)
1030 ret
= peer_clear(peer
, nnode
);
1032 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1035 /* if afi specified and safi not, spin thru safis on this afi */
1036 } else if (safi
== SAFI_UNSPEC
) {
1039 for (tmp_safi
= SAFI_UNICAST
;
1040 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1041 if (!peer
->afc
[afi
][tmp_safi
])
1044 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1045 if (paf
&& paf
->subgroup
)
1046 SET_FLAG(paf
->subgroup
->sflags
,
1047 SUBGRP_STATUS_FORCE_UPDATES
);
1049 if (stype
== BGP_CLEAR_SOFT_NONE
)
1050 ret
= peer_clear(peer
, nnode
);
1052 ret
= peer_clear_soft(peer
, afi
,
1055 /* both afi/safi specified, let the caller know if not defined */
1057 if (!peer
->afc
[afi
][safi
])
1060 paf
= peer_af_find(peer
, afi
, safi
);
1061 if (paf
&& paf
->subgroup
)
1062 SET_FLAG(paf
->subgroup
->sflags
,
1063 SUBGRP_STATUS_FORCE_UPDATES
);
1065 if (stype
== BGP_CLEAR_SOFT_NONE
)
1066 ret
= peer_clear(peer
, nnode
);
1068 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1074 /* `clear ip bgp' functions. */
1075 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1076 enum clear_sort sort
, enum bgp_clear_type stype
,
1083 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1085 /* Clear all neighbors. */
1087 * Pass along pointer to next node to peer_clear() when walking all
1088 * nodes on the BGP instance as that may get freed if it is a
1091 if (sort
== clear_all
) {
1092 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1094 bgp_peer_gr_flags_update(peer
);
1096 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1097 gr_router_detected
= true;
1099 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1103 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1106 if (gr_router_detected
1107 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1108 bgp_zebra_send_capabilities(bgp
, false);
1109 } else if (!gr_router_detected
1110 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1111 bgp_zebra_send_capabilities(bgp
, true);
1114 /* This is to apply read-only mode on this clear. */
1115 if (stype
== BGP_CLEAR_SOFT_NONE
)
1116 bgp
->update_delay_over
= 0;
1121 /* Clear specified neighbor. */
1122 if (sort
== clear_peer
) {
1125 /* Make sockunion for lookup. */
1126 ret
= str2sockunion(arg
, &su
);
1128 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1130 peer
= peer_lookup_by_hostname(bgp
, arg
);
1133 "Malformed address or name: %s\n",
1139 peer
= peer_lookup(bgp
, &su
);
1142 "%% BGP: Unknown neighbor - \"%s\"\n",
1148 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1149 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1151 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1153 /* if afi/safi not defined for this peer, let caller know */
1155 ret
= BGP_ERR_AF_UNCONFIGURED
;
1158 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1163 /* Clear all neighbors belonging to a specific peer-group. */
1164 if (sort
== clear_group
) {
1165 struct peer_group
*group
;
1167 group
= peer_group_lookup(bgp
, arg
);
1169 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1173 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1174 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1177 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1184 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1185 get_afi_safi_str(afi
, safi
, false), arg
);
1190 /* Clear all external (eBGP) neighbors. */
1191 if (sort
== clear_external
) {
1192 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1193 if (peer
->sort
== BGP_PEER_IBGP
)
1196 bgp_peer_gr_flags_update(peer
);
1198 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1199 gr_router_detected
= true;
1201 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1204 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1209 if (gr_router_detected
1210 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1211 bgp_zebra_send_capabilities(bgp
, false);
1212 } else if (!gr_router_detected
1213 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1214 bgp_zebra_send_capabilities(bgp
, true);
1219 "%% BGP: No external %s peer is configured\n",
1220 get_afi_safi_str(afi
, safi
, false));
1225 /* Clear all neighbors belonging to a specific AS. */
1226 if (sort
== clear_as
) {
1229 if (!asn_str2asn(arg
, &as
)) {
1230 vty_out(vty
, "%% BGP: No such AS %s\n", arg
);
1234 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1238 bgp_peer_gr_flags_update(peer
);
1240 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1241 gr_router_detected
= true;
1243 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1246 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1251 if (gr_router_detected
1252 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1253 bgp_zebra_send_capabilities(bgp
, false);
1254 } else if (!gr_router_detected
1255 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1256 bgp_zebra_send_capabilities(bgp
, true);
1261 "%% BGP: No %s peer is configured with AS %s\n",
1262 get_afi_safi_str(afi
, safi
, false), arg
);
1270 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1271 safi_t safi
, enum clear_sort sort
,
1272 enum bgp_clear_type stype
, const char *arg
)
1276 /* BGP structure lookup. */
1278 bgp
= bgp_lookup_by_name(name
);
1280 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1284 bgp
= bgp_get_default();
1286 vty_out(vty
, "No BGP process is configured\n");
1291 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1294 /* clear soft inbound */
1295 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1300 FOREACH_AFI_SAFI (afi
, safi
)
1301 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1302 BGP_CLEAR_SOFT_IN
, NULL
);
1305 /* clear soft outbound */
1306 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1311 FOREACH_AFI_SAFI (afi
, safi
)
1312 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1313 BGP_CLEAR_SOFT_OUT
, NULL
);
1317 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1319 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1322 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1323 uint64_t flag
, int set
)
1328 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1330 return CMD_WARNING_CONFIG_FAILED
;
1333 * If 'neighbor <interface>', then this is for directly connected peers,
1334 * we should not accept disable-connected-check.
1336 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1338 "%s is directly connected peer, cannot accept disable-connected-check\n",
1340 return CMD_WARNING_CONFIG_FAILED
;
1343 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1344 peer_tx_shutdown_message_unset(peer
);
1347 ret
= peer_flag_set(peer
, flag
);
1349 ret
= peer_flag_unset(peer
, flag
);
1351 return bgp_vty_return(vty
, ret
);
1354 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1356 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1359 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1362 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1365 #include "bgpd/bgp_vty_clippy.c"
1367 DEFUN_HIDDEN (bgp_local_mac
,
1369 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1371 "Local MAC config\n"
1372 "VxLAN Network Identifier\n"
1376 "mac-mobility sequence\n"
1386 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1387 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1388 vty_out(vty
, "%% Malformed MAC address\n");
1391 memset(&ip
, 0, sizeof(ip
));
1392 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1394 bgp
= bgp_get_default();
1396 vty_out(vty
, "Default BGP instance is not there\n");
1400 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1403 vty_out(vty
, "Internal error\n");
1410 DEFUN_HIDDEN (no_bgp_local_mac
,
1411 no_bgp_local_mac_cmd
,
1412 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1415 "Local MAC config\n"
1416 "VxLAN Network Identifier\n"
1427 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1428 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1429 vty_out(vty
, "%% Malformed MAC address\n");
1432 memset(&ip
, 0, sizeof(ip
));
1434 bgp
= bgp_get_default();
1436 vty_out(vty
, "Default BGP instance is not there\n");
1440 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1442 vty_out(vty
, "Internal error\n");
1449 DEFUN (no_synchronization
,
1450 no_synchronization_cmd
,
1451 "no synchronization",
1453 "Perform IGP synchronization\n")
1458 DEFUN (no_auto_summary
,
1459 no_auto_summary_cmd
,
1462 "Enable automatic network number summarization\n")
1467 /* "router bgp" commands. */
1468 DEFUN_NOSH (router_bgp
,
1470 "router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME] [as-notation <dot|dot+|plain>]]",
1474 BGP_INSTANCE_HELP_STR
1475 "Force the AS notation output\n"
1476 "use 'AA.BB' format for AS 4 byte values\n"
1477 "use 'AA.BB' format for all AS values\n"
1478 "use plain format for all AS values\n")
1481 int idx_view_vrf
= 3;
1484 int idx_asnotation
= 3;
1485 int idx_asnotation_kind
= 4;
1486 enum asnotation_mode asnotation
= ASNOTATION_UNDEFINED
;
1490 const char *name
= NULL
;
1491 enum bgp_instance_type inst_type
;
1493 // "router bgp" without an ASN
1495 // Pending: Make VRF option available for ASN less config
1496 bgp
= bgp_get_default();
1499 vty_out(vty
, "%% No BGP process is configured\n");
1500 return CMD_WARNING_CONFIG_FAILED
;
1503 if (listcount(bm
->bgp
) > 1) {
1504 vty_out(vty
, "%% Please specify ASN and VRF\n");
1505 return CMD_WARNING_CONFIG_FAILED
;
1511 if (!asn_str2asn(argv
[idx_asn
]->arg
, &as
)) {
1512 vty_out(vty
, "%% BGP: No such AS %s\n",
1513 argv
[idx_asn
]->arg
);
1514 return CMD_WARNING_CONFIG_FAILED
;
1517 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1518 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1519 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1521 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1523 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx_vrf
)) {
1524 idx_view_vrf
= idx_vrf
- 1;
1525 if (argv
[idx_view_vrf
]->text
) {
1526 name
= argv
[idx_vrf
]->arg
;
1528 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1529 if (strmatch(name
, VRF_DEFAULT_NAME
))
1533 BGP_INSTANCE_TYPE_VRF
;
1534 } else if (!strcmp(argv
[idx_view_vrf
]->text
,
1536 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1539 if (argv_find(argv
, argc
, "as-notation", &idx_asnotation
)) {
1540 idx_asnotation_kind
= idx_asnotation
+ 1;
1541 if (strmatch(argv
[idx_asnotation_kind
]->text
, "dot+"))
1542 asnotation
= ASNOTATION_DOTPLUS
;
1543 else if (strmatch(argv
[idx_asnotation_kind
]->text
,
1545 asnotation
= ASNOTATION_DOT
;
1546 else if (strmatch(argv
[idx_asnotation_kind
]->text
,
1548 asnotation
= ASNOTATION_PLAIN
;
1551 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1552 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1554 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
,
1555 argv
[idx_asn
]->arg
, asnotation
);
1557 case BGP_ERR_AS_MISMATCH
:
1558 vty_out(vty
, "BGP is already running; AS is %s\n",
1560 return CMD_WARNING_CONFIG_FAILED
;
1561 case BGP_ERR_INSTANCE_MISMATCH
:
1563 "BGP instance name and AS number mismatch\n");
1565 "BGP instance is already running; AS is %s\n",
1567 return CMD_WARNING_CONFIG_FAILED
;
1571 * If we just instantiated the default instance, complete
1572 * any pending VRF-VPN leaking that was configured via
1573 * earlier "router bgp X vrf FOO" blocks.
1575 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1576 vpn_leak_postchange_all();
1578 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1579 bgp_vpn_leak_export(bgp
);
1580 /* Pending: handle when user tries to change a view to vrf n vv.
1582 /* for pre-existing bgp instance,
1583 * - update as_pretty
1584 * - update asnotation if explicitly mentioned
1586 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
)) {
1587 XFREE(MTYPE_BGP
, bgp
->as_pretty
);
1588 bgp
->as_pretty
= XSTRDUP(MTYPE_BGP
, argv
[idx_asn
]->arg
);
1589 if (!CHECK_FLAG(bgp
->config
, BGP_CONFIG_ASNOTATION
) &&
1590 asnotation
!= ASNOTATION_UNDEFINED
) {
1591 SET_FLAG(bgp
->config
, BGP_CONFIG_ASNOTATION
);
1592 bgp
->asnotation
= asnotation
;
1597 /* unset the auto created flag as the user config is now present */
1598 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1599 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1604 /* "no router bgp" commands. */
1605 DEFUN (no_router_bgp
,
1607 "no router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME] [as-notation <dot|dot+|plain>]]",
1612 BGP_INSTANCE_HELP_STR
1613 "Force the AS notation output\n"
1614 "use 'AA.BB' format for AS 4 byte values\n"
1615 "use 'AA.BB' format for all AS values\n"
1616 "use plain format for all AS values\n")
1622 const char *name
= NULL
;
1624 // "no router bgp" without an ASN
1626 // Pending: Make VRF option available for ASN less config
1627 bgp
= bgp_get_default();
1630 vty_out(vty
, "%% No BGP process is configured\n");
1631 return CMD_WARNING_CONFIG_FAILED
;
1634 if (listcount(bm
->bgp
) > 1) {
1635 vty_out(vty
, "%% Please specify ASN and VRF\n");
1636 return CMD_WARNING_CONFIG_FAILED
;
1640 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1642 return CMD_WARNING_CONFIG_FAILED
;
1645 if (!asn_str2asn(argv
[idx_asn
]->arg
, &as
)) {
1646 vty_out(vty
, "%% BGP: No such AS %s\n",
1647 argv
[idx_asn
]->arg
);
1648 return CMD_WARNING_CONFIG_FAILED
;
1651 name
= argv
[idx_vrf
]->arg
;
1652 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1653 && strmatch(name
, VRF_DEFAULT_NAME
))
1657 /* Lookup bgp structure. */
1658 bgp
= bgp_lookup(as
, name
);
1660 vty_out(vty
, "%% Can't find BGP instance\n");
1661 return CMD_WARNING_CONFIG_FAILED
;
1665 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1667 return CMD_WARNING_CONFIG_FAILED
;
1670 /* Cannot delete default instance if vrf instances exist */
1671 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1672 struct listnode
*node
;
1673 struct bgp
*tmp_bgp
;
1675 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1676 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1678 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1679 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1680 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1681 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1682 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1683 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1684 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1685 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1686 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1687 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1688 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1689 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1690 (bgp
== bgp_get_evpn() &&
1691 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1692 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1693 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1694 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1695 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1696 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1697 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1698 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1699 (hashcount(tmp_bgp
->vnihash
))) {
1701 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1702 return CMD_WARNING_CONFIG_FAILED
;
1713 /* bgp session-dscp */
1715 DEFPY (bgp_session_dscp
,
1716 bgp_session_dscp_cmd
,
1717 "bgp session-dscp (0-63)$dscp",
1719 "Override default (C6) bgp TCP session DSCP value\n"
1720 "Manually configured dscp parameter\n")
1722 bm
->tcp_dscp
= dscp
<< 2;
1727 DEFPY (no_bgp_session_dscp
,
1728 no_bgp_session_dscp_cmd
,
1729 "no bgp session-dscp [(0-63)]",
1732 "Override default (C6) bgp TCP session DSCP value\n"
1733 "Manually configured dscp parameter\n")
1735 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1740 /* BGP router-id. */
1742 DEFPY (bgp_router_id
,
1744 "bgp router-id A.B.C.D",
1746 "Override configured router identifier\n"
1747 "Manually configured router identifier\n")
1749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1750 bgp_router_id_static_set(bgp
, router_id
);
1754 DEFPY (no_bgp_router_id
,
1755 no_bgp_router_id_cmd
,
1756 "no bgp router-id [A.B.C.D]",
1759 "Override configured router identifier\n"
1760 "Manually configured router identifier\n")
1762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1764 if (router_id_str
) {
1765 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1766 vty_out(vty
, "%% BGP router-id doesn't match\n");
1767 return CMD_WARNING_CONFIG_FAILED
;
1771 router_id
.s_addr
= 0;
1772 bgp_router_id_static_set(bgp
, router_id
);
1777 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1778 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1780 "Add community specific parameters\n"
1781 "Create an alias for a community\n"
1782 "Community (AA:BB or AA:BB:CC)\n"
1785 struct community_alias ca
= {};
1786 struct community_alias
*lookup_community
;
1787 struct community_alias
*lookup_alias
;
1788 struct community
*comm
;
1789 struct lcommunity
*lcomm
;
1790 uint8_t invalid
= 0;
1792 comm
= community_str2com(community
);
1795 community_free(&comm
);
1797 lcomm
= lcommunity_str2com(community
);
1800 lcommunity_free(&lcomm
);
1803 vty_out(vty
, "Invalid community format\n");
1807 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1808 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1810 lookup_community
= bgp_ca_community_lookup(&ca
);
1811 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1814 bgp_ca_alias_delete(&ca
);
1815 bgp_ca_community_delete(&ca
);
1818 /* Lookup if community hash table has an item
1819 * with the same alias name.
1821 strlcpy(ca
.community
, lookup_alias
->community
,
1822 sizeof(ca
.community
));
1823 if (bgp_ca_community_lookup(&ca
)) {
1825 "community (%s) already has this alias (%s)\n",
1826 lookup_alias
->community
,
1827 lookup_alias
->alias
);
1830 bgp_ca_alias_delete(&ca
);
1833 if (lookup_community
) {
1834 /* Lookup if alias hash table has an item
1835 * with the same community.
1837 strlcpy(ca
.alias
, lookup_community
->alias
,
1839 if (bgp_ca_alias_lookup(&ca
)) {
1841 "alias (%s) already has this community (%s)\n",
1842 lookup_community
->alias
,
1843 lookup_community
->community
);
1846 bgp_ca_community_delete(&ca
);
1849 bgp_ca_alias_insert(&ca
);
1850 bgp_ca_community_insert(&ca
);
1856 DEFPY (bgp_global_suppress_fib_pending
,
1857 bgp_global_suppress_fib_pending_cmd
,
1858 "[no] bgp suppress-fib-pending",
1861 "Advertise only routes that are programmed in kernel to peers globally\n")
1863 bm_wait_for_fib_set(!no
);
1868 DEFPY (bgp_suppress_fib_pending
,
1869 bgp_suppress_fib_pending_cmd
,
1870 "[no] bgp suppress-fib-pending",
1873 "Advertise only routes that are programmed in kernel to peers\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1877 bgp_suppress_fib_pending_set(bgp
, !no
);
1881 /* BGP Cluster ID. */
1882 DEFUN (bgp_cluster_id
,
1884 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1886 "Configure Route-Reflector Cluster-id\n"
1887 "Route-Reflector Cluster-id in IP address format\n"
1888 "Route-Reflector Cluster-id as 32 bit quantity\n")
1890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1893 struct in_addr cluster
;
1895 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1897 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1898 return CMD_WARNING_CONFIG_FAILED
;
1901 bgp_cluster_id_set(bgp
, &cluster
);
1902 bgp_clear_star_soft_out(vty
, bgp
->name
);
1907 DEFUN (no_bgp_cluster_id
,
1908 no_bgp_cluster_id_cmd
,
1909 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1912 "Configure Route-Reflector Cluster-id\n"
1913 "Route-Reflector Cluster-id in IP address format\n"
1914 "Route-Reflector Cluster-id as 32 bit quantity\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1917 bgp_cluster_id_unset(bgp
);
1918 bgp_clear_star_soft_out(vty
, bgp
->name
);
1927 "Disable BGP route installation to RIB (Zebra)\n")
1929 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1931 "%% No-RIB option is already set, nothing to do here.\n");
1935 bgp_option_norib_set_runtime();
1940 DEFPY (no_bgp_norib
,
1945 "Disable BGP route installation to RIB (Zebra)\n")
1947 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1949 "%% No-RIB option is not set, nothing to do here.\n");
1953 bgp_option_norib_unset_runtime();
1958 DEFPY (no_bgp_send_extra_data
,
1959 no_bgp_send_extra_data_cmd
,
1960 "[no] bgp send-extra-data zebra",
1963 "Extra data to Zebra for display/use\n"
1967 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1969 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1974 DEFUN (bgp_confederation_identifier
,
1975 bgp_confederation_identifier_cmd
,
1976 "bgp confederation identifier ASNUM",
1978 "AS confederation parameters\n"
1980 "Set routing domain confederation AS\n")
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1986 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
1987 vty_out(vty
, "%% BGP: No such AS %s\n", argv
[idx_number
]->arg
);
1988 return CMD_WARNING_CONFIG_FAILED
;
1991 bgp_confederation_id_set(bgp
, as
, argv
[idx_number
]->arg
);
1996 DEFUN (no_bgp_confederation_identifier
,
1997 no_bgp_confederation_identifier_cmd
,
1998 "no bgp confederation identifier [ASNUM]",
2001 "AS confederation parameters\n"
2003 "Set routing domain confederation AS\n")
2005 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2006 bgp_confederation_id_unset(bgp
);
2011 DEFUN (bgp_confederation_peers
,
2012 bgp_confederation_peers_cmd
,
2013 "bgp confederation peers ASNUM...",
2015 "AS confederation parameters\n"
2016 "Peer ASs in BGP confederation\n"
2019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2024 for (i
= idx_asn
; i
< argc
; i
++) {
2025 if (!asn_str2asn(argv
[i
]->arg
, &as
)) {
2026 vty_out(vty
, "%% Invalid confed peer AS value: %s\n",
2031 bgp_confederation_peers_add(bgp
, as
, argv
[i
]->arg
);
2036 DEFUN (no_bgp_confederation_peers
,
2037 no_bgp_confederation_peers_cmd
,
2038 "no bgp confederation peers ASNUM...",
2041 "AS confederation parameters\n"
2042 "Peer ASs in BGP confederation\n"
2045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2050 for (i
= idx_asn
; i
< argc
; i
++) {
2051 if (!asn_str2asn(argv
[i
]->arg
, &as
)) {
2052 vty_out(vty
, "%% Invalid confed peer AS value: %s\n",
2056 bgp_confederation_peers_remove(bgp
, as
);
2062 * Central routine for maximum-paths configuration.
2063 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
2064 * @set: 1 for setting values, 0 for removing the max-paths config.
2066 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
2067 const char *mpaths
, uint16_t options
,
2070 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2071 uint16_t maxpaths
= 0;
2076 afi
= bgp_node_afi(vty
);
2077 safi
= bgp_node_safi(vty
);
2080 maxpaths
= strtol(mpaths
, NULL
, 10);
2081 if (maxpaths
> multipath_num
) {
2083 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2084 maxpaths
, multipath_num
);
2085 return CMD_WARNING_CONFIG_FAILED
;
2087 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2090 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2094 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2095 (set
== 1) ? "" : "un",
2096 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2097 maxpaths
, afi
, safi
);
2098 return CMD_WARNING_CONFIG_FAILED
;
2101 bgp_recalculate_all_bestpaths(bgp
);
2106 DEFUN (bgp_maxmed_admin
,
2107 bgp_maxmed_admin_cmd
,
2108 "bgp max-med administrative ",
2110 "Advertise routes with max-med\n"
2111 "Administratively applied, for an indefinite period\n")
2113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2115 bgp
->v_maxmed_admin
= 1;
2116 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2118 bgp_maxmed_update(bgp
);
2123 DEFUN (bgp_maxmed_admin_medv
,
2124 bgp_maxmed_admin_medv_cmd
,
2125 "bgp max-med administrative (0-4294967295)",
2127 "Advertise routes with max-med\n"
2128 "Administratively applied, for an indefinite period\n"
2129 "Max MED value to be used\n")
2131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2134 bgp
->v_maxmed_admin
= 1;
2135 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2137 bgp_maxmed_update(bgp
);
2142 DEFUN (no_bgp_maxmed_admin
,
2143 no_bgp_maxmed_admin_cmd
,
2144 "no bgp max-med administrative [(0-4294967295)]",
2147 "Advertise routes with max-med\n"
2148 "Administratively applied, for an indefinite period\n"
2149 "Max MED value to be used\n")
2151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2152 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2153 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2154 bgp_maxmed_update(bgp
);
2159 DEFUN (bgp_maxmed_onstartup
,
2160 bgp_maxmed_onstartup_cmd
,
2161 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2163 "Advertise routes with max-med\n"
2164 "Effective on a startup\n"
2165 "Time (seconds) period for max-med\n"
2166 "Max MED value to be used\n")
2168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2171 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2172 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2173 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2174 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2176 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2178 bgp_maxmed_update(bgp
);
2183 DEFUN (no_bgp_maxmed_onstartup
,
2184 no_bgp_maxmed_onstartup_cmd
,
2185 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2188 "Advertise routes with max-med\n"
2189 "Effective on a startup\n"
2190 "Time (seconds) period for max-med\n"
2191 "Max MED value to be used\n")
2193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2195 /* Cancel max-med onstartup if its on */
2196 if (bgp
->t_maxmed_onstartup
) {
2197 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2198 bgp
->maxmed_onstartup_over
= 1;
2201 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2202 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2204 bgp_maxmed_update(bgp
);
2209 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2210 uint16_t update_delay
,
2211 uint16_t establish_wait
)
2213 struct listnode
*node
, *nnode
;
2215 bool vrf_cfg
= false;
2218 * See if update-delay is set per-vrf and warn user to delete it
2219 * Note that we only need to check this if this is the first time
2220 * setting the global config.
2222 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2223 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2224 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2226 "%% update-delay configuration found in vrf %s\n",
2227 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2237 "%%Failed: global update-delay config not permitted\n");
2241 if (!establish_wait
) { /* update-delay <delay> */
2242 bm
->v_update_delay
= update_delay
;
2243 bm
->v_establish_wait
= bm
->v_update_delay
;
2245 /* update-delay <delay> <establish-wait> */
2246 if (update_delay
< establish_wait
) {
2248 "%%Failed: update-delay less than the establish-wait!\n");
2249 return CMD_WARNING_CONFIG_FAILED
;
2252 bm
->v_update_delay
= update_delay
;
2253 bm
->v_establish_wait
= establish_wait
;
2256 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2257 bgp
->v_update_delay
= bm
->v_update_delay
;
2258 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2264 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2266 struct listnode
*node
, *nnode
;
2269 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2270 bm
->v_establish_wait
= bm
->v_update_delay
;
2272 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2273 bgp
->v_update_delay
= bm
->v_update_delay
;
2274 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2280 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2281 uint16_t establish_wait
)
2283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2285 /* if configured globally, per-instance config is not allowed */
2286 if (bm
->v_update_delay
) {
2288 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2289 return CMD_WARNING_CONFIG_FAILED
;
2293 if (!establish_wait
) /* update-delay <delay> */
2295 bgp
->v_update_delay
= update_delay
;
2296 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2300 /* update-delay <delay> <establish-wait> */
2301 if (update_delay
< establish_wait
) {
2303 "%%Failed: update-delay less than the establish-wait!\n");
2304 return CMD_WARNING_CONFIG_FAILED
;
2307 bgp
->v_update_delay
= update_delay
;
2308 bgp
->v_establish_wait
= establish_wait
;
2313 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2317 /* If configured globally, cannot remove from one bgp instance */
2318 if (bm
->v_update_delay
) {
2320 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2321 return CMD_WARNING_CONFIG_FAILED
;
2323 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2324 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2329 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2331 /* If configured globally, no need to display per-instance value */
2332 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2333 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2334 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2335 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2340 /* Global update-delay configuration */
2341 DEFPY (bgp_global_update_delay
,
2342 bgp_global_update_delay_cmd
,
2343 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2345 "Force initial delay for best-path and updates for all bgp instances\n"
2346 "Max delay in seconds\n"
2347 "Establish wait in seconds\n")
2349 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2352 /* Global update-delay deconfiguration */
2353 DEFPY (no_bgp_global_update_delay
,
2354 no_bgp_global_update_delay_cmd
,
2355 "no bgp update-delay [(0-3600) [(1-3600)]]",
2358 "Force initial delay for best-path and updates\n"
2359 "Max delay in seconds\n"
2360 "Establish wait in seconds\n")
2362 return bgp_global_update_delay_deconfig_vty(vty
);
2365 /* Update-delay configuration */
2367 DEFPY (bgp_update_delay
,
2368 bgp_update_delay_cmd
,
2369 "update-delay (0-3600)$delay [(1-3600)$wait]",
2370 "Force initial delay for best-path and updates\n"
2371 "Max delay in seconds\n"
2372 "Establish wait in seconds\n")
2374 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2377 /* Update-delay deconfiguration */
2378 DEFPY (no_bgp_update_delay
,
2379 no_bgp_update_delay_cmd
,
2380 "no update-delay [(0-3600) [(1-3600)]]",
2382 "Force initial delay for best-path and updates\n"
2383 "Max delay in seconds\n"
2384 "Establish wait in seconds\n")
2386 return bgp_update_delay_deconfig_vty(vty
);
2390 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2395 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2396 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2401 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2406 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2407 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2412 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2415 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2416 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2417 vty_out(vty
, " write-quanta %d\n", quanta
);
2420 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2423 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2424 if (quanta
!= BGP_READ_PACKET_MAX
)
2425 vty_out(vty
, " read-quanta %d\n", quanta
);
2428 /* Packet quanta configuration
2430 * XXX: The value set here controls the size of a stack buffer in the IO
2431 * thread. When changing these limits be careful to prevent stack overflow.
2433 * Furthermore, the maximums used here should correspond to
2434 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2436 DEFPY (bgp_wpkt_quanta
,
2437 bgp_wpkt_quanta_cmd
,
2438 "[no] write-quanta (1-64)$quanta",
2440 "How many packets to write to peer socket per run\n"
2441 "Number of packets\n")
2443 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2446 DEFPY (bgp_rpkt_quanta
,
2447 bgp_rpkt_quanta_cmd
,
2448 "[no] read-quanta (1-10)$quanta",
2450 "How many packets to read from peer socket per I/O cycle\n"
2451 "Number of packets\n")
2453 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2456 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2458 if (!bgp
->heuristic_coalesce
)
2459 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2462 /* BGP TCP keepalive */
2463 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2465 if (bgp
->tcp_keepalive_idle
) {
2466 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2467 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2468 bgp
->tcp_keepalive_probes
);
2472 DEFUN (bgp_coalesce_time
,
2473 bgp_coalesce_time_cmd
,
2474 "coalesce-time (0-4294967295)",
2475 "Subgroup coalesce timer\n"
2476 "Subgroup coalesce timer value (in ms)\n")
2478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2482 bgp
->heuristic_coalesce
= false;
2484 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2485 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2490 DEFUN (no_bgp_coalesce_time
,
2491 no_bgp_coalesce_time_cmd
,
2492 "no coalesce-time (0-4294967295)",
2494 "Subgroup coalesce timer\n"
2495 "Subgroup coalesce timer value (in ms)\n")
2497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2499 bgp
->heuristic_coalesce
= true;
2500 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2504 /* Maximum-paths configuration */
2505 DEFUN (bgp_maxpaths
,
2507 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2508 "Forward packets over multiple paths\n"
2509 "Number of paths\n")
2512 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2513 argv
[idx_number
]->arg
, 0, 1);
2516 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2517 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2518 "Forward packets over multiple paths\n"
2519 "Number of paths\n")
2521 DEFUN (bgp_maxpaths_ibgp
,
2522 bgp_maxpaths_ibgp_cmd
,
2523 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2524 "Forward packets over multiple paths\n"
2526 "Number of paths\n")
2529 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2530 argv
[idx_number
]->arg
, 0, 1);
2533 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2534 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2535 "Forward packets over multiple paths\n"
2537 "Number of paths\n")
2539 DEFUN (bgp_maxpaths_ibgp_cluster
,
2540 bgp_maxpaths_ibgp_cluster_cmd
,
2541 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2542 "Forward packets over multiple paths\n"
2545 "Match the cluster length\n")
2548 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2549 argv
[idx_number
]->arg
, true, 1);
2552 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2553 "maximum-paths ibgp " CMD_RANGE_STR(
2554 1, MULTIPATH_NUM
) " equal-cluster-length",
2555 "Forward packets over multiple paths\n"
2558 "Match the cluster length\n")
2560 DEFUN (no_bgp_maxpaths
,
2561 no_bgp_maxpaths_cmd
,
2562 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2564 "Forward packets over multiple paths\n"
2565 "Number of paths\n")
2567 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2570 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2571 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2572 "Forward packets over multiple paths\n"
2573 "Number of paths\n")
2575 DEFUN (no_bgp_maxpaths_ibgp
,
2576 no_bgp_maxpaths_ibgp_cmd
,
2577 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2579 "Forward packets over multiple paths\n"
2582 "Match the cluster length\n")
2584 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2587 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2588 "no maximum-paths ibgp [" CMD_RANGE_STR(
2589 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2591 "Forward packets over multiple paths\n"
2594 "Match the cluster length\n")
2596 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2597 afi_t afi
, safi_t safi
)
2599 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2600 vty_out(vty
, " maximum-paths %d\n",
2601 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2604 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2605 vty_out(vty
, " maximum-paths ibgp %d",
2606 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2607 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2608 vty_out(vty
, " equal-cluster-length");
2617 "timers bgp (0-65535) (0-65535)",
2618 "Adjust routing timers\n"
2620 "Keepalive interval\n"
2623 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2625 int idx_number_2
= 3;
2626 unsigned long keepalive
= 0;
2627 unsigned long holdtime
= 0;
2629 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2630 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2632 /* Holdtime value check. */
2633 if (holdtime
< 3 && holdtime
!= 0) {
2635 "%% hold time value must be either 0 or greater than 3\n");
2636 return CMD_WARNING_CONFIG_FAILED
;
2639 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2640 BGP_DEFAULT_DELAYOPEN
);
2645 DEFUN (no_bgp_timers
,
2647 "no timers bgp [(0-65535) (0-65535)]",
2649 "Adjust routing timers\n"
2651 "Keepalive interval\n"
2654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2655 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2656 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2661 /* BGP minimum holdtime. */
2663 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2664 "bgp minimum-holdtime (1-65535)",
2665 "BGP specific commands\n"
2666 "BGP minimum holdtime\n"
2669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2671 unsigned long min_holdtime
;
2673 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2675 bgp
->default_min_holdtime
= min_holdtime
;
2680 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2681 "no bgp minimum-holdtime [(1-65535)]",
2683 "BGP specific commands\n"
2684 "BGP minimum holdtime\n"
2687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2689 bgp
->default_min_holdtime
= 0;
2694 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2695 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2697 "TCP keepalive parameters\n"
2698 "TCP keepalive idle time (seconds)\n"
2699 "TCP keepalive interval (seconds)\n"
2700 "TCP keepalive maximum probes\n")
2702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2710 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2711 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2714 "TCP keepalive parameters\n"
2715 "TCP keepalive idle time (seconds)\n"
2716 "TCP keepalive interval (seconds)\n"
2717 "TCP keepalive maximum probes\n")
2719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 bgp_tcp_keepalive_unset(bgp
);
2726 DEFUN (bgp_client_to_client_reflection
,
2727 bgp_client_to_client_reflection_cmd
,
2728 "bgp client-to-client reflection",
2730 "Configure client to client route reflection\n"
2731 "reflection of routes allowed\n")
2733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2734 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2735 bgp_clear_star_soft_out(vty
, bgp
->name
);
2740 DEFUN (no_bgp_client_to_client_reflection
,
2741 no_bgp_client_to_client_reflection_cmd
,
2742 "no bgp client-to-client reflection",
2745 "Configure client to client route reflection\n"
2746 "reflection of routes allowed\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2749 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2750 bgp_clear_star_soft_out(vty
, bgp
->name
);
2755 /* "bgp always-compare-med" configuration. */
2756 DEFUN (bgp_always_compare_med
,
2757 bgp_always_compare_med_cmd
,
2758 "bgp always-compare-med",
2760 "Allow comparing MED from different neighbors\n")
2762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2763 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2764 bgp_recalculate_all_bestpaths(bgp
);
2769 DEFUN (no_bgp_always_compare_med
,
2770 no_bgp_always_compare_med_cmd
,
2771 "no bgp always-compare-med",
2774 "Allow comparing MED from different neighbors\n")
2776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2777 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2778 bgp_recalculate_all_bestpaths(bgp
);
2784 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2785 "bgp ebgp-requires-policy",
2787 "Require in and out policy for eBGP peers (RFC8212)\n")
2789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2790 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2794 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2795 "no bgp ebgp-requires-policy",
2798 "Require in and out policy for eBGP peers (RFC8212)\n")
2800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2801 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2805 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2806 "bgp suppress-duplicates",
2808 "Suppress duplicate updates if the route actually not changed\n")
2810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2811 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2815 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2816 "no bgp suppress-duplicates",
2819 "Suppress duplicate updates if the route actually not changed\n")
2821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2822 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2826 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2827 "bgp reject-as-sets",
2829 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2832 struct listnode
*node
, *nnode
;
2835 bgp
->reject_as_sets
= true;
2837 /* Reset existing BGP sessions to reject routes
2838 * with aspath containing AS_SET or AS_CONFED_SET.
2840 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2841 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2842 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2843 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2844 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2851 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2852 "no bgp reject-as-sets",
2855 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2857 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2858 struct listnode
*node
, *nnode
;
2861 bgp
->reject_as_sets
= false;
2863 /* Reset existing BGP sessions to reject routes
2864 * with aspath containing AS_SET or AS_CONFED_SET.
2866 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2867 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2868 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2869 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2870 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2877 /* "bgp deterministic-med" configuration. */
2878 DEFUN (bgp_deterministic_med
,
2879 bgp_deterministic_med_cmd
,
2880 "bgp deterministic-med",
2882 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2886 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2887 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2888 bgp_recalculate_all_bestpaths(bgp
);
2894 DEFUN (no_bgp_deterministic_med
,
2895 no_bgp_deterministic_med_cmd
,
2896 "no bgp deterministic-med",
2899 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2902 int bestpath_per_as_used
;
2906 struct listnode
*node
, *nnode
;
2908 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2909 bestpath_per_as_used
= 0;
2911 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2912 FOREACH_AFI_SAFI (afi
, safi
)
2913 if (bgp_addpath_dmed_required(
2914 peer
->addpath_type
[afi
][safi
])) {
2915 bestpath_per_as_used
= 1;
2919 if (bestpath_per_as_used
)
2923 if (bestpath_per_as_used
) {
2925 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2926 return CMD_WARNING_CONFIG_FAILED
;
2928 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2929 bgp_recalculate_all_bestpaths(bgp
);
2936 /* "bgp graceful-restart mode" configuration. */
2937 DEFUN (bgp_graceful_restart
,
2938 bgp_graceful_restart_cmd
,
2939 "bgp graceful-restart",
2944 int ret
= BGP_GR_FAILURE
;
2946 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2947 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2951 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2953 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2956 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2957 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2959 "Graceful restart configuration changed, reset all peers to take effect\n");
2960 return bgp_vty_return(vty
, ret
);
2963 DEFUN (no_bgp_graceful_restart
,
2964 no_bgp_graceful_restart_cmd
,
2965 "no bgp graceful-restart",
2971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2973 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2974 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2976 int ret
= BGP_GR_FAILURE
;
2978 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2980 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2983 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2984 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2986 "Graceful restart configuration changed, reset all peers to take effect\n");
2988 return bgp_vty_return(vty
, ret
);
2991 DEFUN (bgp_graceful_restart_stalepath_time
,
2992 bgp_graceful_restart_stalepath_time_cmd
,
2993 "bgp graceful-restart stalepath-time (1-4095)",
2995 "Graceful restart capability parameters\n"
2996 "Set the max time to hold onto restarting peer's stale paths\n"
2997 "Delay value (seconds)\n")
2999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3003 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3004 bgp
->stalepath_time
= stalepath
;
3008 DEFUN (bgp_graceful_restart_restart_time
,
3009 bgp_graceful_restart_restart_time_cmd
,
3010 "bgp graceful-restart restart-time (0-4095)",
3012 "Graceful restart capability parameters\n"
3013 "Set the time to wait to delete stale routes before a BGP open message is received\n"
3014 "Delay value (seconds)\n")
3016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3020 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3021 bgp
->restart_time
= restart
;
3025 DEFUN (bgp_graceful_restart_select_defer_time
,
3026 bgp_graceful_restart_select_defer_time_cmd
,
3027 "bgp graceful-restart select-defer-time (0-3600)",
3029 "Graceful restart capability parameters\n"
3030 "Set the time to defer the BGP route selection after restart\n"
3031 "Delay value (seconds, 0 - disable)\n")
3033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3035 uint32_t defer_time
;
3037 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3038 bgp
->select_defer_time
= defer_time
;
3039 if (defer_time
== 0)
3040 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3042 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3047 DEFUN (no_bgp_graceful_restart_stalepath_time
,
3048 no_bgp_graceful_restart_stalepath_time_cmd
,
3049 "no bgp graceful-restart stalepath-time [(1-4095)]",
3052 "Graceful restart capability parameters\n"
3053 "Set the max time to hold onto restarting peer's stale paths\n"
3054 "Delay value (seconds)\n")
3056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3058 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
3062 DEFUN (no_bgp_graceful_restart_restart_time
,
3063 no_bgp_graceful_restart_restart_time_cmd
,
3064 "no bgp graceful-restart restart-time [(0-4095)]",
3067 "Graceful restart capability parameters\n"
3068 "Set the time to wait to delete stale routes before a BGP open message is received\n"
3069 "Delay value (seconds)\n")
3071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3073 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3077 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3078 no_bgp_graceful_restart_select_defer_time_cmd
,
3079 "no bgp graceful-restart select-defer-time [(0-3600)]",
3082 "Graceful restart capability parameters\n"
3083 "Set the time to defer the BGP route selection after restart\n"
3084 "Delay value (seconds)\n")
3086 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3088 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3089 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3094 DEFUN (bgp_graceful_restart_preserve_fw
,
3095 bgp_graceful_restart_preserve_fw_cmd
,
3096 "bgp graceful-restart preserve-fw-state",
3098 "Graceful restart capability parameters\n"
3099 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3102 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3106 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3107 no_bgp_graceful_restart_preserve_fw_cmd
,
3108 "no bgp graceful-restart preserve-fw-state",
3111 "Graceful restart capability parameters\n"
3112 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3115 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3119 DEFPY (bgp_graceful_restart_notification
,
3120 bgp_graceful_restart_notification_cmd
,
3121 "[no$no] bgp graceful-restart notification",
3124 "Graceful restart capability parameters\n"
3125 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3127 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3130 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3132 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3137 DEFPY (bgp_administrative_reset
,
3138 bgp_administrative_reset_cmd
,
3139 "[no$no] bgp hard-administrative-reset",
3142 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3144 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3147 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3149 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3154 DEFUN (bgp_graceful_restart_disable
,
3155 bgp_graceful_restart_disable_cmd
,
3156 "bgp graceful-restart-disable",
3160 int ret
= BGP_GR_FAILURE
;
3162 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3164 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3166 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3168 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3170 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3173 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3175 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3177 "Graceful restart configuration changed, reset all peers to take effect\n");
3179 return bgp_vty_return(vty
, ret
);
3182 DEFUN (no_bgp_graceful_restart_disable
,
3183 no_bgp_graceful_restart_disable_cmd
,
3184 "no bgp graceful-restart-disable",
3190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3192 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3194 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3196 int ret
= BGP_GR_FAILURE
;
3198 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3200 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3203 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3205 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3207 "Graceful restart configuration changed, reset all peers to take effect\n");
3209 return bgp_vty_return(vty
, ret
);
3212 DEFUN (bgp_neighbor_graceful_restart_set
,
3213 bgp_neighbor_graceful_restart_set_cmd
,
3214 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3222 int ret
= BGP_GR_FAILURE
;
3224 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3226 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3228 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3232 return CMD_WARNING_CONFIG_FAILED
;
3234 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3236 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3237 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3239 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3241 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3243 "Graceful restart configuration changed, reset this peer to take effect\n");
3245 return bgp_vty_return(vty
, ret
);
3248 DEFUN (no_bgp_neighbor_graceful_restart
,
3249 no_bgp_neighbor_graceful_restart_set_cmd
,
3250 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3258 int ret
= BGP_GR_FAILURE
;
3261 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3263 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3265 return CMD_WARNING_CONFIG_FAILED
;
3267 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3269 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3271 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3273 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3274 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3276 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3278 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3280 "Graceful restart configuration changed, reset this peer to take effect\n");
3282 return bgp_vty_return(vty
, ret
);
3285 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3286 bgp_neighbor_graceful_restart_helper_set_cmd
,
3287 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3290 GR_NEIGHBOR_HELPER_CMD
3295 int ret
= BGP_GR_FAILURE
;
3297 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3299 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3301 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3303 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3306 return CMD_WARNING_CONFIG_FAILED
;
3309 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3311 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3312 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3314 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3316 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3318 "Graceful restart configuration changed, reset this peer to take effect\n");
3320 return bgp_vty_return(vty
, ret
);
3323 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3324 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3325 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3329 NO_GR_NEIGHBOR_HELPER_CMD
3333 int ret
= BGP_GR_FAILURE
;
3336 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3338 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3340 return CMD_WARNING_CONFIG_FAILED
;
3342 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3344 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3346 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3348 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3349 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3351 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3353 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3355 "Graceful restart configuration changed, reset this peer to take effect\n");
3357 return bgp_vty_return(vty
, ret
);
3360 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3361 bgp_neighbor_graceful_restart_disable_set_cmd
,
3362 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3365 GR_NEIGHBOR_DISABLE_CMD
3370 int ret
= BGP_GR_FAILURE
;
3372 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3374 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3376 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3378 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3380 return CMD_WARNING_CONFIG_FAILED
;
3382 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3384 if (peer
->bgp
->t_startup
)
3385 bgp_peer_gr_flags_update(peer
);
3387 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3388 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3390 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3392 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3394 "Graceful restart configuration changed, reset this peer to take effect\n");
3396 return bgp_vty_return(vty
, ret
);
3399 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3400 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3401 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3405 NO_GR_NEIGHBOR_DISABLE_CMD
3409 int ret
= BGP_GR_FAILURE
;
3412 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3414 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3416 return CMD_WARNING_CONFIG_FAILED
;
3418 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3420 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3422 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3424 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3425 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3427 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3429 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3431 "Graceful restart configuration changed, reset this peer to take effect\n");
3433 return bgp_vty_return(vty
, ret
);
3436 DEFPY (neighbor_graceful_shutdown
,
3437 neighbor_graceful_shutdown_cmd
,
3438 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3442 "Graceful shutdown\n")
3447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3450 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3452 return CMD_WARNING_CONFIG_FAILED
;
3455 ret
= peer_flag_unset_vty(vty
, neighbor
,
3456 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3458 ret
= peer_flag_set_vty(vty
, neighbor
,
3459 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3461 FOREACH_AFI_SAFI (afi
, safi
) {
3462 if (!peer
->afc
[afi
][safi
])
3465 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3472 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3473 bgp_graceful_restart_disable_eor_cmd
,
3474 "bgp graceful-restart disable-eor",
3476 "Graceful restart configuration parameters\n"
3477 "Disable EOR Check\n")
3479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3480 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3485 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3486 no_bgp_graceful_restart_disable_eor_cmd
,
3487 "no bgp graceful-restart disable-eor",
3490 "Graceful restart configuration parameters\n"
3491 "Disable EOR Check\n")
3493 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3494 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3499 DEFUN (bgp_graceful_restart_rib_stale_time
,
3500 bgp_graceful_restart_rib_stale_time_cmd
,
3501 "bgp graceful-restart rib-stale-time (1-3600)",
3503 "Graceful restart configuration parameters\n"
3504 "Specify the stale route removal timer in rib\n"
3505 "Delay value (seconds)\n")
3507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3509 uint32_t stale_time
;
3511 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3512 bgp
->rib_stale_time
= stale_time
;
3513 /* Send the stale timer update message to RIB */
3514 if (bgp_zebra_stale_timer_update(bgp
))
3520 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3521 no_bgp_graceful_restart_rib_stale_time_cmd
,
3522 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3525 "Graceful restart configuration parameters\n"
3526 "Specify the stale route removal timer in rib\n"
3527 "Delay value (seconds)\n")
3529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3531 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3532 /* Send the stale timer update message to RIB */
3533 if (bgp_zebra_stale_timer_update(bgp
))
3539 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3540 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3542 "Enable Long-lived Graceful Restart\n"
3543 "Specifies maximum time to wait before purging long-lived stale routes\n"
3544 "Stale time value (seconds)\n")
3546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3548 uint32_t llgr_stale_time
;
3550 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3551 bgp
->llgr_stale_time
= llgr_stale_time
;
3556 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3557 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3559 "Enable Long-lived Graceful Restart\n"
3560 "Specifies maximum time to wait before purging long-lived stale routes\n"
3561 "Stale time value (seconds)\n")
3563 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3565 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3570 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3573 bgp_static_redo_import_check(bgp
);
3574 bgp_redistribute_redo(bgp
);
3575 bgp_clear_star_soft_out(vty
, bgp
->name
);
3576 bgp_clear_star_soft_in(vty
, bgp
->name
);
3579 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3581 struct listnode
*node
, *nnode
;
3583 bool vrf_cfg
= false;
3585 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3588 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3589 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3590 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3592 "%% graceful-shutdown configuration found in vrf %s\n",
3593 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3594 VRF_DEFAULT_NAME
: bgp
->name
);
3601 "%%Failed: global graceful-shutdown not permitted\n");
3605 /* Set flag globally */
3606 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3608 /* Initiate processing for all BGP instances. */
3609 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3610 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3615 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3617 struct listnode
*node
, *nnode
;
3620 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3623 /* Unset flag globally */
3624 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3626 /* Initiate processing for all BGP instances. */
3627 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3628 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3633 /* "bgp graceful-shutdown" configuration */
3634 DEFUN (bgp_graceful_shutdown
,
3635 bgp_graceful_shutdown_cmd
,
3636 "bgp graceful-shutdown",
3638 "Graceful shutdown parameters\n")
3640 if (vty
->node
== CONFIG_NODE
)
3641 return bgp_global_graceful_shutdown_config_vty(vty
);
3643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3645 /* if configured globally, per-instance config is not allowed */
3646 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3648 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3649 return CMD_WARNING_CONFIG_FAILED
;
3652 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3653 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3654 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3660 DEFUN (no_bgp_graceful_shutdown
,
3661 no_bgp_graceful_shutdown_cmd
,
3662 "no bgp graceful-shutdown",
3665 "Graceful shutdown parameters\n")
3667 if (vty
->node
== CONFIG_NODE
)
3668 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3672 /* If configured globally, cannot remove from one bgp instance */
3673 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3675 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3676 return CMD_WARNING_CONFIG_FAILED
;
3679 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3680 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3681 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3687 /* "bgp fast-external-failover" configuration. */
3688 DEFUN (bgp_fast_external_failover
,
3689 bgp_fast_external_failover_cmd
,
3690 "bgp fast-external-failover",
3692 "Immediately reset session if a link to a directly connected external peer goes down\n")
3694 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3695 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3699 DEFUN (no_bgp_fast_external_failover
,
3700 no_bgp_fast_external_failover_cmd
,
3701 "no bgp fast-external-failover",
3704 "Immediately reset session if a link to a directly connected external peer goes down\n")
3706 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3707 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3711 DEFPY (bgp_bestpath_aigp
,
3712 bgp_bestpath_aigp_cmd
,
3713 "[no$no] bgp bestpath aigp",
3716 "Change the default bestpath selection\n"
3717 "Evaluate the AIGP attribute during the best path selection process\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3722 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3724 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3726 bgp_recalculate_all_bestpaths(bgp
);
3731 /* "bgp bestpath compare-routerid" configuration. */
3732 DEFUN (bgp_bestpath_compare_router_id
,
3733 bgp_bestpath_compare_router_id_cmd
,
3734 "bgp bestpath compare-routerid",
3736 "Change the default bestpath selection\n"
3737 "Compare router-id for identical EBGP paths\n")
3739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3740 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3741 bgp_recalculate_all_bestpaths(bgp
);
3746 DEFUN (no_bgp_bestpath_compare_router_id
,
3747 no_bgp_bestpath_compare_router_id_cmd
,
3748 "no bgp bestpath compare-routerid",
3751 "Change the default bestpath selection\n"
3752 "Compare router-id for identical EBGP paths\n")
3754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3755 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3756 bgp_recalculate_all_bestpaths(bgp
);
3761 /* "bgp bestpath as-path ignore" configuration. */
3762 DEFUN (bgp_bestpath_aspath_ignore
,
3763 bgp_bestpath_aspath_ignore_cmd
,
3764 "bgp bestpath as-path ignore",
3766 "Change the default bestpath selection\n"
3767 "AS-path attribute\n"
3768 "Ignore as-path length in selecting a route\n")
3770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3771 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3772 bgp_recalculate_all_bestpaths(bgp
);
3777 DEFUN (no_bgp_bestpath_aspath_ignore
,
3778 no_bgp_bestpath_aspath_ignore_cmd
,
3779 "no bgp bestpath as-path ignore",
3782 "Change the default bestpath selection\n"
3783 "AS-path attribute\n"
3784 "Ignore as-path length in selecting a route\n")
3786 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3787 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3788 bgp_recalculate_all_bestpaths(bgp
);
3793 /* "bgp bestpath as-path confed" configuration. */
3794 DEFUN (bgp_bestpath_aspath_confed
,
3795 bgp_bestpath_aspath_confed_cmd
,
3796 "bgp bestpath as-path confed",
3798 "Change the default bestpath selection\n"
3799 "AS-path attribute\n"
3800 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3803 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3804 bgp_recalculate_all_bestpaths(bgp
);
3809 DEFUN (no_bgp_bestpath_aspath_confed
,
3810 no_bgp_bestpath_aspath_confed_cmd
,
3811 "no bgp bestpath as-path confed",
3814 "Change the default bestpath selection\n"
3815 "AS-path attribute\n"
3816 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3819 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3820 bgp_recalculate_all_bestpaths(bgp
);
3825 /* "bgp bestpath as-path multipath-relax" configuration. */
3826 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3827 bgp_bestpath_aspath_multipath_relax_cmd
,
3828 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3830 "Change the default bestpath selection\n"
3831 "AS-path attribute\n"
3832 "Allow load sharing across routes that have different AS paths (but same length)\n"
3833 "Generate an AS_SET\n"
3834 "Do not generate an AS_SET\n")
3836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3838 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3840 /* no-as-set is now the default behavior so we can silently
3842 if (argv_find(argv
, argc
, "as-set", &idx
))
3843 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3845 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3847 bgp_recalculate_all_bestpaths(bgp
);
3852 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3853 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3854 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3857 "Change the default bestpath selection\n"
3858 "AS-path attribute\n"
3859 "Allow load sharing across routes that have different AS paths (but same length)\n"
3860 "Generate an AS_SET\n"
3861 "Do not generate an AS_SET\n")
3863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3864 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3865 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3866 bgp_recalculate_all_bestpaths(bgp
);
3871 /* "bgp bestpath peer-type multipath-relax" configuration. */
3872 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3873 bgp_bestpath_peer_type_multipath_relax_cmd
,
3874 "bgp bestpath peer-type multipath-relax",
3876 "Change the default bestpath selection\n"
3878 "Allow load sharing across routes learned from different peer types\n")
3880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3881 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3882 bgp_recalculate_all_bestpaths(bgp
);
3887 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3888 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3889 "no bgp bestpath peer-type multipath-relax",
3891 "Change the default bestpath selection\n"
3893 "Allow load sharing across routes learned from different peer types\n")
3895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3896 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3897 bgp_recalculate_all_bestpaths(bgp
);
3902 /* "bgp log-neighbor-changes" configuration. */
3903 DEFUN (bgp_log_neighbor_changes
,
3904 bgp_log_neighbor_changes_cmd
,
3905 "bgp log-neighbor-changes",
3907 "Log neighbor up/down and reset reason\n")
3909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3910 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3914 DEFUN (no_bgp_log_neighbor_changes
,
3915 no_bgp_log_neighbor_changes_cmd
,
3916 "no bgp log-neighbor-changes",
3919 "Log neighbor up/down and reset reason\n")
3921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3922 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3926 /* "bgp bestpath med" configuration. */
3927 DEFUN (bgp_bestpath_med
,
3928 bgp_bestpath_med_cmd
,
3929 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3931 "Change the default bestpath selection\n"
3933 "Compare MED among confederation paths\n"
3934 "Treat missing MED as the least preferred one\n"
3935 "Treat missing MED as the least preferred one\n"
3936 "Compare MED among confederation paths\n")
3938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3941 if (argv_find(argv
, argc
, "confed", &idx
))
3942 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3944 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3945 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3947 bgp_recalculate_all_bestpaths(bgp
);
3952 DEFUN (no_bgp_bestpath_med
,
3953 no_bgp_bestpath_med_cmd
,
3954 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3957 "Change the default bestpath selection\n"
3959 "Compare MED among confederation paths\n"
3960 "Treat missing MED as the least preferred one\n"
3961 "Treat missing MED as the least preferred one\n"
3962 "Compare MED among confederation paths\n")
3964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3967 if (argv_find(argv
, argc
, "confed", &idx
))
3968 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3970 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3971 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3973 bgp_recalculate_all_bestpaths(bgp
);
3978 /* "bgp bestpath bandwidth" configuration. */
3979 DEFPY (bgp_bestpath_bw
,
3980 bgp_bestpath_bw_cmd
,
3981 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3983 "Change the default bestpath selection\n"
3984 "Link Bandwidth attribute\n"
3985 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3986 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3987 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3994 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3995 return CMD_ERR_INCOMPLETE
;
3997 if (!strcmp(bw_cfg
, "ignore"))
3998 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3999 else if (!strcmp(bw_cfg
, "skip-missing"))
4000 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
4001 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
4002 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
4004 return CMD_ERR_NO_MATCH
;
4006 /* This config is used in route install, so redo that. */
4007 FOREACH_AFI_SAFI (afi
, safi
) {
4008 if (!bgp_fibupd_safi(safi
))
4010 bgp_zebra_announce_table(bgp
, afi
, safi
);
4016 DEFPY (no_bgp_bestpath_bw
,
4017 no_bgp_bestpath_bw_cmd
,
4018 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
4021 "Change the default bestpath selection\n"
4022 "Link Bandwidth attribute\n"
4023 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
4024 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
4025 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
4027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4031 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
4033 /* This config is used in route install, so redo that. */
4034 FOREACH_AFI_SAFI (afi
, safi
) {
4035 if (!bgp_fibupd_safi(safi
))
4037 bgp_zebra_announce_table(bgp
, afi
, safi
);
4042 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
4043 "[no] bgp default <ipv4-unicast|"
4046 "ipv4-labeled-unicast|"
4051 "ipv6-labeled-unicast|"
4053 "l2vpn-evpn>$afi_safi",
4056 "Configure BGP defaults\n"
4057 "Activate ipv4-unicast for a peer by default\n"
4058 "Activate ipv4-multicast for a peer by default\n"
4059 "Activate ipv4-vpn for a peer by default\n"
4060 "Activate ipv4-labeled-unicast for a peer by default\n"
4061 "Activate ipv4-flowspec for a peer by default\n"
4062 "Activate ipv6-unicast for a peer by default\n"
4063 "Activate ipv6-multicast for a peer by default\n"
4064 "Activate ipv6-vpn for a peer by default\n"
4065 "Activate ipv6-labeled-unicast for a peer by default\n"
4066 "Activate ipv6-flowspec for a peer by default\n"
4067 "Activate l2vpn-evpn for a peer by default\n")
4069 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4070 char afi_safi_str
[strlen(afi_safi
) + 1];
4071 char *afi_safi_str_tok
;
4073 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4074 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4075 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4076 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4080 * Impossible situation but making coverity happy
4082 assert(afi
!= AFI_MAX
);
4084 if (strmatch(safi_str
, "labeled"))
4085 safi
= bgp_vty_safi_from_str("labeled-unicast");
4087 safi
= bgp_vty_safi_from_str(safi_str
);
4089 assert(safi
!= SAFI_MAX
);
4091 bgp
->default_af
[afi
][safi
] = false;
4093 if ((safi
== SAFI_LABELED_UNICAST
4094 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4095 || (safi
== SAFI_UNICAST
4096 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4097 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4099 bgp
->default_af
[afi
][safi
] = true;
4105 /* Display hostname in certain command outputs */
4106 DEFUN (bgp_default_show_hostname
,
4107 bgp_default_show_hostname_cmd
,
4108 "bgp default show-hostname",
4110 "Configure BGP defaults\n"
4111 "Show hostname in certain command outputs\n")
4113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4114 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4118 DEFUN (no_bgp_default_show_hostname
,
4119 no_bgp_default_show_hostname_cmd
,
4120 "no bgp default show-hostname",
4123 "Configure BGP defaults\n"
4124 "Show hostname in certain command outputs\n")
4126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4127 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4131 /* Display hostname in certain command outputs */
4132 DEFUN (bgp_default_show_nexthop_hostname
,
4133 bgp_default_show_nexthop_hostname_cmd
,
4134 "bgp default show-nexthop-hostname",
4136 "Configure BGP defaults\n"
4137 "Show hostname for nexthop in certain command outputs\n")
4139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4140 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4144 DEFUN (no_bgp_default_show_nexthop_hostname
,
4145 no_bgp_default_show_nexthop_hostname_cmd
,
4146 "no bgp default show-nexthop-hostname",
4149 "Configure BGP defaults\n"
4150 "Show hostname for nexthop in certain command outputs\n")
4152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4153 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4157 /* "bgp network import-check" configuration. */
4158 DEFUN (bgp_network_import_check
,
4159 bgp_network_import_check_cmd
,
4160 "bgp network import-check",
4162 "BGP network command\n"
4163 "Check BGP network route exists in IGP\n")
4165 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4166 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4167 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4168 bgp_static_redo_import_check(bgp
);
4174 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4175 "bgp network import-check exact",
4177 "BGP network command\n"
4178 "Check BGP network route exists in IGP\n"
4179 "Match route precisely\n")
4181 DEFUN (no_bgp_network_import_check
,
4182 no_bgp_network_import_check_cmd
,
4183 "no bgp network import-check",
4186 "BGP network command\n"
4187 "Check BGP network route exists in IGP\n")
4189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4190 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4191 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4192 bgp_static_redo_import_check(bgp
);
4198 DEFUN (bgp_default_local_preference
,
4199 bgp_default_local_preference_cmd
,
4200 "bgp default local-preference (0-4294967295)",
4202 "Configure BGP defaults\n"
4203 "local preference (higher=more preferred)\n"
4204 "Configure default local preference value\n")
4206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4208 uint32_t local_pref
;
4210 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4212 bgp_default_local_preference_set(bgp
, local_pref
);
4213 bgp_clear_star_soft_in(vty
, bgp
->name
);
4218 DEFUN (no_bgp_default_local_preference
,
4219 no_bgp_default_local_preference_cmd
,
4220 "no bgp default local-preference [(0-4294967295)]",
4223 "Configure BGP defaults\n"
4224 "local preference (higher=more preferred)\n"
4225 "Configure default local preference value\n")
4227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4228 bgp_default_local_preference_unset(bgp
);
4229 bgp_clear_star_soft_in(vty
, bgp
->name
);
4235 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4236 bgp_default_subgroup_pkt_queue_max_cmd
,
4237 "bgp default subgroup-pkt-queue-max (20-100)",
4239 "Configure BGP defaults\n"
4240 "subgroup-pkt-queue-max\n"
4241 "Configure subgroup packet queue max\n")
4243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4247 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4249 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4254 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4255 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4256 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4259 "Configure BGP defaults\n"
4260 "subgroup-pkt-queue-max\n"
4261 "Configure subgroup packet queue max\n")
4263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4264 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4269 DEFUN (bgp_rr_allow_outbound_policy
,
4270 bgp_rr_allow_outbound_policy_cmd
,
4271 "bgp route-reflector allow-outbound-policy",
4273 "Allow modifications made by out route-map\n"
4274 "on ibgp neighbors\n")
4276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4278 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4279 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4280 update_group_announce_rrclients(bgp
);
4281 bgp_clear_star_soft_out(vty
, bgp
->name
);
4287 DEFUN (no_bgp_rr_allow_outbound_policy
,
4288 no_bgp_rr_allow_outbound_policy_cmd
,
4289 "no bgp route-reflector allow-outbound-policy",
4292 "Allow modifications made by out route-map\n"
4293 "on ibgp neighbors\n")
4295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4297 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4298 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4299 update_group_announce_rrclients(bgp
);
4300 bgp_clear_star_soft_out(vty
, bgp
->name
);
4306 DEFUN (bgp_listen_limit
,
4307 bgp_listen_limit_cmd
,
4308 "bgp listen limit (1-65535)",
4310 "BGP Dynamic Neighbors listen commands\n"
4311 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4312 "Configure Dynamic Neighbors listen limit value\n")
4314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4318 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4320 bgp_listen_limit_set(bgp
, listen_limit
);
4325 DEFUN (no_bgp_listen_limit
,
4326 no_bgp_listen_limit_cmd
,
4327 "no bgp listen limit [(1-65535)]",
4330 "BGP Dynamic Neighbors listen commands\n"
4331 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4332 "Configure Dynamic Neighbors listen limit value\n")
4334 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4335 bgp_listen_limit_unset(bgp
);
4341 * Check if this listen range is already configured. Check for exact
4342 * match or overlap based on input.
4344 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4345 struct prefix
*range
, int exact
)
4347 struct listnode
*node
, *nnode
;
4348 struct listnode
*node1
, *nnode1
;
4349 struct peer_group
*group
;
4354 afi
= family2afi(range
->family
);
4355 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4356 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4359 match
= prefix_same(range
, lr
);
4361 match
= (prefix_match(range
, lr
)
4362 || prefix_match(lr
, range
));
4371 DEFUN (bgp_listen_range
,
4372 bgp_listen_range_cmd
,
4373 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4375 "Configure BGP dynamic neighbors listen range\n"
4376 "Configure BGP dynamic neighbors listen range\n"
4378 "Member of the peer-group\n"
4379 "Peer-group name\n")
4381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4382 struct prefix range
;
4383 struct peer_group
*group
, *existing_group
;
4388 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4389 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4390 char *prefix
= argv
[idx
]->arg
;
4391 argv_find(argv
, argc
, "PGNAME", &idx
);
4392 char *peergroup
= argv
[idx
]->arg
;
4394 /* Convert IP prefix string to struct prefix. */
4395 ret
= str2prefix(prefix
, &range
);
4397 vty_out(vty
, "%% Malformed listen range\n");
4398 return CMD_WARNING_CONFIG_FAILED
;
4401 afi
= family2afi(range
.family
);
4403 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4405 "%% Malformed listen range (link-local address)\n");
4406 return CMD_WARNING_CONFIG_FAILED
;
4411 /* Check if same listen range is already configured. */
4412 existing_group
= listen_range_exists(bgp
, &range
, 1);
4413 if (existing_group
) {
4414 if (strcmp(existing_group
->name
, peergroup
) == 0)
4418 "%% Same listen range is attached to peer-group %s\n",
4419 existing_group
->name
);
4420 return CMD_WARNING_CONFIG_FAILED
;
4424 /* Check if an overlapping listen range exists. */
4425 if (listen_range_exists(bgp
, &range
, 0)) {
4427 "%% Listen range overlaps with existing listen range\n");
4428 return CMD_WARNING_CONFIG_FAILED
;
4431 group
= peer_group_lookup(bgp
, peergroup
);
4433 vty_out(vty
, "%% Configure the peer-group first\n");
4434 return CMD_WARNING_CONFIG_FAILED
;
4437 ret
= peer_group_listen_range_add(group
, &range
);
4438 return bgp_vty_return(vty
, ret
);
4441 DEFUN (no_bgp_listen_range
,
4442 no_bgp_listen_range_cmd
,
4443 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4446 "Unconfigure BGP dynamic neighbors listen range\n"
4447 "Unconfigure BGP dynamic neighbors listen range\n"
4449 "Member of the peer-group\n"
4450 "Peer-group name\n")
4452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4453 struct prefix range
;
4454 struct peer_group
*group
;
4459 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4460 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4461 char *prefix
= argv
[idx
]->arg
;
4462 argv_find(argv
, argc
, "PGNAME", &idx
);
4463 char *peergroup
= argv
[idx
]->arg
;
4465 /* Convert IP prefix string to struct prefix. */
4466 ret
= str2prefix(prefix
, &range
);
4468 vty_out(vty
, "%% Malformed listen range\n");
4469 return CMD_WARNING_CONFIG_FAILED
;
4472 afi
= family2afi(range
.family
);
4474 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4476 "%% Malformed listen range (link-local address)\n");
4477 return CMD_WARNING_CONFIG_FAILED
;
4482 group
= peer_group_lookup(bgp
, peergroup
);
4484 vty_out(vty
, "%% Peer-group does not exist\n");
4485 return CMD_WARNING_CONFIG_FAILED
;
4488 ret
= peer_group_listen_range_del(group
, &range
);
4489 return bgp_vty_return(vty
, ret
);
4492 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4494 struct peer_group
*group
;
4495 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4496 struct prefix
*range
;
4499 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4500 vty_out(vty
, " bgp listen limit %d\n",
4501 bgp
->dynamic_neighbors_limit
);
4503 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4504 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4505 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4508 " bgp listen range %pFX peer-group %s\n",
4509 range
, group
->name
);
4516 DEFUN (bgp_disable_connected_route_check
,
4517 bgp_disable_connected_route_check_cmd
,
4518 "bgp disable-ebgp-connected-route-check",
4520 "Disable checking if nexthop is connected on ebgp sessions\n")
4522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4523 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4524 bgp_clear_star_soft_in(vty
, bgp
->name
);
4529 DEFUN (no_bgp_disable_connected_route_check
,
4530 no_bgp_disable_connected_route_check_cmd
,
4531 "no bgp disable-ebgp-connected-route-check",
4534 "Disable checking if nexthop is connected on ebgp sessions\n")
4536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4537 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4538 bgp_clear_star_soft_in(vty
, bgp
->name
);
4544 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4550 int as_type
= AS_SPECIFIED
;
4553 if (as_str
[0] == 'i') {
4555 as_type
= AS_INTERNAL
;
4556 } else if (as_str
[0] == 'e') {
4558 as_type
= AS_EXTERNAL
;
4559 } else if (!asn_str2asn(as_str
, &as
))
4560 as_type
= AS_UNSPECIFIED
;
4562 if (as_type
== AS_UNSPECIFIED
) {
4563 vty_out(vty
, "%% Invalid peer AS: %s\n", as_str
);
4564 return CMD_WARNING_CONFIG_FAILED
;
4566 /* If peer is peer group or interface peer, call proper function. */
4567 ret
= str2sockunion(peer_str
, &su
);
4571 /* Check if existing interface peer */
4572 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4574 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, as_str
);
4576 /* if not interface peer, check peer-group settings */
4577 if (ret
< 0 && !peer
) {
4578 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
,
4582 "%% Create the peer-group or interface first\n");
4583 return CMD_WARNING_CONFIG_FAILED
;
4588 if (peer_address_self_check(bgp
, &su
)) {
4590 "%% Can not configure the local system as neighbor\n");
4591 return CMD_WARNING_CONFIG_FAILED
;
4593 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, as_str
);
4596 return bgp_vty_return(vty
, ret
);
4599 DEFUN (bgp_default_shutdown
,
4600 bgp_default_shutdown_cmd
,
4601 "[no] bgp default shutdown",
4604 "Configure BGP defaults\n"
4605 "Apply administrative shutdown to newly configured peers\n")
4607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4608 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4612 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4614 "Administrative shutdown of the BGP instance\n"
4615 "Add a shutdown message (RFC 8203)\n"
4616 "Shutdown message\n")
4618 char *msgstr
= NULL
;
4620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4623 msgstr
= argv_concat(argv
, argc
, 3);
4625 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4626 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4627 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4628 return CMD_WARNING_CONFIG_FAILED
;
4631 bgp_shutdown_enable(bgp
, msgstr
);
4632 XFREE(MTYPE_TMP
, msgstr
);
4637 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4638 BGP_STR
"Administrative shutdown of the BGP instance\n")
4640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4642 bgp_shutdown_enable(bgp
, NULL
);
4647 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4648 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4652 bgp_shutdown_disable(bgp
);
4657 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4658 "no bgp shutdown message MSG...", NO_STR BGP_STR
4659 "Administrative shutdown of the BGP instance\n"
4660 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4662 DEFUN (neighbor_remote_as
,
4663 neighbor_remote_as_cmd
,
4664 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <ASNUM|internal|external>",
4667 "Specify a BGP neighbor\n"
4669 "Internal BGP peer\n"
4670 "External BGP peer\n")
4673 int idx_remote_as
= 3;
4674 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4675 argv
[idx_remote_as
]->arg
);
4678 DEFPY (bgp_allow_martian
,
4679 bgp_allow_martian_cmd
,
4680 "[no]$no bgp allow-martian-nexthop",
4683 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4685 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4688 bgp
->allow_martian
= false;
4690 bgp
->allow_martian
= true;
4695 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4696 * sessions do not wait for hold timer expiry to bring down the sessions
4697 * when nexthop becomes unreachable
4699 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4700 BGP_STR
"Fast convergence for bgp sessions\n")
4702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4703 bgp
->fast_convergence
= true;
4708 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4709 "no bgp fast-convergence",
4710 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4713 bgp
->fast_convergence
= false;
4718 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4720 const char *peer_group_name
,
4723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4725 int as_type
= AS_UNSPECIFIED
;
4727 struct peer_group
*group
;
4730 group
= peer_group_lookup(bgp
, conf_if
);
4733 vty_out(vty
, "%% Name conflict with peer-group \n");
4734 return CMD_WARNING_CONFIG_FAILED
;
4738 if (as_str
[0] == 'i') {
4739 as_type
= AS_INTERNAL
;
4740 } else if (as_str
[0] == 'e') {
4741 as_type
= AS_EXTERNAL
;
4743 /* Get AS number. */
4744 if (asn_str2asn(as_str
, &as
))
4745 as_type
= AS_SPECIFIED
;
4749 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4752 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4755 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4756 NULL
, true, as_str
);
4759 vty_out(vty
, "%% BGP failed to create peer\n");
4760 return CMD_WARNING_CONFIG_FAILED
;
4764 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4766 /* Request zebra to initiate IPv6 RAs on this interface. We do
4768 * any unnumbered peer in order to not worry about run-time
4770 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4772 * gets deleted later etc.)
4775 bgp_zebra_initiate_radv(bgp
, peer
);
4778 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4779 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4781 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4783 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4785 /* v6only flag changed. Reset bgp seesion */
4786 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4787 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4788 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4789 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4791 bgp_session_reset(peer
);
4794 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4795 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4796 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4797 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4800 if (peer_group_name
) {
4801 group
= peer_group_lookup(bgp
, peer_group_name
);
4803 vty_out(vty
, "%% Configure the peer-group first\n");
4804 return CMD_WARNING_CONFIG_FAILED
;
4807 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4810 return bgp_vty_return(vty
, ret
);
4813 DEFUN (neighbor_interface_config
,
4814 neighbor_interface_config_cmd
,
4815 "neighbor WORD interface [peer-group PGNAME]",
4817 "Interface name or neighbor tag\n"
4818 "Enable BGP on interface\n"
4819 "Member of the peer-group\n"
4820 "Peer-group name\n")
4823 int idx_peer_group_word
= 4;
4825 if (argc
> idx_peer_group_word
)
4826 return peer_conf_interface_get(
4827 vty
, argv
[idx_word
]->arg
, 0,
4828 argv
[idx_peer_group_word
]->arg
, NULL
);
4830 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4834 DEFUN (neighbor_interface_config_v6only
,
4835 neighbor_interface_config_v6only_cmd
,
4836 "neighbor WORD interface v6only [peer-group PGNAME]",
4838 "Interface name or neighbor tag\n"
4839 "Enable BGP on interface\n"
4840 "Enable BGP with v6 link-local only\n"
4841 "Member of the peer-group\n"
4842 "Peer-group name\n")
4845 int idx_peer_group_word
= 5;
4847 if (argc
> idx_peer_group_word
)
4848 return peer_conf_interface_get(
4849 vty
, argv
[idx_word
]->arg
, 1,
4850 argv
[idx_peer_group_word
]->arg
, NULL
);
4852 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4856 DEFUN (neighbor_interface_config_remote_as
,
4857 neighbor_interface_config_remote_as_cmd
,
4858 "neighbor WORD interface remote-as <ASNUM|internal|external>",
4860 "Interface name or neighbor tag\n"
4861 "Enable BGP on interface\n"
4862 "Specify a BGP neighbor\n"
4864 "Internal BGP peer\n"
4865 "External BGP peer\n")
4868 int idx_remote_as
= 4;
4869 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4870 argv
[idx_remote_as
]->arg
);
4873 DEFUN (neighbor_interface_v6only_config_remote_as
,
4874 neighbor_interface_v6only_config_remote_as_cmd
,
4875 "neighbor WORD interface v6only remote-as <ASNUM|internal|external>",
4877 "Interface name or neighbor tag\n"
4878 "Enable BGP with v6 link-local only\n"
4879 "Enable BGP on interface\n"
4880 "Specify a BGP neighbor\n"
4882 "Internal BGP peer\n"
4883 "External BGP peer\n")
4886 int idx_remote_as
= 5;
4887 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4888 argv
[idx_remote_as
]->arg
);
4891 DEFUN (neighbor_peer_group
,
4892 neighbor_peer_group_cmd
,
4893 "neighbor WORD peer-group",
4895 "Interface name or neighbor tag\n"
4896 "Configure peer-group\n")
4898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4901 struct peer_group
*group
;
4903 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4905 vty_out(vty
, "%% Name conflict with interface: \n");
4906 return CMD_WARNING_CONFIG_FAILED
;
4909 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4911 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4912 return CMD_WARNING_CONFIG_FAILED
;
4920 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4924 "Specify a BGP neighbor\n"
4926 "Internal BGP peer\n"
4927 "External BGP peer\n")
4929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4933 struct peer_group
*group
;
4937 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4939 /* look up for neighbor by interface name config. */
4940 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4942 /* Request zebra to terminate IPv6 RAs on this
4945 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4946 peer_notify_unconfig(peer
);
4951 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4953 peer_group_notify_unconfig(group
);
4954 peer_group_delete(group
);
4956 vty_out(vty
, "%% Create the peer-group first\n");
4957 return CMD_WARNING_CONFIG_FAILED
;
4960 peer
= peer_lookup(bgp
, &su
);
4962 if (peer_dynamic_neighbor(peer
)) {
4964 "%% Operation not allowed on a dynamic neighbor\n");
4965 return CMD_WARNING_CONFIG_FAILED
;
4968 other
= peer
->doppelganger
;
4970 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4971 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4973 peer_notify_unconfig(peer
);
4975 if (other
&& other
->status
!= Deleted
) {
4976 peer_notify_unconfig(other
);
4985 DEFUN (no_neighbor_interface_config
,
4986 no_neighbor_interface_config_cmd
,
4987 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4991 "Configure BGP on interface\n"
4992 "Enable BGP with v6 link-local only\n"
4993 "Member of the peer-group\n"
4995 "Specify a BGP neighbor\n"
4997 "Internal BGP peer\n"
4998 "External BGP peer\n")
5000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5004 /* look up for neighbor by interface name config. */
5005 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
5007 /* Request zebra to terminate IPv6 RAs on this interface. */
5009 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5010 peer_notify_unconfig(peer
);
5013 vty_out(vty
, "%% Create the bgp interface first\n");
5014 return CMD_WARNING_CONFIG_FAILED
;
5019 DEFUN (no_neighbor_peer_group
,
5020 no_neighbor_peer_group_cmd
,
5021 "no neighbor WORD peer-group",
5025 "Configure peer-group\n")
5027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5029 struct peer_group
*group
;
5031 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5033 peer_group_notify_unconfig(group
);
5034 peer_group_delete(group
);
5036 vty_out(vty
, "%% Create the peer-group first\n");
5037 return CMD_WARNING_CONFIG_FAILED
;
5042 DEFUN (no_neighbor_interface_peer_group_remote_as
,
5043 no_neighbor_interface_peer_group_remote_as_cmd
,
5044 "no neighbor WORD remote-as <ASNUM|internal|external>",
5047 "Interface name or neighbor tag\n"
5048 "Specify a BGP neighbor\n"
5050 "Internal BGP peer\n"
5051 "External BGP peer\n")
5053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5055 struct peer_group
*group
;
5058 /* look up for neighbor by interface name config. */
5059 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
5061 peer_as_change(peer
, 0, AS_UNSPECIFIED
, NULL
);
5065 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5067 peer_group_remote_as_delete(group
);
5069 vty_out(vty
, "%% Create the peer-group or interface first\n");
5070 return CMD_WARNING_CONFIG_FAILED
;
5075 DEFUN (neighbor_local_as
,
5076 neighbor_local_as_cmd
,
5077 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM",
5080 "Specify a local-as number\n"
5081 "AS number expressed in dotted or plain format used as local AS\n")
5089 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5091 return CMD_WARNING_CONFIG_FAILED
;
5093 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5094 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5095 argv
[idx_number
]->arg
);
5096 return CMD_WARNING_CONFIG_FAILED
;
5099 ret
= peer_local_as_set(peer
, as
, 0, 0, argv
[idx_number
]->arg
);
5100 return bgp_vty_return(vty
, ret
);
5103 DEFUN (neighbor_local_as_no_prepend
,
5104 neighbor_local_as_no_prepend_cmd
,
5105 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend",
5108 "Specify a local-as number\n"
5109 "AS number expressed in dotted or plain format used as local AS\n"
5110 "Do not prepend local-as to updates from ebgp peers\n")
5118 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5120 return CMD_WARNING_CONFIG_FAILED
;
5122 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5123 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5124 argv
[idx_number
]->arg
);
5125 return CMD_WARNING_CONFIG_FAILED
;
5128 ret
= peer_local_as_set(peer
, as
, 1, 0, argv
[idx_number
]->arg
);
5129 return bgp_vty_return(vty
, ret
);
5132 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5133 neighbor_local_as_no_prepend_replace_as_cmd
,
5134 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend replace-as",
5137 "Specify a local-as number\n"
5138 "AS number expressed in dotted or plain format used as local AS\n"
5139 "Do not prepend local-as to updates from ebgp peers\n"
5140 "Do not prepend local-as to updates from ibgp peers\n")
5148 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5150 return CMD_WARNING_CONFIG_FAILED
;
5152 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5153 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5154 argv
[idx_number
]->arg
);
5155 return CMD_WARNING_CONFIG_FAILED
;
5158 ret
= peer_local_as_set(peer
, as
, 1, 1, argv
[idx_number
]->arg
);
5159 return bgp_vty_return(vty
, ret
);
5162 DEFUN (no_neighbor_local_as
,
5163 no_neighbor_local_as_cmd
,
5164 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [ASNUM [no-prepend [replace-as]]]",
5168 "Specify a local-as number\n"
5169 "AS number expressed in dotted or plain format used as local AS\n"
5170 "Do not prepend local-as to updates from ebgp peers\n"
5171 "Do not prepend local-as to updates from ibgp peers\n")
5177 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5179 return CMD_WARNING_CONFIG_FAILED
;
5181 ret
= peer_local_as_unset(peer
);
5182 return bgp_vty_return(vty
, ret
);
5186 DEFUN (neighbor_solo
,
5188 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5191 "Solo peer - part of its own update group\n")
5197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5199 return CMD_WARNING_CONFIG_FAILED
;
5201 ret
= update_group_adjust_soloness(peer
, 1);
5202 return bgp_vty_return(vty
, ret
);
5205 DEFUN (no_neighbor_solo
,
5206 no_neighbor_solo_cmd
,
5207 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5211 "Solo peer - part of its own update group\n")
5217 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5219 return CMD_WARNING_CONFIG_FAILED
;
5221 ret
= update_group_adjust_soloness(peer
, 0);
5222 return bgp_vty_return(vty
, ret
);
5225 DEFUN (neighbor_password
,
5226 neighbor_password_cmd
,
5227 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5238 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5240 return CMD_WARNING_CONFIG_FAILED
;
5242 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5243 return bgp_vty_return(vty
, ret
);
5246 DEFUN (no_neighbor_password
,
5247 no_neighbor_password_cmd
,
5248 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5259 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5261 return CMD_WARNING_CONFIG_FAILED
;
5263 ret
= peer_password_unset(peer
);
5264 return bgp_vty_return(vty
, ret
);
5267 DEFUN (neighbor_activate
,
5268 neighbor_activate_cmd
,
5269 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5272 "Enable the Address Family for this Neighbor\n")
5278 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5280 return CMD_WARNING_CONFIG_FAILED
;
5282 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5283 return bgp_vty_return(vty
, ret
);
5286 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5287 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5288 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5289 "Enable the Address Family for this Neighbor\n")
5291 DEFUN (no_neighbor_activate
,
5292 no_neighbor_activate_cmd
,
5293 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5297 "Enable the Address Family for this Neighbor\n")
5304 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5306 return CMD_WARNING_CONFIG_FAILED
;
5308 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5309 return bgp_vty_return(vty
, ret
);
5312 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5313 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5314 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5315 "Enable the Address Family for this Neighbor\n")
5317 DEFUN (neighbor_set_peer_group
,
5318 neighbor_set_peer_group_cmd
,
5319 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5322 "Member of the peer-group\n"
5323 "Peer-group name\n")
5325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5332 struct peer_group
*group
;
5334 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5336 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5338 vty_out(vty
, "%% Malformed address or name: %s\n",
5339 argv
[idx_peer
]->arg
);
5340 return CMD_WARNING_CONFIG_FAILED
;
5343 if (peer_address_self_check(bgp
, &su
)) {
5345 "%% Can not configure the local system as neighbor\n");
5346 return CMD_WARNING_CONFIG_FAILED
;
5349 /* Disallow for dynamic neighbor. */
5350 peer
= peer_lookup(bgp
, &su
);
5351 if (peer
&& peer_dynamic_neighbor(peer
)) {
5353 "%% Operation not allowed on a dynamic neighbor\n");
5354 return CMD_WARNING_CONFIG_FAILED
;
5358 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5360 vty_out(vty
, "%% Configure the peer-group first\n");
5361 return CMD_WARNING_CONFIG_FAILED
;
5364 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5366 return bgp_vty_return(vty
, ret
);
5369 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5370 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5371 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5372 "Member of the peer-group\n"
5373 "Peer-group name\n")
5375 DEFUN (no_neighbor_set_peer_group
,
5376 no_neighbor_set_peer_group_cmd
,
5377 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5381 "Member of the peer-group\n"
5382 "Peer-group name\n")
5384 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5389 struct peer_group
*group
;
5391 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5393 return CMD_WARNING_CONFIG_FAILED
;
5395 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5397 vty_out(vty
, "%% Configure the peer-group first\n");
5398 return CMD_WARNING_CONFIG_FAILED
;
5401 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5402 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5404 peer_notify_unconfig(peer
);
5405 ret
= peer_delete(peer
);
5407 return bgp_vty_return(vty
, ret
);
5410 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5411 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5412 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5413 "Member of the peer-group\n"
5414 "Peer-group name\n")
5416 /* neighbor passive. */
5417 DEFUN (neighbor_passive
,
5418 neighbor_passive_cmd
,
5419 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5422 "Don't send open messages to this neighbor\n")
5425 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5428 DEFUN (no_neighbor_passive
,
5429 no_neighbor_passive_cmd
,
5430 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5434 "Don't send open messages to this neighbor\n")
5437 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5440 /* neighbor shutdown. */
5441 DEFUN (neighbor_shutdown_msg
,
5442 neighbor_shutdown_msg_cmd
,
5443 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5446 "Administratively shut down this neighbor\n"
5447 "Add a shutdown message (RFC 8203)\n"
5448 "Shutdown message\n")
5454 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5458 return CMD_WARNING_CONFIG_FAILED
;
5459 message
= argv_concat(argv
, argc
, 4);
5460 peer_tx_shutdown_message_set(peer
, message
);
5461 XFREE(MTYPE_TMP
, message
);
5464 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5467 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5468 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5469 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5470 "Administratively shut down this neighbor\n")
5472 DEFUN (no_neighbor_shutdown_msg
,
5473 no_neighbor_shutdown_msg_cmd
,
5474 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5478 "Administratively shut down this neighbor\n"
5479 "Remove a shutdown message (RFC 8203)\n"
5480 "Shutdown message\n")
5484 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5485 PEER_FLAG_SHUTDOWN
);
5488 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5489 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5490 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5491 "Administratively shut down this neighbor\n")
5493 DEFUN(neighbor_shutdown_rtt
,
5494 neighbor_shutdown_rtt_cmd
,
5495 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5498 "Administratively shut down this neighbor\n"
5499 "Shutdown if round-trip-time is higher than expected\n"
5500 "Round-trip-time in milliseconds\n"
5501 "Specify the number of keepalives before shutdown\n"
5502 "The number of keepalives with higher RTT to shutdown\n")
5509 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5512 return CMD_WARNING_CONFIG_FAILED
;
5514 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5516 if (argv_find(argv
, argc
, "count", &idx_count
))
5517 peer
->rtt_keepalive_conf
=
5518 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5520 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5521 PEER_FLAG_RTT_SHUTDOWN
);
5524 DEFUN(no_neighbor_shutdown_rtt
,
5525 no_neighbor_shutdown_rtt_cmd
,
5526 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5530 "Administratively shut down this neighbor\n"
5531 "Shutdown if round-trip-time is higher than expected\n"
5532 "Round-trip-time in milliseconds\n"
5533 "Specify the number of keepalives before shutdown\n"
5534 "The number of keepalives with higher RTT to shutdown\n")
5539 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5542 return CMD_WARNING_CONFIG_FAILED
;
5544 peer
->rtt_expected
= 0;
5545 peer
->rtt_keepalive_conf
= 1;
5547 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5548 PEER_FLAG_RTT_SHUTDOWN
);
5551 /* neighbor capability dynamic. */
5552 DEFUN (neighbor_capability_dynamic
,
5553 neighbor_capability_dynamic_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5557 "Advertise capability to the peer\n"
5558 "Advertise dynamic capability to this neighbor\n")
5561 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5562 PEER_FLAG_DYNAMIC_CAPABILITY
);
5565 DEFUN (no_neighbor_capability_dynamic
,
5566 no_neighbor_capability_dynamic_cmd
,
5567 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5571 "Advertise capability to the peer\n"
5572 "Advertise dynamic capability to this neighbor\n")
5575 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5576 PEER_FLAG_DYNAMIC_CAPABILITY
);
5579 /* neighbor dont-capability-negotiate */
5580 DEFUN (neighbor_dont_capability_negotiate
,
5581 neighbor_dont_capability_negotiate_cmd
,
5582 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5585 "Do not perform capability negotiation\n")
5588 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5589 PEER_FLAG_DONT_CAPABILITY
);
5592 DEFUN (no_neighbor_dont_capability_negotiate
,
5593 no_neighbor_dont_capability_negotiate_cmd
,
5594 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5598 "Do not perform capability negotiation\n")
5601 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5602 PEER_FLAG_DONT_CAPABILITY
);
5605 /* neighbor capability extended next hop encoding */
5606 DEFUN (neighbor_capability_enhe
,
5607 neighbor_capability_enhe_cmd
,
5608 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5611 "Advertise capability to the peer\n"
5612 "Advertise extended next-hop capability to the peer\n")
5617 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5618 if (peer
&& peer
->conf_if
)
5621 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5622 PEER_FLAG_CAPABILITY_ENHE
);
5625 DEFUN (no_neighbor_capability_enhe
,
5626 no_neighbor_capability_enhe_cmd
,
5627 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5631 "Advertise capability to the peer\n"
5632 "Advertise extended next-hop capability to the peer\n")
5637 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5638 if (peer
&& peer
->conf_if
) {
5640 "Peer %s cannot have capability extended-nexthop turned off\n",
5641 argv
[idx_peer
]->arg
);
5642 return CMD_WARNING_CONFIG_FAILED
;
5645 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5646 PEER_FLAG_CAPABILITY_ENHE
);
5649 /* neighbor capability software-version */
5650 DEFPY(neighbor_capability_software_version
,
5651 neighbor_capability_software_version_cmd
,
5652 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor capability software-version",
5656 "Advertise capability to the peer\n"
5657 "Advertise Software Version capability to the peer\n")
5661 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
5662 if (peer
&& peer
->conf_if
)
5666 return peer_flag_unset_vty(vty
, neighbor
,
5667 PEER_FLAG_CAPABILITY_SOFT_VERSION
);
5669 return peer_flag_set_vty(vty
, neighbor
,
5670 PEER_FLAG_CAPABILITY_SOFT_VERSION
);
5673 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5674 afi_t afi
, safi_t safi
, uint64_t flag
,
5680 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5682 return CMD_WARNING_CONFIG_FAILED
;
5685 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5687 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5689 return bgp_vty_return(vty
, ret
);
5692 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5693 afi_t afi
, safi_t safi
, uint64_t flag
)
5695 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5698 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5699 afi_t afi
, safi_t safi
, uint64_t flag
)
5701 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5704 /* neighbor capability orf prefix-list. */
5705 DEFUN (neighbor_capability_orf_prefix
,
5706 neighbor_capability_orf_prefix_cmd
,
5707 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5710 "Advertise capability to the peer\n"
5711 "Advertise ORF capability to the peer\n"
5712 "Advertise prefixlist ORF capability to this neighbor\n"
5713 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5714 "Capability to RECEIVE the ORF from this neighbor\n"
5715 "Capability to SEND the ORF to this neighbor\n")
5717 int idx_send_recv
= 5;
5718 char *peer_str
= argv
[1]->arg
;
5720 afi_t afi
= bgp_node_afi(vty
);
5721 safi_t safi
= bgp_node_safi(vty
);
5723 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5725 return CMD_WARNING_CONFIG_FAILED
;
5727 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5728 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5729 PEER_FLAG_ORF_PREFIX_SM
);
5731 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5732 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5733 PEER_FLAG_ORF_PREFIX_RM
);
5735 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5736 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5737 PEER_FLAG_ORF_PREFIX_SM
)
5738 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5739 PEER_FLAG_ORF_PREFIX_RM
);
5741 return CMD_WARNING_CONFIG_FAILED
;
5745 neighbor_capability_orf_prefix
,
5746 neighbor_capability_orf_prefix_hidden_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5748 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5749 "Advertise capability to the peer\n"
5750 "Advertise ORF capability to the peer\n"
5751 "Advertise prefixlist ORF capability to this neighbor\n"
5752 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5753 "Capability to RECEIVE the ORF from this neighbor\n"
5754 "Capability to SEND the ORF to this neighbor\n")
5756 DEFUN (no_neighbor_capability_orf_prefix
,
5757 no_neighbor_capability_orf_prefix_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5762 "Advertise capability to the peer\n"
5763 "Advertise ORF capability to the peer\n"
5764 "Advertise prefixlist ORF capability to this neighbor\n"
5765 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5766 "Capability to RECEIVE the ORF from this neighbor\n"
5767 "Capability to SEND the ORF to this neighbor\n")
5769 int idx_send_recv
= 6;
5770 char *peer_str
= argv
[2]->arg
;
5772 afi_t afi
= bgp_node_afi(vty
);
5773 safi_t safi
= bgp_node_safi(vty
);
5775 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5777 return CMD_WARNING_CONFIG_FAILED
;
5779 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5780 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5781 PEER_FLAG_ORF_PREFIX_SM
);
5783 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5784 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5785 PEER_FLAG_ORF_PREFIX_RM
);
5787 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5788 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5789 PEER_FLAG_ORF_PREFIX_SM
)
5790 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5791 PEER_FLAG_ORF_PREFIX_RM
);
5793 return CMD_WARNING_CONFIG_FAILED
;
5797 no_neighbor_capability_orf_prefix
,
5798 no_neighbor_capability_orf_prefix_hidden_cmd
,
5799 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5800 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5801 "Advertise capability to the peer\n"
5802 "Advertise ORF capability to the peer\n"
5803 "Advertise prefixlist ORF capability to this neighbor\n"
5804 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5805 "Capability to RECEIVE the ORF from this neighbor\n"
5806 "Capability to SEND the ORF to this neighbor\n")
5808 /* neighbor next-hop-self. */
5809 DEFUN (neighbor_nexthop_self
,
5810 neighbor_nexthop_self_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5814 "Disable the next hop calculation for this neighbor\n")
5817 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5818 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5821 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5823 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5824 "Disable the next hop calculation for this neighbor\n")
5826 /* neighbor next-hop-self. */
5827 DEFUN (neighbor_nexthop_self_force
,
5828 neighbor_nexthop_self_force_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5832 "Disable the next hop calculation for this neighbor\n"
5833 "Set the next hop to self for reflected routes\n")
5836 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5838 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5841 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5842 neighbor_nexthop_self_force_hidden_cmd
,
5843 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5844 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5845 "Disable the next hop calculation for this neighbor\n"
5846 "Set the next hop to self for reflected routes\n")
5848 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5849 neighbor_nexthop_self_all_hidden_cmd
,
5850 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5851 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5852 "Disable the next hop calculation for this neighbor\n"
5853 "Set the next hop to self for reflected routes\n")
5855 DEFUN (no_neighbor_nexthop_self
,
5856 no_neighbor_nexthop_self_cmd
,
5857 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5861 "Disable the next hop calculation for this neighbor\n")
5864 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5865 bgp_node_afi(vty
), bgp_node_safi(vty
),
5866 PEER_FLAG_NEXTHOP_SELF
);
5869 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5870 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5871 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5872 "Disable the next hop calculation for this neighbor\n")
5874 DEFUN (no_neighbor_nexthop_self_force
,
5875 no_neighbor_nexthop_self_force_cmd
,
5876 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5880 "Disable the next hop calculation for this neighbor\n"
5881 "Set the next hop to self for reflected routes\n")
5884 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5885 bgp_node_afi(vty
), bgp_node_safi(vty
),
5886 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5889 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5890 no_neighbor_nexthop_self_force_hidden_cmd
,
5891 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5892 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5893 "Disable the next hop calculation for this neighbor\n"
5894 "Set the next hop to self for reflected routes\n")
5896 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5897 no_neighbor_nexthop_self_all_hidden_cmd
,
5898 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5899 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5900 "Disable the next hop calculation for this neighbor\n"
5901 "Set the next hop to self for reflected routes\n")
5903 /* neighbor as-override */
5904 DEFUN (neighbor_as_override
,
5905 neighbor_as_override_cmd
,
5906 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5909 "Override ASNs in outbound updates if aspath equals remote-as\n")
5912 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5913 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5916 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5917 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5918 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5919 "Override ASNs in outbound updates if aspath equals remote-as\n")
5921 DEFUN (no_neighbor_as_override
,
5922 no_neighbor_as_override_cmd
,
5923 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5927 "Override ASNs in outbound updates if aspath equals remote-as\n")
5930 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5931 bgp_node_afi(vty
), bgp_node_safi(vty
),
5932 PEER_FLAG_AS_OVERRIDE
);
5935 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5936 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5937 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5938 "Override ASNs in outbound updates if aspath equals remote-as\n")
5940 /* neighbor remove-private-AS. */
5941 DEFUN (neighbor_remove_private_as
,
5942 neighbor_remove_private_as_cmd
,
5943 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5946 "Remove private ASNs in outbound updates\n")
5949 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5951 PEER_FLAG_REMOVE_PRIVATE_AS
);
5954 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5955 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5956 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Remove private ASNs in outbound updates\n")
5959 DEFUN (neighbor_remove_private_as_all
,
5960 neighbor_remove_private_as_all_cmd
,
5961 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5964 "Remove private ASNs in outbound updates\n"
5965 "Apply to all AS numbers\n")
5968 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5970 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5973 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5974 neighbor_remove_private_as_all_hidden_cmd
,
5975 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5976 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5977 "Remove private ASNs in outbound updates\n"
5978 "Apply to all AS numbers\n")
5980 DEFUN (neighbor_remove_private_as_replace_as
,
5981 neighbor_remove_private_as_replace_as_cmd
,
5982 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5985 "Remove private ASNs in outbound updates\n"
5986 "Replace private ASNs with our ASN in outbound updates\n")
5989 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5991 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5994 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5995 neighbor_remove_private_as_replace_as_hidden_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5997 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5998 "Remove private ASNs in outbound updates\n"
5999 "Replace private ASNs with our ASN in outbound updates\n")
6001 DEFUN (neighbor_remove_private_as_all_replace_as
,
6002 neighbor_remove_private_as_all_replace_as_cmd
,
6003 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6006 "Remove private ASNs in outbound updates\n"
6007 "Apply to all AS numbers\n"
6008 "Replace private ASNs with our ASN in outbound updates\n")
6011 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6013 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
6017 neighbor_remove_private_as_all_replace_as
,
6018 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6019 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6020 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6021 "Remove private ASNs in outbound updates\n"
6022 "Apply to all AS numbers\n"
6023 "Replace private ASNs with our ASN in outbound updates\n")
6025 DEFUN (no_neighbor_remove_private_as
,
6026 no_neighbor_remove_private_as_cmd
,
6027 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6031 "Remove private ASNs in outbound updates\n")
6034 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6035 bgp_node_afi(vty
), bgp_node_safi(vty
),
6036 PEER_FLAG_REMOVE_PRIVATE_AS
);
6039 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
6040 no_neighbor_remove_private_as_hidden_cmd
,
6041 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6042 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6043 "Remove private ASNs in outbound updates\n")
6045 DEFUN (no_neighbor_remove_private_as_all
,
6046 no_neighbor_remove_private_as_all_cmd
,
6047 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6051 "Remove private ASNs in outbound updates\n"
6052 "Apply to all AS numbers\n")
6055 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6056 bgp_node_afi(vty
), bgp_node_safi(vty
),
6057 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
6060 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6061 no_neighbor_remove_private_as_all_hidden_cmd
,
6062 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6063 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6064 "Remove private ASNs in outbound updates\n"
6065 "Apply to all AS numbers\n")
6067 DEFUN (no_neighbor_remove_private_as_replace_as
,
6068 no_neighbor_remove_private_as_replace_as_cmd
,
6069 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6073 "Remove private ASNs in outbound updates\n"
6074 "Replace private ASNs with our ASN in outbound updates\n")
6077 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6078 bgp_node_afi(vty
), bgp_node_safi(vty
),
6079 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
6082 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6083 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6084 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6085 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6086 "Remove private ASNs in outbound updates\n"
6087 "Replace private ASNs with our ASN in outbound updates\n")
6089 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
6090 no_neighbor_remove_private_as_all_replace_as_cmd
,
6091 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6095 "Remove private ASNs in outbound updates\n"
6096 "Apply to all AS numbers\n"
6097 "Replace private ASNs with our ASN in outbound updates\n")
6100 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6101 bgp_node_afi(vty
), bgp_node_safi(vty
),
6102 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
6106 no_neighbor_remove_private_as_all_replace_as
,
6107 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6109 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6110 "Remove private ASNs in outbound updates\n"
6111 "Apply to all AS numbers\n"
6112 "Replace private ASNs with our ASN in outbound updates\n")
6115 /* neighbor send-community. */
6116 DEFUN (neighbor_send_community
,
6117 neighbor_send_community_cmd
,
6118 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6121 "Send Community attribute to this neighbor\n")
6125 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6127 PEER_FLAG_SEND_COMMUNITY
);
6130 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6131 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6132 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6133 "Send Community attribute to this neighbor\n")
6135 DEFUN (no_neighbor_send_community
,
6136 no_neighbor_send_community_cmd
,
6137 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6141 "Send Community attribute to this neighbor\n")
6145 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6146 bgp_node_afi(vty
), bgp_node_safi(vty
),
6147 PEER_FLAG_SEND_COMMUNITY
);
6150 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6151 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6152 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6153 "Send Community attribute to this neighbor\n")
6155 /* neighbor send-community extended. */
6156 DEFUN (neighbor_send_community_type
,
6157 neighbor_send_community_type_cmd
,
6158 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6161 "Send Community attribute to this neighbor\n"
6162 "Send Standard and Extended Community attributes\n"
6163 "Send Standard, Large and Extended Community attributes\n"
6164 "Send Extended Community attributes\n"
6165 "Send Standard Community attributes\n"
6166 "Send Large Community attributes\n")
6168 const char *type
= argv
[argc
- 1]->text
;
6169 char *peer_str
= argv
[1]->arg
;
6171 afi_t afi
= bgp_node_afi(vty
);
6172 safi_t safi
= bgp_node_safi(vty
);
6174 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6176 return CMD_WARNING_CONFIG_FAILED
;
6178 if (strmatch(type
, "standard"))
6179 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6180 PEER_FLAG_SEND_COMMUNITY
);
6182 if (strmatch(type
, "extended"))
6183 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6184 PEER_FLAG_SEND_EXT_COMMUNITY
);
6186 if (strmatch(type
, "large"))
6187 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6188 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6190 if (strmatch(type
, "both")) {
6191 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6192 PEER_FLAG_SEND_COMMUNITY
)
6193 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6194 PEER_FLAG_SEND_EXT_COMMUNITY
);
6196 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6197 PEER_FLAG_SEND_COMMUNITY
)
6198 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6199 PEER_FLAG_SEND_EXT_COMMUNITY
)
6200 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6201 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6205 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6206 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6207 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6208 "Send Community attribute to this neighbor\n"
6209 "Send Standard and Extended Community attributes\n"
6210 "Send Standard, Large and Extended Community attributes\n"
6211 "Send Extended Community attributes\n"
6212 "Send Standard Community attributes\n"
6213 "Send Large Community attributes\n")
6215 DEFUN (no_neighbor_send_community_type
,
6216 no_neighbor_send_community_type_cmd
,
6217 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6221 "Send Community attribute to this neighbor\n"
6222 "Send Standard and Extended Community attributes\n"
6223 "Send Standard, Large and Extended Community attributes\n"
6224 "Send Extended Community attributes\n"
6225 "Send Standard Community attributes\n"
6226 "Send Large Community attributes\n")
6228 const char *type
= argv
[argc
- 1]->text
;
6229 char *peer_str
= argv
[2]->arg
;
6231 afi_t afi
= bgp_node_afi(vty
);
6232 safi_t safi
= bgp_node_safi(vty
);
6234 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6236 return CMD_WARNING_CONFIG_FAILED
;
6238 if (strmatch(type
, "standard"))
6239 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6240 PEER_FLAG_SEND_COMMUNITY
);
6242 if (strmatch(type
, "extended"))
6243 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6244 PEER_FLAG_SEND_EXT_COMMUNITY
);
6246 if (strmatch(type
, "large"))
6247 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6248 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6250 if (strmatch(type
, "both")) {
6252 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6253 PEER_FLAG_SEND_COMMUNITY
)
6254 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6255 PEER_FLAG_SEND_EXT_COMMUNITY
);
6258 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6259 PEER_FLAG_SEND_COMMUNITY
)
6260 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6261 PEER_FLAG_SEND_EXT_COMMUNITY
)
6262 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6263 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6267 no_neighbor_send_community_type
,
6268 no_neighbor_send_community_type_hidden_cmd
,
6269 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6270 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6271 "Send Community attribute to this neighbor\n"
6272 "Send Standard and Extended Community attributes\n"
6273 "Send Standard, Large and Extended Community attributes\n"
6274 "Send Extended Community attributes\n"
6275 "Send Standard Community attributes\n"
6276 "Send Large Community attributes\n")
6278 /* neighbor soft-reconfig. */
6279 DEFUN (neighbor_soft_reconfiguration
,
6280 neighbor_soft_reconfiguration_cmd
,
6281 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6284 "Per neighbor soft reconfiguration\n"
6285 "Allow inbound soft reconfiguration for this neighbor\n")
6288 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6290 PEER_FLAG_SOFT_RECONFIG
);
6293 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6294 neighbor_soft_reconfiguration_hidden_cmd
,
6295 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6296 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6297 "Per neighbor soft reconfiguration\n"
6298 "Allow inbound soft reconfiguration for this neighbor\n")
6300 DEFUN (no_neighbor_soft_reconfiguration
,
6301 no_neighbor_soft_reconfiguration_cmd
,
6302 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6306 "Per neighbor soft reconfiguration\n"
6307 "Allow inbound soft reconfiguration for this neighbor\n")
6310 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6311 bgp_node_afi(vty
), bgp_node_safi(vty
),
6312 PEER_FLAG_SOFT_RECONFIG
);
6315 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6316 no_neighbor_soft_reconfiguration_hidden_cmd
,
6317 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6318 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6319 "Per neighbor soft reconfiguration\n"
6320 "Allow inbound soft reconfiguration for this neighbor\n")
6322 DEFUN (neighbor_route_reflector_client
,
6323 neighbor_route_reflector_client_cmd
,
6324 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6327 "Configure a neighbor as Route Reflector client\n")
6333 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6335 return CMD_WARNING_CONFIG_FAILED
;
6337 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6339 PEER_FLAG_REFLECTOR_CLIENT
);
6342 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6343 neighbor_route_reflector_client_hidden_cmd
,
6344 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6345 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6346 "Configure a neighbor as Route Reflector client\n")
6348 DEFUN (no_neighbor_route_reflector_client
,
6349 no_neighbor_route_reflector_client_cmd
,
6350 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6354 "Configure a neighbor as Route Reflector client\n")
6357 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6358 bgp_node_afi(vty
), bgp_node_safi(vty
),
6359 PEER_FLAG_REFLECTOR_CLIENT
);
6362 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6363 no_neighbor_route_reflector_client_hidden_cmd
,
6364 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6365 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6366 "Configure a neighbor as Route Reflector client\n")
6368 /* neighbor route-server-client. */
6369 DEFUN (neighbor_route_server_client
,
6370 neighbor_route_server_client_cmd
,
6371 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6374 "Configure a neighbor as Route Server client\n")
6379 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6381 return CMD_WARNING_CONFIG_FAILED
;
6382 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6384 PEER_FLAG_RSERVER_CLIENT
);
6387 ALIAS_HIDDEN(neighbor_route_server_client
,
6388 neighbor_route_server_client_hidden_cmd
,
6389 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6390 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6391 "Configure a neighbor as Route Server client\n")
6393 DEFUN (no_neighbor_route_server_client
,
6394 no_neighbor_route_server_client_cmd
,
6395 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6399 "Configure a neighbor as Route Server client\n")
6402 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6403 bgp_node_afi(vty
), bgp_node_safi(vty
),
6404 PEER_FLAG_RSERVER_CLIENT
);
6407 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6408 no_neighbor_route_server_client_hidden_cmd
,
6409 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6410 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6411 "Configure a neighbor as Route Server client\n")
6413 DEFUN (neighbor_nexthop_local_unchanged
,
6414 neighbor_nexthop_local_unchanged_cmd
,
6415 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6418 "Configure treatment of outgoing link-local nexthop attribute\n"
6419 "Leave link-local nexthop unchanged for this peer\n")
6422 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6424 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6427 DEFUN (no_neighbor_nexthop_local_unchanged
,
6428 no_neighbor_nexthop_local_unchanged_cmd
,
6429 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6433 "Configure treatment of outgoing link-local-nexthop attribute\n"
6434 "Leave link-local nexthop unchanged for this peer\n")
6437 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6438 bgp_node_afi(vty
), bgp_node_safi(vty
),
6439 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6442 DEFUN (neighbor_attr_unchanged
,
6443 neighbor_attr_unchanged_cmd
,
6444 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6447 "BGP attribute is propagated unchanged to this neighbor\n"
6448 "As-path attribute\n"
6449 "Nexthop attribute\n"
6453 char *peer_str
= argv
[1]->arg
;
6455 bool aspath
= false;
6456 bool nexthop
= false;
6458 afi_t afi
= bgp_node_afi(vty
);
6459 safi_t safi
= bgp_node_safi(vty
);
6462 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6464 return CMD_WARNING_CONFIG_FAILED
;
6466 if (argv_find(argv
, argc
, "as-path", &idx
))
6470 if (argv_find(argv
, argc
, "next-hop", &idx
))
6474 if (argv_find(argv
, argc
, "med", &idx
))
6477 /* no flags means all of them! */
6478 if (!aspath
&& !nexthop
&& !med
) {
6479 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6480 PEER_FLAG_AS_PATH_UNCHANGED
);
6481 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6482 PEER_FLAG_NEXTHOP_UNCHANGED
);
6483 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6484 PEER_FLAG_MED_UNCHANGED
);
6487 if (peer_af_flag_check(peer
, afi
, safi
,
6488 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6489 ret
|= peer_af_flag_unset_vty(
6490 vty
, peer_str
, afi
, safi
,
6491 PEER_FLAG_AS_PATH_UNCHANGED
);
6494 ret
|= peer_af_flag_set_vty(
6495 vty
, peer_str
, afi
, safi
,
6496 PEER_FLAG_AS_PATH_UNCHANGED
);
6499 if (peer_af_flag_check(peer
, afi
, safi
,
6500 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6501 ret
|= peer_af_flag_unset_vty(
6502 vty
, peer_str
, afi
, safi
,
6503 PEER_FLAG_NEXTHOP_UNCHANGED
);
6506 ret
|= peer_af_flag_set_vty(
6507 vty
, peer_str
, afi
, safi
,
6508 PEER_FLAG_NEXTHOP_UNCHANGED
);
6511 if (peer_af_flag_check(peer
, afi
, safi
,
6512 PEER_FLAG_MED_UNCHANGED
)) {
6513 ret
|= peer_af_flag_unset_vty(
6514 vty
, peer_str
, afi
, safi
,
6515 PEER_FLAG_MED_UNCHANGED
);
6518 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6519 PEER_FLAG_MED_UNCHANGED
);
6526 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6527 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6528 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6529 "BGP attribute is propagated unchanged to this neighbor\n"
6530 "As-path attribute\n"
6531 "Nexthop attribute\n"
6534 DEFUN (no_neighbor_attr_unchanged
,
6535 no_neighbor_attr_unchanged_cmd
,
6536 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6540 "BGP attribute is propagated unchanged to this neighbor\n"
6541 "As-path attribute\n"
6542 "Nexthop attribute\n"
6546 char *peer_str
= argv
[2]->arg
;
6548 bool aspath
= false;
6549 bool nexthop
= false;
6551 afi_t afi
= bgp_node_afi(vty
);
6552 safi_t safi
= bgp_node_safi(vty
);
6555 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6557 return CMD_WARNING_CONFIG_FAILED
;
6559 if (argv_find(argv
, argc
, "as-path", &idx
))
6563 if (argv_find(argv
, argc
, "next-hop", &idx
))
6567 if (argv_find(argv
, argc
, "med", &idx
))
6570 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6571 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6572 PEER_FLAG_AS_PATH_UNCHANGED
)
6573 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6574 PEER_FLAG_NEXTHOP_UNCHANGED
)
6575 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6576 PEER_FLAG_MED_UNCHANGED
);
6579 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6580 PEER_FLAG_AS_PATH_UNCHANGED
);
6583 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6584 PEER_FLAG_NEXTHOP_UNCHANGED
);
6587 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6588 PEER_FLAG_MED_UNCHANGED
);
6594 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6595 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6596 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6597 "BGP attribute is propagated unchanged to this neighbor\n"
6598 "As-path attribute\n"
6599 "Nexthop attribute\n"
6602 /* EBGP multihop configuration. */
6603 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6604 const char *ttl_str
)
6609 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6611 return CMD_WARNING_CONFIG_FAILED
;
6614 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6619 ttl
= strtoul(ttl_str
, NULL
, 10);
6621 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6624 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6628 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6630 return CMD_WARNING_CONFIG_FAILED
;
6632 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6635 /* neighbor ebgp-multihop. */
6636 DEFUN (neighbor_ebgp_multihop
,
6637 neighbor_ebgp_multihop_cmd
,
6638 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6641 "Allow EBGP neighbors not on directly connected networks\n")
6644 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6647 DEFUN (neighbor_ebgp_multihop_ttl
,
6648 neighbor_ebgp_multihop_ttl_cmd
,
6649 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6652 "Allow EBGP neighbors not on directly connected networks\n"
6653 "maximum hop count\n")
6657 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6658 argv
[idx_number
]->arg
);
6661 DEFUN (no_neighbor_ebgp_multihop
,
6662 no_neighbor_ebgp_multihop_cmd
,
6663 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6667 "Allow EBGP neighbors not on directly connected networks\n"
6668 "maximum hop count\n")
6671 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6674 DEFPY (neighbor_aigp
,
6676 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6680 "Enable send and receive of the AIGP attribute per neighbor\n")
6684 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6686 return CMD_WARNING_CONFIG_FAILED
;
6689 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6691 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6694 static uint8_t get_role_by_name(const char *role_str
)
6696 if (strncmp(role_str
, "peer", 2) == 0)
6698 if (strncmp(role_str
, "provider", 2) == 0)
6699 return ROLE_PROVIDER
;
6700 if (strncmp(role_str
, "customer", 2) == 0)
6701 return ROLE_CUSTOMER
;
6702 if (strncmp(role_str
, "rs-server", 4) == 0)
6703 return ROLE_RS_SERVER
;
6704 if (strncmp(role_str
, "rs-client", 4) == 0)
6705 return ROLE_RS_CLIENT
;
6706 return ROLE_UNDEFINED
;
6709 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6710 const char *role_str
, bool strict_mode
)
6714 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6716 return CMD_WARNING_CONFIG_FAILED
;
6717 uint8_t role
= get_role_by_name(role_str
);
6719 if (role
== ROLE_UNDEFINED
)
6720 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6721 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6724 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6728 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6730 return CMD_WARNING_CONFIG_FAILED
;
6731 return bgp_vty_return(vty
, peer_role_unset(peer
));
6734 DEFPY(neighbor_role
,
6736 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6739 "Set session role\n"
6745 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6749 DEFPY(neighbor_role_strict
,
6750 neighbor_role_strict_cmd
,
6751 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6754 "Set session role\n"
6756 "Use additional restriction on peer\n")
6761 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6765 DEFPY(no_neighbor_role
,
6766 no_neighbor_role_cmd
,
6767 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6771 "Set session role\n"
6773 "Use additional restriction on peer\n")
6777 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6780 /* disable-connected-check */
6781 DEFUN (neighbor_disable_connected_check
,
6782 neighbor_disable_connected_check_cmd
,
6783 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6786 "one-hop away EBGP peer using loopback address\n"
6787 "Enforce EBGP neighbors perform multihop\n")
6790 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6791 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6794 DEFUN (no_neighbor_disable_connected_check
,
6795 no_neighbor_disable_connected_check_cmd
,
6796 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6800 "one-hop away EBGP peer using loopback address\n"
6801 "Enforce EBGP neighbors perform multihop\n")
6804 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6805 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6808 /* disable-link-bw-encoding-ieee */
6809 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6810 neighbor_disable_link_bw_encoding_ieee_cmd
,
6811 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6813 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6817 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6818 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6821 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6822 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6823 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6824 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6825 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6829 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6830 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6833 /* extended-optional-parameters */
6834 DEFUN(neighbor_extended_optional_parameters
,
6835 neighbor_extended_optional_parameters_cmd
,
6836 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6837 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6838 "Force the extended optional parameters format for OPEN messages\n")
6842 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6843 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6846 DEFUN(no_neighbor_extended_optional_parameters
,
6847 no_neighbor_extended_optional_parameters_cmd
,
6848 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6849 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6850 "Force the extended optional parameters format for OPEN messages\n")
6854 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6855 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6858 /* enforce-first-as */
6859 DEFUN (neighbor_enforce_first_as
,
6860 neighbor_enforce_first_as_cmd
,
6861 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6864 "Enforce the first AS for EBGP routes\n")
6868 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6869 PEER_FLAG_ENFORCE_FIRST_AS
);
6872 DEFUN (no_neighbor_enforce_first_as
,
6873 no_neighbor_enforce_first_as_cmd
,
6874 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6878 "Enforce the first AS for EBGP routes\n")
6882 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6883 PEER_FLAG_ENFORCE_FIRST_AS
);
6887 DEFUN (neighbor_description
,
6888 neighbor_description_cmd
,
6889 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6892 "Neighbor specific description\n"
6893 "Up to 80 characters describing this neighbor\n")
6900 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6902 return CMD_WARNING_CONFIG_FAILED
;
6904 str
= argv_concat(argv
, argc
, idx_line
);
6906 peer_description_set(peer
, str
);
6908 XFREE(MTYPE_TMP
, str
);
6913 DEFUN (no_neighbor_description
,
6914 no_neighbor_description_cmd
,
6915 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6919 "Neighbor specific description\n")
6924 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6926 return CMD_WARNING_CONFIG_FAILED
;
6928 peer_description_unset(peer
);
6933 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6934 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6935 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6936 "Neighbor specific description\n"
6937 "Up to 80 characters describing this neighbor\n")
6939 /* Neighbor update-source. */
6940 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6941 const char *source_str
)
6947 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6949 return CMD_WARNING_CONFIG_FAILED
;
6955 if (str2sockunion(source_str
, &su
) == 0)
6956 peer_update_source_addr_set(peer
, &su
);
6958 if (str2prefix(source_str
, &p
)) {
6960 "%% Invalid update-source, remove prefix length \n");
6961 return CMD_WARNING_CONFIG_FAILED
;
6963 peer_update_source_if_set(peer
, source_str
);
6966 peer_update_source_unset(peer
);
6971 #define BGP_UPDATE_SOURCE_HELP_STR \
6974 "Interface name (requires zebra to be running)\n"
6976 DEFUN (neighbor_update_source
,
6977 neighbor_update_source_cmd
,
6978 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6981 "Source of routing updates\n"
6982 BGP_UPDATE_SOURCE_HELP_STR
)
6986 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6987 argv
[idx_peer_2
]->arg
);
6990 DEFUN (no_neighbor_update_source
,
6991 no_neighbor_update_source_cmd
,
6992 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6996 "Source of routing updates\n"
6997 BGP_UPDATE_SOURCE_HELP_STR
)
7000 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7003 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7004 afi_t afi
, safi_t safi
,
7005 const char *rmap
, int set
)
7009 struct route_map
*route_map
= NULL
;
7011 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7013 return CMD_WARNING_CONFIG_FAILED
;
7017 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7018 ret
= peer_default_originate_set(peer
, afi
, safi
,
7021 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7023 return bgp_vty_return(vty
, ret
);
7026 /* neighbor default-originate. */
7027 DEFUN (neighbor_default_originate
,
7028 neighbor_default_originate_cmd
,
7029 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7032 "Originate default route to this neighbor\n")
7035 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7037 bgp_node_safi(vty
), NULL
, 1);
7040 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7041 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7042 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7043 "Originate default route to this neighbor\n")
7045 DEFUN (neighbor_default_originate_rmap
,
7046 neighbor_default_originate_rmap_cmd
,
7047 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
7050 "Originate default route to this neighbor\n"
7051 "Route-map to specify criteria to originate default\n"
7056 return peer_default_originate_set_vty(
7057 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7058 argv
[idx_word
]->arg
, 1);
7062 neighbor_default_originate_rmap
,
7063 neighbor_default_originate_rmap_hidden_cmd
,
7064 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
7065 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7066 "Originate default route to this neighbor\n"
7067 "Route-map to specify criteria to originate default\n"
7070 DEFUN (no_neighbor_default_originate
,
7071 no_neighbor_default_originate_cmd
,
7072 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7076 "Originate default route to this neighbor\n"
7077 "Route-map to specify criteria to originate default\n"
7081 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7083 bgp_node_safi(vty
), NULL
, 0);
7087 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7088 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7089 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7090 "Originate default route to this neighbor\n"
7091 "Route-map to specify criteria to originate default\n"
7095 /* Set neighbor's BGP port. */
7096 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
7097 const char *port_str
)
7103 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7105 return CMD_WARNING_CONFIG_FAILED
;
7108 sp
= getservbyname("bgp", "tcp");
7109 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
7111 port
= strtoul(port_str
, NULL
, 10);
7114 peer_port_set(peer
, port
);
7119 /* Set specified peer's BGP port. */
7120 DEFUN (neighbor_port
,
7122 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7125 "Neighbor's BGP port\n"
7126 "TCP port number\n")
7130 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7131 argv
[idx_number
]->arg
);
7134 DEFUN (no_neighbor_port
,
7135 no_neighbor_port_cmd
,
7136 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7140 "Neighbor's BGP port\n"
7141 "TCP port number\n")
7144 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7148 /* neighbor weight. */
7149 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7150 safi_t safi
, const char *weight_str
)
7154 unsigned long weight
;
7156 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7158 return CMD_WARNING_CONFIG_FAILED
;
7160 weight
= strtoul(weight_str
, NULL
, 10);
7162 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7163 return bgp_vty_return(vty
, ret
);
7166 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7172 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7174 return CMD_WARNING_CONFIG_FAILED
;
7176 ret
= peer_weight_unset(peer
, afi
, safi
);
7177 return bgp_vty_return(vty
, ret
);
7180 DEFUN (neighbor_weight
,
7181 neighbor_weight_cmd
,
7182 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7185 "Set default weight for routes from this neighbor\n"
7190 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7191 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7194 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7195 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7196 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7197 "Set default weight for routes from this neighbor\n"
7200 DEFUN (no_neighbor_weight
,
7201 no_neighbor_weight_cmd
,
7202 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7206 "Set default weight for routes from this neighbor\n"
7210 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7211 bgp_node_afi(vty
), bgp_node_safi(vty
));
7214 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7215 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7216 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7217 "Set default weight for routes from this neighbor\n"
7221 /* Override capability negotiation. */
7222 DEFUN (neighbor_override_capability
,
7223 neighbor_override_capability_cmd
,
7224 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7227 "Override capability negotiation result\n")
7230 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7231 PEER_FLAG_OVERRIDE_CAPABILITY
);
7234 DEFUN (no_neighbor_override_capability
,
7235 no_neighbor_override_capability_cmd
,
7236 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7240 "Override capability negotiation result\n")
7243 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7244 PEER_FLAG_OVERRIDE_CAPABILITY
);
7247 DEFUN (neighbor_strict_capability
,
7248 neighbor_strict_capability_cmd
,
7249 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7252 "Strict capability negotiation match\n")
7256 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7257 PEER_FLAG_STRICT_CAP_MATCH
);
7260 DEFUN (no_neighbor_strict_capability
,
7261 no_neighbor_strict_capability_cmd
,
7262 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7266 "Strict capability negotiation match\n")
7270 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7271 PEER_FLAG_STRICT_CAP_MATCH
);
7274 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7275 const char *keep_str
, const char *hold_str
)
7282 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7284 return CMD_WARNING_CONFIG_FAILED
;
7286 keepalive
= strtoul(keep_str
, NULL
, 10);
7287 holdtime
= strtoul(hold_str
, NULL
, 10);
7289 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7291 return bgp_vty_return(vty
, ret
);
7294 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7299 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7301 return CMD_WARNING_CONFIG_FAILED
;
7303 ret
= peer_timers_unset(peer
);
7305 return bgp_vty_return(vty
, ret
);
7308 DEFUN (neighbor_timers
,
7309 neighbor_timers_cmd
,
7310 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7313 "BGP per neighbor timers\n"
7314 "Keepalive interval\n"
7319 int idx_number_2
= 4;
7320 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7321 argv
[idx_number
]->arg
,
7322 argv
[idx_number_2
]->arg
);
7325 DEFUN (no_neighbor_timers
,
7326 no_neighbor_timers_cmd
,
7327 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7331 "BGP per neighbor timers\n"
7332 "Keepalive interval\n"
7336 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7340 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7341 const char *time_str
)
7347 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7349 return CMD_WARNING_CONFIG_FAILED
;
7351 connect
= strtoul(time_str
, NULL
, 10);
7353 ret
= peer_timers_connect_set(peer
, connect
);
7355 return bgp_vty_return(vty
, ret
);
7358 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7363 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7365 return CMD_WARNING_CONFIG_FAILED
;
7367 ret
= peer_timers_connect_unset(peer
);
7369 return bgp_vty_return(vty
, ret
);
7372 DEFUN (neighbor_timers_connect
,
7373 neighbor_timers_connect_cmd
,
7374 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7377 "BGP per neighbor timers\n"
7378 "BGP connect timer\n"
7383 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7384 argv
[idx_number
]->arg
);
7387 DEFUN (no_neighbor_timers_connect
,
7388 no_neighbor_timers_connect_cmd
,
7389 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7393 "BGP per neighbor timers\n"
7394 "BGP connect timer\n"
7398 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7401 DEFPY (neighbor_timers_delayopen
,
7402 neighbor_timers_delayopen_cmd
,
7403 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7406 "BGP per neighbor timers\n"
7407 "RFC 4271 DelayOpenTimer\n"
7408 "DelayOpenTime timer interval\n")
7412 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7414 return CMD_WARNING_CONFIG_FAILED
;
7417 if (peer_timers_delayopen_unset(peer
))
7418 return CMD_WARNING_CONFIG_FAILED
;
7420 if (peer_timers_delayopen_set(peer
, interval
))
7421 return CMD_WARNING_CONFIG_FAILED
;
7427 DEFPY (no_neighbor_timers_delayopen
,
7428 no_neighbor_timers_delayopen_cmd
,
7429 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7433 "BGP per neighbor timers\n"
7434 "RFC 4271 DelayOpenTimer\n"
7435 "DelayOpenTime timer interval\n")
7439 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7441 return CMD_WARNING_CONFIG_FAILED
;
7443 if (peer_timers_delayopen_unset(peer
))
7444 return CMD_WARNING_CONFIG_FAILED
;
7449 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7450 const char *time_str
, int set
)
7454 uint32_t routeadv
= 0;
7456 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7458 return CMD_WARNING_CONFIG_FAILED
;
7461 routeadv
= strtoul(time_str
, NULL
, 10);
7464 ret
= peer_advertise_interval_set(peer
, routeadv
);
7466 ret
= peer_advertise_interval_unset(peer
);
7468 return bgp_vty_return(vty
, ret
);
7471 DEFUN (neighbor_advertise_interval
,
7472 neighbor_advertise_interval_cmd
,
7473 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7476 "Minimum interval between sending BGP routing updates\n"
7477 "time in seconds\n")
7481 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7482 argv
[idx_number
]->arg
, 1);
7485 DEFUN (no_neighbor_advertise_interval
,
7486 no_neighbor_advertise_interval_cmd
,
7487 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7491 "Minimum interval between sending BGP routing updates\n"
7492 "time in seconds\n")
7495 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7499 /* Time to wait before processing route-map updates */
7500 DEFUN (bgp_set_route_map_delay_timer
,
7501 bgp_set_route_map_delay_timer_cmd
,
7502 "bgp route-map delay-timer (0-600)",
7504 "BGP route-map delay timer\n"
7505 "Time in secs to wait before processing route-map changes\n"
7506 "0 disables the timer, no route updates happen when route-maps change\n")
7509 uint32_t rmap_delay_timer
;
7511 if (argv
[idx_number
]->arg
) {
7512 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7513 bm
->rmap_update_timer
= rmap_delay_timer
;
7515 /* if the dynamic update handling is being disabled, and a timer
7517 * running, stop the timer and act as if the timer has already
7520 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7521 THREAD_OFF(bm
->t_rmap_update
);
7522 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7527 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7528 return CMD_WARNING_CONFIG_FAILED
;
7532 DEFUN (no_bgp_set_route_map_delay_timer
,
7533 no_bgp_set_route_map_delay_timer_cmd
,
7534 "no bgp route-map delay-timer [(0-600)]",
7537 "Default BGP route-map delay timer\n"
7538 "Reset to default time to wait for processing route-map changes\n"
7539 "0 disables the timer, no route updates happen when route-maps change\n")
7542 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7547 /* neighbor interface */
7548 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7553 peer
= peer_lookup_vty(vty
, ip_str
);
7554 if (!peer
|| peer
->conf_if
) {
7555 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7556 return CMD_WARNING_CONFIG_FAILED
;
7560 peer_interface_set(peer
, str
);
7562 peer_interface_unset(peer
);
7567 DEFUN (neighbor_interface
,
7568 neighbor_interface_cmd
,
7569 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7578 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7581 DEFUN (no_neighbor_interface
,
7582 no_neighbor_interface_cmd
,
7583 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7592 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7595 DEFUN (neighbor_distribute_list
,
7596 neighbor_distribute_list_cmd
,
7597 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7600 "Filter updates to/from this neighbor\n"
7601 "IP Access-list name\n"
7602 "Filter incoming updates\n"
7603 "Filter outgoing updates\n")
7610 const char *pstr
= argv
[idx_peer
]->arg
;
7611 const char *acl
= argv
[idx_acl
]->arg
;
7612 const char *inout
= argv
[argc
- 1]->text
;
7614 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7616 return CMD_WARNING_CONFIG_FAILED
;
7618 /* Check filter direction. */
7619 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7620 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7623 return bgp_vty_return(vty
, ret
);
7627 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7628 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7629 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7630 "Filter updates to/from this neighbor\n"
7631 "IP Access-list name\n"
7632 "Filter incoming updates\n"
7633 "Filter outgoing updates\n")
7635 DEFUN (no_neighbor_distribute_list
,
7636 no_neighbor_distribute_list_cmd
,
7637 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7641 "Filter updates to/from this neighbor\n"
7642 "IP Access-list name\n"
7643 "Filter incoming updates\n"
7644 "Filter outgoing updates\n")
7650 const char *pstr
= argv
[idx_peer
]->arg
;
7651 const char *inout
= argv
[argc
- 1]->text
;
7653 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7655 return CMD_WARNING_CONFIG_FAILED
;
7657 /* Check filter direction. */
7658 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7659 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7662 return bgp_vty_return(vty
, ret
);
7666 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7667 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7668 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7669 "Filter updates to/from this neighbor\n"
7670 "IP Access-list name\n"
7671 "Filter incoming updates\n"
7672 "Filter outgoing updates\n")
7674 /* Set prefix list to the peer. */
7675 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7676 afi_t afi
, safi_t safi
,
7677 const char *name_str
,
7678 const char *direct_str
)
7681 int direct
= FILTER_IN
;
7684 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7686 return CMD_WARNING_CONFIG_FAILED
;
7688 /* Check filter direction. */
7689 if (strncmp(direct_str
, "i", 1) == 0)
7691 else if (strncmp(direct_str
, "o", 1) == 0)
7692 direct
= FILTER_OUT
;
7694 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7696 return bgp_vty_return(vty
, ret
);
7699 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7700 afi_t afi
, safi_t safi
,
7701 const char *direct_str
)
7705 int direct
= FILTER_IN
;
7707 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7709 return CMD_WARNING_CONFIG_FAILED
;
7711 /* Check filter direction. */
7712 if (strncmp(direct_str
, "i", 1) == 0)
7714 else if (strncmp(direct_str
, "o", 1) == 0)
7715 direct
= FILTER_OUT
;
7717 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7719 return bgp_vty_return(vty
, ret
);
7722 DEFUN (neighbor_prefix_list
,
7723 neighbor_prefix_list_cmd
,
7724 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7727 "Filter updates to/from this neighbor\n"
7728 "Name of a prefix list\n"
7729 "Filter incoming updates\n"
7730 "Filter outgoing updates\n")
7735 return peer_prefix_list_set_vty(
7736 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7737 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7740 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7741 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7742 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7743 "Filter updates to/from this neighbor\n"
7744 "Name of a prefix list\n"
7745 "Filter incoming updates\n"
7746 "Filter outgoing updates\n")
7748 DEFUN (no_neighbor_prefix_list
,
7749 no_neighbor_prefix_list_cmd
,
7750 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7754 "Filter updates to/from this neighbor\n"
7755 "Name of a prefix list\n"
7756 "Filter incoming updates\n"
7757 "Filter outgoing updates\n")
7761 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7762 bgp_node_afi(vty
), bgp_node_safi(vty
),
7763 argv
[idx_in_out
]->arg
);
7766 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7767 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7768 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7769 "Filter updates to/from this neighbor\n"
7770 "Name of a prefix list\n"
7771 "Filter incoming updates\n"
7772 "Filter outgoing updates\n")
7774 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7775 safi_t safi
, const char *name_str
,
7776 const char *direct_str
)
7780 int direct
= FILTER_IN
;
7782 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7784 return CMD_WARNING_CONFIG_FAILED
;
7786 /* Check filter direction. */
7787 if (strncmp(direct_str
, "i", 1) == 0)
7789 else if (strncmp(direct_str
, "o", 1) == 0)
7790 direct
= FILTER_OUT
;
7792 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7794 return bgp_vty_return(vty
, ret
);
7797 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7798 safi_t safi
, const char *direct_str
)
7802 int direct
= FILTER_IN
;
7804 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7806 return CMD_WARNING_CONFIG_FAILED
;
7808 /* Check filter direction. */
7809 if (strncmp(direct_str
, "i", 1) == 0)
7811 else if (strncmp(direct_str
, "o", 1) == 0)
7812 direct
= FILTER_OUT
;
7814 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7816 return bgp_vty_return(vty
, ret
);
7819 DEFUN (neighbor_filter_list
,
7820 neighbor_filter_list_cmd
,
7821 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7824 "Establish BGP filters\n"
7825 "AS path access-list name\n"
7826 "Filter incoming routes\n"
7827 "Filter outgoing routes\n")
7832 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7833 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7834 argv
[idx_in_out
]->arg
);
7837 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7838 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7839 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7840 "Establish BGP filters\n"
7841 "AS path access-list name\n"
7842 "Filter incoming routes\n"
7843 "Filter outgoing routes\n")
7845 DEFUN (no_neighbor_filter_list
,
7846 no_neighbor_filter_list_cmd
,
7847 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7851 "Establish BGP filters\n"
7852 "AS path access-list name\n"
7853 "Filter incoming routes\n"
7854 "Filter outgoing routes\n")
7858 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7859 bgp_node_afi(vty
), bgp_node_safi(vty
),
7860 argv
[idx_in_out
]->arg
);
7863 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7864 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7865 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7866 "Establish BGP filters\n"
7867 "AS path access-list name\n"
7868 "Filter incoming routes\n"
7869 "Filter outgoing routes\n")
7871 /* Set advertise-map to the peer. */
7872 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7873 afi_t afi
, safi_t safi
,
7874 const char *advertise_str
,
7875 const char *condition_str
, bool condition
,
7878 int ret
= CMD_WARNING_CONFIG_FAILED
;
7880 struct route_map
*advertise_map
;
7881 struct route_map
*condition_map
;
7883 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7887 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7888 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7891 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7892 advertise_map
, condition_str
,
7893 condition_map
, condition
);
7895 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7896 advertise_map
, condition_str
,
7897 condition_map
, condition
);
7899 return bgp_vty_return(vty
, ret
);
7902 DEFPY (bgp_condadv_period
,
7903 bgp_condadv_period_cmd
,
7904 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7907 "Conditional advertisement settings\n"
7908 "Set period to rescan BGP table to check if condition is met\n"
7909 "Period between BGP table scans, in seconds; default 60\n")
7911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7913 bgp
->condition_check_period
=
7914 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7919 DEFPY (neighbor_advertise_map
,
7920 neighbor_advertise_map_cmd
,
7921 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7925 "Route-map to conditionally advertise routes\n"
7926 "Name of advertise map\n"
7927 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7928 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7929 "Name of the exist or non exist map\n")
7931 bool condition
= CONDITION_EXIST
;
7933 if (!strcmp(exist
, "non-exist-map"))
7934 condition
= CONDITION_NON_EXIST
;
7936 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7937 bgp_node_safi(vty
), advertise_str
,
7938 condition_str
, condition
, !no
);
7941 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7942 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7943 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7944 "Route-map to conditionally advertise routes\n"
7945 "Name of advertise map\n"
7946 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7947 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7948 "Name of the exist or non exist map\n")
7950 /* Set route-map to the peer. */
7951 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7952 afi_t afi
, safi_t safi
, const char *name_str
,
7953 const char *direct_str
)
7957 int direct
= RMAP_IN
;
7958 struct route_map
*route_map
;
7960 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7962 return CMD_WARNING_CONFIG_FAILED
;
7964 /* Check filter direction. */
7965 if (strncmp(direct_str
, "in", 2) == 0)
7967 else if (strncmp(direct_str
, "o", 1) == 0)
7970 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7971 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7973 return bgp_vty_return(vty
, ret
);
7976 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7977 afi_t afi
, safi_t safi
,
7978 const char *direct_str
)
7982 int direct
= RMAP_IN
;
7984 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7986 return CMD_WARNING_CONFIG_FAILED
;
7988 /* Check filter direction. */
7989 if (strncmp(direct_str
, "in", 2) == 0)
7991 else if (strncmp(direct_str
, "o", 1) == 0)
7994 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7996 return bgp_vty_return(vty
, ret
);
7999 DEFUN (neighbor_route_map
,
8000 neighbor_route_map_cmd
,
8001 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
8004 "Apply route map to neighbor\n"
8005 "Name of route map\n"
8006 "Apply map to incoming routes\n"
8007 "Apply map to outbound routes\n")
8012 return peer_route_map_set_vty(
8013 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8014 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
8017 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
8018 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
8019 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8020 "Apply route map to neighbor\n"
8021 "Name of route map\n"
8022 "Apply map to incoming routes\n"
8023 "Apply map to outbound routes\n")
8025 DEFUN (no_neighbor_route_map
,
8026 no_neighbor_route_map_cmd
,
8027 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
8031 "Apply route map to neighbor\n"
8032 "Name of route map\n"
8033 "Apply map to incoming routes\n"
8034 "Apply map to outbound routes\n")
8038 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8039 bgp_node_afi(vty
), bgp_node_safi(vty
),
8040 argv
[idx_in_out
]->arg
);
8043 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
8044 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
8045 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8046 "Apply route map to neighbor\n"
8047 "Name of route map\n"
8048 "Apply map to incoming routes\n"
8049 "Apply map to outbound routes\n")
8051 /* Set unsuppress-map to the peer. */
8052 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8053 afi_t afi
, safi_t safi
,
8054 const char *name_str
)
8058 struct route_map
*route_map
;
8060 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8062 return CMD_WARNING_CONFIG_FAILED
;
8064 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8065 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8067 return bgp_vty_return(vty
, ret
);
8070 /* Unset route-map from the peer. */
8071 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8072 afi_t afi
, safi_t safi
)
8077 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8079 return CMD_WARNING_CONFIG_FAILED
;
8081 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8083 return bgp_vty_return(vty
, ret
);
8086 DEFUN (neighbor_unsuppress_map
,
8087 neighbor_unsuppress_map_cmd
,
8088 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8091 "Route-map to selectively unsuppress suppressed routes\n"
8092 "Name of route map\n")
8096 return peer_unsuppress_map_set_vty(
8097 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8098 argv
[idx_word
]->arg
);
8101 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8102 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8104 "Route-map to selectively unsuppress suppressed routes\n"
8105 "Name of route map\n")
8107 DEFUN (no_neighbor_unsuppress_map
,
8108 no_neighbor_unsuppress_map_cmd
,
8109 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8113 "Route-map to selectively unsuppress suppressed routes\n"
8114 "Name of route map\n")
8117 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8119 bgp_node_safi(vty
));
8122 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8123 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8124 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8125 "Route-map to selectively unsuppress suppressed routes\n"
8126 "Name of route map\n")
8128 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8129 afi_t afi
, safi_t safi
,
8130 const char *num_str
,
8131 const char *threshold_str
, int warning
,
8132 const char *restart_str
,
8133 const char *force_str
)
8141 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8143 return CMD_WARNING_CONFIG_FAILED
;
8145 max
= strtoul(num_str
, NULL
, 10);
8147 threshold
= atoi(threshold_str
);
8149 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8152 restart
= atoi(restart_str
);
8156 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8157 restart
, force_str
? true : false);
8159 return bgp_vty_return(vty
, ret
);
8162 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8163 afi_t afi
, safi_t safi
)
8168 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8170 return CMD_WARNING_CONFIG_FAILED
;
8172 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8174 return bgp_vty_return(vty
, ret
);
8177 /* Maximum number of prefix to be sent to the neighbor. */
8178 DEFUN(neighbor_maximum_prefix_out
,
8179 neighbor_maximum_prefix_out_cmd
,
8180 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8183 "Maximum number of prefixes to be sent to this peer\n"
8184 "Maximum no. of prefix limit\n")
8191 afi_t afi
= bgp_node_afi(vty
);
8192 safi_t safi
= bgp_node_safi(vty
);
8194 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8196 return CMD_WARNING_CONFIG_FAILED
;
8198 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8200 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8202 return bgp_vty_return(vty
, ret
);
8205 DEFUN(no_neighbor_maximum_prefix_out
,
8206 no_neighbor_maximum_prefix_out_cmd
,
8207 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8211 "Maximum number of prefixes to be sent to this peer\n"
8212 "Maximum no. of prefix limit\n")
8217 afi_t afi
= bgp_node_afi(vty
);
8218 safi_t safi
= bgp_node_safi(vty
);
8220 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8222 return CMD_WARNING_CONFIG_FAILED
;
8224 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8226 return bgp_vty_return(vty
, ret
);
8229 /* Maximum number of prefix configuration. Prefix count is different
8230 for each peer configuration. So this configuration can be set for
8231 each peer configuration. */
8232 DEFUN (neighbor_maximum_prefix
,
8233 neighbor_maximum_prefix_cmd
,
8234 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8237 "Maximum number of prefix accept from this peer\n"
8238 "maximum no. of prefix limit\n"
8239 "Force checking all received routes not only accepted\n")
8246 if (argv_find(argv
, argc
, "force", &idx_force
))
8247 force
= argv
[idx_force
]->arg
;
8249 return peer_maximum_prefix_set_vty(
8250 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8251 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8254 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8255 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8256 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8257 "Maximum number of prefix accept from this peer\n"
8258 "maximum no. of prefix limit\n"
8259 "Force checking all received routes not only accepted\n")
8261 DEFUN (neighbor_maximum_prefix_threshold
,
8262 neighbor_maximum_prefix_threshold_cmd
,
8263 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8266 "Maximum number of prefix accept from this peer\n"
8267 "maximum no. of prefix limit\n"
8268 "Threshold value (%) at which to generate a warning msg\n"
8269 "Force checking all received routes not only accepted\n")
8273 int idx_number_2
= 4;
8277 if (argv_find(argv
, argc
, "force", &idx_force
))
8278 force
= argv
[idx_force
]->arg
;
8280 return peer_maximum_prefix_set_vty(
8281 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8282 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8286 neighbor_maximum_prefix_threshold
,
8287 neighbor_maximum_prefix_threshold_hidden_cmd
,
8288 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8289 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8290 "Maximum number of prefix accept from this peer\n"
8291 "maximum no. of prefix limit\n"
8292 "Threshold value (%) at which to generate a warning msg\n"
8293 "Force checking all received routes not only accepted\n")
8295 DEFUN (neighbor_maximum_prefix_warning
,
8296 neighbor_maximum_prefix_warning_cmd
,
8297 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8300 "Maximum number of prefix accept from this peer\n"
8301 "maximum no. of prefix limit\n"
8302 "Only give warning message when limit is exceeded\n"
8303 "Force checking all received routes not only accepted\n")
8310 if (argv_find(argv
, argc
, "force", &idx_force
))
8311 force
= argv
[idx_force
]->arg
;
8313 return peer_maximum_prefix_set_vty(
8314 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8315 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8319 neighbor_maximum_prefix_warning
,
8320 neighbor_maximum_prefix_warning_hidden_cmd
,
8321 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8322 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8323 "Maximum number of prefix accept from this peer\n"
8324 "maximum no. of prefix limit\n"
8325 "Only give warning message when limit is exceeded\n"
8326 "Force checking all received routes not only accepted\n")
8328 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8329 neighbor_maximum_prefix_threshold_warning_cmd
,
8330 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8333 "Maximum number of prefix accept from this peer\n"
8334 "maximum no. of prefix limit\n"
8335 "Threshold value (%) at which to generate a warning msg\n"
8336 "Only give warning message when limit is exceeded\n"
8337 "Force checking all received routes not only accepted\n")
8341 int idx_number_2
= 4;
8345 if (argv_find(argv
, argc
, "force", &idx_force
))
8346 force
= argv
[idx_force
]->arg
;
8348 return peer_maximum_prefix_set_vty(
8349 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8350 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8354 neighbor_maximum_prefix_threshold_warning
,
8355 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8356 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8357 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8358 "Maximum number of prefix accept from this peer\n"
8359 "maximum no. of prefix limit\n"
8360 "Threshold value (%) at which to generate a warning msg\n"
8361 "Only give warning message when limit is exceeded\n"
8362 "Force checking all received routes not only accepted\n")
8364 DEFUN (neighbor_maximum_prefix_restart
,
8365 neighbor_maximum_prefix_restart_cmd
,
8366 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8369 "Maximum number of prefix accept from this peer\n"
8370 "maximum no. of prefix limit\n"
8371 "Restart bgp connection after limit is exceeded\n"
8372 "Restart interval in minutes\n"
8373 "Force checking all received routes not only accepted\n")
8377 int idx_number_2
= 5;
8381 if (argv_find(argv
, argc
, "force", &idx_force
))
8382 force
= argv
[idx_force
]->arg
;
8384 return peer_maximum_prefix_set_vty(
8385 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8386 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8390 neighbor_maximum_prefix_restart
,
8391 neighbor_maximum_prefix_restart_hidden_cmd
,
8392 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8393 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8394 "Maximum number of prefix accept from this peer\n"
8395 "maximum no. of prefix limit\n"
8396 "Restart bgp connection after limit is exceeded\n"
8397 "Restart interval in minutes\n"
8398 "Force checking all received routes not only accepted\n")
8400 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8401 neighbor_maximum_prefix_threshold_restart_cmd
,
8402 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8405 "Maximum number of prefixes to accept from this peer\n"
8406 "maximum no. of prefix limit\n"
8407 "Threshold value (%) at which to generate a warning msg\n"
8408 "Restart bgp connection after limit is exceeded\n"
8409 "Restart interval in minutes\n"
8410 "Force checking all received routes not only accepted\n")
8414 int idx_number_2
= 4;
8415 int idx_number_3
= 6;
8419 if (argv_find(argv
, argc
, "force", &idx_force
))
8420 force
= argv
[idx_force
]->arg
;
8422 return peer_maximum_prefix_set_vty(
8423 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8424 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8425 argv
[idx_number_3
]->arg
, force
);
8429 neighbor_maximum_prefix_threshold_restart
,
8430 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8431 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8432 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8433 "Maximum number of prefixes to accept from this peer\n"
8434 "maximum no. of prefix limit\n"
8435 "Threshold value (%) at which to generate a warning msg\n"
8436 "Restart bgp connection after limit is exceeded\n"
8437 "Restart interval in minutes\n"
8438 "Force checking all received routes not only accepted\n")
8440 DEFUN (no_neighbor_maximum_prefix
,
8441 no_neighbor_maximum_prefix_cmd
,
8442 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8446 "Maximum number of prefixes to accept from this peer\n"
8447 "maximum no. of prefix limit\n"
8448 "Threshold value (%) at which to generate a warning msg\n"
8449 "Restart bgp connection after limit is exceeded\n"
8450 "Restart interval in minutes\n"
8451 "Only give warning message when limit is exceeded\n"
8452 "Force checking all received routes not only accepted\n")
8455 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8457 bgp_node_safi(vty
));
8461 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8462 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8463 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8464 "Maximum number of prefixes to accept from this peer\n"
8465 "maximum no. of prefix limit\n"
8466 "Threshold value (%) at which to generate a warning msg\n"
8467 "Restart bgp connection after limit is exceeded\n"
8468 "Restart interval in minutes\n"
8469 "Only give warning message when limit is exceeded\n"
8470 "Force checking all received routes not only accepted\n")
8472 /* "neighbor accept-own" */
8473 DEFPY (neighbor_accept_own
,
8474 neighbor_accept_own_cmd
,
8475 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8479 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8482 afi_t afi
= bgp_node_afi(vty
);
8483 safi_t safi
= bgp_node_safi(vty
);
8486 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8488 return CMD_WARNING_CONFIG_FAILED
;
8491 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8493 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8495 return bgp_vty_return(vty
, ret
);
8498 /* "neighbor soo" */
8499 DEFPY (neighbor_soo
,
8501 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8504 "Set the Site-of-Origin (SoO) extended community\n"
8505 "VPN extended community\n")
8508 afi_t afi
= bgp_node_afi(vty
);
8509 safi_t safi
= bgp_node_safi(vty
);
8510 struct ecommunity
*ecomm_soo
;
8512 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8514 return CMD_WARNING_CONFIG_FAILED
;
8516 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8518 vty_out(vty
, "%% Malformed SoO extended community\n");
8521 ecommunity_str(ecomm_soo
);
8523 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8524 ecommunity_free(&peer
->soo
[afi
][safi
]);
8525 peer
->soo
[afi
][safi
] = ecomm_soo
;
8526 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8529 return bgp_vty_return(vty
,
8530 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8533 DEFPY (no_neighbor_soo
,
8534 no_neighbor_soo_cmd
,
8535 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8539 "Set the Site-of-Origin (SoO) extended community\n"
8540 "VPN extended community\n")
8543 afi_t afi
= bgp_node_afi(vty
);
8544 safi_t safi
= bgp_node_safi(vty
);
8546 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8548 return CMD_WARNING_CONFIG_FAILED
;
8550 ecommunity_free(&peer
->soo
[afi
][safi
]);
8552 return bgp_vty_return(
8553 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8556 /* "neighbor allowas-in" */
8557 DEFUN (neighbor_allowas_in
,
8558 neighbor_allowas_in_cmd
,
8559 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8562 "Accept as-path with my AS present in it\n"
8563 "Number of occurrences of AS number\n"
8564 "Only accept my AS in the as-path if the route was originated in my AS\n")
8567 int idx_number_origin
= 3;
8573 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8575 return CMD_WARNING_CONFIG_FAILED
;
8577 if (argc
<= idx_number_origin
)
8580 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8583 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8586 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8589 return bgp_vty_return(vty
, ret
);
8593 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8594 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8595 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8596 "Accept as-path with my AS present in it\n"
8597 "Number of occurrences of AS number\n"
8598 "Only accept my AS in the as-path if the route was originated in my AS\n")
8600 DEFUN (no_neighbor_allowas_in
,
8601 no_neighbor_allowas_in_cmd
,
8602 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8606 "allow local ASN appears in aspath attribute\n"
8607 "Number of occurrences of AS number\n"
8608 "Only accept my AS in the as-path if the route was originated in my AS\n")
8614 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8616 return CMD_WARNING_CONFIG_FAILED
;
8618 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8619 bgp_node_safi(vty
));
8621 return bgp_vty_return(vty
, ret
);
8625 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8626 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8627 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8628 "allow local ASN appears in aspath attribute\n"
8629 "Number of occurrences of AS number\n"
8630 "Only accept my AS in the as-path if the route was originated in my AS\n")
8632 DEFUN (neighbor_ttl_security
,
8633 neighbor_ttl_security_cmd
,
8634 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8637 "BGP ttl-security parameters\n"
8638 "Specify the maximum number of hops to the BGP peer\n"
8639 "Number of hops to BGP peer\n")
8646 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8648 return CMD_WARNING_CONFIG_FAILED
;
8650 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8653 * If 'neighbor swpX', then this is for directly connected peers,
8654 * we should not accept a ttl-security hops value greater than 1.
8656 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8658 "%s is directly connected peer, hops cannot exceed 1\n",
8659 argv
[idx_peer
]->arg
);
8660 return CMD_WARNING_CONFIG_FAILED
;
8663 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8666 DEFUN (no_neighbor_ttl_security
,
8667 no_neighbor_ttl_security_cmd
,
8668 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8672 "BGP ttl-security parameters\n"
8673 "Specify the maximum number of hops to the BGP peer\n"
8674 "Number of hops to BGP peer\n")
8679 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8681 return CMD_WARNING_CONFIG_FAILED
;
8683 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8686 /* disable-addpath-rx */
8687 DEFUN(neighbor_disable_addpath_rx
,
8688 neighbor_disable_addpath_rx_cmd
,
8689 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8692 "Do not accept additional paths\n")
8694 char *peer_str
= argv
[1]->arg
;
8696 afi_t afi
= bgp_node_afi(vty
);
8697 safi_t safi
= bgp_node_safi(vty
);
8699 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8701 return CMD_WARNING_CONFIG_FAILED
;
8703 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8704 PEER_FLAG_DISABLE_ADDPATH_RX
);
8707 DEFUN(no_neighbor_disable_addpath_rx
,
8708 no_neighbor_disable_addpath_rx_cmd
,
8709 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8713 "Do not accept additional paths\n")
8715 char *peer_str
= argv
[2]->arg
;
8717 afi_t afi
= bgp_node_afi(vty
);
8718 safi_t safi
= bgp_node_safi(vty
);
8720 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8722 return CMD_WARNING_CONFIG_FAILED
;
8724 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8725 PEER_FLAG_DISABLE_ADDPATH_RX
);
8728 DEFUN (neighbor_addpath_tx_all_paths
,
8729 neighbor_addpath_tx_all_paths_cmd
,
8730 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8733 "Use addpath to advertise all paths to a neighbor\n")
8738 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8740 return CMD_WARNING_CONFIG_FAILED
;
8742 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8747 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8748 neighbor_addpath_tx_all_paths_hidden_cmd
,
8749 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8751 "Use addpath to advertise all paths to a neighbor\n")
8753 DEFUN (no_neighbor_addpath_tx_all_paths
,
8754 no_neighbor_addpath_tx_all_paths_cmd
,
8755 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8759 "Use addpath to advertise all paths to a neighbor\n")
8764 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8766 return CMD_WARNING_CONFIG_FAILED
;
8768 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8769 != BGP_ADDPATH_ALL
) {
8771 "%% Peer not currently configured to transmit all paths.");
8772 return CMD_WARNING_CONFIG_FAILED
;
8775 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8781 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8782 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8783 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8784 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8785 "Use addpath to advertise all paths to a neighbor\n")
8787 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8788 neighbor_addpath_tx_bestpath_per_as_cmd
,
8789 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8792 "Use addpath to advertise the bestpath per each neighboring AS\n")
8797 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8799 return CMD_WARNING_CONFIG_FAILED
;
8801 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8802 BGP_ADDPATH_BEST_PER_AS
);
8807 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8808 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8809 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8810 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8811 "Use addpath to advertise the bestpath per each neighboring AS\n")
8813 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8814 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8815 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8819 "Use addpath to advertise the bestpath per each neighboring AS\n")
8824 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8826 return CMD_WARNING_CONFIG_FAILED
;
8828 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8829 != BGP_ADDPATH_BEST_PER_AS
) {
8831 "%% Peer not currently configured to transmit all best path per as.");
8832 return CMD_WARNING_CONFIG_FAILED
;
8835 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8841 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8842 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8843 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8844 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8845 "Use addpath to advertise the bestpath per each neighboring AS\n")
8848 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8849 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8852 "Detect AS loops before sending to neighbor\n")
8856 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8858 return CMD_WARNING_CONFIG_FAILED
;
8860 peer
->as_path_loop_detection
= true;
8866 no_neighbor_aspath_loop_detection
,
8867 no_neighbor_aspath_loop_detection_cmd
,
8868 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8872 "Detect AS loops before sending to neighbor\n")
8876 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8878 return CMD_WARNING_CONFIG_FAILED
;
8880 peer
->as_path_loop_detection
= false;
8885 DEFPY(neighbor_path_attribute_discard
,
8886 neighbor_path_attribute_discard_cmd
,
8887 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...",
8890 "Manipulate path attributes from incoming UPDATE messages\n"
8891 "Drop specified attributes from incoming UPDATE messages\n"
8892 "Attribute number\n")
8896 char *discard_attrs
= NULL
;
8898 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8900 return CMD_WARNING_CONFIG_FAILED
;
8902 argv_find(argv
, argc
, "(1-255)", &idx
);
8904 discard_attrs
= argv_concat(argv
, argc
, idx
);
8906 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, true);
8908 XFREE(MTYPE_TMP
, discard_attrs
);
8913 DEFPY(no_neighbor_path_attribute_discard
,
8914 no_neighbor_path_attribute_discard_cmd
,
8915 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]",
8919 "Manipulate path attributes from incoming UPDATE messages\n"
8920 "Drop specified attributes from incoming UPDATE messages\n"
8921 "Attribute number\n")
8925 char *discard_attrs
= NULL
;
8927 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8929 return CMD_WARNING_CONFIG_FAILED
;
8931 argv_find(argv
, argc
, "(1-255)", &idx
);
8933 discard_attrs
= argv
[idx
]->arg
;
8935 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, false);
8937 XFREE(MTYPE_TMP
, discard_attrs
);
8942 DEFPY(neighbor_path_attribute_treat_as_withdraw
,
8943 neighbor_path_attribute_treat_as_withdraw_cmd
,
8944 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8947 "Manipulate path attributes from incoming UPDATE messages\n"
8948 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8949 "Attribute number\n")
8953 char *withdraw_attrs
= NULL
;
8955 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8957 return CMD_WARNING_CONFIG_FAILED
;
8959 argv_find(argv
, argc
, "(1-255)", &idx
);
8961 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8963 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, true);
8965 XFREE(MTYPE_TMP
, withdraw_attrs
);
8970 DEFPY(no_neighbor_path_attribute_treat_as_withdraw
,
8971 no_neighbor_path_attribute_treat_as_withdraw_cmd
,
8972 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8976 "Manipulate path attributes from incoming UPDATE messages\n"
8977 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8978 "Attribute number\n")
8982 char *withdraw_attrs
= NULL
;
8984 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8986 return CMD_WARNING_CONFIG_FAILED
;
8988 argv_find(argv
, argc
, "(1-255)", &idx
);
8990 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8992 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, false);
8994 XFREE(MTYPE_TMP
, withdraw_attrs
);
8999 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
9000 struct ecommunity
**list
, bool is_rt6
)
9002 struct ecommunity
*ecom
= NULL
;
9003 struct ecommunity
*ecomadd
;
9005 for (; argc
; --argc
, ++argv
) {
9007 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
9008 ECOMMUNITY_ROUTE_TARGET
,
9011 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
9012 ECOMMUNITY_ROUTE_TARGET
,
9015 vty_out(vty
, "Malformed community-list value\n");
9017 ecommunity_free(&ecom
);
9018 return CMD_WARNING_CONFIG_FAILED
;
9022 ecommunity_merge(ecom
, ecomadd
);
9023 ecommunity_free(&ecomadd
);
9030 ecommunity_free(&*list
);
9038 * v2vimport is true if we are handling a `import vrf ...` command
9040 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9044 switch (vty
->node
) {
9053 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9058 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9059 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9060 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9061 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9063 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9067 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9068 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9069 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9070 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9072 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9079 DEFPY (af_rd_vpn_export
,
9080 af_rd_vpn_export_cmd
,
9081 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9083 "Specify route distinguisher\n"
9084 "Between current address-family and vpn\n"
9085 "For routes leaked from current address-family to vpn\n"
9086 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9089 struct prefix_rd prd
;
9095 if (argv_find(argv
, argc
, "no", &idx
))
9099 ret
= str2prefix_rd(rd_str
, &prd
);
9101 vty_out(vty
, "%% Malformed rd\n");
9102 return CMD_WARNING_CONFIG_FAILED
;
9106 afi
= vpn_policy_getafi(vty
, bgp
, false);
9108 return CMD_WARNING_CONFIG_FAILED
;
9111 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9113 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9114 bgp_get_default(), bgp
);
9117 bgp
->vpn_policy
[afi
].tovpn_rd_pretty
=
9118 XSTRDUP(MTYPE_BGP
, rd_str
);
9119 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
9120 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9121 BGP_VPN_POLICY_TOVPN_RD_SET
);
9123 XFREE(MTYPE_BGP
, bgp
->vpn_policy
[afi
].tovpn_rd_pretty
);
9124 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9125 BGP_VPN_POLICY_TOVPN_RD_SET
);
9128 /* post-change: re-export vpn routes */
9129 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9130 bgp_get_default(), bgp
);
9135 ALIAS (af_rd_vpn_export
,
9136 af_no_rd_vpn_export_cmd
,
9139 "Specify route distinguisher\n"
9140 "Between current address-family and vpn\n"
9141 "For routes leaked from current address-family to vpn\n")
9143 DEFPY (af_label_vpn_export
,
9144 af_label_vpn_export_cmd
,
9145 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9147 "label value for VRF\n"
9148 "Between current address-family and vpn\n"
9149 "For routes leaked from current address-family to vpn\n"
9150 "Label Value <0-1048575>\n"
9151 "Automatically assign a label\n")
9153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9154 mpls_label_t label
= MPLS_LABEL_NONE
;
9159 if (argv_find(argv
, argc
, "no", &idx
))
9162 /* If "no ...", squash trailing parameter */
9168 label
= label_val
; /* parser should force unsigned */
9171 afi
= vpn_policy_getafi(vty
, bgp
, false);
9173 return CMD_WARNING_CONFIG_FAILED
;
9176 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9177 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9182 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9184 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9185 bgp_get_default(), bgp
);
9187 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9188 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9190 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9193 * label has previously been automatically
9194 * assigned by labelpool: release it
9196 * NB if tovpn_label == MPLS_LABEL_NONE it
9197 * means the automatic assignment is in flight
9198 * and therefore the labelpool callback must
9199 * detect that the auto label is not needed.
9202 bgp_lp_release(LP_TYPE_VRF
,
9203 &bgp
->vpn_policy
[afi
],
9204 bgp
->vpn_policy
[afi
].tovpn_label
);
9206 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9207 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9210 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9212 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9213 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9214 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9215 vpn_leak_label_callback
);
9218 /* post-change: re-export vpn routes */
9219 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9220 bgp_get_default(), bgp
);
9222 hook_call(bgp_snmp_update_last_changed
, bgp
);
9226 DEFPY (af_sid_vpn_export
,
9227 af_sid_vpn_export_cmd
,
9228 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9230 "sid value for VRF\n"
9231 "Between current address-family and vpn\n"
9232 "For routes leaked from current address-family to vpn\n"
9233 "Sid allocation index\n"
9234 "Automatically assign a label\n")
9236 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9242 if (argv_find(argv
, argc
, "no", &idx
))
9244 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9245 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9247 afi
= vpn_policy_getafi(vty
, bgp
, false);
9249 return CMD_WARNING_CONFIG_FAILED
;
9253 vty_out(vty
, "It's not implemented\n");
9254 return CMD_WARNING_CONFIG_FAILED
;
9257 if (bgp
->tovpn_sid_index
!= 0 ||
9258 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9260 "per-vrf sid and per-af sid are mutually exclusive\n"
9261 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9262 return CMD_WARNING_CONFIG_FAILED
;
9265 /* skip when it's already configured */
9266 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9267 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9268 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9272 * mode change between sid_idx and sid_auto isn't supported.
9273 * user must negate sid vpn export when they want to change the mode
9275 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9276 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9277 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9278 vty_out(vty
, "it's already configured as %s.\n",
9279 sid_auto
? "auto-mode" : "idx-mode");
9280 return CMD_WARNING_CONFIG_FAILED
;
9284 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9285 bgp_get_default(), bgp
);
9288 /* SID allocation auto-mode */
9290 zlog_debug("%s: auto sid alloc.", __func__
);
9291 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9292 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9294 /* SID allocation index-mode */
9296 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9297 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9301 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9302 bgp_get_default(), bgp
);
9306 DEFPY (bgp_sid_vpn_export
,
9307 bgp_sid_vpn_export_cmd
,
9308 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9310 "sid value for VRF\n"
9311 "Between current vrf and vpn\n"
9312 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9313 "For routes leaked from current vrf to vpn\n"
9314 "Sid allocation index\n"
9315 "Automatically assign a label\n")
9317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9320 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9321 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9324 /* when per-VRF SID is not set, do nothing */
9325 if (bgp
->tovpn_sid_index
== 0 &&
9326 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9331 bgp
->tovpn_sid_index
= 0;
9332 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9335 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9336 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9337 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9338 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9339 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9340 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9342 "per-vrf sid and per-af sid are mutually exclusive\n"
9343 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9344 return CMD_WARNING_CONFIG_FAILED
;
9347 /* skip when it's already configured */
9348 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9349 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9353 * mode change between sid_idx and sid_auto isn't supported.
9354 * user must negate sid vpn export when they want to change the mode
9356 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9358 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9359 vty_out(vty
, "it's already configured as %s.\n",
9360 sid_auto
? "auto-mode" : "idx-mode");
9361 return CMD_WARNING_CONFIG_FAILED
;
9365 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9367 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9371 /* SID allocation auto-mode */
9373 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9374 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9375 } else if (sid_idx
!= 0) {
9376 /* SID allocation index-mode */
9378 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9380 bgp
->tovpn_sid_index
= sid_idx
;
9384 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9386 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9387 bgp_get_default(), bgp
);
9392 ALIAS (af_label_vpn_export
,
9393 af_no_label_vpn_export_cmd
,
9394 "no label vpn export",
9396 "label value for VRF\n"
9397 "Between current address-family and vpn\n"
9398 "For routes leaked from current address-family to vpn\n")
9400 ALIAS (bgp_sid_vpn_export
,
9401 no_bgp_sid_vpn_export_cmd
,
9402 "no$no sid vpn per-vrf export",
9404 "sid value for VRF\n"
9405 "Between current vrf and vpn\n"
9406 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9407 "For routes leaked from current vrf to vpn\n")
9409 DEFPY (af_nexthop_vpn_export
,
9410 af_nexthop_vpn_export_cmd
,
9411 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9413 "Specify next hop to use for VRF advertised prefixes\n"
9414 "Between current address-family and vpn\n"
9415 "For routes leaked from current address-family to vpn\n"
9419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9425 vty_out(vty
, "%% Nexthop required\n");
9426 return CMD_WARNING_CONFIG_FAILED
;
9428 if (!sockunion2hostprefix(nexthop_su
, &p
))
9429 return CMD_WARNING_CONFIG_FAILED
;
9432 afi
= vpn_policy_getafi(vty
, bgp
, false);
9434 return CMD_WARNING_CONFIG_FAILED
;
9437 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9439 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9440 bgp_get_default(), bgp
);
9443 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9444 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9445 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9447 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9448 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9451 /* post-change: re-export vpn routes */
9452 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9453 bgp_get_default(), bgp
);
9458 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9460 if (!strcmp(dstr
, "import")) {
9461 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9462 } else if (!strcmp(dstr
, "export")) {
9463 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9464 } else if (!strcmp(dstr
, "both")) {
9465 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9466 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9468 vty_out(vty
, "%% direction parse error\n");
9469 return CMD_WARNING_CONFIG_FAILED
;
9474 DEFPY (af_rt_vpn_imexport
,
9475 af_rt_vpn_imexport_cmd
,
9476 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9478 "Specify route target list\n"
9479 "Specify route target list\n"
9480 "Between current address-family and vpn\n"
9481 "For routes leaked from vpn to current address-family: match any\n"
9482 "For routes leaked from current address-family to vpn: set\n"
9483 "both import: match any and export: set\n"
9484 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9488 struct ecommunity
*ecom
= NULL
;
9489 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9490 enum vpn_policy_direction dir
;
9495 if (argv_find(argv
, argc
, "no", &idx
))
9498 afi
= vpn_policy_getafi(vty
, bgp
, false);
9500 return CMD_WARNING_CONFIG_FAILED
;
9502 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9503 if (ret
!= CMD_SUCCESS
)
9507 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9508 vty_out(vty
, "%% Missing RTLIST\n");
9509 return CMD_WARNING_CONFIG_FAILED
;
9511 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9512 if (ret
!= CMD_SUCCESS
) {
9517 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9521 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9524 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9526 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9527 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9528 ecommunity_dup(ecom
);
9530 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9532 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9533 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9536 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9540 ecommunity_free(&ecom
);
9545 ALIAS (af_rt_vpn_imexport
,
9546 af_no_rt_vpn_imexport_cmd
,
9547 "no <rt|route-target> vpn <import|export|both>$direction_str",
9549 "Specify route target list\n"
9550 "Specify route target list\n"
9551 "Between current address-family and vpn\n"
9552 "For routes leaked from vpn to current address-family\n"
9553 "For routes leaked from current address-family to vpn\n"
9554 "both import and export\n")
9556 DEFPY (af_route_map_vpn_imexport
,
9557 af_route_map_vpn_imexport_cmd
,
9558 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9559 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9561 "Specify route map\n"
9562 "Between current address-family and vpn\n"
9563 "For routes leaked from vpn to current address-family\n"
9564 "For routes leaked from current address-family to vpn\n"
9565 "name of route-map\n")
9567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9569 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9570 enum vpn_policy_direction dir
;
9575 if (argv_find(argv
, argc
, "no", &idx
))
9578 afi
= vpn_policy_getafi(vty
, bgp
, false);
9580 return CMD_WARNING_CONFIG_FAILED
;
9582 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9583 if (ret
!= CMD_SUCCESS
)
9586 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9590 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9593 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9594 XFREE(MTYPE_ROUTE_MAP_NAME
,
9595 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9596 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9597 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9598 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9599 route_map_lookup_warn_noexist(vty
, rmap_str
);
9600 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9603 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9604 XFREE(MTYPE_ROUTE_MAP_NAME
,
9605 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9606 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9607 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9610 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9616 ALIAS (af_route_map_vpn_imexport
,
9617 af_no_route_map_vpn_imexport_cmd
,
9618 "no route-map vpn <import|export>$direction_str",
9620 "Specify route map\n"
9621 "Between current address-family and vpn\n"
9622 "For routes leaked from vpn to current address-family\n"
9623 "For routes leaked from current address-family to vpn\n")
9625 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9626 "import vrf route-map RMAP$rmap_str",
9627 "Import routes from another VRF\n"
9628 "Vrf routes being filtered\n"
9629 "Specify route map\n"
9630 "name of route-map\n")
9632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9633 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9635 struct bgp
*bgp_default
;
9637 afi
= vpn_policy_getafi(vty
, bgp
, true);
9639 return CMD_WARNING_CONFIG_FAILED
;
9641 bgp_default
= bgp_get_default();
9646 /* Auto-create assuming the same AS */
9647 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9648 BGP_INSTANCE_TYPE_DEFAULT
, NULL
,
9649 ASNOTATION_UNDEFINED
);
9653 "VRF default is not configured as a bgp instance\n");
9658 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9660 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9661 XFREE(MTYPE_ROUTE_MAP_NAME
,
9662 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9663 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9664 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9665 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9666 route_map_lookup_warn_noexist(vty
, rmap_str
);
9667 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9670 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9671 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9673 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9678 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9679 "no import vrf route-map [RMAP$rmap_str]",
9681 "Import routes from another VRF\n"
9682 "Vrf routes being filtered\n"
9683 "Specify route map\n"
9684 "name of route-map\n")
9686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9687 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9690 afi
= vpn_policy_getafi(vty
, bgp
, true);
9692 return CMD_WARNING_CONFIG_FAILED
;
9694 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9696 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9697 XFREE(MTYPE_ROUTE_MAP_NAME
,
9698 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9699 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9700 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9702 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9703 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9704 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9706 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9711 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9712 "[no] import vrf VIEWVRFNAME$import_name",
9714 "Import routes from another VRF\n"
9715 "VRF to import from\n"
9716 "The name of the VRF\n")
9718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9719 struct listnode
*node
;
9720 struct bgp
*vrf_bgp
, *bgp_default
;
9723 bool remove
= false;
9726 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9730 if (import_name
== NULL
) {
9731 vty_out(vty
, "%% Missing import name\n");
9735 if (strcmp(import_name
, "route-map") == 0) {
9736 vty_out(vty
, "%% Must include route-map name\n");
9740 if (argv_find(argv
, argc
, "no", &idx
))
9743 afi
= vpn_policy_getafi(vty
, bgp
, true);
9745 return CMD_WARNING_CONFIG_FAILED
;
9747 safi
= bgp_node_safi(vty
);
9749 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9750 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9751 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9752 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9753 remove
? "unimport" : "import", import_name
);
9757 bgp_default
= bgp_get_default();
9759 /* Auto-create assuming the same AS */
9760 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9761 BGP_INSTANCE_TYPE_DEFAULT
, NULL
,
9762 ASNOTATION_UNDEFINED
);
9766 "VRF default is not configured as a bgp instance\n");
9771 vrf_bgp
= bgp_lookup_by_name(import_name
);
9773 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9774 vrf_bgp
= bgp_default
;
9776 /* Auto-create assuming the same AS */
9777 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
,
9778 NULL
, ASNOTATION_UNDEFINED
);
9781 "VRF %s is not configured as a bgp instance\n",
9788 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9790 /* Already importing from "import_vrf"? */
9791 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9793 if (strcmp(vname
, import_name
) == 0)
9797 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9803 /* This command is valid only in a bgp vrf instance or the default instance */
9804 DEFPY (bgp_imexport_vpn
,
9805 bgp_imexport_vpn_cmd
,
9806 "[no] <import|export>$direction_str vpn",
9808 "Import routes to this address-family\n"
9809 "Export routes from this address-family\n"
9810 "to/from default instance VPN RIB\n")
9812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9819 enum vpn_policy_direction dir
;
9821 if (argv_find(argv
, argc
, "no", &idx
))
9824 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9825 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9827 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9828 return CMD_WARNING_CONFIG_FAILED
;
9831 afi
= bgp_node_afi(vty
);
9832 safi
= bgp_node_safi(vty
);
9833 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9834 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9835 return CMD_WARNING_CONFIG_FAILED
;
9838 if (!strcmp(direction_str
, "import")) {
9839 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9840 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9841 } else if (!strcmp(direction_str
, "export")) {
9842 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9843 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9845 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9846 return CMD_WARNING_CONFIG_FAILED
;
9849 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9852 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9853 if (!previous_state
) {
9854 /* trigger export current vrf */
9855 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9858 if (previous_state
) {
9859 /* trigger un-export current vrf */
9860 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9862 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9865 hook_call(bgp_snmp_init_stats
, bgp
);
9870 DEFPY (af_routetarget_import
,
9871 af_routetarget_import_cmd
,
9872 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9874 "Specify route target list\n"
9875 "Specify route target list\n"
9876 "Specify route target list\n"
9877 "Specify route target list\n"
9878 "Flow-spec redirect type route target\n"
9879 "Import routes to this address-family\n"
9880 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9884 struct ecommunity
*ecom
= NULL
;
9886 int idx
= 0, idx_unused
= 0;
9890 if (argv_find(argv
, argc
, "no", &idx
))
9893 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9894 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9897 afi
= vpn_policy_getafi(vty
, bgp
, false);
9899 return CMD_WARNING_CONFIG_FAILED
;
9901 if (rt6
&& afi
!= AFI_IP6
)
9902 return CMD_WARNING_CONFIG_FAILED
;
9905 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9906 vty_out(vty
, "%% Missing RTLIST\n");
9907 return CMD_WARNING_CONFIG_FAILED
;
9909 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9910 if (ret
!= CMD_SUCCESS
)
9915 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9916 ecommunity_free(&bgp
->vpn_policy
[afi
]
9917 .import_redirect_rtlist
);
9918 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9919 ecommunity_dup(ecom
);
9921 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9922 ecommunity_free(&bgp
->vpn_policy
[afi
]
9923 .import_redirect_rtlist
);
9924 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9928 ecommunity_free(&ecom
);
9933 DEFUN_NOSH (address_family_ipv4_safi
,
9934 address_family_ipv4_safi_cmd
,
9935 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9936 "Enter Address Family command mode\n"
9938 BGP_SAFI_WITH_LABEL_HELP_STR
)
9942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9943 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9944 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9945 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9946 && safi
!= SAFI_EVPN
) {
9948 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9949 return CMD_WARNING_CONFIG_FAILED
;
9951 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9953 vty
->node
= BGP_IPV4_NODE
;
9958 DEFUN_NOSH (address_family_ipv6_safi
,
9959 address_family_ipv6_safi_cmd
,
9960 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9961 "Enter Address Family command mode\n"
9963 BGP_SAFI_WITH_LABEL_HELP_STR
)
9966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9967 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9968 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9969 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9970 && safi
!= SAFI_EVPN
) {
9972 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9973 return CMD_WARNING_CONFIG_FAILED
;
9975 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9977 vty
->node
= BGP_IPV6_NODE
;
9982 #ifdef KEEP_OLD_VPN_COMMANDS
9983 DEFUN_NOSH (address_family_vpnv4
,
9984 address_family_vpnv4_cmd
,
9985 "address-family vpnv4 [unicast]",
9986 "Enter Address Family command mode\n"
9988 BGP_AF_MODIFIER_STR
)
9990 vty
->node
= BGP_VPNV4_NODE
;
9994 DEFUN_NOSH (address_family_vpnv6
,
9995 address_family_vpnv6_cmd
,
9996 "address-family vpnv6 [unicast]",
9997 "Enter Address Family command mode\n"
9999 BGP_AF_MODIFIER_STR
)
10001 vty
->node
= BGP_VPNV6_NODE
;
10002 return CMD_SUCCESS
;
10004 #endif /* KEEP_OLD_VPN_COMMANDS */
10006 DEFUN_NOSH (address_family_evpn
,
10007 address_family_evpn_cmd
,
10008 "address-family l2vpn evpn",
10009 "Enter Address Family command mode\n"
10011 BGP_AF_MODIFIER_STR
)
10013 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10014 vty
->node
= BGP_EVPN_NODE
;
10015 return CMD_SUCCESS
;
10018 DEFUN_NOSH (bgp_segment_routing_srv6
,
10019 bgp_segment_routing_srv6_cmd
,
10020 "segment-routing srv6",
10021 "Segment-Routing configuration\n"
10022 "Segment-Routing SRv6 configuration\n")
10024 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10025 bgp
->srv6_enabled
= true;
10026 vty
->node
= BGP_SRV6_NODE
;
10027 return CMD_SUCCESS
;
10030 DEFUN (no_bgp_segment_routing_srv6
,
10031 no_bgp_segment_routing_srv6_cmd
,
10032 "no segment-routing srv6",
10034 "Segment-Routing configuration\n"
10035 "Segment-Routing SRv6 configuration\n")
10037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10039 if (strlen(bgp
->srv6_locator_name
) > 0)
10040 if (bgp_srv6_locator_unset(bgp
) < 0)
10041 return CMD_WARNING_CONFIG_FAILED
;
10043 bgp
->srv6_enabled
= false;
10044 return CMD_SUCCESS
;
10047 DEFPY (bgp_srv6_locator
,
10048 bgp_srv6_locator_cmd
,
10049 "locator NAME$name",
10050 "Specify SRv6 locator\n"
10051 "Specify SRv6 locator\n")
10053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10056 if (strlen(bgp
->srv6_locator_name
) > 0
10057 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
10058 vty_out(vty
, "srv6 locator is already configured\n");
10059 return CMD_WARNING_CONFIG_FAILED
;
10062 snprintf(bgp
->srv6_locator_name
,
10063 sizeof(bgp
->srv6_locator_name
), "%s", name
);
10065 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
10067 return CMD_WARNING_CONFIG_FAILED
;
10069 return CMD_SUCCESS
;
10072 DEFPY (no_bgp_srv6_locator
,
10073 no_bgp_srv6_locator_cmd
,
10074 "no locator NAME$name",
10076 "Specify SRv6 locator\n"
10077 "Specify SRv6 locator\n")
10079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10081 /* when locator isn't configured, do nothing */
10082 if (strlen(bgp
->srv6_locator_name
) < 1)
10083 return CMD_SUCCESS
;
10085 /* name validation */
10086 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
10087 vty_out(vty
, "%% No srv6 locator is configured\n");
10088 return CMD_WARNING_CONFIG_FAILED
;
10091 /* unset locator */
10092 if (bgp_srv6_locator_unset(bgp
) < 0)
10093 return CMD_WARNING_CONFIG_FAILED
;
10095 return CMD_SUCCESS
;
10098 DEFPY (show_bgp_srv6
,
10100 "show bgp segment-routing srv6",
10103 "BGP Segment Routing\n"
10104 "BGP Segment Routing SRv6\n")
10107 struct listnode
*node
;
10108 struct srv6_locator_chunk
*chunk
;
10109 struct bgp_srv6_function
*func
;
10111 bgp
= bgp_get_default();
10113 return CMD_SUCCESS
;
10115 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
10116 vty_out(vty
, "locator_chunks:\n");
10117 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10118 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
10119 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
10120 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
10121 vty_out(vty
, " func-length: %d\n",
10122 chunk
->function_bits_length
);
10123 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
10126 vty_out(vty
, "functions:\n");
10127 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10128 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
10129 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10132 vty_out(vty
, "bgps:\n");
10133 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10134 vty_out(vty
, "- name: %s\n",
10135 bgp
->name
? bgp
->name
: "default");
10137 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
10138 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
10139 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
10140 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
10141 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
10144 return CMD_SUCCESS
;
10147 DEFUN_NOSH (exit_address_family
,
10148 exit_address_family_cmd
,
10149 "exit-address-family",
10150 "Exit from Address Family configuration mode\n")
10152 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10153 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10154 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10155 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10156 || vty
->node
== BGP_EVPN_NODE
10157 || vty
->node
== BGP_FLOWSPECV4_NODE
10158 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10159 vty
->node
= BGP_NODE
;
10160 return CMD_SUCCESS
;
10163 /* Recalculate bestpath and re-advertise a prefix */
10164 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10165 const char *ip_str
, afi_t afi
, safi_t safi
,
10166 struct prefix_rd
*prd
)
10169 struct prefix match
;
10170 struct bgp_dest
*dest
;
10171 struct bgp_dest
*rm
;
10173 struct bgp_table
*table
;
10174 struct bgp_table
*rib
;
10176 /* BGP structure lookup. */
10178 bgp
= bgp_lookup_by_name(view_name
);
10180 vty_out(vty
, "%% Can't find BGP instance %s\n",
10182 return CMD_WARNING
;
10185 bgp
= bgp_get_default();
10187 vty_out(vty
, "%% No BGP process is configured\n");
10188 return CMD_WARNING
;
10192 /* Check IP address argument. */
10193 ret
= str2prefix(ip_str
, &match
);
10195 vty_out(vty
, "%% address is malformed\n");
10196 return CMD_WARNING
;
10199 match
.family
= afi2family(afi
);
10200 rib
= bgp
->rib
[afi
][safi
];
10202 if (safi
== SAFI_MPLS_VPN
) {
10203 for (dest
= bgp_table_top(rib
); dest
;
10204 dest
= bgp_route_next(dest
)) {
10205 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10207 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10210 table
= bgp_dest_get_bgp_table_info(dest
);
10214 rm
= bgp_node_match(table
, &match
);
10216 const struct prefix
*rm_p
=
10217 bgp_dest_get_prefix(rm
);
10219 if (rm_p
->prefixlen
== match
.prefixlen
) {
10220 SET_FLAG(rm
->flags
,
10221 BGP_NODE_USER_CLEAR
);
10222 bgp_process(bgp
, rm
, afi
, safi
);
10224 bgp_dest_unlock_node(rm
);
10228 dest
= bgp_node_match(rib
, &match
);
10229 if (dest
!= NULL
) {
10230 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10232 if (dest_p
->prefixlen
== match
.prefixlen
) {
10233 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10234 bgp_process(bgp
, dest
, afi
, safi
);
10236 bgp_dest_unlock_node(dest
);
10240 return CMD_SUCCESS
;
10243 /* one clear bgp command to rule them all */
10244 DEFUN (clear_ip_bgp_all
,
10245 clear_ip_bgp_all_cmd
,
10246 "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|ASNUM|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]",
10250 BGP_INSTANCE_HELP_STR
10253 BGP_SAFI_WITH_LABEL_HELP_STR
10254 BGP_AF_MODIFIER_STR
10255 "Clear all peers\n"
10256 "BGP IPv4 neighbor to clear\n"
10257 "BGP IPv6 neighbor to clear\n"
10258 "BGP neighbor on interface to clear\n"
10259 "Clear peers with the AS number in plain or dotted format\n"
10260 "Clear all external peers\n"
10261 "Clear all members of peer-group\n"
10262 "BGP peer-group name\n"
10267 "Push out prefix-list ORF and do inbound soft reconfig\n"
10269 "Reset message statistics\n")
10273 afi_t afi
= AFI_UNSPEC
;
10274 safi_t safi
= SAFI_UNSPEC
;
10275 enum clear_sort clr_sort
= clear_peer
;
10276 enum bgp_clear_type clr_type
;
10277 char *clr_arg
= NULL
;
10281 /* clear [ip] bgp */
10282 if (argv_find(argv
, argc
, "ip", &idx
))
10285 /* [<vrf> VIEWVRFNAME] */
10286 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10287 vrf
= argv
[idx
+ 1]->arg
;
10289 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10291 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10292 /* [<view> VIEWVRFNAME] */
10293 vrf
= argv
[idx
+ 1]->arg
;
10296 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10297 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10298 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10300 /* <*|A.B.C.D|X:X::X:X|WORD|ASNUM|external|peer-group PGNAME> */
10301 if (argv_find(argv
, argc
, "*", &idx
)) {
10302 clr_sort
= clear_all
;
10303 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10304 clr_sort
= clear_peer
;
10305 clr_arg
= argv
[idx
]->arg
;
10306 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10307 clr_sort
= clear_peer
;
10308 clr_arg
= argv
[idx
]->arg
;
10309 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10310 clr_sort
= clear_group
;
10312 clr_arg
= argv
[idx
]->arg
;
10313 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10314 clr_sort
= clear_peer
;
10315 clr_arg
= argv
[idx
]->arg
;
10316 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10317 clr_sort
= clear_peer
;
10318 clr_arg
= argv
[idx
]->arg
;
10319 } else if (argv_find(argv
, argc
, "ASNUM", &idx
)) {
10320 clr_sort
= clear_as
;
10321 clr_arg
= argv
[idx
]->arg
;
10322 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10323 clr_sort
= clear_external
;
10326 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10327 if (argv_find(argv
, argc
, "soft", &idx
)) {
10328 if (argv_find(argv
, argc
, "in", &idx
)
10329 || argv_find(argv
, argc
, "out", &idx
))
10330 clr_type
= strmatch(argv
[idx
]->text
, "in")
10331 ? BGP_CLEAR_SOFT_IN
10332 : BGP_CLEAR_SOFT_OUT
;
10334 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10335 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10336 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10337 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10338 : BGP_CLEAR_SOFT_IN
;
10339 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10340 clr_type
= BGP_CLEAR_SOFT_OUT
;
10341 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10342 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10344 clr_type
= BGP_CLEAR_SOFT_NONE
;
10346 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10349 DEFUN (clear_ip_bgp_prefix
,
10350 clear_ip_bgp_prefix_cmd
,
10351 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10355 BGP_INSTANCE_HELP_STR
10356 "Clear bestpath and re-advertise\n"
10360 char *prefix
= NULL
;
10364 /* [<view|vrf> VIEWVRFNAME] */
10365 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10366 vrf
= argv
[idx
+ 1]->arg
;
10368 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10370 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10371 /* [<view> VIEWVRFNAME] */
10372 vrf
= argv
[idx
+ 1]->arg
;
10376 prefix
= argv
[argc
- 1]->arg
;
10378 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10381 DEFUN (clear_bgp_ipv6_safi_prefix
,
10382 clear_bgp_ipv6_safi_prefix_cmd
,
10383 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10389 "Clear bestpath and re-advertise\n"
10393 int idx_ipv6_prefix
= 0;
10394 safi_t safi
= SAFI_UNICAST
;
10395 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10396 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10398 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10399 return bgp_clear_prefix(
10400 vty
, NULL
, prefix
, AFI_IP6
,
10404 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10405 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10406 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10410 BGP_INSTANCE_HELP_STR
10413 "Clear bestpath and re-advertise\n"
10417 int idx_vrfview
= 0;
10418 int idx_ipv6_prefix
= 0;
10419 safi_t safi
= SAFI_UNICAST
;
10420 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10421 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10422 char *vrfview
= NULL
;
10424 /* [<view|vrf> VIEWVRFNAME] */
10425 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10426 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10427 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10429 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10430 /* [<view> VIEWVRFNAME] */
10431 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10433 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10435 return bgp_clear_prefix(
10436 vty
, vrfview
, prefix
,
10437 AFI_IP6
, safi
, NULL
);
10440 DEFUN (show_bgp_views
,
10441 show_bgp_views_cmd
,
10442 "show [ip] bgp views",
10446 "Show the defined BGP views\n")
10448 struct list
*inst
= bm
->bgp
;
10449 struct listnode
*node
;
10452 vty_out(vty
, "Defined BGP views:\n");
10453 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10455 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10457 vty_out(vty
, "\t%s (AS%s)\n", bgp
->name
? bgp
->name
: "(null)",
10461 return CMD_SUCCESS
;
10464 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10468 struct listnode
*node
;
10470 *peers_cfgd
= *peers_estbd
= 0;
10471 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10472 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10475 if (peer_established(peer
))
10480 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10483 int peers_cfg
, peers_estb
;
10485 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10488 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10490 : (int64_t)bgp
->vrf_id
;
10491 json_object_string_add(json
, "type", type
);
10492 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10493 json_object_string_addf(json
, "routerId", "%pI4",
10495 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10496 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10497 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10498 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10499 json_object_string_add(
10501 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10505 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10506 json_object
*json
, const char *name
,
10507 const char *type
, bool use_vrf
)
10509 int peers_cfg
, peers_estb
;
10511 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10515 print_bgp_vrfs(bgp
, vty
, json
, type
);
10517 vty_out(vty
, "BGP instance %s VRF id %d\n",
10519 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10520 : (int)bgp
->vrf_id
);
10521 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10523 "Num Configured Peers %d, Established %d\n",
10524 peers_cfg
, peers_estb
);
10527 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10529 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10536 print_bgp_vrfs(bgp
, vty
, json
, type
);
10538 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10540 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10541 : (int)bgp
->vrf_id
,
10542 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10543 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10544 bgp
->l3vni
, &bgp
->rmac
,
10545 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10550 return CMD_SUCCESS
;
10553 DEFPY (show_bgp_vrfs
,
10555 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10560 "Specific VRF name\n"
10563 struct list
*inst
= bm
->bgp
;
10564 struct listnode
*node
;
10566 bool uj
= use_json(argc
, argv
);
10567 json_object
*json
= NULL
;
10568 json_object
*json_vrfs
= NULL
;
10569 json_object
*json_vrf
= NULL
;
10571 const char *name
= vrf_name
;
10575 json
= json_object_new_object();
10578 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10579 bgp
= bgp_get_default();
10582 bgp
= bgp_lookup_by_name(name
);
10587 vty_json(vty
, json
);
10590 "%% Specified BGP instance not found\n");
10592 return CMD_WARNING
;
10598 json_vrf
= json_object_new_object();
10600 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10604 json_object_object_add(json
, name
, json_vrf
);
10605 vty_json(vty
, json
);
10608 return CMD_SUCCESS
;
10612 json_vrfs
= json_object_new_object();
10614 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10618 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10622 if (!uj
&& count
== 1) {
10624 "%4s %-5s %-16s %9s %10s %-37s\n",
10625 "Type", "Id", "routerId", "#PeersCfg",
10626 "#PeersEstb", "Name");
10627 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10628 "L3-VNI", "RouterMAC", "Interface");
10631 json_vrf
= json_object_new_object();
10633 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10634 name
= VRF_DEFAULT_NAME
;
10641 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10645 json_object_object_add(json_vrfs
, name
, json_vrf
);
10649 json_object_object_add(json
, "vrfs", json_vrfs
);
10650 json_object_int_add(json
, "totalVrfs", count
);
10651 vty_json(vty
, json
);
10655 "\nTotal number of VRFs (including default): %d\n",
10659 return CMD_SUCCESS
;
10662 DEFUN (show_bgp_mac_hash
,
10663 show_bgp_mac_hash_cmd
,
10664 "show bgp mac hash",
10668 "Mac Address database\n")
10670 bgp_mac_dump_table(vty
);
10672 return CMD_SUCCESS
;
10675 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10677 struct vty
*vty
= (struct vty
*)args
;
10678 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10680 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10683 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10685 vty_out(vty
, "self nexthop database:\n");
10686 bgp_nexthop_show_address_hash(vty
, bgp
);
10688 vty_out(vty
, "Tunnel-ip database:\n");
10689 hash_iterate(bgp
->tip_hash
,
10690 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10694 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10695 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10696 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10697 "martian next-hops\n"
10698 "martian next-hop database\n")
10700 struct bgp
*bgp
= NULL
;
10704 /* [<vrf> VIEWVRFNAME] */
10705 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10706 name
= argv
[idx
+ 1]->arg
;
10707 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10709 } else if (argv_find(argv
, argc
, "view", &idx
))
10710 /* [<view> VIEWVRFNAME] */
10711 name
= argv
[idx
+ 1]->arg
;
10713 bgp
= bgp_lookup_by_name(name
);
10715 bgp
= bgp_get_default();
10718 vty_out(vty
, "%% No BGP process is configured\n");
10719 return CMD_WARNING
;
10721 bgp_show_martian_nexthops(vty
, bgp
);
10723 return CMD_SUCCESS
;
10726 DEFUN (show_bgp_memory
,
10727 show_bgp_memory_cmd
,
10728 "show [ip] bgp memory",
10732 "Global BGP memory statistics\n")
10734 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10735 unsigned long count
;
10737 /* RIB related usage stats */
10738 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10739 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10740 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10741 count
* sizeof(struct bgp_dest
)));
10743 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10744 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10746 count
* sizeof(struct bgp_path_info
)));
10747 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10748 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10751 memstrbuf
, sizeof(memstrbuf
),
10752 count
* sizeof(struct bgp_path_info_extra
)));
10754 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10755 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10756 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10757 count
* sizeof(struct bgp_static
)));
10759 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10760 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10761 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10762 count
* sizeof(struct bpacket
)));
10765 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10766 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10767 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10768 count
* sizeof(struct bgp_adj_in
)));
10769 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10770 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10771 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10772 count
* sizeof(struct bgp_adj_out
)));
10774 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10775 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10777 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10778 count
* sizeof(struct bgp_nexthop_cache
)));
10780 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10781 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10783 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10784 count
* sizeof(struct bgp_damp_info
)));
10787 count
= attr_count();
10788 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10789 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10790 count
* sizeof(struct attr
)));
10792 if ((count
= attr_unknown_count()))
10793 vty_out(vty
, "%ld unknown attributes\n", count
);
10795 /* AS_PATH attributes */
10796 count
= aspath_count();
10797 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10798 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10799 count
* sizeof(struct aspath
)));
10801 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10802 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10803 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10804 count
* sizeof(struct assegment
)));
10806 /* Other attributes */
10807 if ((count
= community_count()))
10808 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10809 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10810 count
* sizeof(struct community
)));
10811 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10813 "%ld BGP ext-community entries, using %s of memory\n",
10815 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10816 count
* sizeof(struct ecommunity
)));
10817 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10819 "%ld BGP large-community entries, using %s of memory\n",
10820 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10821 count
* sizeof(struct lcommunity
)));
10823 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10824 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10825 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10826 count
* sizeof(struct cluster_list
)));
10828 /* Peer related usage */
10829 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10830 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10831 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10832 count
* sizeof(struct peer
)));
10834 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10835 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10836 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10837 count
* sizeof(struct peer_group
)));
10840 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10841 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10842 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10843 count
* sizeof(regex_t
)));
10844 return CMD_SUCCESS
;
10847 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10849 json_object
*bestpath
= json_object_new_object();
10851 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10852 json_object_string_add(bestpath
, "asPath", "ignore");
10854 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10855 json_object_string_add(bestpath
, "asPath", "confed");
10857 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10858 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10859 json_object_string_add(bestpath
, "multiPathRelax",
10862 json_object_string_add(bestpath
, "multiPathRelax",
10865 json_object_string_add(bestpath
, "multiPathRelax", "false");
10867 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10868 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10870 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10871 json_object_string_add(bestpath
, "compareRouterId", "true");
10872 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10873 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10874 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10875 json_object_string_add(bestpath
, "med", "confed");
10876 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10877 json_object_string_add(bestpath
, "med",
10878 "missing-as-worst");
10880 json_object_string_add(bestpath
, "med", "true");
10883 json_object_object_add(json
, "bestPath", bestpath
);
10886 /* Print the error code/subcode for why the peer is down */
10887 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10888 json_object
*json_peer
, bool use_json
)
10890 const char *code_str
;
10891 const char *subcode_str
;
10894 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10895 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10896 char errorcodesubcode_hexstr
[5];
10897 char errorcodesubcode_str
[256];
10899 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10900 subcode_str
= bgp_notify_subcode_str(
10902 peer
->notify
.subcode
);
10904 snprintf(errorcodesubcode_hexstr
,
10905 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10906 peer
->notify
.code
, peer
->notify
.subcode
);
10907 json_object_string_add(json_peer
,
10908 "lastErrorCodeSubcode",
10909 errorcodesubcode_hexstr
);
10910 snprintf(errorcodesubcode_str
, 255, "%s%s",
10911 code_str
, subcode_str
);
10912 json_object_string_add(json_peer
,
10913 "lastNotificationReason",
10914 errorcodesubcode_str
);
10915 json_object_boolean_add(json_peer
,
10916 "lastNotificationHardReset",
10917 peer
->notify
.hard_reset
);
10918 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10919 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10920 && (peer
->notify
.subcode
10921 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10922 || peer
->notify
.subcode
10923 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10924 && peer
->notify
.length
) {
10926 const char *msg_str
;
10928 msg_str
= bgp_notify_admin_message(
10929 msgbuf
, sizeof(msgbuf
),
10930 (uint8_t *)peer
->notify
.data
,
10931 peer
->notify
.length
);
10933 json_object_string_add(
10935 "lastShutdownDescription",
10940 json_object_string_add(json_peer
, "lastResetDueTo",
10941 peer_down_str
[(int)peer
->last_reset
]);
10942 json_object_int_add(json_peer
, "lastResetCode",
10944 json_object_string_add(json_peer
, "softwareVersion",
10945 peer
->soft_version
? peer
->soft_version
10948 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10949 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10950 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10952 bgp_notify_subcode_str(peer
->notify
.code
,
10953 peer
->notify
.subcode
);
10954 vty_out(vty
, " Notification %s (%s%s%s)\n",
10955 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10958 code_str
, subcode_str
,
10959 peer
->notify
.hard_reset
10960 ? bgp_notify_subcode_str(
10962 BGP_NOTIFY_CEASE_HARD_RESET
)
10965 vty_out(vty
, " %s (%s)\n",
10966 peer_down_str
[(int)peer
->last_reset
],
10967 peer
->soft_version
? peer
->soft_version
10973 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10976 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10979 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10980 struct peer
*peer
, json_object
*json_peer
,
10981 int max_neighbor_width
, bool use_json
)
10983 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10987 if (peer_dynamic_neighbor(peer
))
10988 json_object_boolean_true_add(json_peer
,
10990 if (peer
->hostname
)
10991 json_object_string_add(json_peer
, "hostname",
10994 if (peer
->domainname
)
10995 json_object_string_add(json_peer
, "domainname",
10997 json_object_int_add(json_peer
, "connectionsEstablished",
10998 peer
->established
);
10999 json_object_int_add(json_peer
, "connectionsDropped",
11001 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11002 use_json
, json_peer
);
11003 if (peer_established(peer
))
11004 json_object_string_add(json_peer
, "lastResetDueTo",
11005 "AFI/SAFI Not Negotiated");
11007 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
11010 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
11012 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
11013 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11014 peer
->hostname
, peer
->host
);
11016 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11018 /* pad the neighbor column with spaces */
11019 if (len
< max_neighbor_width
)
11020 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11022 vty_out(vty
, "%7d %7d %9s", peer
->established
,
11024 peer_uptime(peer
->uptime
, timebuf
,
11025 BGP_UPTIME_LEN
, 0, NULL
));
11026 if (peer_established(peer
))
11027 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
11029 bgp_show_peer_reset(vty
, peer
, NULL
,
11034 /* Strip peer's description to the given size. */
11035 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
11037 static char stripped
[BUFSIZ
];
11039 uint32_t last_space
= 0;
11042 if (*(desc
+ i
) == 0) {
11043 stripped
[i
] = '\0';
11046 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
11048 stripped
[i
] = *(desc
+ i
);
11052 if (last_space
> size
)
11053 stripped
[size
+ 1] = '\0';
11055 stripped
[last_space
] = '\0';
11060 /* Determine whether var peer should be filtered out of the summary. */
11061 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
11062 struct peer
*fpeer
, int as_type
,
11066 /* filter neighbor XXXX */
11067 if (fpeer
&& fpeer
!= peer
)
11070 /* filter remote-as (internal|external) */
11071 if (as_type
!= AS_UNSPECIFIED
) {
11072 if (peer
->as_type
== AS_SPECIFIED
) {
11073 if (as_type
== AS_INTERNAL
) {
11074 if (peer
->as
!= peer
->local_as
)
11076 } else if (peer
->as
== peer
->local_as
)
11078 } else if (as_type
!= peer
->as_type
)
11080 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
11086 /* Show BGP peer's summary information.
11088 * Peer's description is stripped according to if `wide` option is given
11091 * When adding new columns to `show bgp summary` output, please make
11092 * sure `Desc` is the lastest column to show because it can contain
11093 * whitespaces and the whole output will be tricky.
11095 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
11096 struct peer
*fpeer
, int as_type
, as_t as
,
11097 uint16_t show_flags
)
11100 struct listnode
*node
, *nnode
;
11101 unsigned int count
= 0, dn_count
= 0;
11102 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
11103 char neighbor_buf
[VTY_BUFSIZ
];
11104 int neighbor_col_default_width
= 16;
11105 int len
, failed_count
= 0;
11106 unsigned int filtered_count
= 0;
11107 int max_neighbor_width
= 0;
11109 json_object
*json
= NULL
;
11110 json_object
*json_peer
= NULL
;
11111 json_object
*json_peers
= NULL
;
11112 struct peer_af
*paf
;
11113 struct bgp_filter
*filter
;
11114 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11115 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11116 bool show_established
=
11117 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11118 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11119 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11121 /* labeled-unicast routes are installed in the unicast table so in order
11123 * display the correct PfxRcd value we must look at SAFI_UNICAST
11126 if (safi
== SAFI_LABELED_UNICAST
)
11127 pfx_rcd_safi
= SAFI_UNICAST
;
11129 pfx_rcd_safi
= safi
;
11132 json
= json_object_new_object();
11133 json_peers
= json_object_new_object();
11134 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11135 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11142 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11145 if (peer
->afc
[afi
][safi
]) {
11146 /* See if we have at least a single failed peer */
11147 if (bgp_has_peer_failed(peer
, afi
, safi
))
11151 if (peer_dynamic_neighbor(peer
))
11156 /* Loop over all neighbors that will be displayed to determine
11158 * characters are needed for the Neighbor column
11160 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11161 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11168 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11171 if (peer
->afc
[afi
][safi
]) {
11172 memset(dn_flag
, '\0', sizeof(dn_flag
));
11173 if (peer_dynamic_neighbor(peer
))
11177 && CHECK_FLAG(bgp
->flags
,
11178 BGP_FLAG_SHOW_HOSTNAME
))
11179 snprintf(neighbor_buf
,
11180 sizeof(neighbor_buf
),
11181 "%s%s(%s) ", dn_flag
,
11182 peer
->hostname
, peer
->host
);
11184 snprintf(neighbor_buf
,
11185 sizeof(neighbor_buf
), "%s%s ",
11186 dn_flag
, peer
->host
);
11188 len
= strlen(neighbor_buf
);
11190 if (len
> max_neighbor_width
)
11191 max_neighbor_width
= len
;
11193 /* See if we have at least a single failed peer */
11194 if (bgp_has_peer_failed(peer
, afi
, safi
))
11200 /* Originally we displayed the Neighbor column as 16
11201 * characters wide so make that the default
11203 if (max_neighbor_width
< neighbor_col_default_width
)
11204 max_neighbor_width
= neighbor_col_default_width
;
11207 if (show_failed
&& !failed_count
) {
11209 json_object_int_add(json
, "failedPeersCount", 0);
11210 json_object_int_add(json
, "dynamicPeers", dn_count
);
11211 json_object_int_add(json
, "totalPeers", count
);
11213 vty_json(vty
, json
);
11215 vty_out(vty
, "%% No failed BGP neighbors found\n");
11217 return CMD_SUCCESS
;
11220 count
= 0; /* Reset the value as its used again */
11221 filtered_count
= 0;
11223 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11224 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11227 if (!peer
->afc
[afi
][safi
])
11231 unsigned long ents
;
11232 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11235 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11237 : (int64_t)bgp
->vrf_id
;
11239 /* Usage summary and header */
11241 json_object_string_addf(json
, "routerId",
11244 asn_asn2json(json
, "as", bgp
->as
,
11246 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11247 json_object_string_add(
11250 == BGP_INSTANCE_TYPE_DEFAULT
)
11255 "BGP router identifier %pI4, local AS number %s vrf-id %d",
11256 &bgp
->router_id
, bgp
->as_pretty
,
11257 bgp
->vrf_id
== VRF_UNKNOWN
11259 : (int)bgp
->vrf_id
);
11260 vty_out(vty
, "\n");
11263 if (bgp_update_delay_configured(bgp
)) {
11265 json_object_int_add(
11266 json
, "updateDelayLimit",
11267 bgp
->v_update_delay
);
11269 if (bgp
->v_update_delay
11270 != bgp
->v_establish_wait
)
11271 json_object_int_add(
11273 "updateDelayEstablishWait",
11274 bgp
->v_establish_wait
);
11276 if (bgp_update_delay_active(bgp
)) {
11277 json_object_string_add(
11279 "updateDelayFirstNeighbor",
11280 bgp
->update_delay_begin_time
);
11281 json_object_boolean_true_add(
11283 "updateDelayInProgress");
11285 if (bgp
->update_delay_over
) {
11286 json_object_string_add(
11288 "updateDelayFirstNeighbor",
11289 bgp
->update_delay_begin_time
);
11290 json_object_string_add(
11292 "updateDelayBestpathResumed",
11293 bgp
->update_delay_end_time
);
11294 json_object_string_add(
11296 "updateDelayZebraUpdateResume",
11297 bgp
->update_delay_zebra_resume_time
);
11298 json_object_string_add(
11300 "updateDelayPeerUpdateResume",
11301 bgp
->update_delay_peers_resume_time
);
11306 "Read-only mode update-delay limit: %d seconds\n",
11307 bgp
->v_update_delay
);
11308 if (bgp
->v_update_delay
11309 != bgp
->v_establish_wait
)
11311 " Establish wait: %d seconds\n",
11312 bgp
->v_establish_wait
);
11314 if (bgp_update_delay_active(bgp
)) {
11316 " First neighbor established: %s\n",
11317 bgp
->update_delay_begin_time
);
11319 " Delay in progress\n");
11321 if (bgp
->update_delay_over
) {
11323 " First neighbor established: %s\n",
11324 bgp
->update_delay_begin_time
);
11326 " Best-paths resumed: %s\n",
11327 bgp
->update_delay_end_time
);
11329 " zebra update resumed: %s\n",
11330 bgp
->update_delay_zebra_resume_time
);
11332 " peers update resumed: %s\n",
11333 bgp
->update_delay_peers_resume_time
);
11340 if (bgp_maxmed_onstartup_configured(bgp
)
11341 && bgp
->maxmed_active
)
11342 json_object_boolean_true_add(
11343 json
, "maxMedOnStartup");
11344 if (bgp
->v_maxmed_admin
)
11345 json_object_boolean_true_add(
11346 json
, "maxMedAdministrative");
11348 json_object_int_add(
11349 json
, "tableVersion",
11350 bgp_table_version(bgp
->rib
[afi
][safi
]));
11352 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11353 json_object_int_add(json
, "ribCount", ents
);
11354 json_object_int_add(
11356 ents
* sizeof(struct bgp_dest
));
11358 ents
= bgp
->af_peer_count
[afi
][safi
];
11359 json_object_int_add(json
, "peerCount", ents
);
11360 json_object_int_add(json
, "peerMemory",
11361 ents
* sizeof(struct peer
));
11363 if ((ents
= listcount(bgp
->group
))) {
11364 json_object_int_add(
11365 json
, "peerGroupCount", ents
);
11366 json_object_int_add(
11367 json
, "peerGroupMemory",
11368 ents
* sizeof(struct
11372 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11373 BGP_CONFIG_DAMPENING
))
11374 json_object_boolean_true_add(
11375 json
, "dampeningEnabled");
11378 if (bgp_maxmed_onstartup_configured(bgp
)
11379 && bgp
->maxmed_active
)
11381 "Max-med on-startup active\n");
11382 if (bgp
->v_maxmed_admin
)
11384 "Max-med administrative active\n");
11387 "BGP table version %" PRIu64
11390 bgp
->rib
[afi
][safi
]));
11392 ents
= bgp_table_count(
11393 bgp
->rib
[afi
][safi
]);
11395 "RIB entries %ld, using %s of memory\n",
11405 /* Peer related usage */
11406 ents
= bgp
->af_peer_count
[afi
][safi
];
11408 "Peers %ld, using %s of memory\n",
11418 if ((ents
= listcount(bgp
->group
)))
11420 "Peer groups %ld, using %s of memory\n",
11430 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11431 BGP_CONFIG_DAMPENING
))
11433 "Dampening enabled.\n");
11436 vty_out(vty
, "\n");
11438 /* Subtract 8 here because 'Neighbor' is
11440 vty_out(vty
, "Neighbor");
11441 vty_out(vty
, "%*s",
11442 max_neighbor_width
- 8, " ");
11444 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11449 paf
= peer_af_find(peer
, afi
, safi
);
11450 filter
= &peer
->filter
[afi
][safi
];
11453 /* Works for both failed & successful cases */
11454 if (peer_dynamic_neighbor(peer
))
11459 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11465 bgp_has_peer_failed(peer
, afi
, safi
)) {
11466 json_peer
= json_object_new_object();
11467 bgp_show_failed_summary(vty
, bgp
, peer
,
11468 json_peer
, 0, use_json
);
11469 } else if (!show_failed
) {
11470 if (show_established
11471 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11476 json_peer
= json_object_new_object();
11477 if (peer_dynamic_neighbor(peer
)) {
11478 json_object_boolean_true_add(json_peer
,
11482 if (peer
->hostname
)
11483 json_object_string_add(json_peer
, "hostname",
11486 if (peer
->domainname
)
11487 json_object_string_add(json_peer
, "domainname",
11490 asn_asn2json(json_peer
, "remoteAs", peer
->as
,
11492 asn_asn2json(json_peer
, "localAs",
11493 peer
->change_local_as
11494 ? peer
->change_local_as
11497 json_object_int_add(json_peer
, "version", 4);
11498 json_object_int_add(json_peer
, "msgRcvd",
11499 PEER_TOTAL_RX(peer
));
11500 json_object_int_add(json_peer
, "msgSent",
11501 PEER_TOTAL_TX(peer
));
11503 atomic_size_t outq_count
, inq_count
;
11504 outq_count
= atomic_load_explicit(
11505 &peer
->obuf
->count
,
11506 memory_order_relaxed
);
11507 inq_count
= atomic_load_explicit(
11508 &peer
->ibuf
->count
,
11509 memory_order_relaxed
);
11511 json_object_int_add(json_peer
, "tableVersion",
11512 peer
->version
[afi
][safi
]);
11513 json_object_int_add(json_peer
, "outq",
11515 json_object_int_add(json_peer
, "inq",
11517 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11518 use_json
, json_peer
);
11520 json_object_int_add(json_peer
, "pfxRcd",
11521 peer
->pcount
[afi
][pfx_rcd_safi
]);
11523 if (paf
&& PAF_SUBGRP(paf
))
11524 json_object_int_add(
11525 json_peer
, "pfxSnt",
11526 (PAF_SUBGRP(paf
))->scount
);
11528 json_object_int_add(json_peer
, "pfxSnt",
11531 /* BGP FSM state */
11532 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11533 || CHECK_FLAG(peer
->bgp
->flags
,
11534 BGP_FLAG_SHUTDOWN
))
11535 json_object_string_add(json_peer
,
11538 else if (peer
->afc_recv
[afi
][safi
])
11539 json_object_string_add(
11540 json_peer
, "state",
11541 lookup_msg(bgp_status_msg
,
11542 peer
->status
, NULL
));
11543 else if (CHECK_FLAG(
11545 PEER_STATUS_PREFIX_OVERFLOW
))
11546 json_object_string_add(json_peer
,
11550 json_object_string_add(
11551 json_peer
, "state",
11552 lookup_msg(bgp_status_msg
,
11553 peer
->status
, NULL
));
11555 /* BGP peer state */
11556 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11557 || CHECK_FLAG(peer
->bgp
->flags
,
11558 BGP_FLAG_SHUTDOWN
))
11559 json_object_string_add(json_peer
,
11562 else if (CHECK_FLAG(
11564 PEER_STATUS_PREFIX_OVERFLOW
))
11565 json_object_string_add(json_peer
,
11568 else if (CHECK_FLAG(peer
->flags
,
11569 PEER_FLAG_PASSIVE
))
11570 json_object_string_add(json_peer
,
11573 else if (CHECK_FLAG(peer
->sflags
,
11574 PEER_STATUS_NSF_WAIT
))
11575 json_object_string_add(json_peer
,
11578 else if (CHECK_FLAG(
11580 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11581 && (!bgp_inbound_policy_exists(peer
,
11583 || !bgp_outbound_policy_exists(
11585 json_object_string_add(json_peer
,
11589 json_object_string_add(
11590 json_peer
, "peerState", "OK");
11592 json_object_int_add(json_peer
, "connectionsEstablished",
11593 peer
->established
);
11594 json_object_int_add(json_peer
, "connectionsDropped",
11597 json_object_string_add(
11598 json_peer
, "desc", peer
->desc
);
11600 /* Avoid creating empty peer dicts in JSON */
11601 if (json_peer
== NULL
)
11605 json_object_string_add(json_peer
, "idType",
11607 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11608 json_object_string_add(json_peer
, "idType",
11610 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11611 json_object_string_add(json_peer
, "idType",
11613 json_object_object_add(json_peers
, peer
->host
,
11616 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11622 bgp_has_peer_failed(peer
, afi
, safi
)) {
11623 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11624 max_neighbor_width
,
11626 } else if (!show_failed
) {
11627 if (show_established
11628 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11633 if ((count
- filtered_count
) == 1) {
11634 /* display headline before the first
11636 vty_out(vty
, "\n");
11638 /* Subtract 8 here because 'Neighbor' is
11640 vty_out(vty
, "Neighbor");
11641 vty_out(vty
, "%*s",
11642 max_neighbor_width
- 8, " ");
11645 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11646 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11649 memset(dn_flag
, '\0', sizeof(dn_flag
));
11650 if (peer_dynamic_neighbor(peer
)) {
11655 && CHECK_FLAG(bgp
->flags
,
11656 BGP_FLAG_SHOW_HOSTNAME
))
11657 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11661 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11663 /* pad the neighbor column with spaces */
11664 if (len
< max_neighbor_width
)
11665 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11668 atomic_size_t outq_count
, inq_count
;
11669 outq_count
= atomic_load_explicit(
11670 &peer
->obuf
->count
,
11671 memory_order_relaxed
);
11672 inq_count
= atomic_load_explicit(
11673 &peer
->ibuf
->count
,
11674 memory_order_relaxed
);
11676 vty_out(vty
, "4 ");
11677 vty_out(vty
, ASN_FORMAT_SPACE(bgp
->asnotation
),
11683 peer
->change_local_as
11684 ? &peer
->change_local_as
11685 : &peer
->local_as
);
11687 " %9u %9u %8" PRIu64
" %4zu %4zu %8s",
11688 PEER_TOTAL_RX(peer
),
11689 PEER_TOTAL_TX(peer
),
11690 peer
->version
[afi
][safi
], inq_count
,
11692 peer_uptime(peer
->uptime
, timebuf
,
11693 BGP_UPTIME_LEN
, 0, NULL
));
11695 if (peer_established(peer
)) {
11696 if (peer
->afc_recv
[afi
][safi
]) {
11699 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11700 && !bgp_inbound_policy_exists(
11702 vty_out(vty
, " %12s",
11711 vty_out(vty
, " NoNeg");
11714 if (paf
&& PAF_SUBGRP(paf
)) {
11717 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11718 && !bgp_outbound_policy_exists(
11720 vty_out(vty
, " %8s",
11729 vty_out(vty
, " NoNeg");
11732 if (CHECK_FLAG(peer
->flags
,
11733 PEER_FLAG_SHUTDOWN
)
11734 || CHECK_FLAG(peer
->bgp
->flags
,
11735 BGP_FLAG_SHUTDOWN
))
11736 vty_out(vty
, " Idle (Admin)");
11737 else if (CHECK_FLAG(
11739 PEER_STATUS_PREFIX_OVERFLOW
))
11740 vty_out(vty
, " Idle (PfxCt)");
11742 vty_out(vty
, " %12s",
11743 lookup_msg(bgp_status_msg
,
11744 peer
->status
, NULL
));
11746 vty_out(vty
, " %8u", 0);
11748 /* Make sure `Desc` column is the lastest in
11752 vty_out(vty
, " %s",
11753 bgp_peer_description_stripped(
11755 show_wide
? 64 : 20));
11757 vty_out(vty
, " N/A");
11758 vty_out(vty
, "\n");
11765 json_object_object_add(json
, "peers", json_peers
);
11766 json_object_int_add(json
, "failedPeers", failed_count
);
11767 json_object_int_add(json
, "displayedPeers",
11768 count
- filtered_count
);
11769 json_object_int_add(json
, "totalPeers", count
);
11770 json_object_int_add(json
, "dynamicPeers", dn_count
);
11773 bgp_show_bestpath_json(bgp
, json
);
11775 vty_json(vty
, json
);
11778 if (filtered_count
== count
)
11779 vty_out(vty
, "\n%% No matching neighbor\n");
11782 vty_out(vty
, "\nDisplayed neighbors %d",
11784 else if (as_type
!= AS_UNSPECIFIED
|| as
11785 || fpeer
|| show_established
)
11786 vty_out(vty
, "\nDisplayed neighbors %d",
11787 count
- filtered_count
);
11789 vty_out(vty
, "\nTotal number of neighbors %d\n",
11793 vty_out(vty
, "No %s neighbor is configured\n",
11794 get_afi_safi_str(afi
, safi
, false));
11798 vty_out(vty
, "* - dynamic neighbor\n");
11799 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11800 dn_count
, bgp
->dynamic_neighbors_limit
);
11804 return CMD_SUCCESS
;
11807 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11808 int safi
, struct peer
*fpeer
, int as_type
,
11809 as_t as
, uint16_t show_flags
)
11812 int afi_wildcard
= (afi
== AFI_MAX
);
11813 int safi_wildcard
= (safi
== SAFI_MAX
);
11814 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11815 bool nbr_output
= false;
11816 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11818 if (use_json
&& is_wildcard
)
11819 vty_out(vty
, "{\n");
11821 afi
= 1; /* AFI_IP */
11822 while (afi
< AFI_MAX
) {
11824 safi
= 1; /* SAFI_UNICAST */
11825 while (safi
< SAFI_MAX
) {
11826 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11831 * So limit output to those afi/safi
11833 * actualy have something interesting in
11838 vty_out(vty
, ",\n");
11842 vty_out(vty
, "\"%s\":",
11843 get_afi_safi_str(afi
,
11848 "\n%s Summary (%s):\n",
11849 get_afi_safi_str(afi
,
11855 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11856 as_type
, as
, show_flags
);
11859 if (!safi_wildcard
)
11867 if (use_json
&& is_wildcard
)
11868 vty_out(vty
, "}\n");
11869 else if (!nbr_output
) {
11871 vty_out(vty
, "{}\n");
11873 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11878 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11880 const char *neighbor
,
11881 int as_type
, as_t as
,
11882 uint16_t show_flags
)
11884 struct listnode
*node
, *nnode
;
11886 struct peer
*fpeer
= NULL
;
11888 bool nbr_output
= false;
11889 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11892 vty_out(vty
, "{\n");
11894 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11898 vty_out(vty
, ",\n");
11902 vty_out(vty
, "\"%s\":",
11903 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11908 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11913 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11918 vty_out(vty
, "}\n");
11919 else if (!nbr_output
)
11920 vty_out(vty
, "%% BGP instance not found\n");
11923 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11924 safi_t safi
, const char *neighbor
, int as_type
,
11925 as_t as
, uint16_t show_flags
)
11928 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11929 struct peer
*fpeer
= NULL
;
11932 if (strmatch(name
, "all")) {
11933 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11936 return CMD_SUCCESS
;
11938 bgp
= bgp_lookup_by_name(name
);
11942 vty_out(vty
, "{}\n");
11945 "%% BGP instance not found\n");
11946 return CMD_WARNING
;
11950 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11953 return CMD_WARNING
;
11955 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11956 as_type
, as
, show_flags
);
11957 return CMD_SUCCESS
;
11961 bgp
= bgp_get_default();
11965 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11968 return CMD_WARNING
;
11970 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11974 vty_out(vty
, "{}\n");
11976 vty_out(vty
, "%% BGP instance not found\n");
11977 return CMD_WARNING
;
11980 return CMD_SUCCESS
;
11983 /* `show [ip] bgp summary' commands. */
11984 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11985 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11986 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11987 "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <ASNUM|internal|external>>] [terse] [wide] [json$uj]",
11988 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11989 BGP_SAFI_WITH_LABEL_HELP_STR
11990 "Display the entries for all address families\n"
11991 "Summary of BGP neighbor status\n"
11992 "Show only sessions in Established state\n"
11993 "Show only sessions not in Established state\n"
11994 "Show only the specified neighbor session\n"
11995 "Neighbor to display information about\n"
11996 "Neighbor to display information about\n"
11997 "Neighbor on BGP configured interface\n"
11998 "Show only the specified remote AS sessions\n" AS_STR
11999 "Internal (iBGP) AS sessions\n"
12000 "External (eBGP) AS sessions\n"
12001 "Shorten the information on BGP instances\n"
12002 "Increase table width for longer output\n" JSON_STR
)
12005 afi_t afi
= AFI_MAX
;
12006 safi_t safi
= SAFI_MAX
;
12007 as_t as
= 0; /* 0 means AS filter not set */
12008 int as_type
= AS_UNSPECIFIED
;
12009 uint16_t show_flags
= 0;
12013 /* show [ip] bgp */
12014 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
12016 /* [<vrf> VIEWVRFNAME] */
12017 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12018 vrf
= argv
[idx
+ 1]->arg
;
12019 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12021 } else if (argv_find(argv
, argc
, "view", &idx
))
12022 /* [<view> VIEWVRFNAME] */
12023 vrf
= argv
[idx
+ 1]->arg
;
12024 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
12025 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
12026 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
12029 if (argv_find(argv
, argc
, "failed", &idx
))
12030 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
12032 if (argv_find(argv
, argc
, "established", &idx
))
12033 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
12035 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
12036 if (argv
[idx
+ 1]->arg
[0] == 'i')
12037 as_type
= AS_INTERNAL
;
12038 else if (argv
[idx
+ 1]->arg
[0] == 'e')
12039 as_type
= AS_EXTERNAL
;
12040 else if (!asn_str2asn(argv
[idx
+ 1]->arg
, &as
)) {
12042 "%% Invalid neighbor remote-as value: %s\n",
12043 argv
[idx
+ 1]->arg
);
12044 return CMD_SUCCESS
;
12048 if (argv_find(argv
, argc
, "terse", &idx
))
12049 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
12051 if (argv_find(argv
, argc
, "wide", &idx
))
12052 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
12054 if (argv_find(argv
, argc
, "json", &idx
))
12055 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
12057 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
12061 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
12064 return get_afi_safi_json_str(afi
, safi
);
12066 return get_afi_safi_vty_str(afi
, safi
);
12070 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
12071 afi_t afi
, safi_t safi
,
12072 uint16_t adv_smcap
, uint16_t adv_rmcap
,
12073 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
12074 bool use_json
, json_object
*json_pref
)
12077 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
12078 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
12080 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
12081 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
12082 json_object_string_add(json_pref
, "sendMode",
12083 "advertisedAndReceived");
12084 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
12085 json_object_string_add(json_pref
, "sendMode",
12087 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
12088 json_object_string_add(json_pref
, "sendMode",
12091 vty_out(vty
, " Send-mode: ");
12092 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
12093 vty_out(vty
, "advertised");
12094 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
12095 vty_out(vty
, "%sreceived",
12096 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12100 vty_out(vty
, "\n");
12105 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12106 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
12108 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12109 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12110 json_object_string_add(json_pref
, "recvMode",
12111 "advertisedAndReceived");
12112 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12113 json_object_string_add(json_pref
, "recvMode",
12115 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12116 json_object_string_add(json_pref
, "recvMode",
12119 vty_out(vty
, " Receive-mode: ");
12120 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12121 vty_out(vty
, "advertised");
12122 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12123 vty_out(vty
, "%sreceived",
12124 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12128 vty_out(vty
, "\n");
12133 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
12140 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12141 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12142 && (peer_established(p
))) {
12143 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
12144 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
12148 json_object_boolean_add(json
, "rBit", rbit
);
12149 json_object_boolean_add(json
, "nBit", nbit
);
12151 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
12152 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
12156 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12160 const char *mode
= "NotApplicable";
12163 vty_out(vty
, "\n Remote GR Mode: ");
12165 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12166 && (peer_established(peer
))) {
12168 if ((peer
->nsf_af_count
== 0)
12169 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12173 } else if (peer
->nsf_af_count
== 0
12174 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12178 } else if (peer
->nsf_af_count
!= 0
12179 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12186 json_object_string_add(json
, "remoteGrMode", mode
);
12188 vty_out(vty
, "%s\n", mode
);
12191 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12195 const char *mode
= "Invalid";
12198 vty_out(vty
, " Local GR Mode: ");
12200 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12202 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12204 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12206 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12207 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12209 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12211 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12218 json_object_string_add(json
, "localGrMode", mode
);
12220 vty_out(vty
, "%s\n", mode
);
12223 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12224 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12228 json_object
*json_afi_safi
= NULL
;
12229 json_object
*json_timer
= NULL
;
12230 json_object
*json_endofrib_status
= NULL
;
12231 bool eor_flag
= false;
12233 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12234 if (!peer
->afc
[afi
][safi
])
12237 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12238 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12242 json_afi_safi
= json_object_new_object();
12243 json_endofrib_status
= json_object_new_object();
12244 json_timer
= json_object_new_object();
12247 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12253 vty_out(vty
, " %s:\n",
12254 get_afi_safi_str(afi
, safi
, false));
12256 vty_out(vty
, " F bit: ");
12259 if (peer
->nsf
[afi
][safi
] &&
12260 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12261 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12264 json_object_boolean_true_add(json_afi_safi
,
12267 vty_out(vty
, "True\n");
12270 json_object_boolean_false_add(json_afi_safi
,
12273 vty_out(vty
, "False\n");
12277 vty_out(vty
, " End-of-RIB sent: ");
12279 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12280 PEER_STATUS_EOR_SEND
)) {
12282 json_object_boolean_true_add(
12283 json_endofrib_status
, "endOfRibSend");
12285 PRINT_EOR_JSON(eor_flag
);
12287 vty_out(vty
, "Yes\n");
12289 " End-of-RIB sent after update: ");
12291 PRINT_EOR(eor_flag
);
12295 json_object_boolean_false_add(
12296 json_endofrib_status
, "endOfRibSend");
12297 json_object_boolean_false_add(
12298 json_endofrib_status
,
12299 "endOfRibSentAfterUpdate");
12301 vty_out(vty
, "No\n");
12303 " End-of-RIB sent after update: ");
12304 vty_out(vty
, "No\n");
12309 vty_out(vty
, " End-of-RIB received: ");
12311 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12312 PEER_STATUS_EOR_RECEIVED
)) {
12314 json_object_boolean_true_add(
12315 json_endofrib_status
, "endOfRibRecv");
12317 vty_out(vty
, "Yes\n");
12320 json_object_boolean_false_add(
12321 json_endofrib_status
, "endOfRibRecv");
12323 vty_out(vty
, "No\n");
12327 json_object_int_add(json_timer
, "stalePathTimer",
12328 peer
->bgp
->stalepath_time
);
12330 if (peer
->t_gr_stale
!= NULL
) {
12331 json_object_int_add(json_timer
,
12332 "stalePathTimerRemaining",
12333 thread_timer_remain_second(
12334 peer
->t_gr_stale
));
12337 /* Display Configured Selection
12338 * Deferral only when when
12339 * Gr mode is enabled.
12341 if (CHECK_FLAG(peer
->flags
,
12342 PEER_FLAG_GRACEFUL_RESTART
)) {
12343 json_object_int_add(json_timer
,
12344 "selectionDeferralTimer",
12345 peer
->bgp
->stalepath_time
);
12348 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12351 json_object_int_add(
12353 "selectionDeferralTimerRemaining",
12354 thread_timer_remain_second(
12355 peer
->bgp
->gr_info
[afi
][safi
]
12356 .t_select_deferral
));
12359 vty_out(vty
, " Timers:\n");
12361 " Configured Stale Path Time(sec): %u\n",
12362 peer
->bgp
->stalepath_time
);
12364 if (peer
->t_gr_stale
!= NULL
)
12366 " Stale Path Remaining(sec): %ld\n",
12367 thread_timer_remain_second(
12368 peer
->t_gr_stale
));
12369 /* Display Configured Selection
12370 * Deferral only when when
12371 * Gr mode is enabled.
12373 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12375 " Configured Selection Deferral Time(sec): %u\n",
12376 peer
->bgp
->select_defer_time
);
12378 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12381 " Selection Deferral Time Remaining(sec): %ld\n",
12382 thread_timer_remain_second(
12383 peer
->bgp
->gr_info
[afi
][safi
]
12384 .t_select_deferral
));
12387 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12388 json_endofrib_status
);
12389 json_object_object_add(json_afi_safi
, "timers",
12391 json_object_object_add(
12392 json
, get_afi_safi_str(afi
, safi
, true),
12398 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12403 json_object
*json_timer
= NULL
;
12405 json_timer
= json_object_new_object();
12407 json_object_int_add(json_timer
, "configuredRestartTimer",
12408 p
->bgp
->restart_time
);
12410 json_object_int_add(json_timer
, "receivedRestartTimer",
12413 if (p
->t_gr_restart
!= NULL
)
12414 json_object_int_add(
12415 json_timer
, "restartTimerRemaining",
12416 thread_timer_remain_second(p
->t_gr_restart
));
12418 json_object_object_add(json
, "timers", json_timer
);
12421 vty_out(vty
, " Timers:\n");
12422 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12423 p
->bgp
->restart_time
);
12425 vty_out(vty
, " Received Restart Time(sec): %u\n",
12427 if (p
->t_gr_restart
!= NULL
)
12428 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12429 thread_timer_remain_second(p
->t_gr_restart
));
12430 if (p
->t_gr_restart
!= NULL
) {
12431 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12432 thread_timer_remain_second(p
->t_gr_restart
));
12437 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12440 char dn_flag
[2] = {0};
12441 /* '*' + v6 address of neighbor */
12442 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12444 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12449 json_object_string_addf(json
, "neighborAddr", "%pSU",
12452 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12455 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12459 json_object_string_add(json
, "neighborAddr",
12462 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12465 /* more gr info in new format */
12466 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12469 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12470 safi_t safi
, bool use_json
,
12471 json_object
*json_neigh
)
12473 struct bgp_filter
*filter
;
12474 struct peer_af
*paf
;
12475 char orf_pfx_name
[BUFSIZ
];
12477 json_object
*json_af
= NULL
;
12478 json_object
*json_prefA
= NULL
;
12479 json_object
*json_prefB
= NULL
;
12480 json_object
*json_addr
= NULL
;
12481 json_object
*json_advmap
= NULL
;
12484 json_addr
= json_object_new_object();
12485 json_af
= json_object_new_object();
12486 filter
= &p
->filter
[afi
][safi
];
12488 if (peer_group_active(p
))
12489 json_object_string_add(json_addr
, "peerGroupMember",
12492 paf
= peer_af_find(p
, afi
, safi
);
12493 if (paf
&& PAF_SUBGRP(paf
)) {
12494 json_object_int_add(json_addr
, "updateGroupId",
12495 PAF_UPDGRP(paf
)->id
);
12496 json_object_int_add(json_addr
, "subGroupId",
12497 PAF_SUBGRP(paf
)->id
);
12498 json_object_int_add(json_addr
, "packetQueueLength",
12499 bpacket_queue_virtual_length(paf
));
12502 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12503 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12504 PEER_CAP_ORF_PREFIX_SM_RCV
)
12505 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12506 PEER_CAP_ORF_PREFIX_RM_ADV
)
12507 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12508 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12509 json_object_int_add(json_af
, "orfType",
12511 json_prefA
= json_object_new_object();
12512 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12513 PEER_CAP_ORF_PREFIX_SM_ADV
,
12514 PEER_CAP_ORF_PREFIX_RM_ADV
,
12515 PEER_CAP_ORF_PREFIX_SM_RCV
,
12516 PEER_CAP_ORF_PREFIX_RM_RCV
,
12517 use_json
, json_prefA
);
12518 json_object_object_add(json_af
, "orfPrefixList",
12522 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12523 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12524 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12525 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12526 PEER_CAP_ORF_PREFIX_RM_ADV
)
12527 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12528 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12529 json_object_int_add(json_af
, "orfOldType",
12530 ORF_TYPE_PREFIX_OLD
);
12531 json_prefB
= json_object_new_object();
12532 bgp_show_peer_afi_orf_cap(
12533 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12534 PEER_CAP_ORF_PREFIX_RM_ADV
,
12535 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12536 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12538 json_object_object_add(json_af
, "orfOldPrefixList",
12542 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12543 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12544 PEER_CAP_ORF_PREFIX_SM_RCV
)
12545 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12546 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12547 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12548 PEER_CAP_ORF_PREFIX_RM_ADV
)
12549 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12550 PEER_CAP_ORF_PREFIX_RM_RCV
)
12551 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12552 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12553 json_object_object_add(json_addr
, "afDependentCap",
12556 json_object_free(json_af
);
12558 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12559 p
->host
, afi
, safi
);
12560 orf_pfx_count
= prefix_bgp_show_prefix_list(
12561 NULL
, afi
, orf_pfx_name
, use_json
);
12563 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12564 PEER_STATUS_ORF_PREFIX_SEND
)
12565 || orf_pfx_count
) {
12566 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12567 PEER_STATUS_ORF_PREFIX_SEND
))
12568 json_object_boolean_true_add(json_neigh
,
12571 json_object_int_add(json_addr
, "orfRecvCounter",
12574 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12575 PEER_STATUS_ORF_WAIT_REFRESH
))
12576 json_object_string_add(
12577 json_addr
, "orfFirstUpdate",
12578 "deferredUntilORFOrRouteRefreshRecvd");
12580 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12581 PEER_FLAG_REFLECTOR_CLIENT
))
12582 json_object_boolean_true_add(json_addr
,
12583 "routeReflectorClient");
12584 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12585 PEER_FLAG_RSERVER_CLIENT
))
12586 json_object_boolean_true_add(json_addr
,
12587 "routeServerClient");
12588 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12589 json_object_boolean_true_add(json_addr
,
12590 "inboundSoftConfigPermit");
12592 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12593 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12594 json_object_boolean_true_add(
12596 "privateAsNumsAllReplacedInUpdatesToNbr");
12597 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12598 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12599 json_object_boolean_true_add(
12601 "privateAsNumsReplacedInUpdatesToNbr");
12602 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12603 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12604 json_object_boolean_true_add(
12606 "privateAsNumsAllRemovedInUpdatesToNbr");
12607 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12608 PEER_FLAG_REMOVE_PRIVATE_AS
))
12609 json_object_boolean_true_add(
12611 "privateAsNumsRemovedInUpdatesToNbr");
12613 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12614 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12615 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12616 json_object_boolean_true_add(json_addr
,
12617 "allowAsInOrigin");
12619 json_object_int_add(json_addr
, "allowAsInCount",
12620 p
->allowas_in
[afi
][safi
]);
12623 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12624 json_object_boolean_true_add(
12626 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12629 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12630 json_object_string_add(json_addr
,
12631 "overrideASNsInOutboundUpdates",
12632 "ifAspathEqualRemoteAs");
12634 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12635 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12636 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12637 json_object_boolean_true_add(json_addr
,
12638 "routerAlwaysNextHop");
12639 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12640 PEER_FLAG_AS_PATH_UNCHANGED
))
12641 json_object_boolean_true_add(
12642 json_addr
, "unchangedAsPathPropogatedToNbr");
12643 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12644 PEER_FLAG_NEXTHOP_UNCHANGED
))
12645 json_object_boolean_true_add(
12646 json_addr
, "unchangedNextHopPropogatedToNbr");
12647 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12648 json_object_boolean_true_add(
12649 json_addr
, "unchangedMedPropogatedToNbr");
12650 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12651 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12652 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12653 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12654 PEER_FLAG_SEND_COMMUNITY
)
12655 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12656 PEER_FLAG_SEND_EXT_COMMUNITY
))
12657 json_object_string_add(json_addr
,
12658 "commAttriSentToNbr",
12659 "extendedAndStandard");
12660 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12661 PEER_FLAG_SEND_EXT_COMMUNITY
))
12662 json_object_string_add(json_addr
,
12663 "commAttriSentToNbr",
12666 json_object_string_add(json_addr
,
12667 "commAttriSentToNbr",
12670 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12671 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12672 if (p
->default_rmap
[afi
][safi
].name
)
12673 json_object_string_add(
12674 json_addr
, "defaultRouteMap",
12675 p
->default_rmap
[afi
][safi
].name
);
12677 if (paf
&& PAF_SUBGRP(paf
)
12678 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12679 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12680 json_object_boolean_true_add(json_addr
,
12683 json_object_boolean_true_add(json_addr
,
12687 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12688 if (is_evpn_enabled())
12689 json_object_boolean_true_add(
12690 json_addr
, "advertiseAllVnis");
12693 if (filter
->plist
[FILTER_IN
].name
12694 || filter
->dlist
[FILTER_IN
].name
12695 || filter
->aslist
[FILTER_IN
].name
12696 || filter
->map
[RMAP_IN
].name
)
12697 json_object_boolean_true_add(json_addr
,
12698 "inboundPathPolicyConfig");
12699 if (filter
->plist
[FILTER_OUT
].name
12700 || filter
->dlist
[FILTER_OUT
].name
12701 || filter
->aslist
[FILTER_OUT
].name
12702 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12703 json_object_boolean_true_add(
12704 json_addr
, "outboundPathPolicyConfig");
12707 if (filter
->plist
[FILTER_IN
].name
)
12708 json_object_string_add(json_addr
,
12709 "incomingUpdatePrefixFilterList",
12710 filter
->plist
[FILTER_IN
].name
);
12711 if (filter
->plist
[FILTER_OUT
].name
)
12712 json_object_string_add(json_addr
,
12713 "outgoingUpdatePrefixFilterList",
12714 filter
->plist
[FILTER_OUT
].name
);
12716 /* distribute-list */
12717 if (filter
->dlist
[FILTER_IN
].name
)
12718 json_object_string_add(
12719 json_addr
, "incomingUpdateNetworkFilterList",
12720 filter
->dlist
[FILTER_IN
].name
);
12721 if (filter
->dlist
[FILTER_OUT
].name
)
12722 json_object_string_add(
12723 json_addr
, "outgoingUpdateNetworkFilterList",
12724 filter
->dlist
[FILTER_OUT
].name
);
12727 if (filter
->aslist
[FILTER_IN
].name
)
12728 json_object_string_add(json_addr
,
12729 "incomingUpdateAsPathFilterList",
12730 filter
->aslist
[FILTER_IN
].name
);
12731 if (filter
->aslist
[FILTER_OUT
].name
)
12732 json_object_string_add(json_addr
,
12733 "outgoingUpdateAsPathFilterList",
12734 filter
->aslist
[FILTER_OUT
].name
);
12737 if (filter
->map
[RMAP_IN
].name
)
12738 json_object_string_add(
12739 json_addr
, "routeMapForIncomingAdvertisements",
12740 filter
->map
[RMAP_IN
].name
);
12741 if (filter
->map
[RMAP_OUT
].name
)
12742 json_object_string_add(
12743 json_addr
, "routeMapForOutgoingAdvertisements",
12744 filter
->map
[RMAP_OUT
].name
);
12746 /* ebgp-requires-policy (inbound) */
12747 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12748 && !bgp_inbound_policy_exists(p
, filter
))
12749 json_object_string_add(
12750 json_addr
, "inboundEbgpRequiresPolicy",
12751 "Inbound updates discarded due to missing policy");
12753 /* ebgp-requires-policy (outbound) */
12754 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12755 && (!bgp_outbound_policy_exists(p
, filter
)))
12756 json_object_string_add(
12757 json_addr
, "outboundEbgpRequiresPolicy",
12758 "Outbound updates discarded due to missing policy");
12760 /* unsuppress-map */
12761 if (filter
->usmap
.name
)
12762 json_object_string_add(json_addr
,
12763 "selectiveUnsuppressRouteMap",
12764 filter
->usmap
.name
);
12766 /* advertise-map */
12767 if (filter
->advmap
.aname
) {
12768 json_advmap
= json_object_new_object();
12769 json_object_string_add(json_advmap
, "condition",
12770 filter
->advmap
.condition
12773 json_object_string_add(json_advmap
, "conditionMap",
12774 filter
->advmap
.cname
);
12775 json_object_string_add(json_advmap
, "advertiseMap",
12776 filter
->advmap
.aname
);
12777 json_object_string_add(
12778 json_advmap
, "advertiseStatus",
12779 filter
->advmap
.update_type
==
12780 UPDATE_TYPE_ADVERTISE
12783 json_object_object_add(json_addr
, "advertiseMap",
12787 /* Receive prefix count */
12788 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12789 p
->pcount
[afi
][safi
]);
12790 if (paf
&& PAF_SUBGRP(paf
))
12791 json_object_int_add(json_addr
, "sentPrefixCounter",
12792 (PAF_SUBGRP(paf
))->scount
);
12794 /* Maximum prefix */
12795 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12796 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12797 p
->pmax_out
[afi
][safi
]);
12799 /* Maximum prefix */
12800 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12801 json_object_int_add(json_addr
, "prefixAllowedMax",
12802 p
->pmax
[afi
][safi
]);
12803 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12804 PEER_FLAG_MAX_PREFIX_WARNING
))
12805 json_object_boolean_true_add(
12806 json_addr
, "prefixAllowedMaxWarning");
12807 json_object_int_add(json_addr
,
12808 "prefixAllowedWarningThresh",
12809 p
->pmax_threshold
[afi
][safi
]);
12810 if (p
->pmax_restart
[afi
][safi
])
12811 json_object_int_add(
12813 "prefixAllowedRestartIntervalMsecs",
12814 p
->pmax_restart
[afi
][safi
] * 60000);
12816 json_object_object_add(json_neigh
,
12817 get_afi_safi_str(afi
, safi
, true),
12821 filter
= &p
->filter
[afi
][safi
];
12823 vty_out(vty
, " For address family: %s\n",
12824 get_afi_safi_str(afi
, safi
, false));
12826 if (peer_group_active(p
))
12827 vty_out(vty
, " %s peer-group member\n",
12830 paf
= peer_af_find(p
, afi
, safi
);
12831 if (paf
&& PAF_SUBGRP(paf
)) {
12832 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12833 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12834 vty_out(vty
, " Packet Queue length %d\n",
12835 bpacket_queue_virtual_length(paf
));
12837 vty_out(vty
, " Not part of any update group\n");
12839 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12840 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12841 PEER_CAP_ORF_PREFIX_SM_RCV
)
12842 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12843 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12844 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12845 PEER_CAP_ORF_PREFIX_RM_ADV
)
12846 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12847 PEER_CAP_ORF_PREFIX_RM_RCV
)
12848 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12849 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12850 vty_out(vty
, " AF-dependant capabilities:\n");
12852 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12853 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12854 PEER_CAP_ORF_PREFIX_SM_RCV
)
12855 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12856 PEER_CAP_ORF_PREFIX_RM_ADV
)
12857 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12858 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12860 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12862 bgp_show_peer_afi_orf_cap(
12863 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12864 PEER_CAP_ORF_PREFIX_RM_ADV
,
12865 PEER_CAP_ORF_PREFIX_SM_RCV
,
12866 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12870 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12872 PEER_CAP_ORF_PREFIX_RM_ADV
)
12873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12874 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12876 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12877 ORF_TYPE_PREFIX_OLD
);
12878 bgp_show_peer_afi_orf_cap(
12879 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12880 PEER_CAP_ORF_PREFIX_RM_ADV
,
12881 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12882 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12885 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12886 p
->host
, afi
, safi
);
12887 orf_pfx_count
= prefix_bgp_show_prefix_list(
12888 NULL
, afi
, orf_pfx_name
, use_json
);
12890 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12891 PEER_STATUS_ORF_PREFIX_SEND
)
12892 || orf_pfx_count
) {
12893 vty_out(vty
, " Outbound Route Filter (ORF):");
12894 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12895 PEER_STATUS_ORF_PREFIX_SEND
))
12896 vty_out(vty
, " sent;");
12898 vty_out(vty
, " received (%d entries)",
12900 vty_out(vty
, "\n");
12902 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12903 PEER_STATUS_ORF_WAIT_REFRESH
))
12905 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12907 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12908 PEER_FLAG_REFLECTOR_CLIENT
))
12909 vty_out(vty
, " Route-Reflector Client\n");
12910 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12911 PEER_FLAG_RSERVER_CLIENT
))
12912 vty_out(vty
, " Route-Server Client\n");
12913 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12915 " Inbound soft reconfiguration allowed\n");
12917 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12918 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12920 " Private AS numbers (all) replaced in updates to this neighbor\n");
12921 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12922 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12924 " Private AS numbers replaced in updates to this neighbor\n");
12925 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12926 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12928 " Private AS numbers (all) removed in updates to this neighbor\n");
12929 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12930 PEER_FLAG_REMOVE_PRIVATE_AS
))
12932 " Private AS numbers removed in updates to this neighbor\n");
12934 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12935 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12936 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12938 " Local AS allowed as path origin\n");
12941 " Local AS allowed in path, %d occurrences\n",
12942 p
->allowas_in
[afi
][safi
]);
12945 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12946 vty_out(vty
, " %s\n",
12947 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12948 ->human_description
);
12950 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12952 " Override ASNs in outbound updates if aspath equals remote-as\n");
12954 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12955 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12956 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12957 vty_out(vty
, " NEXT_HOP is always this router\n");
12958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12959 PEER_FLAG_AS_PATH_UNCHANGED
))
12961 " AS_PATH is propagated unchanged to this neighbor\n");
12962 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12963 PEER_FLAG_NEXTHOP_UNCHANGED
))
12965 " NEXT_HOP is propagated unchanged to this neighbor\n");
12966 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12968 " MED is propagated unchanged to this neighbor\n");
12969 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12970 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12971 PEER_FLAG_SEND_EXT_COMMUNITY
)
12972 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12973 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12975 " Community attribute sent to this neighbor");
12976 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12977 PEER_FLAG_SEND_COMMUNITY
)
12978 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12979 PEER_FLAG_SEND_EXT_COMMUNITY
)
12980 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12981 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12982 vty_out(vty
, "(all)\n");
12983 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12984 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12985 vty_out(vty
, "(large)\n");
12986 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12987 PEER_FLAG_SEND_EXT_COMMUNITY
))
12988 vty_out(vty
, "(extended)\n");
12990 vty_out(vty
, "(standard)\n");
12992 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12993 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12994 vty_out(vty
, " Default information originate,");
12996 if (p
->default_rmap
[afi
][safi
].name
)
12997 vty_out(vty
, " default route-map %s%s,",
12998 p
->default_rmap
[afi
][safi
].map
? "*"
13000 p
->default_rmap
[afi
][safi
].name
);
13001 if (paf
&& PAF_SUBGRP(paf
)
13002 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
13003 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
13004 vty_out(vty
, " default sent\n");
13006 vty_out(vty
, " default not sent\n");
13009 /* advertise-vni-all */
13010 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
13011 if (is_evpn_enabled())
13012 vty_out(vty
, " advertise-all-vni\n");
13015 if (filter
->plist
[FILTER_IN
].name
13016 || filter
->dlist
[FILTER_IN
].name
13017 || filter
->aslist
[FILTER_IN
].name
13018 || filter
->map
[RMAP_IN
].name
)
13019 vty_out(vty
, " Inbound path policy configured\n");
13020 if (filter
->plist
[FILTER_OUT
].name
13021 || filter
->dlist
[FILTER_OUT
].name
13022 || filter
->aslist
[FILTER_OUT
].name
13023 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
13024 vty_out(vty
, " Outbound path policy configured\n");
13027 if (filter
->plist
[FILTER_IN
].name
)
13029 " Incoming update prefix filter list is %s%s\n",
13030 filter
->plist
[FILTER_IN
].plist
? "*" : "",
13031 filter
->plist
[FILTER_IN
].name
);
13032 if (filter
->plist
[FILTER_OUT
].name
)
13034 " Outgoing update prefix filter list is %s%s\n",
13035 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
13036 filter
->plist
[FILTER_OUT
].name
);
13038 /* distribute-list */
13039 if (filter
->dlist
[FILTER_IN
].name
)
13041 " Incoming update network filter list is %s%s\n",
13042 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
13043 filter
->dlist
[FILTER_IN
].name
);
13044 if (filter
->dlist
[FILTER_OUT
].name
)
13046 " Outgoing update network filter list is %s%s\n",
13047 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
13048 filter
->dlist
[FILTER_OUT
].name
);
13051 if (filter
->aslist
[FILTER_IN
].name
)
13053 " Incoming update AS path filter list is %s%s\n",
13054 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
13055 filter
->aslist
[FILTER_IN
].name
);
13056 if (filter
->aslist
[FILTER_OUT
].name
)
13058 " Outgoing update AS path filter list is %s%s\n",
13059 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
13060 filter
->aslist
[FILTER_OUT
].name
);
13063 if (filter
->map
[RMAP_IN
].name
)
13065 " Route map for incoming advertisements is %s%s\n",
13066 filter
->map
[RMAP_IN
].map
? "*" : "",
13067 filter
->map
[RMAP_IN
].name
);
13068 if (filter
->map
[RMAP_OUT
].name
)
13070 " Route map for outgoing advertisements is %s%s\n",
13071 filter
->map
[RMAP_OUT
].map
? "*" : "",
13072 filter
->map
[RMAP_OUT
].name
);
13074 /* ebgp-requires-policy (inbound) */
13075 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
13076 && !bgp_inbound_policy_exists(p
, filter
))
13078 " Inbound updates discarded due to missing policy\n");
13080 /* ebgp-requires-policy (outbound) */
13081 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
13082 && !bgp_outbound_policy_exists(p
, filter
))
13084 " Outbound updates discarded due to missing policy\n");
13086 /* unsuppress-map */
13087 if (filter
->usmap
.name
)
13089 " Route map for selective unsuppress is %s%s\n",
13090 filter
->usmap
.map
? "*" : "",
13091 filter
->usmap
.name
);
13093 /* advertise-map */
13094 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
13096 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
13097 filter
->advmap
.condition
? "EXIST"
13099 filter
->advmap
.cmap
? "*" : "",
13100 filter
->advmap
.cname
,
13101 filter
->advmap
.amap
? "*" : "",
13102 filter
->advmap
.aname
,
13103 filter
->advmap
.update_type
==
13104 UPDATE_TYPE_ADVERTISE
13108 /* Receive prefix count */
13109 vty_out(vty
, " %u accepted prefixes\n",
13110 p
->pcount
[afi
][safi
]);
13112 /* maximum-prefix-out */
13113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
13114 PEER_FLAG_MAX_PREFIX_OUT
))
13116 " Maximum allowed prefixes sent %u\n",
13117 p
->pmax_out
[afi
][safi
]);
13119 /* Maximum prefix */
13120 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13122 " Maximum prefixes allowed %u%s\n",
13123 p
->pmax
[afi
][safi
],
13124 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13125 PEER_FLAG_MAX_PREFIX_WARNING
)
13126 ? " (warning-only)"
13128 vty_out(vty
, " Threshold for warning message %d%%",
13129 p
->pmax_threshold
[afi
][safi
]);
13130 if (p
->pmax_restart
[afi
][safi
])
13131 vty_out(vty
, ", restart interval %d min",
13132 p
->pmax_restart
[afi
][safi
]);
13133 vty_out(vty
, "\n");
13136 vty_out(vty
, "\n");
13140 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13144 char timebuf
[BGP_UPTIME_LEN
];
13150 json_object
*json_neigh
= NULL
;
13152 uint32_t sync_tcp_mss
;
13157 json_neigh
= json_object_new_object();
13159 memset(dn_flag
, '\0', sizeof(dn_flag
));
13160 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13164 if (p
->conf_if
) /* Configured interface name. */
13165 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
13167 else /* Configured IP address. */
13168 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13173 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13174 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13176 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13177 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
13180 asn_asn2json(json_neigh
, "remoteAs", p
->as
, bgp
->asnotation
);
13182 if (p
->change_local_as
)
13183 asn_asn2json(json_neigh
, "localAs", p
->change_local_as
,
13186 asn_asn2json(json_neigh
, "localAs", p
->local_as
,
13189 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13190 json_object_boolean_true_add(json_neigh
,
13191 "localAsNoPrepend");
13193 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13194 json_object_boolean_true_add(json_neigh
,
13195 "localAsReplaceAs");
13197 if ((p
->as_type
== AS_SPECIFIED
) ||
13198 (p
->as_type
== AS_EXTERNAL
) ||
13199 (p
->as_type
== AS_INTERNAL
)) {
13200 vty_out(vty
, "remote AS ");
13201 vty_out(vty
, ASN_FORMAT(bgp
->asnotation
), &p
->as
);
13202 vty_out(vty
, ", ");
13204 vty_out(vty
, "remote AS Unspecified, ");
13205 vty_out(vty
, "local AS ");
13206 vty_out(vty
, ASN_FORMAT(bgp
->asnotation
),
13207 p
->change_local_as
? &p
->change_local_as
13209 vty_out(vty
, "%s%s, ",
13210 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13213 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13217 /* peer type internal or confed-internal */
13218 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13220 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13221 json_object_boolean_true_add(
13222 json_neigh
, "nbrConfedInternalLink");
13224 json_object_boolean_true_add(json_neigh
,
13225 "nbrInternalLink");
13227 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13228 vty_out(vty
, "confed-internal link\n");
13230 vty_out(vty
, "internal link\n");
13232 /* peer type external or confed-external */
13233 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13235 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13236 json_object_boolean_true_add(
13237 json_neigh
, "nbrConfedExternalLink");
13239 json_object_boolean_true_add(json_neigh
,
13240 "nbrExternalLink");
13242 if (bgp_confederation_peers_check(bgp
, p
->as
))
13243 vty_out(vty
, "confed-external link\n");
13245 vty_out(vty
, "external link\n");
13249 json_object_boolean_true_add(json_neigh
,
13250 "nbrUnspecifiedLink");
13252 vty_out(vty
, "unspecified link\n");
13257 json_object_string_add(json_neigh
, "localRole",
13258 bgp_get_name_by_role(p
->local_role
));
13259 json_object_string_add(json_neigh
, "remoteRole",
13260 bgp_get_name_by_role(p
->remote_role
));
13262 vty_out(vty
, " Local Role: %s\n",
13263 bgp_get_name_by_role(p
->local_role
));
13264 vty_out(vty
, " Remote Role: %s\n",
13265 bgp_get_name_by_role(p
->remote_role
));
13272 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13274 vty_out(vty
, " Description: %s\n", p
->desc
);
13279 json_object_string_add(json_neigh
, "hostname",
13283 json_object_string_add(json_neigh
, "domainname",
13286 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13287 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13290 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13294 json_object_string_add(json_neigh
, "hostname",
13301 json_object_string_add(json_neigh
, "peerGroup",
13305 struct prefix prefix
, *range
= NULL
;
13307 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13308 range
= peer_group_lookup_dynamic_neighbor_range(
13309 p
->group
, &prefix
);
13312 json_object_string_addf(
13314 "peerSubnetRangeGroup", "%pFX",
13320 " Member of peer-group %s for session parameters\n",
13324 struct prefix prefix
, *range
= NULL
;
13326 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13327 range
= peer_group_lookup_dynamic_neighbor_range(
13328 p
->group
, &prefix
);
13332 " Belongs to the subnet range group: %pFX\n",
13340 /* Administrative shutdown. */
13341 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13342 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13343 json_object_boolean_true_add(json_neigh
,
13347 json_object_int_add(json_neigh
, "bgpVersion", 4);
13348 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13350 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13353 /* Confederation */
13354 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13355 && bgp_confederation_peers_check(bgp
, p
->as
))
13356 json_object_boolean_true_add(json_neigh
,
13360 json_object_string_add(
13361 json_neigh
, "bgpState",
13362 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13364 if (peer_established(p
)) {
13367 uptime
= monotime(NULL
);
13368 uptime
-= p
->uptime
;
13369 epoch_tbuf
= time(NULL
) - uptime
;
13371 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13373 json_object_string_add(json_neigh
, "bgpTimerUpString",
13374 peer_uptime(p
->uptime
, timebuf
,
13377 json_object_int_add(json_neigh
,
13378 "bgpTimerUpEstablishedEpoch",
13382 else if (p
->status
== Active
) {
13383 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13384 json_object_string_add(json_neigh
, "bgpStateIs",
13386 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13387 json_object_string_add(json_neigh
, "bgpStateIs",
13395 uptime
= monotime(NULL
);
13396 uptime
-= p
->readtime
;
13397 gmtime_r(&uptime
, &tm
);
13399 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13400 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13401 + (tm
.tm_hour
* 3600000));
13403 uptime
= monotime(NULL
);
13404 uptime
-= p
->last_write
;
13405 gmtime_r(&uptime
, &tm
);
13407 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13408 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13409 + (tm
.tm_hour
* 3600000));
13411 uptime
= monotime(NULL
);
13412 uptime
-= p
->update_time
;
13413 gmtime_r(&uptime
, &tm
);
13415 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13416 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13417 + (tm
.tm_hour
* 3600000));
13419 /* Configured timer values. */
13420 json_object_int_add(json_neigh
,
13421 "bgpTimerConfiguredHoldTimeMsecs",
13422 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13423 ? p
->holdtime
* 1000
13424 : bgp
->default_holdtime
* 1000);
13425 json_object_int_add(json_neigh
,
13426 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13427 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13428 ? p
->keepalive
* 1000
13429 : bgp
->default_keepalive
* 1000);
13430 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13431 p
->v_holdtime
* 1000);
13432 json_object_int_add(json_neigh
,
13433 "bgpTimerKeepAliveIntervalMsecs",
13434 p
->v_keepalive
* 1000);
13435 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13436 json_object_int_add(json_neigh
,
13437 "bgpTimerDelayOpenTimeMsecs",
13438 p
->v_delayopen
* 1000);
13441 /* Configured and Synced tcp-mss value for peer */
13442 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13443 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13444 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13446 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13450 /* Extended Optional Parameters Length for BGP OPEN Message */
13451 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13452 json_object_boolean_true_add(
13453 json_neigh
, "extendedOptionalParametersLength");
13455 json_object_boolean_false_add(
13456 json_neigh
, "extendedOptionalParametersLength");
13458 /* Conditional advertisements */
13459 json_object_int_add(
13461 "bgpTimerConfiguredConditionalAdvertisementsSec",
13462 bgp
->condition_check_period
);
13463 if (thread_is_scheduled(bgp
->t_condition_check
))
13464 json_object_int_add(
13466 "bgpTimerUntilConditionalAdvertisementsSec",
13467 thread_timer_remain_second(
13468 bgp
->t_condition_check
));
13470 /* Administrative shutdown. */
13471 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13472 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13473 vty_out(vty
, " Administratively shut down\n");
13476 vty_out(vty
, " BGP version 4");
13477 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13478 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13480 /* Confederation */
13481 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13482 && bgp_confederation_peers_check(bgp
, p
->as
))
13484 " Neighbor under common administration\n");
13487 vty_out(vty
, " BGP state = %s",
13488 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13490 if (peer_established(p
))
13491 vty_out(vty
, ", up for %8s",
13492 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13495 else if (p
->status
== Active
) {
13496 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13497 vty_out(vty
, " (passive)");
13498 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13499 vty_out(vty
, " (NSF passive)");
13501 vty_out(vty
, "\n");
13504 vty_out(vty
, " Last read %s",
13505 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13507 vty_out(vty
, ", Last write %s\n",
13508 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13511 /* Configured timer values. */
13513 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13514 p
->v_holdtime
, p
->v_keepalive
);
13515 vty_out(vty
, " Configured hold time is %d seconds",
13516 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13518 : bgp
->default_holdtime
);
13519 vty_out(vty
, ", keepalive interval is %d seconds\n",
13520 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13522 : bgp
->default_keepalive
);
13523 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13525 " Configured DelayOpenTime is %d seconds\n",
13528 /* Configured and synced tcp-mss value for peer */
13529 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13530 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13531 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13532 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13535 /* Extended Optional Parameters Length for BGP OPEN Message */
13536 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13538 " Extended Optional Parameters Length is enabled\n");
13540 /* Conditional advertisements */
13542 " Configured conditional advertisements interval is %d seconds\n",
13543 bgp
->condition_check_period
);
13544 if (thread_is_scheduled(bgp
->t_condition_check
))
13546 " Time until conditional advertisements begin is %lu seconds\n",
13547 thread_timer_remain_second(
13548 bgp
->t_condition_check
));
13551 if (peer_established(p
) &&
13552 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13554 json_object
*json_cap
= NULL
;
13556 json_cap
= json_object_new_object();
13559 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13560 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13561 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13562 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13563 json_object_string_add(
13564 json_cap
, "4byteAs",
13565 "advertisedAndReceived");
13566 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13567 json_object_string_add(json_cap
,
13570 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13571 json_object_string_add(json_cap
,
13576 /* Extended Message Support */
13577 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13578 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13579 json_object_string_add(json_cap
,
13581 "advertisedAndReceived");
13582 else if (CHECK_FLAG(p
->cap
,
13583 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13584 json_object_string_add(json_cap
,
13587 else if (CHECK_FLAG(p
->cap
,
13588 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13589 json_object_string_add(json_cap
,
13594 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13595 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13596 json_object
*json_add
= NULL
;
13597 const char *print_store
;
13599 json_add
= json_object_new_object();
13601 FOREACH_AFI_SAFI (afi
, safi
) {
13602 json_object
*json_sub
= NULL
;
13603 json_sub
= json_object_new_object();
13604 print_store
= get_afi_safi_str(
13608 p
->af_cap
[afi
][safi
],
13609 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13611 p
->af_cap
[afi
][safi
],
13612 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13616 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13620 PEER_CAP_ADDPATH_AF_TX_RCV
))
13621 json_object_boolean_true_add(
13623 "txAdvertisedAndReceived");
13628 PEER_CAP_ADDPATH_AF_TX_ADV
))
13629 json_object_boolean_true_add(
13636 PEER_CAP_ADDPATH_AF_TX_RCV
))
13637 json_object_boolean_true_add(
13643 p
->af_cap
[afi
][safi
],
13644 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13646 p
->af_cap
[afi
][safi
],
13647 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13651 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13655 PEER_CAP_ADDPATH_AF_RX_RCV
))
13656 json_object_boolean_true_add(
13658 "rxAdvertisedAndReceived");
13663 PEER_CAP_ADDPATH_AF_RX_ADV
))
13664 json_object_boolean_true_add(
13671 PEER_CAP_ADDPATH_AF_RX_RCV
))
13672 json_object_boolean_true_add(
13678 p
->af_cap
[afi
][safi
],
13679 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13681 p
->af_cap
[afi
][safi
],
13682 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13684 p
->af_cap
[afi
][safi
],
13685 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13687 p
->af_cap
[afi
][safi
],
13688 PEER_CAP_ADDPATH_AF_RX_RCV
))
13689 json_object_object_add(
13690 json_add
, print_store
,
13693 json_object_free(json_sub
);
13696 json_object_object_add(json_cap
, "addPath",
13701 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13702 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13703 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13704 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13705 json_object_string_add(
13706 json_cap
, "dynamic",
13707 "advertisedAndReceived");
13708 else if (CHECK_FLAG(p
->cap
,
13709 PEER_CAP_DYNAMIC_ADV
))
13710 json_object_string_add(json_cap
,
13713 else if (CHECK_FLAG(p
->cap
,
13714 PEER_CAP_DYNAMIC_RCV
))
13715 json_object_string_add(json_cap
,
13721 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13722 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13723 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13724 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13725 json_object_string_add(
13727 "advertisedAndReceived");
13728 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13729 json_object_string_add(json_cap
, "role",
13731 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13732 json_object_string_add(json_cap
, "role",
13736 /* Extended nexthop */
13737 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13738 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13739 json_object
*json_nxt
= NULL
;
13740 const char *print_store
;
13743 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13744 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13745 json_object_string_add(
13746 json_cap
, "extendedNexthop",
13747 "advertisedAndReceived");
13748 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13749 json_object_string_add(
13750 json_cap
, "extendedNexthop",
13752 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13753 json_object_string_add(
13754 json_cap
, "extendedNexthop",
13757 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13758 json_nxt
= json_object_new_object();
13760 for (safi
= SAFI_UNICAST
;
13761 safi
< SAFI_MAX
; safi
++) {
13765 PEER_CAP_ENHE_AF_RCV
)) {
13771 json_object_string_add(
13774 "recieved"); /* misspelled for compatibility */
13777 json_object_object_add(
13779 "extendedNexthopFamililesByPeer",
13784 /* Long-lived Graceful Restart */
13785 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13786 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13787 json_object
*json_llgr
= NULL
;
13788 const char *afi_safi_str
;
13790 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13791 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13792 json_object_string_add(
13794 "longLivedGracefulRestart",
13795 "advertisedAndReceived");
13796 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13797 json_object_string_add(
13799 "longLivedGracefulRestart",
13801 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13802 json_object_string_add(
13804 "longLivedGracefulRestart",
13807 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13808 json_llgr
= json_object_new_object();
13810 FOREACH_AFI_SAFI (afi
, safi
) {
13814 PEER_CAP_ENHE_AF_RCV
)) {
13820 json_object_string_add(
13826 json_object_object_add(
13828 "longLivedGracefulRestartByPeer",
13833 /* Route Refresh */
13834 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13835 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13836 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13837 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13838 (CHECK_FLAG(p
->cap
,
13839 PEER_CAP_REFRESH_NEW_RCV
) ||
13841 PEER_CAP_REFRESH_OLD_RCV
))) {
13844 PEER_CAP_REFRESH_OLD_RCV
) &&
13847 PEER_CAP_REFRESH_NEW_RCV
))
13848 json_object_string_add(
13851 "advertisedAndReceivedOldNew");
13855 PEER_CAP_REFRESH_OLD_RCV
))
13856 json_object_string_add(
13859 "advertisedAndReceivedOld");
13861 json_object_string_add(
13864 "advertisedAndReceivedNew");
13866 } else if (CHECK_FLAG(p
->cap
,
13867 PEER_CAP_REFRESH_ADV
))
13868 json_object_string_add(json_cap
,
13871 else if (CHECK_FLAG(p
->cap
,
13872 PEER_CAP_REFRESH_NEW_RCV
) ||
13874 PEER_CAP_REFRESH_OLD_RCV
))
13875 json_object_string_add(json_cap
,
13880 /* Enhanced Route Refresh */
13881 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13882 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13883 if (CHECK_FLAG(p
->cap
,
13884 PEER_CAP_ENHANCED_RR_ADV
) &&
13886 PEER_CAP_ENHANCED_RR_RCV
))
13887 json_object_string_add(
13889 "enhancedRouteRefresh",
13890 "advertisedAndReceived");
13891 else if (CHECK_FLAG(p
->cap
,
13892 PEER_CAP_ENHANCED_RR_ADV
))
13893 json_object_string_add(
13895 "enhancedRouteRefresh",
13897 else if (CHECK_FLAG(p
->cap
,
13898 PEER_CAP_ENHANCED_RR_RCV
))
13899 json_object_string_add(
13901 "enhancedRouteRefresh",
13905 /* Multiprotocol Extensions */
13906 json_object
*json_multi
= NULL
;
13908 json_multi
= json_object_new_object();
13910 FOREACH_AFI_SAFI (afi
, safi
) {
13911 if (p
->afc_adv
[afi
][safi
] ||
13912 p
->afc_recv
[afi
][safi
]) {
13913 json_object
*json_exten
= NULL
;
13914 json_exten
= json_object_new_object();
13916 if (p
->afc_adv
[afi
][safi
] &&
13917 p
->afc_recv
[afi
][safi
])
13918 json_object_boolean_true_add(
13920 "advertisedAndReceived");
13921 else if (p
->afc_adv
[afi
][safi
])
13922 json_object_boolean_true_add(
13925 else if (p
->afc_recv
[afi
][safi
])
13926 json_object_boolean_true_add(
13927 json_exten
, "received");
13929 json_object_object_add(
13931 get_afi_safi_str(afi
, safi
,
13936 json_object_object_add(json_cap
,
13937 "multiprotocolExtensions",
13940 /* Hostname capabilities */
13941 json_object
*json_hname
= NULL
;
13943 json_hname
= json_object_new_object();
13945 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13946 json_object_string_add(
13947 json_hname
, "advHostName",
13948 bgp
->peer_self
->hostname
13949 ? bgp
->peer_self
->hostname
13951 json_object_string_add(
13952 json_hname
, "advDomainName",
13953 bgp
->peer_self
->domainname
13954 ? bgp
->peer_self
->domainname
13959 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13960 json_object_string_add(
13961 json_hname
, "rcvHostName",
13962 p
->hostname
? p
->hostname
: "n/a");
13963 json_object_string_add(
13964 json_hname
, "rcvDomainName",
13965 p
->domainname
? p
->domainname
: "n/a");
13968 json_object_object_add(json_cap
, "hostName",
13971 /* Software Version capability */
13972 json_object
*json_soft_version
= NULL
;
13974 json_soft_version
= json_object_new_object();
13976 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_ADV
))
13977 json_object_string_add(
13979 "advertisedSoftwareVersion",
13980 cmd_software_version_get());
13982 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_RCV
))
13983 json_object_string_add(
13985 "receivedSoftwareVersion",
13986 p
->soft_version
? p
->soft_version
13989 json_object_object_add(json_cap
, "softwareVersion",
13990 json_soft_version
);
13992 /* Graceful Restart */
13993 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13994 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13995 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13996 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13997 json_object_string_add(
13998 json_cap
, "gracefulRestart",
13999 "advertisedAndReceived");
14000 else if (CHECK_FLAG(p
->cap
,
14001 PEER_CAP_RESTART_ADV
))
14002 json_object_string_add(
14004 "gracefulRestartCapability",
14006 else if (CHECK_FLAG(p
->cap
,
14007 PEER_CAP_RESTART_RCV
))
14008 json_object_string_add(
14010 "gracefulRestartCapability",
14013 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14014 int restart_af_count
= 0;
14015 json_object
*json_restart
= NULL
;
14016 json_restart
= json_object_new_object();
14018 json_object_int_add(
14020 "gracefulRestartRemoteTimerMsecs",
14021 p
->v_gr_restart
* 1000);
14023 FOREACH_AFI_SAFI (afi
, safi
) {
14027 PEER_CAP_RESTART_AF_RCV
)) {
14028 json_object
*json_sub
=
14031 json_object_new_object();
14037 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
14038 json_object_boolean_true_add(
14041 restart_af_count
++;
14042 json_object_object_add(
14051 if (!restart_af_count
) {
14052 json_object_string_add(
14054 "addressFamiliesByPeer",
14056 json_object_free(json_restart
);
14058 json_object_object_add(
14060 "addressFamiliesByPeer",
14064 json_object_object_add(
14065 json_neigh
, "neighborCapabilities", json_cap
);
14067 vty_out(vty
, " Neighbor capabilities:\n");
14070 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
14071 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
14072 vty_out(vty
, " 4 Byte AS:");
14073 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
14074 vty_out(vty
, " advertised");
14075 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
14076 vty_out(vty
, " %sreceived",
14081 vty_out(vty
, "\n");
14084 /* Extended Message Support */
14085 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
14086 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
14087 vty_out(vty
, " Extended Message:");
14088 if (CHECK_FLAG(p
->cap
,
14089 PEER_CAP_EXTENDED_MESSAGE_ADV
))
14090 vty_out(vty
, " advertised");
14091 if (CHECK_FLAG(p
->cap
,
14092 PEER_CAP_EXTENDED_MESSAGE_RCV
))
14093 vty_out(vty
, " %sreceived",
14096 PEER_CAP_EXTENDED_MESSAGE_ADV
)
14099 vty_out(vty
, "\n");
14103 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
14104 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
14105 vty_out(vty
, " AddPath:\n");
14107 FOREACH_AFI_SAFI (afi
, safi
) {
14109 p
->af_cap
[afi
][safi
],
14110 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
14112 p
->af_cap
[afi
][safi
],
14113 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
14114 vty_out(vty
, " %s: TX ",
14122 PEER_CAP_ADDPATH_AF_TX_ADV
))
14129 PEER_CAP_ADDPATH_AF_TX_RCV
))
14136 PEER_CAP_ADDPATH_AF_TX_ADV
)
14140 vty_out(vty
, "\n");
14144 p
->af_cap
[afi
][safi
],
14145 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
14147 p
->af_cap
[afi
][safi
],
14148 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14149 vty_out(vty
, " %s: RX ",
14157 PEER_CAP_ADDPATH_AF_RX_ADV
))
14164 PEER_CAP_ADDPATH_AF_RX_RCV
))
14171 PEER_CAP_ADDPATH_AF_RX_ADV
)
14175 vty_out(vty
, "\n");
14181 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
14182 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
14183 vty_out(vty
, " Dynamic:");
14184 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
14185 vty_out(vty
, " advertised");
14186 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
14187 vty_out(vty
, " %sreceived",
14189 PEER_CAP_DYNAMIC_ADV
)
14192 vty_out(vty
, "\n");
14196 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
14197 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
14198 vty_out(vty
, " Role:");
14199 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
14200 vty_out(vty
, " advertised");
14201 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
14202 vty_out(vty
, " %sreceived",
14207 vty_out(vty
, "\n");
14210 /* Extended nexthop */
14211 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14212 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14213 vty_out(vty
, " Extended nexthop:");
14214 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14215 vty_out(vty
, " advertised");
14216 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14217 vty_out(vty
, " %sreceived",
14222 vty_out(vty
, "\n");
14224 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14226 " Address families by peer:\n ");
14227 for (safi
= SAFI_UNICAST
;
14228 safi
< SAFI_MAX
; safi
++)
14232 PEER_CAP_ENHE_AF_RCV
))
14242 /* Long-lived Graceful Restart */
14243 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14244 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14246 " Long-lived Graceful Restart:");
14247 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14248 vty_out(vty
, " advertised");
14249 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14250 vty_out(vty
, " %sreceived",
14255 vty_out(vty
, "\n");
14257 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14259 " Address families by peer:\n");
14260 FOREACH_AFI_SAFI (afi
, safi
)
14264 PEER_CAP_LLGR_AF_RCV
))
14274 /* Route Refresh */
14275 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14276 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14277 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14278 vty_out(vty
, " Route refresh:");
14279 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14280 vty_out(vty
, " advertised");
14281 if (CHECK_FLAG(p
->cap
,
14282 PEER_CAP_REFRESH_NEW_RCV
) ||
14284 PEER_CAP_REFRESH_OLD_RCV
))
14285 vty_out(vty
, " %sreceived(%s)",
14287 PEER_CAP_REFRESH_ADV
)
14292 PEER_CAP_REFRESH_OLD_RCV
) &&
14295 PEER_CAP_REFRESH_NEW_RCV
))
14299 PEER_CAP_REFRESH_OLD_RCV
)
14303 vty_out(vty
, "\n");
14306 /* Enhanced Route Refresh */
14307 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14308 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14309 vty_out(vty
, " Enhanced Route Refresh:");
14310 if (CHECK_FLAG(p
->cap
,
14311 PEER_CAP_ENHANCED_RR_ADV
))
14312 vty_out(vty
, " advertised");
14313 if (CHECK_FLAG(p
->cap
,
14314 PEER_CAP_ENHANCED_RR_RCV
))
14315 vty_out(vty
, " %sreceived",
14317 PEER_CAP_REFRESH_ADV
)
14320 vty_out(vty
, "\n");
14323 /* Multiprotocol Extensions */
14324 FOREACH_AFI_SAFI (afi
, safi
)
14325 if (p
->afc_adv
[afi
][safi
] ||
14326 p
->afc_recv
[afi
][safi
]) {
14327 vty_out(vty
, " Address Family %s:",
14328 get_afi_safi_str(afi
, safi
,
14330 if (p
->afc_adv
[afi
][safi
])
14331 vty_out(vty
, " advertised");
14332 if (p
->afc_recv
[afi
][safi
])
14333 vty_out(vty
, " %sreceived",
14334 p
->afc_adv
[afi
][safi
]
14337 vty_out(vty
, "\n");
14340 /* Hostname capability */
14341 vty_out(vty
, " Hostname Capability:");
14343 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14345 " advertised (name: %s,domain name: %s)",
14346 bgp
->peer_self
->hostname
14347 ? bgp
->peer_self
->hostname
14349 bgp
->peer_self
->domainname
14350 ? bgp
->peer_self
->domainname
14353 vty_out(vty
, " not advertised");
14356 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14358 " received (name: %s,domain name: %s)",
14359 p
->hostname
? p
->hostname
: "n/a",
14360 p
->domainname
? p
->domainname
: "n/a");
14362 vty_out(vty
, " not received");
14365 vty_out(vty
, "\n");
14367 /* Software Version capability */
14368 vty_out(vty
, " Version Capability:");
14370 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_ADV
)) {
14372 " advertised software version (%s)",
14373 cmd_software_version_get());
14375 vty_out(vty
, " not advertised");
14377 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_RCV
)) {
14378 vty_out(vty
, " received software version (%s)",
14379 p
->soft_version
? p
->soft_version
14382 vty_out(vty
, " not received");
14384 vty_out(vty
, "\n");
14386 /* Graceful Restart */
14387 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14388 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14390 " Graceful Restart Capability:");
14391 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14392 vty_out(vty
, " advertised");
14393 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14394 vty_out(vty
, " %sreceived",
14396 PEER_CAP_RESTART_ADV
)
14399 vty_out(vty
, "\n");
14401 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14402 int restart_af_count
= 0;
14405 " Remote Restart timer is %d seconds\n",
14408 " Address families by peer:\n ");
14410 FOREACH_AFI_SAFI (afi
, safi
)
14414 PEER_CAP_RESTART_AF_RCV
)) {
14415 vty_out(vty
, "%s%s(%s)",
14427 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14429 : "not preserved");
14430 restart_af_count
++;
14432 if (!restart_af_count
)
14433 vty_out(vty
, "none");
14434 vty_out(vty
, "\n");
14436 } /* Graceful Restart */
14440 /* graceful restart information */
14441 json_object
*json_grace
= NULL
;
14442 json_object
*json_grace_send
= NULL
;
14443 json_object
*json_grace_recv
= NULL
;
14444 int eor_send_af_count
= 0;
14445 int eor_receive_af_count
= 0;
14448 json_grace
= json_object_new_object();
14449 json_grace_send
= json_object_new_object();
14450 json_grace_recv
= json_object_new_object();
14452 if ((peer_established(p
)) &&
14453 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14454 FOREACH_AFI_SAFI (afi
, safi
) {
14455 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14456 PEER_STATUS_EOR_SEND
)) {
14457 json_object_boolean_true_add(
14459 get_afi_safi_str(afi
, safi
,
14461 eor_send_af_count
++;
14464 FOREACH_AFI_SAFI (afi
, safi
) {
14465 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14466 PEER_STATUS_EOR_RECEIVED
)) {
14467 json_object_boolean_true_add(
14469 get_afi_safi_str(afi
, safi
,
14471 eor_receive_af_count
++;
14475 json_object_object_add(json_grace
, "endOfRibSend",
14477 json_object_object_add(json_grace
, "endOfRibRecv",
14481 if (p
->t_gr_restart
)
14482 json_object_int_add(
14483 json_grace
, "gracefulRestartTimerMsecs",
14484 thread_timer_remain_second(p
->t_gr_restart
) *
14488 json_object_int_add(
14489 json_grace
, "gracefulStalepathTimerMsecs",
14490 thread_timer_remain_second(p
->t_gr_stale
) *
14492 /* more gr info in new format */
14493 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14494 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14497 vty_out(vty
, " Graceful restart information:\n");
14498 if ((peer_established(p
)) &&
14499 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14501 vty_out(vty
, " End-of-RIB send: ");
14502 FOREACH_AFI_SAFI (afi
, safi
) {
14503 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14504 PEER_STATUS_EOR_SEND
)) {
14505 vty_out(vty
, "%s%s",
14506 eor_send_af_count
? ", " : "",
14507 get_afi_safi_str(afi
, safi
,
14509 eor_send_af_count
++;
14512 vty_out(vty
, "\n");
14513 vty_out(vty
, " End-of-RIB received: ");
14514 FOREACH_AFI_SAFI (afi
, safi
) {
14515 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14516 PEER_STATUS_EOR_RECEIVED
)) {
14517 vty_out(vty
, "%s%s",
14518 eor_receive_af_count
? ", "
14520 get_afi_safi_str(afi
, safi
,
14522 eor_receive_af_count
++;
14525 vty_out(vty
, "\n");
14528 if (p
->t_gr_restart
)
14530 " The remaining time of restart timer is %ld\n",
14531 thread_timer_remain_second(p
->t_gr_restart
));
14535 " The remaining time of stalepath timer is %ld\n",
14536 thread_timer_remain_second(p
->t_gr_stale
));
14538 /* more gr info in new format */
14539 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14543 json_object
*json_stat
= NULL
;
14544 json_stat
= json_object_new_object();
14545 /* Packet counts. */
14547 atomic_size_t outq_count
, inq_count
;
14548 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14549 memory_order_relaxed
);
14550 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14551 memory_order_relaxed
);
14553 json_object_int_add(json_stat
, "depthInq",
14554 (unsigned long)inq_count
);
14555 json_object_int_add(json_stat
, "depthOutq",
14556 (unsigned long)outq_count
);
14557 json_object_int_add(json_stat
, "opensSent",
14558 atomic_load_explicit(&p
->open_out
,
14559 memory_order_relaxed
));
14560 json_object_int_add(json_stat
, "opensRecv",
14561 atomic_load_explicit(&p
->open_in
,
14562 memory_order_relaxed
));
14563 json_object_int_add(json_stat
, "notificationsSent",
14564 atomic_load_explicit(&p
->notify_out
,
14565 memory_order_relaxed
));
14566 json_object_int_add(json_stat
, "notificationsRecv",
14567 atomic_load_explicit(&p
->notify_in
,
14568 memory_order_relaxed
));
14569 json_object_int_add(json_stat
, "updatesSent",
14570 atomic_load_explicit(&p
->update_out
,
14571 memory_order_relaxed
));
14572 json_object_int_add(json_stat
, "updatesRecv",
14573 atomic_load_explicit(&p
->update_in
,
14574 memory_order_relaxed
));
14575 json_object_int_add(json_stat
, "keepalivesSent",
14576 atomic_load_explicit(&p
->keepalive_out
,
14577 memory_order_relaxed
));
14578 json_object_int_add(json_stat
, "keepalivesRecv",
14579 atomic_load_explicit(&p
->keepalive_in
,
14580 memory_order_relaxed
));
14581 json_object_int_add(json_stat
, "routeRefreshSent",
14582 atomic_load_explicit(&p
->refresh_out
,
14583 memory_order_relaxed
));
14584 json_object_int_add(json_stat
, "routeRefreshRecv",
14585 atomic_load_explicit(&p
->refresh_in
,
14586 memory_order_relaxed
));
14587 json_object_int_add(json_stat
, "capabilitySent",
14588 atomic_load_explicit(&p
->dynamic_cap_out
,
14589 memory_order_relaxed
));
14590 json_object_int_add(json_stat
, "capabilityRecv",
14591 atomic_load_explicit(&p
->dynamic_cap_in
,
14592 memory_order_relaxed
));
14593 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14594 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14595 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14597 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14598 notify_out
, notify_in
, update_out
, update_in
,
14599 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14600 dynamic_cap_out
, dynamic_cap_in
;
14601 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14602 memory_order_relaxed
);
14603 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14604 memory_order_relaxed
);
14605 open_out
= atomic_load_explicit(&p
->open_out
,
14606 memory_order_relaxed
);
14608 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14609 notify_out
= atomic_load_explicit(&p
->notify_out
,
14610 memory_order_relaxed
);
14611 notify_in
= atomic_load_explicit(&p
->notify_in
,
14612 memory_order_relaxed
);
14613 update_out
= atomic_load_explicit(&p
->update_out
,
14614 memory_order_relaxed
);
14615 update_in
= atomic_load_explicit(&p
->update_in
,
14616 memory_order_relaxed
);
14617 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14618 memory_order_relaxed
);
14619 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14620 memory_order_relaxed
);
14621 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14622 memory_order_relaxed
);
14623 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14624 memory_order_relaxed
);
14625 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14626 memory_order_relaxed
);
14627 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14628 memory_order_relaxed
);
14630 /* Packet counts. */
14631 vty_out(vty
, " Message statistics:\n");
14632 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14633 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14634 vty_out(vty
, " Sent Rcvd\n");
14635 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14637 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14639 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14641 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14643 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14645 vty_out(vty
, " Capability: %10zu %10zu\n",
14646 dynamic_cap_out
, dynamic_cap_in
);
14647 vty_out(vty
, " Total: %10u %10u\n",
14648 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14652 /* advertisement-interval */
14653 json_object_int_add(json_neigh
,
14654 "minBtwnAdvertisementRunsTimerMsecs",
14655 p
->v_routeadv
* 1000);
14657 /* Update-source. */
14658 if (p
->update_if
|| p
->update_source
) {
14660 json_object_string_add(json_neigh
,
14663 else if (p
->update_source
)
14664 json_object_string_addf(json_neigh
,
14665 "updateSource", "%pSU",
14669 /* advertisement-interval */
14671 " Minimum time between advertisement runs is %d seconds\n",
14674 /* Update-source. */
14675 if (p
->update_if
|| p
->update_source
) {
14676 vty_out(vty
, " Update source is ");
14678 vty_out(vty
, "%s", p
->update_if
);
14679 else if (p
->update_source
)
14680 vty_out(vty
, "%pSU", p
->update_source
);
14681 vty_out(vty
, "\n");
14684 vty_out(vty
, "\n");
14687 /* Address Family Information */
14688 json_object
*json_hold
= NULL
;
14691 json_hold
= json_object_new_object();
14693 FOREACH_AFI_SAFI (afi
, safi
)
14694 if (p
->afc
[afi
][safi
])
14695 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14699 json_object_object_add(json_neigh
, "addressFamilyInfo",
14701 json_object_int_add(json_neigh
, "connectionsEstablished",
14703 json_object_int_add(json_neigh
, "connectionsDropped",
14706 vty_out(vty
, " Connections established %d; dropped %d\n",
14707 p
->established
, p
->dropped
);
14709 if (!p
->last_reset
) {
14711 json_object_string_add(json_neigh
, "lastReset",
14714 vty_out(vty
, " Last reset never\n");
14720 uptime
= monotime(NULL
);
14721 uptime
-= p
->resettime
;
14722 gmtime_r(&uptime
, &tm
);
14724 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14726 + (tm
.tm_min
* 60000)
14727 + (tm
.tm_hour
* 3600000));
14728 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14730 vty_out(vty
, " Last reset %s, ",
14731 peer_uptime(p
->resettime
, timebuf
,
14732 BGP_UPTIME_LEN
, 0, NULL
));
14734 bgp_show_peer_reset(vty
, p
, NULL
, false);
14735 if (p
->last_reset_cause_size
) {
14736 msg
= p
->last_reset_cause
;
14738 " Message received that caused BGP to send a NOTIFICATION:\n ");
14739 for (i
= 1; i
<= p
->last_reset_cause_size
;
14741 vty_out(vty
, "%02X", *msg
++);
14743 if (i
!= p
->last_reset_cause_size
) {
14745 vty_out(vty
, "\n ");
14746 } else if (i
% 4 == 0) {
14751 vty_out(vty
, "\n");
14756 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14758 json_object_boolean_true_add(json_neigh
,
14759 "prefixesConfigExceedMax");
14762 " Peer had exceeded the max. no. of prefixes configured.\n");
14764 if (p
->t_pmax_restart
) {
14766 json_object_boolean_true_add(
14767 json_neigh
, "reducePrefixNumFrom");
14768 json_object_int_add(json_neigh
,
14769 "restartInTimerMsec",
14770 thread_timer_remain_second(
14775 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14776 p
->host
, thread_timer_remain_second(
14777 p
->t_pmax_restart
));
14780 json_object_boolean_true_add(
14782 "reducePrefixNumAndClearIpBgp");
14785 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14790 /* EBGP Multihop and GTSM */
14791 if (p
->sort
!= BGP_PEER_IBGP
) {
14793 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14794 json_object_int_add(json_neigh
,
14795 "externalBgpNbrMaxHopsAway",
14798 json_object_int_add(json_neigh
,
14799 "externalBgpNbrMaxHopsAway",
14802 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14804 " External BGP neighbor may be up to %d hops away.\n",
14808 " External BGP neighbor may be up to %d hops away.\n",
14813 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14814 json_object_int_add(json_neigh
,
14815 "internalBgpNbrMaxHopsAway",
14818 json_object_int_add(json_neigh
,
14819 "internalBgpNbrMaxHopsAway",
14822 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14824 " Internal BGP neighbor may be up to %d hops away.\n",
14828 " Internal BGP neighbor may be up to %d hops away.\n",
14833 /* Local address. */
14836 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14838 json_object_int_add(json_neigh
, "portLocal",
14839 ntohs(p
->su_local
->sin
.sin_port
));
14841 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14842 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14845 json_object_string_add(json_neigh
, "hostLocal",
14847 json_object_int_add(json_neigh
, "portLocal", -1);
14851 /* Remote address. */
14852 if (p
->su_remote
) {
14854 json_object_string_addf(json_neigh
, "hostForeign",
14855 "%pSU", p
->su_remote
);
14856 json_object_int_add(json_neigh
, "portForeign",
14857 ntohs(p
->su_remote
->sin
.sin_port
));
14859 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14861 ntohs(p
->su_remote
->sin
.sin_port
));
14864 json_object_string_add(json_neigh
, "hostForeign",
14866 json_object_int_add(json_neigh
, "portForeign", -1);
14870 /* Nexthop display. */
14873 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14875 json_object_string_addf(json_neigh
, "nexthopGlobal",
14876 "%pI6", &p
->nexthop
.v6_global
);
14877 json_object_string_addf(json_neigh
, "nexthopLocal",
14878 "%pI6", &p
->nexthop
.v6_local
);
14879 if (p
->shared_network
)
14880 json_object_string_add(json_neigh
,
14884 json_object_string_add(json_neigh
,
14886 "nonSharedNetwork");
14888 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14889 vty_out(vty
, "Nexthop global: %pI6\n",
14890 &p
->nexthop
.v6_global
);
14891 vty_out(vty
, "Nexthop local: %pI6\n",
14892 &p
->nexthop
.v6_local
);
14893 vty_out(vty
, "BGP connection: %s\n",
14894 p
->shared_network
? "shared network"
14895 : "non shared network");
14899 json_object_string_add(json_neigh
, "nexthop",
14901 json_object_string_add(json_neigh
, "nexthopGlobal",
14903 json_object_string_add(json_neigh
, "nexthopLocal",
14905 json_object_string_add(json_neigh
, "bgpConnection",
14910 /* Timer information. */
14912 json_object_int_add(json_neigh
, "connectRetryTimer",
14914 if (peer_established(p
)) {
14915 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14917 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14918 json_object_int_add(json_neigh
,
14919 "shutdownRttInMsecs",
14921 json_object_int_add(json_neigh
,
14922 "shutdownRttAfterCount",
14923 p
->rtt_keepalive_rcv
);
14927 json_object_int_add(
14928 json_neigh
, "nextStartTimerDueInMsecs",
14929 thread_timer_remain_second(p
->t_start
) * 1000);
14931 json_object_int_add(
14932 json_neigh
, "nextConnectTimerDueInMsecs",
14933 thread_timer_remain_second(p
->t_connect
)
14935 if (p
->t_routeadv
) {
14936 json_object_int_add(json_neigh
, "mraiInterval",
14938 json_object_int_add(
14939 json_neigh
, "mraiTimerExpireInMsecs",
14940 thread_timer_remain_second(p
->t_routeadv
)
14944 json_object_int_add(json_neigh
, "authenticationEnabled",
14948 json_object_string_add(json_neigh
, "readThread", "on");
14950 json_object_string_add(json_neigh
, "readThread", "off");
14952 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14953 json_object_string_add(json_neigh
, "writeThread", "on");
14955 json_object_string_add(json_neigh
, "writeThread",
14958 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14960 if (peer_established(p
)) {
14961 vty_out(vty
, "Estimated round trip time: %d ms\n",
14963 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14965 "Shutdown when RTT > %dms, count > %u\n",
14966 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14969 vty_out(vty
, "Next start timer due in %ld seconds\n",
14970 thread_timer_remain_second(p
->t_start
));
14972 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14973 thread_timer_remain_second(p
->t_connect
));
14976 "MRAI (interval %u) timer expires in %ld seconds\n",
14978 thread_timer_remain_second(p
->t_routeadv
));
14980 vty_out(vty
, "Peer Authentication Enabled\n");
14982 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14983 p
->t_read
? "on" : "off",
14984 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14989 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14990 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14991 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14994 vty_out(vty
, "\n");
14996 /* BFD information. */
14998 bgp_bfd_show_info(vty
, p
, json_neigh
);
15001 if (p
->conf_if
) /* Configured interface name. */
15002 json_object_object_add(json
, p
->conf_if
, json_neigh
);
15003 else /* Configured IP address. */
15004 json_object_object_add(json
, p
->host
, json_neigh
);
15008 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
15009 enum show_type type
,
15010 union sockunion
*su
,
15011 const char *conf_if
, afi_t afi
,
15014 struct listnode
*node
, *nnode
;
15016 bool found
= false;
15017 safi_t safi
= SAFI_UNICAST
;
15018 json_object
*json_neighbor
= NULL
;
15020 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15022 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15025 if ((peer
->afc
[afi
][safi
]) == 0)
15029 json_neighbor
= json_object_new_object();
15031 if (type
== show_all
) {
15032 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
15035 json_object_object_add(json
, peer
->host
,
15038 } else if (type
== show_peer
) {
15041 && !strcmp(peer
->conf_if
, conf_if
))
15043 && !strcmp(peer
->hostname
, conf_if
))) {
15045 bgp_show_peer_gr_status(vty
, peer
,
15049 if (sockunion_same(&peer
->su
, su
)) {
15051 bgp_show_peer_gr_status(vty
, peer
,
15057 json_object_object_add(json
, peer
->host
,
15060 json_object_free(json_neighbor
);
15068 if (type
== show_peer
&& !found
) {
15070 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15072 vty_out(vty
, "%% No such neighbor\n");
15076 vty_out(vty
, "\n");
15078 return CMD_SUCCESS
;
15081 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
15082 enum show_type type
, union sockunion
*su
,
15083 const char *conf_if
, bool use_json
,
15086 struct listnode
*node
, *nnode
;
15089 bool nbr_output
= false;
15090 afi_t afi
= AFI_MAX
;
15091 safi_t safi
= SAFI_MAX
;
15093 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
15095 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
15099 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15100 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15105 bgp_show_peer(vty
, peer
, use_json
, json
);
15111 && !strcmp(peer
->conf_if
, conf_if
))
15113 && !strcmp(peer
->hostname
, conf_if
))) {
15115 bgp_show_peer(vty
, peer
, use_json
,
15119 if (sockunion_same(&peer
->su
, su
)) {
15121 bgp_show_peer(vty
, peer
, use_json
,
15126 case show_ipv4_peer
:
15127 case show_ipv6_peer
:
15128 FOREACH_SAFI (safi
) {
15129 if (peer
->afc
[afi
][safi
]) {
15132 && !strcmp(peer
->conf_if
, conf_if
))
15134 && !strcmp(peer
->hostname
, conf_if
))) {
15136 bgp_show_peer(vty
, peer
, use_json
,
15141 if (sockunion_same(&peer
->su
, su
)) {
15143 bgp_show_peer(vty
, peer
, use_json
,
15151 case show_ipv4_all
:
15152 case show_ipv6_all
:
15153 FOREACH_SAFI (safi
) {
15154 if (peer
->afc
[afi
][safi
]) {
15155 bgp_show_peer(vty
, peer
, use_json
, json
);
15164 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15165 type
== show_ipv6_peer
) && !find
) {
15167 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15169 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15172 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15173 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15174 vty_out(vty
, "%% No BGP neighbors found\n");
15177 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15178 json
, JSON_C_TO_STRING_PRETTY
));
15180 vty_out(vty
, "\n");
15183 return CMD_SUCCESS
;
15186 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15187 enum show_type type
,
15188 const char *ip_str
,
15189 afi_t afi
, json_object
*json
)
15194 union sockunion su
;
15196 bgp
= bgp_get_default();
15202 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
15205 ret
= str2sockunion(ip_str
, &su
);
15207 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
15208 ip_str
, afi
, json
);
15210 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15213 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15217 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15218 enum show_type type
,
15219 const char *ip_str
,
15222 struct listnode
*node
, *nnode
;
15224 union sockunion su
;
15225 json_object
*json
= NULL
;
15226 int ret
, is_first
= 1;
15227 bool nbr_output
= false;
15230 vty_out(vty
, "{\n");
15232 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15235 if (!(json
= json_object_new_object())) {
15237 EC_BGP_JSON_MEM_ERROR
,
15238 "Unable to allocate memory for JSON object");
15240 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15244 json_object_int_add(json
, "vrfId",
15245 (bgp
->vrf_id
== VRF_UNKNOWN
)
15247 : (int64_t)bgp
->vrf_id
);
15248 json_object_string_add(
15250 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15255 vty_out(vty
, ",\n");
15259 vty_out(vty
, "\"%s\":",
15260 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15264 vty_out(vty
, "\nInstance %s:\n",
15265 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15270 if (type
== show_peer
|| type
== show_ipv4_peer
||
15271 type
== show_ipv6_peer
) {
15272 ret
= str2sockunion(ip_str
, &su
);
15274 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15277 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15280 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15283 json_object_free(json
);
15288 vty_out(vty
, "}\n");
15289 else if (!nbr_output
)
15290 vty_out(vty
, "%% BGP instance not found\n");
15293 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15294 enum show_type type
, const char *ip_str
,
15299 union sockunion su
;
15300 json_object
*json
= NULL
;
15303 if (strmatch(name
, "all")) {
15304 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15306 return CMD_SUCCESS
;
15308 bgp
= bgp_lookup_by_name(name
);
15311 json
= json_object_new_object();
15312 vty_json(vty
, json
);
15315 "%% BGP instance not found\n");
15317 return CMD_WARNING
;
15321 bgp
= bgp_get_default();
15325 json
= json_object_new_object();
15327 ret
= str2sockunion(ip_str
, &su
);
15329 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15332 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15335 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15338 json_object_free(json
);
15341 vty_out(vty
, "{}\n");
15343 vty_out(vty
, "%% BGP instance not found\n");
15346 return CMD_SUCCESS
;
15351 /* "show [ip] bgp neighbors graceful-restart" commands. */
15352 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15353 show_ip_bgp_neighbors_graceful_restart_cmd
,
15354 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15360 "Neighbor to display information about\n"
15361 "Neighbor to display information about\n"
15362 "Neighbor on BGP configured interface\n"
15366 char *sh_arg
= NULL
;
15367 enum show_type sh_type
;
15369 afi_t afi
= AFI_MAX
;
15370 bool uj
= use_json(argc
, argv
);
15372 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15377 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15378 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15379 || argv_find(argv
, argc
, "WORD", &idx
)) {
15380 sh_type
= show_peer
;
15381 sh_arg
= argv
[idx
]->arg
;
15383 sh_type
= show_all
;
15385 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15386 return CMD_SUCCESS
;
15389 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15393 /* "show [ip] bgp neighbors" commands. */
15394 DEFUN (show_ip_bgp_neighbors
,
15395 show_ip_bgp_neighbors_cmd
,
15396 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15400 BGP_INSTANCE_HELP_STR
15403 "Detailed information on TCP and BGP neighbor connections\n"
15404 "Neighbor to display information about\n"
15405 "Neighbor to display information about\n"
15406 "Neighbor on BGP configured interface\n"
15410 char *sh_arg
= NULL
;
15411 enum show_type sh_type
;
15412 afi_t afi
= AFI_MAX
;
15414 bool uj
= use_json(argc
, argv
);
15418 /* [<vrf> VIEWVRFNAME] */
15419 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15420 vrf
= argv
[idx
+ 1]->arg
;
15421 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15423 } else if (argv_find(argv
, argc
, "view", &idx
))
15424 /* [<view> VIEWVRFNAME] */
15425 vrf
= argv
[idx
+ 1]->arg
;
15429 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15430 sh_type
= show_ipv4_all
;
15432 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15433 sh_type
= show_ipv6_all
;
15436 sh_type
= show_all
;
15439 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15440 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15441 || argv_find(argv
, argc
, "WORD", &idx
)) {
15442 sh_type
= show_peer
;
15443 sh_arg
= argv
[idx
]->arg
;
15446 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15447 sh_type
= show_ipv4_peer
;
15448 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15449 sh_type
= show_ipv6_peer
;
15452 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15455 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15456 paths' and `show ip mbgp paths'. Those functions results are the
15458 DEFUN (show_ip_bgp_paths
,
15459 show_ip_bgp_paths_cmd
,
15460 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15465 "Path information\n")
15467 vty_out(vty
, "Address Refcnt Path\n");
15468 aspath_print_all_vty(vty
);
15469 return CMD_SUCCESS
;
15474 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15477 struct community
*com
;
15479 com
= (struct community
*)bucket
->data
;
15480 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15481 community_str(com
, false, false));
15484 /* Show BGP's community internal data. */
15485 DEFUN (show_ip_bgp_community_info
,
15486 show_ip_bgp_community_info_cmd
,
15487 "show [ip] bgp community-info",
15491 "List all bgp community information\n")
15493 vty_out(vty
, "Address Refcnt Community\n");
15495 hash_iterate(community_hash(),
15496 (void (*)(struct hash_bucket
*,
15497 void *))community_show_all_iterator
,
15500 return CMD_SUCCESS
;
15503 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15506 struct lcommunity
*lcom
;
15508 lcom
= (struct lcommunity
*)bucket
->data
;
15509 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15510 lcommunity_str(lcom
, false, false));
15513 /* Show BGP's community internal data. */
15514 DEFUN (show_ip_bgp_lcommunity_info
,
15515 show_ip_bgp_lcommunity_info_cmd
,
15516 "show ip bgp large-community-info",
15520 "List all bgp large-community information\n")
15522 vty_out(vty
, "Address Refcnt Large-community\n");
15524 hash_iterate(lcommunity_hash(),
15525 (void (*)(struct hash_bucket
*,
15526 void *))lcommunity_show_all_iterator
,
15529 return CMD_SUCCESS
;
15531 /* Graceful Restart */
15533 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15538 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15540 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15542 switch (bgp_global_gr_mode
) {
15544 case GLOBAL_HELPER
:
15545 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15549 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15552 case GLOBAL_DISABLE
:
15553 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15556 case GLOBAL_INVALID
:
15558 "Global BGP GR Mode Invalid\n");
15561 vty_out(vty
, "\n");
15564 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15565 enum show_type type
,
15566 const char *ip_str
,
15567 afi_t afi
, bool use_json
)
15569 json_object
*json
= NULL
;
15572 json
= json_object_new_object();
15574 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15577 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15579 bgp_show_neighbor_graceful_restart_vty(
15580 vty
, type
, ip_str
, afi
, json
);
15583 } else if (afi
!= AFI_MAX
) {
15584 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15588 json_object_free(json
);
15589 return CMD_ERR_INCOMPLETE
;
15593 vty_json(vty
, json
);
15595 return CMD_SUCCESS
;
15597 /* Graceful Restart */
15599 DEFUN (show_ip_bgp_attr_info
,
15600 show_ip_bgp_attr_info_cmd
,
15601 "show [ip] bgp attribute-info",
15605 "List all bgp attribute information\n")
15607 attr_show_all(vty
);
15608 return CMD_SUCCESS
;
15611 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15612 afi_t afi
, safi_t safi
,
15613 bool use_json
, json_object
*json
)
15616 struct listnode
*node
;
15619 enum vpn_policy_direction dir
;
15622 json_object
*json_import_vrfs
= NULL
;
15623 json_object
*json_export_vrfs
= NULL
;
15625 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15628 vty_json(vty
, json
);
15630 return CMD_WARNING
;
15633 /* Provide context for the block */
15634 json_object_string_add(json
, "vrf", name
? name
: "default");
15635 json_object_string_add(json
, "afiSafi",
15636 get_afi_safi_str(afi
, safi
, true));
15638 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15639 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15640 json_object_string_add(json
, "importFromVrfs", "none");
15641 json_object_string_add(json
, "importRts", "none");
15643 json_import_vrfs
= json_object_new_array();
15645 for (ALL_LIST_ELEMENTS_RO(
15646 bgp
->vpn_policy
[afi
].import_vrf
,
15648 json_object_array_add(json_import_vrfs
,
15649 json_object_new_string(vname
));
15651 json_object_object_add(json
, "importFromVrfs",
15653 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15654 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15655 ecom_str
= ecommunity_ecom2str(
15656 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15657 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15658 json_object_string_add(json
, "importRts",
15660 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15662 json_object_string_add(json
, "importRts",
15666 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15667 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15668 json_object_string_add(json
, "exportToVrfs", "none");
15669 json_object_string_add(json
, "routeDistinguisher",
15671 json_object_string_add(json
, "exportRts", "none");
15673 json_export_vrfs
= json_object_new_array();
15675 for (ALL_LIST_ELEMENTS_RO(
15676 bgp
->vpn_policy
[afi
].export_vrf
,
15678 json_object_array_add(json_export_vrfs
,
15679 json_object_new_string(vname
));
15680 json_object_object_add(json
, "exportToVrfs",
15682 json_object_string_addf(
15683 json
, "routeDistinguisher", "%s",
15684 bgp
->vpn_policy
[afi
].tovpn_rd_pretty
);
15685 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15686 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15687 ecom_str
= ecommunity_ecom2str(
15688 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15689 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15690 json_object_string_add(json
, "exportRts",
15692 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15694 json_object_string_add(json
, "exportRts",
15699 vty_json(vty
, json
);
15702 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15705 vty_out(vty
, "%% No such BGP instance exist\n");
15706 return CMD_WARNING
;
15709 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15710 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15712 "This VRF is not importing %s routes from any other VRF\n",
15713 get_afi_safi_str(afi
, safi
, false));
15716 "This VRF is importing %s routes from the following VRFs:\n",
15717 get_afi_safi_str(afi
, safi
, false));
15719 for (ALL_LIST_ELEMENTS_RO(
15720 bgp
->vpn_policy
[afi
].import_vrf
,
15722 vty_out(vty
, " %s\n", vname
);
15724 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15726 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15727 ecom_str
= ecommunity_ecom2str(
15728 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15729 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15730 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15732 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15734 vty_out(vty
, "Import RT(s):\n");
15737 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15738 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15740 "This VRF is not exporting %s routes to any other VRF\n",
15741 get_afi_safi_str(afi
, safi
, false));
15744 "This VRF is exporting %s routes to the following VRFs:\n",
15745 get_afi_safi_str(afi
, safi
, false));
15747 for (ALL_LIST_ELEMENTS_RO(
15748 bgp
->vpn_policy
[afi
].export_vrf
,
15750 vty_out(vty
, " %s\n", vname
);
15752 vty_out(vty
, "RD: ");
15753 vty_out(vty
, BGP_RD_AS_FORMAT(bgp
->asnotation
),
15754 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15755 vty_out(vty
, "\n");
15757 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15758 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15759 ecom_str
= ecommunity_ecom2str(
15760 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15761 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15762 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15763 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15765 vty_out(vty
, "Import RT(s):\n");
15769 return CMD_SUCCESS
;
15772 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15773 safi_t safi
, bool use_json
)
15775 struct listnode
*node
, *nnode
;
15777 char *vrf_name
= NULL
;
15778 json_object
*json
= NULL
;
15779 json_object
*json_vrf
= NULL
;
15780 json_object
*json_vrfs
= NULL
;
15783 json
= json_object_new_object();
15784 json_vrfs
= json_object_new_object();
15787 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15789 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15790 vrf_name
= bgp
->name
;
15793 json_vrf
= json_object_new_object();
15795 vty_out(vty
, "\nInstance %s:\n",
15796 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15797 ? VRF_DEFAULT_NAME
: bgp
->name
);
15799 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15801 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15802 json_object_object_add(json_vrfs
,
15803 VRF_DEFAULT_NAME
, json_vrf
);
15805 json_object_object_add(json_vrfs
, vrf_name
,
15811 json_object_object_add(json
, "vrfs", json_vrfs
);
15812 vty_json(vty
, json
);
15815 return CMD_SUCCESS
;
15818 /* "show [ip] bgp route-leak" command. */
15819 DEFUN (show_ip_bgp_route_leak
,
15820 show_ip_bgp_route_leak_cmd
,
15821 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15825 BGP_INSTANCE_HELP_STR
15828 "Route leaking information\n"
15832 afi_t afi
= AFI_MAX
;
15833 safi_t safi
= SAFI_MAX
;
15835 bool uj
= use_json(argc
, argv
);
15837 json_object
*json
= NULL
;
15839 /* show [ip] bgp */
15840 if (argv_find(argv
, argc
, "ip", &idx
)) {
15842 safi
= SAFI_UNICAST
;
15844 /* [vrf VIEWVRFNAME] */
15845 if (argv_find(argv
, argc
, "view", &idx
)) {
15847 "%% This command is not applicable to BGP views\n");
15848 return CMD_WARNING
;
15851 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15852 vrf
= argv
[idx
+ 1]->arg
;
15853 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15856 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15857 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15858 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15860 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15862 "%% This command is applicable only for unicast ipv4|ipv6\n");
15863 return CMD_WARNING
;
15866 if (vrf
&& strmatch(vrf
, "all"))
15867 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15870 json
= json_object_new_object();
15872 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15875 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15876 safi_t safi
, bool uj
)
15878 struct listnode
*node
, *nnode
;
15881 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15883 vty_out(vty
, "\nInstance %s:\n",
15884 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15888 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15892 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15893 int safi
, uint64_t subgrp_id
, bool uj
)
15898 if (strmatch(name
, "all")) {
15899 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15900 return CMD_SUCCESS
;
15902 bgp
= bgp_lookup_by_name(name
);
15905 bgp
= bgp_get_default();
15909 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15910 return CMD_SUCCESS
;
15913 DEFUN (show_ip_bgp_updgrps
,
15914 show_ip_bgp_updgrps_cmd
,
15915 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15919 BGP_INSTANCE_HELP_STR
15921 BGP_SAFI_WITH_LABEL_HELP_STR
15922 "Detailed info about dynamic update groups\n"
15923 "Specific subgroup to display detailed info for\n"
15927 afi_t afi
= AFI_IP6
;
15928 safi_t safi
= SAFI_UNICAST
;
15929 uint64_t subgrp_id
= 0;
15933 bool uj
= use_json(argc
, argv
);
15935 /* show [ip] bgp */
15936 if (argv_find(argv
, argc
, "ip", &idx
))
15938 /* [<vrf> VIEWVRFNAME] */
15939 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15940 vrf
= argv
[idx
+ 1]->arg
;
15941 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15943 } else if (argv_find(argv
, argc
, "view", &idx
))
15944 /* [<view> VIEWVRFNAME] */
15945 vrf
= argv
[idx
+ 1]->arg
;
15946 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15947 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15948 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15951 /* get subgroup id, if provided */
15953 if (argv
[idx
]->type
== VARIABLE_TKN
)
15954 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15956 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15959 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15960 show_bgp_instance_all_ipv6_updgrps_cmd
,
15961 "show [ip] bgp <view|vrf> all update-groups [json]",
15965 BGP_INSTANCE_ALL_HELP_STR
15966 "Detailed info about dynamic update groups\n"
15969 bool uj
= use_json(argc
, argv
);
15971 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15972 return CMD_SUCCESS
;
15975 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15976 show_bgp_l2vpn_evpn_updgrps_cmd
,
15977 "show [ip] bgp l2vpn evpn update-groups",
15981 "l2vpn address family\n"
15982 "evpn sub-address family\n"
15983 "Detailed info about dynamic update groups\n")
15986 uint64_t subgrp_id
= 0;
15988 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15989 return CMD_SUCCESS
;
15992 DEFUN (show_bgp_updgrps_stats
,
15993 show_bgp_updgrps_stats_cmd
,
15994 "show [ip] bgp update-groups statistics",
15998 "Detailed info about dynamic update groups\n"
16003 bgp
= bgp_get_default();
16005 update_group_show_stats(bgp
, vty
);
16007 return CMD_SUCCESS
;
16010 DEFUN (show_bgp_instance_updgrps_stats
,
16011 show_bgp_instance_updgrps_stats_cmd
,
16012 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
16016 BGP_INSTANCE_HELP_STR
16017 "Detailed info about dynamic update groups\n"
16023 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
16025 update_group_show_stats(bgp
, vty
);
16027 return CMD_SUCCESS
;
16030 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
16031 afi_t afi
, safi_t safi
,
16032 const char *what
, uint64_t subgrp_id
)
16037 bgp
= bgp_lookup_by_name(name
);
16039 bgp
= bgp_get_default();
16042 if (!strcmp(what
, "advertise-queue"))
16043 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
16045 else if (!strcmp(what
, "advertised-routes"))
16046 update_group_show_advertised(bgp
, afi
, safi
, vty
,
16048 else if (!strcmp(what
, "packet-queue"))
16049 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
16054 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
16055 show_ip_bgp_instance_updgrps_adj_s_cmd
,
16056 "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",
16057 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
16059 "Detailed info about dynamic update groups\n"
16060 "Specific subgroup to display info for\n"
16061 "Advertisement queue\n"
16062 "Announced routes\n"
16065 uint64_t subgrp_id
= 0;
16069 subgrp_id
= strtoull(sgid
, NULL
, 10);
16074 afiz
= bgp_vty_afi_from_str(afi
);
16078 afiz
= bgp_vty_afi_from_str(afi
);
16079 if (afiz
!= AFI_IP
)
16081 "%% Cannot specify both 'ip' and 'ipv6'\n");
16082 return CMD_WARNING
;
16085 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
16087 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
16088 return CMD_SUCCESS
;
16091 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
16094 struct listnode
*node
, *nnode
;
16095 struct prefix
*range
;
16100 const char *peer_status
;
16104 json_object
*json_peer_group
= NULL
;
16105 json_object
*json_peer_group_afc
= NULL
;
16106 json_object
*json_peer_group_members
= NULL
;
16107 json_object
*json_peer_group_dynamic
= NULL
;
16108 json_object
*json_peer_group_dynamic_af
= NULL
;
16109 json_object
*json_peer_group_ranges
= NULL
;
16111 conf
= group
->conf
;
16114 json_peer_group
= json_object_new_object();
16115 json_peer_group_afc
= json_object_new_array();
16118 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
16120 asn_asn2json(json_peer_group
, "remoteAs", conf
->as
,
16121 bgp_get_asnotation(conf
->bgp
));
16123 vty_out(vty
, "\nBGP peer-group %s, remote AS ",
16125 vty_out(vty
, ASN_FORMAT(bgp_get_asnotation(conf
->bgp
)),
16127 vty_out(vty
, "\n");
16129 } else if (conf
->as_type
== AS_INTERNAL
) {
16131 asn_asn2json(json
, "remoteAs", group
->bgp
->as
,
16132 group
->bgp
->asnotation
);
16134 vty_out(vty
, "\nBGP peer-group %s, remote AS %s\n",
16135 group
->name
, group
->bgp
->as_pretty
);
16138 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
16141 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
16143 json_object_string_add(json_peer_group
, "type",
16146 vty_out(vty
, " Peer-group type is internal\n");
16149 json_object_string_add(json_peer_group
, "type",
16152 vty_out(vty
, " Peer-group type is external\n");
16155 /* Display AFs configured. */
16157 vty_out(vty
, " Configured address-families:");
16159 FOREACH_AFI_SAFI (afi
, safi
) {
16160 if (conf
->afc
[afi
][safi
]) {
16163 json_object_array_add(
16164 json_peer_group_afc
,
16165 json_object_new_string(get_afi_safi_str(
16166 afi
, safi
, false)));
16168 vty_out(vty
, " %s;",
16169 get_afi_safi_str(afi
, safi
, false));
16174 json_object_object_add(json_peer_group
,
16175 "addressFamiliesConfigured",
16176 json_peer_group_afc
);
16179 vty_out(vty
, " none\n");
16181 vty_out(vty
, "\n");
16184 /* Display listen ranges (for dynamic neighbors), if any */
16185 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16186 lr_count
= listcount(group
->listen_range
[afi
]);
16189 if (!json_peer_group_dynamic
)
16190 json_peer_group_dynamic
=
16191 json_object_new_object();
16193 json_peer_group_dynamic_af
=
16194 json_object_new_object();
16195 json_peer_group_ranges
=
16196 json_object_new_array();
16197 json_object_int_add(json_peer_group_dynamic_af
,
16198 "count", lr_count
);
16200 vty_out(vty
, " %d %s listen range(s)\n",
16201 lr_count
, afi2str(afi
));
16204 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16209 snprintfrr(buf
, sizeof(buf
), "%pFX",
16212 json_object_array_add(
16213 json_peer_group_ranges
,
16214 json_object_new_string(buf
));
16216 vty_out(vty
, " %pFX\n", range
);
16221 json_object_object_add(
16222 json_peer_group_dynamic_af
, "ranges",
16223 json_peer_group_ranges
);
16225 json_object_object_add(
16226 json_peer_group_dynamic
, afi2str(afi
),
16227 json_peer_group_dynamic_af
);
16232 if (json_peer_group_dynamic
)
16233 json_object_object_add(json_peer_group
, "dynamicRanges",
16234 json_peer_group_dynamic
);
16236 /* Display group members and their status */
16237 if (listcount(group
->peer
)) {
16239 json_peer_group_members
= json_object_new_object();
16241 vty_out(vty
, " Peer-group members:\n");
16242 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16243 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16244 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16245 peer_status
= "Idle (Admin)";
16246 else if (CHECK_FLAG(peer
->sflags
,
16247 PEER_STATUS_PREFIX_OVERFLOW
))
16248 peer_status
= "Idle (PfxCt)";
16250 peer_status
= lookup_msg(bgp_status_msg
,
16251 peer
->status
, NULL
);
16253 dynamic
= peer_dynamic_neighbor(peer
);
16256 json_object
*json_peer_group_member
=
16257 json_object_new_object();
16259 json_object_string_add(json_peer_group_member
,
16260 "status", peer_status
);
16263 json_object_boolean_true_add(
16264 json_peer_group_member
,
16267 json_object_object_add(json_peer_group_members
,
16269 json_peer_group_member
);
16271 vty_out(vty
, " %s %s %s \n", peer
->host
,
16272 dynamic
? "(dynamic)" : "",
16277 json_object_object_add(json_peer_group
, "members",
16278 json_peer_group_members
);
16282 json_object_object_add(json
, group
->name
, json_peer_group
);
16284 return CMD_SUCCESS
;
16287 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16288 const char *group_name
, bool uj
)
16291 struct listnode
*node
, *nnode
;
16292 struct peer_group
*group
;
16293 bool found
= false;
16294 json_object
*json
= NULL
;
16297 json
= json_object_new_object();
16299 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16303 vty_json(vty
, json
);
16305 vty_out(vty
, "%% BGP instance not found\n");
16307 return CMD_WARNING
;
16310 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16312 if (strmatch(group
->name
, group_name
)) {
16313 bgp_show_one_peer_group(vty
, group
, json
);
16318 bgp_show_one_peer_group(vty
, group
, json
);
16322 if (group_name
&& !found
&& !uj
)
16323 vty_out(vty
, "%% No such peer-group\n");
16326 vty_json(vty
, json
);
16328 return CMD_SUCCESS
;
16331 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16332 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16333 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16334 "Detailed information on BGP peer groups\n"
16335 "Peer group name\n" JSON_STR
)
16339 bool uj
= use_json(argc
, argv
);
16341 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16343 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16345 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16349 /* Redistribute VTY commands. */
16351 DEFUN (bgp_redistribute_ipv4
,
16352 bgp_redistribute_ipv4_cmd
,
16353 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16354 "Redistribute information from another routing protocol\n"
16355 FRR_IP_REDIST_HELP_STR_BGPD
)
16357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16358 int idx_protocol
= 1;
16361 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16363 vty_out(vty
, "%% Invalid route type\n");
16364 return CMD_WARNING_CONFIG_FAILED
;
16367 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16368 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16372 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16373 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16374 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16376 DEFUN (bgp_redistribute_ipv4_rmap
,
16377 bgp_redistribute_ipv4_rmap_cmd
,
16378 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16379 "Redistribute information from another routing protocol\n"
16380 FRR_IP_REDIST_HELP_STR_BGPD
16381 "Route map reference\n"
16382 "Pointer to route-map entries\n")
16384 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16385 int idx_protocol
= 1;
16388 struct bgp_redist
*red
;
16390 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16391 vty
, argv
[idx_word
]->arg
);
16393 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16395 vty_out(vty
, "%% Invalid route type\n");
16396 return CMD_WARNING_CONFIG_FAILED
;
16399 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16401 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16402 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16406 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16407 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16408 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16409 "Route map reference\n"
16410 "Pointer to route-map entries\n")
16412 DEFUN (bgp_redistribute_ipv4_metric
,
16413 bgp_redistribute_ipv4_metric_cmd
,
16414 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16415 "Redistribute information from another routing protocol\n"
16416 FRR_IP_REDIST_HELP_STR_BGPD
16417 "Metric for redistributed routes\n"
16418 "Default metric\n")
16420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16421 int idx_protocol
= 1;
16422 int idx_number
= 3;
16425 struct bgp_redist
*red
;
16428 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16430 vty_out(vty
, "%% Invalid route type\n");
16431 return CMD_WARNING_CONFIG_FAILED
;
16433 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16435 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16436 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16437 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16441 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16442 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16443 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16444 "Metric for redistributed routes\n"
16445 "Default metric\n")
16447 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16448 bgp_redistribute_ipv4_rmap_metric_cmd
,
16449 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16450 "Redistribute information from another routing protocol\n"
16451 FRR_IP_REDIST_HELP_STR_BGPD
16452 "Route map reference\n"
16453 "Pointer to route-map entries\n"
16454 "Metric for redistributed routes\n"
16455 "Default metric\n")
16457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16458 int idx_protocol
= 1;
16460 int idx_number
= 5;
16463 struct bgp_redist
*red
;
16465 struct route_map
*route_map
=
16466 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16468 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16470 vty_out(vty
, "%% Invalid route type\n");
16471 return CMD_WARNING_CONFIG_FAILED
;
16473 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16475 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16477 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16478 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16479 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16483 bgp_redistribute_ipv4_rmap_metric
,
16484 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16485 "redistribute " FRR_IP_REDIST_STR_BGPD
16486 " route-map RMAP_NAME metric (0-4294967295)",
16487 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16488 "Route map reference\n"
16489 "Pointer to route-map entries\n"
16490 "Metric for redistributed routes\n"
16491 "Default metric\n")
16493 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16494 bgp_redistribute_ipv4_metric_rmap_cmd
,
16495 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16496 "Redistribute information from another routing protocol\n"
16497 FRR_IP_REDIST_HELP_STR_BGPD
16498 "Metric for redistributed routes\n"
16500 "Route map reference\n"
16501 "Pointer to route-map entries\n")
16503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16504 int idx_protocol
= 1;
16505 int idx_number
= 3;
16509 struct bgp_redist
*red
;
16511 struct route_map
*route_map
=
16512 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16514 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16516 vty_out(vty
, "%% Invalid route type\n");
16517 return CMD_WARNING_CONFIG_FAILED
;
16519 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16521 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16522 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16524 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16525 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16529 bgp_redistribute_ipv4_metric_rmap
,
16530 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16531 "redistribute " FRR_IP_REDIST_STR_BGPD
16532 " metric (0-4294967295) route-map RMAP_NAME",
16533 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16534 "Metric for redistributed routes\n"
16536 "Route map reference\n"
16537 "Pointer to route-map entries\n")
16539 DEFUN (bgp_redistribute_ipv4_ospf
,
16540 bgp_redistribute_ipv4_ospf_cmd
,
16541 "redistribute <ospf|table> (1-65535)",
16542 "Redistribute information from another routing protocol\n"
16543 "Open Shortest Path First (OSPFv2)\n"
16544 "Non-main Kernel Routing Table\n"
16545 "Instance ID/Table ID\n")
16547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16548 int idx_ospf_table
= 1;
16549 int idx_number
= 2;
16550 unsigned short instance
;
16551 unsigned short protocol
;
16553 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16555 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16556 protocol
= ZEBRA_ROUTE_OSPF
;
16558 protocol
= ZEBRA_ROUTE_TABLE
;
16560 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16561 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16564 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16565 "redistribute <ospf|table> (1-65535)",
16566 "Redistribute information from another routing protocol\n"
16567 "Open Shortest Path First (OSPFv2)\n"
16568 "Non-main Kernel Routing Table\n"
16569 "Instance ID/Table ID\n")
16571 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16572 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16573 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16574 "Redistribute information from another routing protocol\n"
16575 "Open Shortest Path First (OSPFv2)\n"
16576 "Non-main Kernel Routing Table\n"
16577 "Instance ID/Table ID\n"
16578 "Route map reference\n"
16579 "Pointer to route-map entries\n")
16581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16582 int idx_ospf_table
= 1;
16583 int idx_number
= 2;
16585 struct bgp_redist
*red
;
16586 unsigned short instance
;
16589 struct route_map
*route_map
=
16590 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16592 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16593 protocol
= ZEBRA_ROUTE_OSPF
;
16595 protocol
= ZEBRA_ROUTE_TABLE
;
16597 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16598 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16600 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16601 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16604 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16605 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16606 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16607 "Redistribute information from another routing protocol\n"
16608 "Open Shortest Path First (OSPFv2)\n"
16609 "Non-main Kernel Routing Table\n"
16610 "Instance ID/Table ID\n"
16611 "Route map reference\n"
16612 "Pointer to route-map entries\n")
16614 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16615 bgp_redistribute_ipv4_ospf_metric_cmd
,
16616 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16617 "Redistribute information from another routing protocol\n"
16618 "Open Shortest Path First (OSPFv2)\n"
16619 "Non-main Kernel Routing Table\n"
16620 "Instance ID/Table ID\n"
16621 "Metric for redistributed routes\n"
16622 "Default metric\n")
16624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16625 int idx_ospf_table
= 1;
16626 int idx_number
= 2;
16627 int idx_number_2
= 4;
16629 struct bgp_redist
*red
;
16630 unsigned short instance
;
16634 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16635 protocol
= ZEBRA_ROUTE_OSPF
;
16637 protocol
= ZEBRA_ROUTE_TABLE
;
16639 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16640 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16642 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16643 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16645 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16648 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16649 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16650 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16651 "Redistribute information from another routing protocol\n"
16652 "Open Shortest Path First (OSPFv2)\n"
16653 "Non-main Kernel Routing Table\n"
16654 "Instance ID/Table ID\n"
16655 "Metric for redistributed routes\n"
16656 "Default metric\n")
16658 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16659 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16660 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16661 "Redistribute information from another routing protocol\n"
16662 "Open Shortest Path First (OSPFv2)\n"
16663 "Non-main Kernel Routing Table\n"
16664 "Instance ID/Table ID\n"
16665 "Route map reference\n"
16666 "Pointer to route-map entries\n"
16667 "Metric for redistributed routes\n"
16668 "Default metric\n")
16670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16671 int idx_ospf_table
= 1;
16672 int idx_number
= 2;
16674 int idx_number_2
= 6;
16676 struct bgp_redist
*red
;
16677 unsigned short instance
;
16680 struct route_map
*route_map
=
16681 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16683 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16684 protocol
= ZEBRA_ROUTE_OSPF
;
16686 protocol
= ZEBRA_ROUTE_TABLE
;
16688 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16689 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16691 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16693 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16694 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16696 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16700 bgp_redistribute_ipv4_ospf_rmap_metric
,
16701 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16702 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16703 "Redistribute information from another routing protocol\n"
16704 "Open Shortest Path First (OSPFv2)\n"
16705 "Non-main Kernel Routing Table\n"
16706 "Instance ID/Table ID\n"
16707 "Route map reference\n"
16708 "Pointer to route-map entries\n"
16709 "Metric for redistributed routes\n"
16710 "Default metric\n")
16712 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16713 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16714 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16715 "Redistribute information from another routing protocol\n"
16716 "Open Shortest Path First (OSPFv2)\n"
16717 "Non-main Kernel Routing Table\n"
16718 "Instance ID/Table ID\n"
16719 "Metric for redistributed routes\n"
16721 "Route map reference\n"
16722 "Pointer to route-map entries\n")
16724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16725 int idx_ospf_table
= 1;
16726 int idx_number
= 2;
16727 int idx_number_2
= 4;
16730 struct bgp_redist
*red
;
16731 unsigned short instance
;
16734 struct route_map
*route_map
=
16735 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16737 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16738 protocol
= ZEBRA_ROUTE_OSPF
;
16740 protocol
= ZEBRA_ROUTE_TABLE
;
16742 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16743 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16745 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16746 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16749 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16750 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16754 bgp_redistribute_ipv4_ospf_metric_rmap
,
16755 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16756 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16757 "Redistribute information from another routing protocol\n"
16758 "Open Shortest Path First (OSPFv2)\n"
16759 "Non-main Kernel Routing Table\n"
16760 "Instance ID/Table ID\n"
16761 "Metric for redistributed routes\n"
16763 "Route map reference\n"
16764 "Pointer to route-map entries\n")
16766 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16767 no_bgp_redistribute_ipv4_ospf_cmd
,
16768 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16770 "Redistribute information from another routing protocol\n"
16771 "Open Shortest Path First (OSPFv2)\n"
16772 "Non-main Kernel Routing Table\n"
16773 "Instance ID/Table ID\n"
16774 "Metric for redistributed routes\n"
16776 "Route map reference\n"
16777 "Pointer to route-map entries\n")
16779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16780 int idx_ospf_table
= 2;
16781 int idx_number
= 3;
16782 unsigned short instance
;
16785 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16786 protocol
= ZEBRA_ROUTE_OSPF
;
16788 protocol
= ZEBRA_ROUTE_TABLE
;
16790 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16791 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16795 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16796 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16798 "Redistribute information from another routing protocol\n"
16799 "Open Shortest Path First (OSPFv2)\n"
16800 "Non-main Kernel Routing Table\n"
16801 "Instance ID/Table ID\n"
16802 "Metric for redistributed routes\n"
16804 "Route map reference\n"
16805 "Pointer to route-map entries\n")
16807 DEFUN (no_bgp_redistribute_ipv4
,
16808 no_bgp_redistribute_ipv4_cmd
,
16809 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16811 "Redistribute information from another routing protocol\n"
16812 FRR_IP_REDIST_HELP_STR_BGPD
16813 "Metric for redistributed routes\n"
16815 "Route map reference\n"
16816 "Pointer to route-map entries\n")
16818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16819 int idx_protocol
= 2;
16822 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16824 vty_out(vty
, "%% Invalid route type\n");
16825 return CMD_WARNING_CONFIG_FAILED
;
16827 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16831 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16832 "no redistribute " FRR_IP_REDIST_STR_BGPD
16833 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16835 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16836 "Metric for redistributed routes\n"
16838 "Route map reference\n"
16839 "Pointer to route-map entries\n")
16841 DEFUN (bgp_redistribute_ipv6
,
16842 bgp_redistribute_ipv6_cmd
,
16843 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16844 "Redistribute information from another routing protocol\n"
16845 FRR_IP6_REDIST_HELP_STR_BGPD
)
16847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16848 int idx_protocol
= 1;
16851 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16853 vty_out(vty
, "%% Invalid route type\n");
16854 return CMD_WARNING_CONFIG_FAILED
;
16857 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16858 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16861 DEFUN (bgp_redistribute_ipv6_rmap
,
16862 bgp_redistribute_ipv6_rmap_cmd
,
16863 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16864 "Redistribute information from another routing protocol\n"
16865 FRR_IP6_REDIST_HELP_STR_BGPD
16866 "Route map reference\n"
16867 "Pointer to route-map entries\n")
16869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16870 int idx_protocol
= 1;
16873 struct bgp_redist
*red
;
16875 struct route_map
*route_map
=
16876 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16878 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16880 vty_out(vty
, "%% Invalid route type\n");
16881 return CMD_WARNING_CONFIG_FAILED
;
16884 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16886 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16887 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16890 DEFUN (bgp_redistribute_ipv6_metric
,
16891 bgp_redistribute_ipv6_metric_cmd
,
16892 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16893 "Redistribute information from another routing protocol\n"
16894 FRR_IP6_REDIST_HELP_STR_BGPD
16895 "Metric for redistributed routes\n"
16896 "Default metric\n")
16898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16899 int idx_protocol
= 1;
16900 int idx_number
= 3;
16903 struct bgp_redist
*red
;
16906 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16908 vty_out(vty
, "%% Invalid route type\n");
16909 return CMD_WARNING_CONFIG_FAILED
;
16911 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16913 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16914 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16915 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16918 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16919 bgp_redistribute_ipv6_rmap_metric_cmd
,
16920 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16921 "Redistribute information from another routing protocol\n"
16922 FRR_IP6_REDIST_HELP_STR_BGPD
16923 "Route map reference\n"
16924 "Pointer to route-map entries\n"
16925 "Metric for redistributed routes\n"
16926 "Default metric\n")
16928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16929 int idx_protocol
= 1;
16931 int idx_number
= 5;
16934 struct bgp_redist
*red
;
16936 struct route_map
*route_map
=
16937 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16939 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16941 vty_out(vty
, "%% Invalid route type\n");
16942 return CMD_WARNING_CONFIG_FAILED
;
16944 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16946 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16948 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16949 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16951 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16954 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16955 bgp_redistribute_ipv6_metric_rmap_cmd
,
16956 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16957 "Redistribute information from another routing protocol\n"
16958 FRR_IP6_REDIST_HELP_STR_BGPD
16959 "Metric for redistributed routes\n"
16961 "Route map reference\n"
16962 "Pointer to route-map entries\n")
16964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16965 int idx_protocol
= 1;
16966 int idx_number
= 3;
16970 struct bgp_redist
*red
;
16972 struct route_map
*route_map
=
16973 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16975 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16977 vty_out(vty
, "%% Invalid route type\n");
16978 return CMD_WARNING_CONFIG_FAILED
;
16980 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16982 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16983 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16986 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16987 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16990 DEFUN (no_bgp_redistribute_ipv6
,
16991 no_bgp_redistribute_ipv6_cmd
,
16992 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16994 "Redistribute information from another routing protocol\n"
16995 FRR_IP6_REDIST_HELP_STR_BGPD
16996 "Metric for redistributed routes\n"
16998 "Route map reference\n"
16999 "Pointer to route-map entries\n")
17001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
17002 int idx_protocol
= 2;
17005 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
17007 vty_out(vty
, "%% Invalid route type\n");
17008 return CMD_WARNING_CONFIG_FAILED
;
17011 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
17014 /* Neighbor update tcp-mss. */
17015 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
17016 const char *tcp_mss_str
)
17019 uint32_t tcp_mss_val
= 0;
17021 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
17023 return CMD_WARNING_CONFIG_FAILED
;
17026 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
17027 peer_tcp_mss_set(peer
, tcp_mss_val
);
17029 peer_tcp_mss_unset(peer
);
17032 return CMD_SUCCESS
;
17035 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
17036 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
17037 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
17038 "TCP max segment size\n"
17041 int peer_index
= 1;
17045 " Warning: Reset BGP session for tcp-mss value to take effect\n");
17046 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
17047 argv
[mss_index
]->arg
);
17050 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
17051 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
17052 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
17053 "TCP max segment size\n"
17056 int peer_index
= 2;
17059 " Warning: Reset BGP session for tcp-mss value to take effect\n");
17060 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
17063 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
17064 "[no$no] bgp retain route-target all",
17066 "Retain BGP updates\n"
17067 "Retain BGP updates based on route-target values\n"
17068 "Retain all BGP updates\n")
17071 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
17073 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
17074 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
17075 if (check
!= !no
) {
17077 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
17078 [bgp_node_safi(vty
)],
17079 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
17081 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
17082 [bgp_node_safi(vty
)],
17083 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
17084 /* trigger a flush to re-sync with ADJ-RIB-in */
17085 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
17086 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
17088 return CMD_SUCCESS
;
17091 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
17092 afi_t afi
, safi_t safi
)
17096 /* Unicast redistribution only. */
17097 if (safi
!= SAFI_UNICAST
)
17100 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
17101 /* Redistribute BGP does not make sense. */
17102 if (i
!= ZEBRA_ROUTE_BGP
) {
17103 struct list
*red_list
;
17104 struct listnode
*node
;
17105 struct bgp_redist
*red
;
17107 red_list
= bgp
->redist
[afi
][i
];
17111 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
17112 /* "redistribute" configuration. */
17113 vty_out(vty
, " redistribute %s",
17114 zebra_route_string(i
));
17116 vty_out(vty
, " %d", red
->instance
);
17117 if (red
->redist_metric_flag
)
17118 vty_out(vty
, " metric %u",
17119 red
->redist_metric
);
17120 if (red
->rmap
.name
)
17121 vty_out(vty
, " route-map %s",
17123 vty_out(vty
, "\n");
17129 /* peer-group helpers for config-write */
17131 bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
17133 if (!peer_group_active(peer
)) {
17134 if (CHECK_FLAG(peer
->flags_invert
, flag
))
17135 return !CHECK_FLAG(peer
->flags
, flag
);
17137 return !!CHECK_FLAG(peer
->flags
, flag
);
17140 return !!CHECK_FLAG(peer
->flags_override
, flag
);
17143 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
17146 if (!peer_group_active(peer
)) {
17147 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
17148 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
17150 return peer_af_flag_check(peer
, afi
, safi
, flag
);
17153 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
17156 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
17157 uint8_t type
, int direct
)
17159 struct bgp_filter
*filter
;
17161 if (peer_group_active(peer
))
17162 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
17165 filter
= &peer
->filter
[afi
][safi
];
17167 case PEER_FT_DISTRIBUTE_LIST
:
17168 return !!(filter
->dlist
[direct
].name
);
17169 case PEER_FT_FILTER_LIST
:
17170 return !!(filter
->aslist
[direct
].name
);
17171 case PEER_FT_PREFIX_LIST
:
17172 return !!(filter
->plist
[direct
].name
);
17173 case PEER_FT_ROUTE_MAP
:
17174 return !!(filter
->map
[direct
].name
);
17175 case PEER_FT_UNSUPPRESS_MAP
:
17176 return !!(filter
->usmap
.name
);
17177 case PEER_FT_ADVERTISE_MAP
:
17178 return !!(filter
->advmap
.aname
17179 && ((filter
->advmap
.condition
== direct
)
17180 && filter
->advmap
.cname
));
17186 /* Return true if the addpath type is set for peer and different from
17189 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
17192 enum bgp_addpath_strat type
, g_type
;
17194 type
= peer
->addpath_type
[afi
][safi
];
17196 if (type
!= BGP_ADDPATH_NONE
) {
17197 if (peer_group_active(peer
)) {
17198 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
17200 if (type
!= g_type
)
17212 /* This is part of the address-family block (unicast only) */
17213 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17217 uint32_t tovpn_sid_index
= 0;
17219 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17220 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17221 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17222 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17223 bgp
->vpn_policy
[afi
]
17224 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17226 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17227 bgp
->vpn_policy
[afi
]
17228 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17230 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17231 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17232 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17233 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17236 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17237 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17239 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17242 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17243 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17244 bgp
->vpn_policy
[afi
].tovpn_label
);
17248 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17249 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17250 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17251 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17252 } else if (tovpn_sid_index
!= 0) {
17253 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17257 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17258 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
17259 bgp
->vpn_policy
[afi
].tovpn_rd_pretty
);
17261 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17262 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17264 char buf
[PREFIX_STRLEN
];
17265 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17266 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17269 vty_out(vty
, "%*snexthop vpn export %s\n",
17273 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17274 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17276 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17277 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17279 char *b
= ecommunity_ecom2str(
17280 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17281 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17282 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17283 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17285 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17286 char *b
= ecommunity_ecom2str(
17287 bgp
->vpn_policy
[afi
]
17288 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17289 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17290 ECOMMUNITY_ROUTE_TARGET
);
17291 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17292 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17294 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17295 char *b
= ecommunity_ecom2str(
17296 bgp
->vpn_policy
[afi
]
17297 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17298 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17299 ECOMMUNITY_ROUTE_TARGET
);
17300 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17301 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17305 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17306 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17307 bgp
->vpn_policy
[afi
]
17308 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17310 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17311 char *b
= ecommunity_ecom2str(
17312 bgp
->vpn_policy
[afi
]
17313 .import_redirect_rtlist
,
17314 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17315 ECOMMUNITY_ROUTE_TARGET
);
17317 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17318 != ECOMMUNITY_SIZE
)
17319 vty_out(vty
, "%*srt6 redirect import %s\n",
17322 vty_out(vty
, "%*srt redirect import %s\n",
17324 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17328 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17329 afi_t afi
, safi_t safi
)
17331 struct bgp_filter
*filter
;
17335 filter
= &peer
->filter
[afi
][safi
];
17337 /* distribute-list. */
17338 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17340 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17341 filter
->dlist
[FILTER_IN
].name
);
17343 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17345 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17346 filter
->dlist
[FILTER_OUT
].name
);
17349 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17351 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17352 filter
->plist
[FILTER_IN
].name
);
17354 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17356 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17357 filter
->plist
[FILTER_OUT
].name
);
17360 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17361 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17362 filter
->map
[RMAP_IN
].name
);
17364 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17366 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17367 filter
->map
[RMAP_OUT
].name
);
17369 /* unsuppress-map */
17370 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17371 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17372 filter
->usmap
.name
);
17374 /* advertise-map : always applied in OUT direction*/
17375 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17376 CONDITION_NON_EXIST
))
17378 " neighbor %s advertise-map %s non-exist-map %s\n",
17379 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17381 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17383 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17384 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17387 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17389 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17390 filter
->aslist
[FILTER_IN
].name
);
17392 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17394 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17395 filter
->aslist
[FILTER_OUT
].name
);
17398 /* BGP peer configuration display function. */
17399 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17402 struct peer
*g_peer
= NULL
;
17404 int if_pg_printed
= false;
17405 int if_ras_printed
= false;
17407 /* Skip dynamic neighbors. */
17408 if (peer_dynamic_neighbor(peer
))
17412 addr
= peer
->conf_if
;
17416 /************************************
17417 ****** Global to the neighbor ******
17418 ************************************/
17419 if (peer
->conf_if
) {
17420 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17421 vty_out(vty
, " neighbor %s interface v6only", addr
);
17423 vty_out(vty
, " neighbor %s interface", addr
);
17425 if (peer_group_active(peer
)) {
17426 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17427 if_pg_printed
= true;
17428 } else if (peer
->as_type
== AS_SPECIFIED
) {
17429 vty_out(vty
, " remote-as %s", peer
->as_pretty
);
17430 if_ras_printed
= true;
17431 } else if (peer
->as_type
== AS_INTERNAL
) {
17432 vty_out(vty
, " remote-as internal");
17433 if_ras_printed
= true;
17434 } else if (peer
->as_type
== AS_EXTERNAL
) {
17435 vty_out(vty
, " remote-as external");
17436 if_ras_printed
= true;
17439 vty_out(vty
, "\n");
17442 /* remote-as and peer-group */
17443 /* peer is a member of a peer-group */
17444 if (peer_group_active(peer
)) {
17445 g_peer
= peer
->group
->conf
;
17447 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17448 if (peer
->as_type
== AS_SPECIFIED
) {
17449 vty_out(vty
, " neighbor %s remote-as %s\n",
17450 addr
, peer
->as_pretty
);
17451 } else if (peer
->as_type
== AS_INTERNAL
) {
17453 " neighbor %s remote-as internal\n",
17455 } else if (peer
->as_type
== AS_EXTERNAL
) {
17457 " neighbor %s remote-as external\n",
17462 /* For swpX peers we displayed the peer-group
17463 * via 'neighbor swpX interface peer-group PGNAME' */
17464 if (!if_pg_printed
)
17465 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17466 peer
->group
->name
);
17469 /* peer is NOT a member of a peer-group */
17471 /* peer is a peer-group, declare the peer-group */
17472 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17473 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17476 if (!if_ras_printed
) {
17477 if (peer
->as_type
== AS_SPECIFIED
) {
17478 vty_out(vty
, " neighbor %s remote-as %s\n",
17479 addr
, peer
->as_pretty
);
17480 } else if (peer
->as_type
== AS_INTERNAL
) {
17482 " neighbor %s remote-as internal\n",
17484 } else if (peer
->as_type
== AS_EXTERNAL
) {
17486 " neighbor %s remote-as external\n",
17493 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17494 vty_out(vty
, " neighbor %s local-as %s", addr
,
17495 peer
->change_local_as_pretty
);
17496 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17497 vty_out(vty
, " no-prepend");
17498 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17499 vty_out(vty
, " replace-as");
17500 vty_out(vty
, "\n");
17505 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17509 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17510 if (peer
->tx_shutdown_message
)
17511 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17512 peer
->tx_shutdown_message
);
17514 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17517 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17518 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17519 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17522 if (peer
->bfd_config
)
17523 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17526 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17527 vty_out(vty
, " neighbor %s password %s\n", addr
,
17530 /* neighbor solo */
17531 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17532 if (!peer_group_active(peer
)) {
17533 vty_out(vty
, " neighbor %s solo\n", addr
);
17538 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17539 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17542 /* Local interface name */
17543 if (peer
->ifname
) {
17544 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17547 /* TCP max segment size */
17548 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17549 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17552 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17553 vty_out(vty
, " neighbor %s passive\n", addr
);
17555 /* ebgp-multihop */
17556 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17557 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17558 && peer
->ttl
== MAXTTL
)) {
17559 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17560 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17566 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17567 vty_out(vty
, " neighbor %s aigp\n", addr
);
17569 /* graceful-shutdown */
17570 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17571 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17574 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17575 peer
->local_role
!= ROLE_UNDEFINED
)
17576 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17577 bgp_get_name_by_role(peer
->local_role
),
17578 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17582 /* ttl-security hops */
17583 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17584 if (!peer_group_active(peer
)
17585 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17586 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17587 addr
, peer
->gtsm_hops
);
17591 /* disable-connected-check */
17592 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17593 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17595 /* link-bw-encoding-ieee */
17596 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17597 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17600 /* extended-optional-parameters */
17601 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17602 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17605 /* enforce-first-as */
17606 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17607 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17609 /* update-source */
17610 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17611 if (peer
->update_source
)
17612 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17613 peer
->update_source
);
17614 else if (peer
->update_if
)
17615 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17619 /* advertisement-interval */
17620 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17621 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17625 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17626 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17627 peer
->keepalive
, peer
->holdtime
);
17629 /* timers connect */
17630 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17631 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17633 /* need special-case handling for changed default values due to
17634 * config profile / version (because there is no "timers bgp connect"
17635 * command, we need to save this per-peer :/)
17637 else if (!peer_group_active(peer
) && !peer
->connect
&&
17638 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17639 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17640 peer
->bgp
->default_connect_retry
);
17642 /* timers delayopen */
17643 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17644 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17646 /* Save config even though flag is not set if default values have been
17649 else if (!peer_group_active(peer
) && !peer
->delayopen
17650 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17651 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17652 peer
->bgp
->default_delayopen
);
17654 /* capability dynamic */
17655 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17656 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17658 /* capability extended-nexthop */
17659 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17660 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17663 " no neighbor %s capability extended-nexthop\n",
17665 else if (!peer
->conf_if
)
17667 " neighbor %s capability extended-nexthop\n",
17671 /* capability software-version */
17672 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_SOFT_VERSION
))
17673 vty_out(vty
, " neighbor %s capability software-version\n",
17676 /* dont-capability-negotiation */
17677 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17678 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17680 /* override-capability */
17681 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17682 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17684 /* strict-capability-match */
17685 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17686 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17688 /* Sender side AS path loop detection. */
17689 if (peer
->as_path_loop_detection
)
17690 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17693 /* path-attribute discard */
17694 char discard_attrs_str
[BUFSIZ
] = {0};
17695 bool discard_attrs
= bgp_path_attribute_discard(
17696 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17699 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17700 discard_attrs_str
);
17702 /* path-attribute treat-as-withdraw */
17703 char withdraw_attrs_str
[BUFSIZ
] = {0};
17704 bool withdraw_attrs
= bgp_path_attribute_treat_as_withdraw(
17705 peer
, withdraw_attrs_str
, sizeof(withdraw_attrs_str
));
17707 if (withdraw_attrs
)
17709 " neighbor %s path-attribute treat-as-withdraw %s\n",
17710 addr
, withdraw_attrs_str
);
17712 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17713 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17715 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17716 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17718 " neighbor %s graceful-restart-helper\n", addr
);
17719 } else if (CHECK_FLAG(
17720 peer
->peer_gr_new_status_flag
,
17721 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17723 " neighbor %s graceful-restart\n", addr
);
17725 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17726 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17728 peer
->peer_gr_new_status_flag
,
17729 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17730 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17736 /* BGP peer configuration display function. */
17737 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17738 struct peer
*peer
, afi_t afi
, safi_t safi
)
17740 struct peer
*g_peer
= NULL
;
17742 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17744 /* Skip dynamic neighbors. */
17745 if (peer_dynamic_neighbor(peer
))
17749 addr
= peer
->conf_if
;
17753 /************************************
17754 ****** Per AF to the neighbor ******
17755 ************************************/
17756 if (peer_group_active(peer
)) {
17757 g_peer
= peer
->group
->conf
;
17759 /* If the peer-group is active but peer is not, print a 'no
17761 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17762 vty_out(vty
, " no neighbor %s activate\n", addr
);
17765 /* If the peer-group is not active but peer is, print an
17767 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17768 vty_out(vty
, " neighbor %s activate\n", addr
);
17771 if (peer
->afc
[afi
][safi
]) {
17772 if (safi
== SAFI_ENCAP
)
17773 vty_out(vty
, " neighbor %s activate\n", addr
);
17774 else if (!bgp
->default_af
[afi
][safi
])
17775 vty_out(vty
, " neighbor %s activate\n", addr
);
17777 if (bgp
->default_af
[afi
][safi
])
17778 vty_out(vty
, " no neighbor %s activate\n",
17783 /* addpath TX knobs */
17784 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17785 switch (peer
->addpath_type
[afi
][safi
]) {
17786 case BGP_ADDPATH_ALL
:
17787 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17790 case BGP_ADDPATH_BEST_PER_AS
:
17792 " neighbor %s addpath-tx-bestpath-per-AS\n",
17795 case BGP_ADDPATH_MAX
:
17796 case BGP_ADDPATH_NONE
:
17801 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17802 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17804 /* ORF capability. */
17805 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17806 || peergroup_af_flag_check(peer
, afi
, safi
,
17807 PEER_FLAG_ORF_PREFIX_RM
)) {
17808 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17810 if (peergroup_af_flag_check(peer
, afi
, safi
,
17811 PEER_FLAG_ORF_PREFIX_SM
)
17812 && peergroup_af_flag_check(peer
, afi
, safi
,
17813 PEER_FLAG_ORF_PREFIX_RM
))
17814 vty_out(vty
, " both");
17815 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17816 PEER_FLAG_ORF_PREFIX_SM
))
17817 vty_out(vty
, " send");
17819 vty_out(vty
, " receive");
17820 vty_out(vty
, "\n");
17823 /* Route reflector client. */
17824 if (peergroup_af_flag_check(peer
, afi
, safi
,
17825 PEER_FLAG_REFLECTOR_CLIENT
)) {
17826 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17829 /* next-hop-self force */
17830 if (peergroup_af_flag_check(peer
, afi
, safi
,
17831 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17832 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17835 /* next-hop-self */
17836 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17837 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17840 /* remove-private-AS */
17841 if (peergroup_af_flag_check(peer
, afi
, safi
,
17842 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17843 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17847 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17848 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17849 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17853 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17854 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17855 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17858 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17859 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17860 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17864 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17865 vty_out(vty
, " neighbor %s as-override\n", addr
);
17868 /* send-community print. */
17869 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17870 PEER_FLAG_SEND_COMMUNITY
);
17871 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17872 PEER_FLAG_SEND_EXT_COMMUNITY
);
17873 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17874 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17876 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17877 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17880 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17883 " no neighbor %s send-community extended\n",
17887 vty_out(vty
, " no neighbor %s send-community large\n",
17891 /* Default information */
17892 if (peergroup_af_flag_check(peer
, afi
, safi
,
17893 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17894 vty_out(vty
, " neighbor %s default-originate", addr
);
17896 if (peer
->default_rmap
[afi
][safi
].name
)
17897 vty_out(vty
, " route-map %s",
17898 peer
->default_rmap
[afi
][safi
].name
);
17900 vty_out(vty
, "\n");
17903 /* Soft reconfiguration inbound. */
17904 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17905 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17909 /* maximum-prefix. */
17910 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17911 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17912 peer
->pmax
[afi
][safi
]);
17914 if (peer
->pmax_threshold
[afi
][safi
]
17915 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17916 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17917 if (peer_af_flag_check(peer
, afi
, safi
,
17918 PEER_FLAG_MAX_PREFIX_WARNING
))
17919 vty_out(vty
, " warning-only");
17920 if (peer
->pmax_restart
[afi
][safi
])
17921 vty_out(vty
, " restart %u",
17922 peer
->pmax_restart
[afi
][safi
]);
17923 if (peer_af_flag_check(peer
, afi
, safi
,
17924 PEER_FLAG_MAX_PREFIX_FORCE
))
17925 vty_out(vty
, " force");
17927 vty_out(vty
, "\n");
17930 /* maximum-prefix-out */
17931 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17932 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17933 addr
, peer
->pmax_out
[afi
][safi
]);
17935 /* Route server client. */
17936 if (peergroup_af_flag_check(peer
, afi
, safi
,
17937 PEER_FLAG_RSERVER_CLIENT
)) {
17938 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17941 /* Nexthop-local unchanged. */
17942 if (peergroup_af_flag_check(peer
, afi
, safi
,
17943 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17944 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17947 /* allowas-in <1-10> */
17948 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17949 if (peer_af_flag_check(peer
, afi
, safi
,
17950 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17951 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17952 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17953 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17955 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17956 peer
->allowas_in
[afi
][safi
]);
17961 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17962 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17965 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17966 char *soo_str
= ecommunity_ecom2str(
17967 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17969 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17970 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17974 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17975 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17976 peer
->weight
[afi
][safi
]);
17979 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17981 /* atribute-unchanged. */
17982 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17983 || (safi
!= SAFI_EVPN
17984 && peer_af_flag_check(peer
, afi
, safi
,
17985 PEER_FLAG_NEXTHOP_UNCHANGED
))
17986 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17988 if (!peer_group_active(peer
)
17989 || peergroup_af_flag_check(peer
, afi
, safi
,
17990 PEER_FLAG_AS_PATH_UNCHANGED
)
17991 || peergroup_af_flag_check(peer
, afi
, safi
,
17992 PEER_FLAG_NEXTHOP_UNCHANGED
)
17993 || peergroup_af_flag_check(peer
, afi
, safi
,
17994 PEER_FLAG_MED_UNCHANGED
)) {
17997 " neighbor %s attribute-unchanged%s%s%s\n",
17999 peer_af_flag_check(peer
, afi
, safi
,
18000 PEER_FLAG_AS_PATH_UNCHANGED
)
18003 peer_af_flag_check(peer
, afi
, safi
,
18004 PEER_FLAG_NEXTHOP_UNCHANGED
)
18007 peer_af_flag_check(peer
, afi
, safi
,
18008 PEER_FLAG_MED_UNCHANGED
)
18015 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
18018 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
18019 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
18020 vty_out(vty
, " no bgp retain route-target all\n");
18023 /* Address family based peer configuration display. */
18024 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
18028 struct peer_group
*group
;
18029 struct listnode
*node
, *nnode
;
18032 vty_frame(vty
, " !\n address-family ");
18033 if (afi
== AFI_IP
) {
18034 if (safi
== SAFI_UNICAST
)
18035 vty_frame(vty
, "ipv4 unicast");
18036 else if (safi
== SAFI_LABELED_UNICAST
)
18037 vty_frame(vty
, "ipv4 labeled-unicast");
18038 else if (safi
== SAFI_MULTICAST
)
18039 vty_frame(vty
, "ipv4 multicast");
18040 else if (safi
== SAFI_MPLS_VPN
)
18041 vty_frame(vty
, "ipv4 vpn");
18042 else if (safi
== SAFI_ENCAP
)
18043 vty_frame(vty
, "ipv4 encap");
18044 else if (safi
== SAFI_FLOWSPEC
)
18045 vty_frame(vty
, "ipv4 flowspec");
18046 } else if (afi
== AFI_IP6
) {
18047 if (safi
== SAFI_UNICAST
)
18048 vty_frame(vty
, "ipv6 unicast");
18049 else if (safi
== SAFI_LABELED_UNICAST
)
18050 vty_frame(vty
, "ipv6 labeled-unicast");
18051 else if (safi
== SAFI_MULTICAST
)
18052 vty_frame(vty
, "ipv6 multicast");
18053 else if (safi
== SAFI_MPLS_VPN
)
18054 vty_frame(vty
, "ipv6 vpn");
18055 else if (safi
== SAFI_ENCAP
)
18056 vty_frame(vty
, "ipv6 encap");
18057 else if (safi
== SAFI_FLOWSPEC
)
18058 vty_frame(vty
, "ipv6 flowspec");
18059 } else if (afi
== AFI_L2VPN
) {
18060 if (safi
== SAFI_EVPN
)
18061 vty_frame(vty
, "l2vpn evpn");
18063 vty_frame(vty
, "\n");
18065 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
18067 bgp_config_write_network(vty
, bgp
, afi
, safi
);
18069 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
18071 /* BGP flag dampening. */
18072 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
18073 bgp_config_write_damp(vty
, afi
, safi
);
18075 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
18076 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
18078 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18079 /* Do not display doppelganger peers */
18080 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18081 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
18084 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
18085 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
18087 if (safi
== SAFI_EVPN
)
18088 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
18090 if (safi
== SAFI_FLOWSPEC
)
18091 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
18093 if (safi
== SAFI_MPLS_VPN
)
18094 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
18096 if (safi
== SAFI_UNICAST
) {
18097 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
18098 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
18099 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
18101 vty_out(vty
, " export vpn\n");
18103 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
18104 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
18106 vty_out(vty
, " import vpn\n");
18108 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
18109 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
18112 for (ALL_LIST_ELEMENTS_RO(
18113 bgp
->vpn_policy
[afi
].import_vrf
, node
,
18115 vty_out(vty
, " import vrf %s\n", name
);
18119 vty_endframe(vty
, " exit-address-family\n");
18122 int bgp_config_write(struct vty
*vty
)
18125 struct peer_group
*group
;
18127 struct listnode
*node
, *nnode
;
18128 struct listnode
*mnode
, *mnnode
;
18131 uint32_t tovpn_sid_index
= 0;
18133 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
18134 vty_out(vty
, "bgp route-map delay-timer %u\n",
18135 bm
->rmap_update_timer
);
18137 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
18138 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
18139 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
18140 vty_out(vty
, " %d", bm
->v_establish_wait
);
18141 vty_out(vty
, "\n");
18144 if (bm
->wait_for_fib
)
18145 vty_out(vty
, "bgp suppress-fib-pending\n");
18147 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18148 vty_out(vty
, "bgp graceful-shutdown\n");
18150 /* No-RIB (Zebra) option flag configuration */
18151 if (bgp_option_check(BGP_OPT_NO_FIB
))
18152 vty_out(vty
, "bgp no-rib\n");
18154 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
18155 vty_out(vty
, "bgp send-extra-data zebra\n");
18157 /* BGP session DSCP value */
18158 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
18159 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
18161 /* BGP InQ limit */
18162 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
18163 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
18165 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
18166 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
18168 /* BGP configuration. */
18169 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
18171 /* skip all auto created vrf as they dont have user config */
18172 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
18175 /* Router bgp ASN */
18176 vty_out(vty
, "router bgp %s", bgp
->as_pretty
);
18179 vty_out(vty
, " %s %s",
18180 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
18181 ? "view" : "vrf", bgp
->name
);
18182 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_ASNOTATION
))
18183 vty_out(vty
, " as-notation %s",
18184 asn_mode2str(bgp
->asnotation
));
18186 vty_out(vty
, "\n");
18188 /* BGP fast-external-failover. */
18189 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
18190 vty_out(vty
, " no bgp fast-external-failover\n");
18192 /* BGP router ID. */
18193 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
18194 vty_out(vty
, " bgp router-id %pI4\n",
18195 &bgp
->router_id_static
);
18197 /* Suppress fib pending */
18198 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
18199 vty_out(vty
, " bgp suppress-fib-pending\n");
18201 /* BGP log-neighbor-changes. */
18202 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18203 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
18204 vty_out(vty
, " %sbgp log-neighbor-changes\n",
18205 CHECK_FLAG(bgp
->flags
,
18206 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18210 /* BGP configuration. */
18211 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
18212 vty_out(vty
, " bgp always-compare-med\n");
18214 /* RFC8212 default eBGP policy. */
18215 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
18216 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
18217 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
18218 CHECK_FLAG(bgp
->flags
,
18219 BGP_FLAG_EBGP_REQUIRES_POLICY
)
18223 /* draft-ietf-idr-deprecate-as-set-confed-set */
18224 if (bgp
->reject_as_sets
)
18225 vty_out(vty
, " bgp reject-as-sets\n");
18227 /* Suppress duplicate updates if the route actually not changed
18229 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
18230 != SAVE_BGP_SUPPRESS_DUPLICATES
)
18231 vty_out(vty
, " %sbgp suppress-duplicates\n",
18232 CHECK_FLAG(bgp
->flags
,
18233 BGP_FLAG_SUPPRESS_DUPLICATES
)
18237 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
18239 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
18240 SAVE_BGP_HARD_ADMIN_RESET
)
18241 vty_out(vty
, " %sbgp hard-administrative-reset\n",
18242 CHECK_FLAG(bgp
->flags
,
18243 BGP_FLAG_HARD_ADMIN_RESET
)
18247 /* BGP default <afi>-<safi> */
18248 FOREACH_AFI_SAFI (afi
, safi
) {
18249 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
18250 if (!bgp
->default_af
[afi
][safi
])
18251 vty_out(vty
, " no bgp default %s\n",
18252 get_bgp_default_af_flag(afi
,
18254 } else if (bgp
->default_af
[afi
][safi
])
18255 vty_out(vty
, " bgp default %s\n",
18256 get_bgp_default_af_flag(afi
, safi
));
18259 /* BGP default local-preference. */
18260 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18261 vty_out(vty
, " bgp default local-preference %u\n",
18262 bgp
->default_local_pref
);
18264 /* BGP default show-hostname */
18265 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18266 != SAVE_BGP_SHOW_HOSTNAME
)
18267 vty_out(vty
, " %sbgp default show-hostname\n",
18268 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18272 /* BGP default show-nexthop-hostname */
18273 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18274 != SAVE_BGP_SHOW_HOSTNAME
)
18275 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18276 CHECK_FLAG(bgp
->flags
,
18277 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18281 /* BGP default subgroup-pkt-queue-max. */
18282 if (bgp
->default_subgroup_pkt_queue_max
18283 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18284 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18285 bgp
->default_subgroup_pkt_queue_max
);
18287 /* BGP client-to-client reflection. */
18288 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18289 vty_out(vty
, " no bgp client-to-client reflection\n");
18291 /* BGP cluster ID. */
18292 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18293 vty_out(vty
, " bgp cluster-id %pI4\n",
18296 /* Disable ebgp connected nexthop check */
18297 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18299 " bgp disable-ebgp-connected-route-check\n");
18301 /* Confederation identifier*/
18302 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18303 vty_out(vty
, " bgp confederation identifier %s\n",
18304 bgp
->confed_id_pretty
);
18306 /* Confederation peer */
18307 if (bgp
->confed_peers_cnt
> 0) {
18310 vty_out(vty
, " bgp confederation peers");
18312 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18313 vty_out(vty
, " %s",
18314 bgp
->confed_peers
[i
].as_pretty
);
18316 vty_out(vty
, "\n");
18319 /* BGP deterministic-med. */
18320 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18321 != SAVE_BGP_DETERMINISTIC_MED
)
18322 vty_out(vty
, " %sbgp deterministic-med\n",
18323 CHECK_FLAG(bgp
->flags
,
18324 BGP_FLAG_DETERMINISTIC_MED
)
18328 /* BGP update-delay. */
18329 bgp_config_write_update_delay(vty
, bgp
);
18331 if (bgp
->v_maxmed_onstartup
18332 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18333 vty_out(vty
, " bgp max-med on-startup %u",
18334 bgp
->v_maxmed_onstartup
);
18335 if (bgp
->maxmed_onstartup_value
18336 != BGP_MAXMED_VALUE_DEFAULT
)
18337 vty_out(vty
, " %u",
18338 bgp
->maxmed_onstartup_value
);
18339 vty_out(vty
, "\n");
18341 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18342 vty_out(vty
, " bgp max-med administrative");
18343 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18344 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18345 vty_out(vty
, "\n");
18349 bgp_config_write_wpkt_quanta(vty
, bgp
);
18351 bgp_config_write_rpkt_quanta(vty
, bgp
);
18353 /* coalesce time */
18354 bgp_config_write_coalesce_time(vty
, bgp
);
18356 /* BGP per-instance graceful-shutdown */
18357 /* BGP-wide settings and per-instance settings are mutually
18360 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18361 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18362 vty_out(vty
, " bgp graceful-shutdown\n");
18364 /* Long-lived Graceful Restart */
18365 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18367 " bgp long-lived-graceful-restart stale-time %u\n",
18368 bgp
->llgr_stale_time
);
18370 /* BGP graceful-restart. */
18371 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18373 " bgp graceful-restart stalepath-time %u\n",
18374 bgp
->stalepath_time
);
18376 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18377 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18378 bgp
->restart_time
);
18380 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18381 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18382 vty_out(vty
, " %sbgp graceful-restart notification\n",
18383 CHECK_FLAG(bgp
->flags
,
18384 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18388 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18390 " bgp graceful-restart select-defer-time %u\n",
18391 bgp
->select_defer_time
);
18393 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18394 vty_out(vty
, " bgp graceful-restart\n");
18396 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18397 vty_out(vty
, " bgp graceful-restart-disable\n");
18399 /* BGP graceful-restart Preserve State F bit. */
18400 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18402 " bgp graceful-restart preserve-fw-state\n");
18404 /* BGP TCP keepalive */
18405 bgp_config_tcp_keepalive(vty
, bgp
);
18407 /* Stale timer for RIB */
18408 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18410 " bgp graceful-restart rib-stale-time %u\n",
18411 bgp
->rib_stale_time
);
18413 /* BGP bestpath method. */
18414 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18415 vty_out(vty
, " bgp bestpath as-path ignore\n");
18416 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18417 vty_out(vty
, " bgp bestpath as-path confed\n");
18419 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18420 if (CHECK_FLAG(bgp
->flags
,
18421 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18423 " bgp bestpath as-path multipath-relax as-set\n");
18426 " bgp bestpath as-path multipath-relax\n");
18430 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18432 " bgp route-reflector allow-outbound-policy\n");
18434 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18435 vty_out(vty
, " bgp bestpath compare-routerid\n");
18436 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18437 vty_out(vty
, " bgp bestpath aigp\n");
18438 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18439 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18440 vty_out(vty
, " bgp bestpath med");
18441 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18442 vty_out(vty
, " confed");
18443 if (CHECK_FLAG(bgp
->flags
,
18444 BGP_FLAG_MED_MISSING_AS_WORST
))
18445 vty_out(vty
, " missing-as-worst");
18446 vty_out(vty
, "\n");
18449 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18451 " bgp bestpath peer-type multipath-relax\n");
18453 /* Link bandwidth handling. */
18454 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18455 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18456 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18457 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18458 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18459 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18461 /* BGP network import check. */
18462 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18463 != SAVE_BGP_IMPORT_CHECK
)
18464 vty_out(vty
, " %sbgp network import-check\n",
18465 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18469 /* BGP timers configuration. */
18470 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18471 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18472 vty_out(vty
, " timers bgp %u %u\n",
18473 bgp
->default_keepalive
, bgp
->default_holdtime
);
18475 /* BGP minimum holdtime configuration. */
18476 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18477 && bgp
->default_min_holdtime
!= 0)
18478 vty_out(vty
, " bgp minimum-holdtime %u\n",
18479 bgp
->default_min_holdtime
);
18481 /* Conditional advertisement timer configuration */
18482 if (bgp
->condition_check_period
18483 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18485 " bgp conditional-advertisement timer %u\n",
18486 bgp
->condition_check_period
);
18489 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18490 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18493 /* Normal neighbor configuration. */
18494 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18495 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18496 bgp_config_write_peer_global(vty
, bgp
, peer
);
18499 /* listen range and limit for dynamic BGP neighbors */
18500 bgp_config_write_listen(vty
, bgp
);
18503 * BGP default autoshutdown neighbors
18505 * This must be placed after any peer and peer-group
18506 * configuration, to avoid setting all peers to shutdown after
18507 * a daemon restart, which is undesired behavior. (see #2286)
18509 if (bgp
->autoshutdown
)
18510 vty_out(vty
, " bgp default shutdown\n");
18512 /* BGP instance administrative shutdown */
18513 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18514 vty_out(vty
, " bgp shutdown\n");
18516 if (bgp
->allow_martian
)
18517 vty_out(vty
, " bgp allow-martian-nexthop\n");
18519 if (bgp
->fast_convergence
)
18520 vty_out(vty
, " bgp fast-convergence\n");
18522 if (bgp
->srv6_enabled
) {
18523 vty_frame(vty
, " !\n segment-routing srv6\n");
18524 if (strlen(bgp
->srv6_locator_name
))
18525 vty_out(vty
, " locator %s\n",
18526 bgp
->srv6_locator_name
);
18527 vty_endframe(vty
, " exit\n");
18530 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18531 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18532 vty_out(vty
, " sid vpn per-vrf export auto\n");
18533 } else if (tovpn_sid_index
!= 0) {
18534 vty_out(vty
, " sid vpn per-vrf export %d\n",
18538 /* IPv4 unicast configuration. */
18539 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18541 /* IPv4 multicast configuration. */
18542 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18544 /* IPv4 labeled-unicast configuration. */
18545 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18547 /* IPv4 VPN configuration. */
18548 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18550 /* ENCAPv4 configuration. */
18551 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18553 /* FLOWSPEC v4 configuration. */
18554 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18556 /* IPv6 unicast configuration. */
18557 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18559 /* IPv6 multicast configuration. */
18560 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18562 /* IPv6 labeled-unicast configuration. */
18563 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18564 SAFI_LABELED_UNICAST
);
18566 /* IPv6 VPN configuration. */
18567 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18569 /* ENCAPv6 configuration. */
18570 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18572 /* FLOWSPEC v6 configuration. */
18573 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18575 /* EVPN configuration. */
18576 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18578 hook_call(bgp_inst_config_write
, bgp
, vty
);
18580 #ifdef ENABLE_BGP_VNC
18581 bgp_rfapi_cfg_write(vty
, bgp
);
18584 vty_out(vty
, "exit\n");
18585 vty_out(vty
, "!\n");
18591 /* BGP node structure. */
18592 static struct cmd_node bgp_node
= {
18595 .parent_node
= CONFIG_NODE
,
18596 .prompt
= "%s(config-router)# ",
18597 .config_write
= bgp_config_write
,
18600 static struct cmd_node bgp_ipv4_unicast_node
= {
18601 .name
= "bgp ipv4 unicast",
18602 .node
= BGP_IPV4_NODE
,
18603 .parent_node
= BGP_NODE
,
18604 .prompt
= "%s(config-router-af)# ",
18608 static struct cmd_node bgp_ipv4_multicast_node
= {
18609 .name
= "bgp ipv4 multicast",
18610 .node
= BGP_IPV4M_NODE
,
18611 .parent_node
= BGP_NODE
,
18612 .prompt
= "%s(config-router-af)# ",
18616 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18617 .name
= "bgp ipv4 labeled unicast",
18618 .node
= BGP_IPV4L_NODE
,
18619 .parent_node
= BGP_NODE
,
18620 .prompt
= "%s(config-router-af)# ",
18624 static struct cmd_node bgp_ipv6_unicast_node
= {
18625 .name
= "bgp ipv6 unicast",
18626 .node
= BGP_IPV6_NODE
,
18627 .parent_node
= BGP_NODE
,
18628 .prompt
= "%s(config-router-af)# ",
18632 static struct cmd_node bgp_ipv6_multicast_node
= {
18633 .name
= "bgp ipv6 multicast",
18634 .node
= BGP_IPV6M_NODE
,
18635 .parent_node
= BGP_NODE
,
18636 .prompt
= "%s(config-router-af)# ",
18640 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18641 .name
= "bgp ipv6 labeled unicast",
18642 .node
= BGP_IPV6L_NODE
,
18643 .parent_node
= BGP_NODE
,
18644 .prompt
= "%s(config-router-af)# ",
18648 static struct cmd_node bgp_vpnv4_node
= {
18649 .name
= "bgp vpnv4",
18650 .node
= BGP_VPNV4_NODE
,
18651 .parent_node
= BGP_NODE
,
18652 .prompt
= "%s(config-router-af)# ",
18656 static struct cmd_node bgp_vpnv6_node
= {
18657 .name
= "bgp vpnv6",
18658 .node
= BGP_VPNV6_NODE
,
18659 .parent_node
= BGP_NODE
,
18660 .prompt
= "%s(config-router-af-vpnv6)# ",
18664 static struct cmd_node bgp_evpn_node
= {
18665 .name
= "bgp evpn",
18666 .node
= BGP_EVPN_NODE
,
18667 .parent_node
= BGP_NODE
,
18668 .prompt
= "%s(config-router-evpn)# ",
18672 static struct cmd_node bgp_evpn_vni_node
= {
18673 .name
= "bgp evpn vni",
18674 .node
= BGP_EVPN_VNI_NODE
,
18675 .parent_node
= BGP_EVPN_NODE
,
18676 .prompt
= "%s(config-router-af-vni)# ",
18679 static struct cmd_node bgp_flowspecv4_node
= {
18680 .name
= "bgp ipv4 flowspec",
18681 .node
= BGP_FLOWSPECV4_NODE
,
18682 .parent_node
= BGP_NODE
,
18683 .prompt
= "%s(config-router-af)# ",
18687 static struct cmd_node bgp_flowspecv6_node
= {
18688 .name
= "bgp ipv6 flowspec",
18689 .node
= BGP_FLOWSPECV6_NODE
,
18690 .parent_node
= BGP_NODE
,
18691 .prompt
= "%s(config-router-af-vpnv6)# ",
18695 static struct cmd_node bgp_srv6_node
= {
18696 .name
= "bgp srv6",
18697 .node
= BGP_SRV6_NODE
,
18698 .parent_node
= BGP_NODE
,
18699 .prompt
= "%s(config-router-srv6)# ",
18702 static void community_list_vty(void);
18704 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18707 struct peer_group
*group
;
18708 struct listnode
*lnbgp
, *lnpeer
;
18710 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18711 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18713 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18717 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18721 struct listnode
*lnbgp
, *lnpeer
;
18723 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18724 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18725 /* only provide suggestions on the appropriate input
18727 * they'll otherwise show up multiple times */
18728 enum cmd_token_type match_type
;
18729 char *name
= peer
->host
;
18731 if (peer
->conf_if
) {
18732 match_type
= VARIABLE_TKN
;
18733 name
= peer
->conf_if
;
18734 } else if (strchr(peer
->host
, ':'))
18735 match_type
= IPV6_TKN
;
18737 match_type
= IPV4_TKN
;
18739 if (token
->type
!= match_type
)
18742 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18747 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18749 bgp_ac_peer(comps
, token
);
18751 if (token
->type
== VARIABLE_TKN
)
18752 bgp_ac_peergroup(comps
, token
);
18755 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18756 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18757 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18758 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18759 {.completions
= NULL
}};
18761 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18762 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18763 {.completions
= NULL
} };
18765 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18767 static struct thread
*t_bgp_cfg
;
18769 bool bgp_config_inprocess(void)
18771 return thread_is_scheduled(t_bgp_cfg
);
18774 static void bgp_config_finish(struct thread
*t
)
18776 struct listnode
*node
;
18779 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18780 hook_call(bgp_config_end
, bgp
);
18783 static void bgp_config_start(void)
18785 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18786 THREAD_OFF(t_bgp_cfg
);
18787 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18788 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18791 /* When we receive a hook the configuration is read,
18792 * we start a timer to make sure we postpone sending
18793 * EoR before route-maps are processed.
18794 * This is especially valid if using `bgp route-map delay-timer`.
18796 static void bgp_config_end(void)
18798 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18799 uint32_t bgp_post_config_delay
=
18800 thread_is_scheduled(bm
->t_rmap_update
)
18801 ? thread_timer_remain_second(bm
->t_rmap_update
)
18802 : BGP_POST_CONFIG_DELAY_SECONDS
;
18804 /* If BGP config processing thread isn't running, then
18805 * we can return and rely it's properly handled.
18807 if (!bgp_config_inprocess())
18810 THREAD_OFF(t_bgp_cfg
);
18812 /* Start a new timer to make sure we don't send EoR
18813 * before route-maps are processed.
18815 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18816 bgp_post_config_delay
, &t_bgp_cfg
);
18819 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18822 struct interface
*ifp
;
18823 struct bgp_interface
*iifp
;
18825 FOR_ALL_INTERFACES (vrf
, ifp
) {
18830 if_vty_config_start(vty
, ifp
);
18832 if (CHECK_FLAG(iifp
->flags
,
18833 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18834 vty_out(vty
, " mpls bgp forwarding\n");
18838 if_vty_config_end(vty
);
18844 /* Configuration write function for bgpd. */
18845 static int config_write_interface(struct vty
*vty
)
18848 struct vrf
*vrf
= NULL
;
18850 /* Display all VRF aware OSPF interface configuration */
18851 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18852 write
+= config_write_interface_one(vty
, vrf
);
18858 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18859 "[no$no] mpls bgp forwarding",
18860 NO_STR MPLS_STR BGP_STR
18861 "Enable MPLS forwarding for eBGP directly connected peers\n")
18864 struct bgp_interface
*iifp
;
18866 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18869 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18870 return CMD_WARNING_CONFIG_FAILED
;
18872 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18873 if (check
!= !no
) {
18875 UNSET_FLAG(iifp
->flags
,
18876 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18878 SET_FLAG(iifp
->flags
,
18879 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18880 /* trigger a nht update on eBGP sessions */
18881 if (if_is_operative(ifp
))
18882 bgp_nht_ifp_up(ifp
);
18884 return CMD_SUCCESS
;
18887 DEFPY (bgp_inq_limit
,
18889 "bgp input-queue-limit (1-4294967295)$limit",
18891 "Set the BGP Input Queue limit for all peers when message parsing\n"
18892 "Input-Queue limit\n")
18894 bm
->inq_limit
= limit
;
18896 return CMD_SUCCESS
;
18899 DEFPY (no_bgp_inq_limit
,
18900 no_bgp_inq_limit_cmd
,
18901 "no bgp input-queue-limit [(1-4294967295)$limit]",
18904 "Set the BGP Input Queue limit for all peers when message parsing\n"
18905 "Input-Queue limit\n")
18907 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18909 return CMD_SUCCESS
;
18912 DEFPY (bgp_outq_limit
,
18913 bgp_outq_limit_cmd
,
18914 "bgp output-queue-limit (1-4294967295)$limit",
18916 "Set the BGP Output Queue limit for all peers when message parsing\n"
18917 "Output-Queue limit\n")
18919 bm
->outq_limit
= limit
;
18921 return CMD_SUCCESS
;
18924 DEFPY (no_bgp_outq_limit
,
18925 no_bgp_outq_limit_cmd
,
18926 "no bgp output-queue-limit [(1-4294967295)$limit]",
18929 "Set the BGP Output Queue limit for all peers when message parsing\n"
18930 "Output-Queue limit\n")
18932 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18934 return CMD_SUCCESS
;
18938 /* Initialization of BGP interface. */
18939 static void bgp_vty_if_init(void)
18941 /* Install interface node. */
18942 if_cmd_init(config_write_interface
);
18944 /* "mpls bgp forwarding" commands. */
18945 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18948 void bgp_vty_init(void)
18950 cmd_variable_handler_register(bgp_var_neighbor
);
18951 cmd_variable_handler_register(bgp_var_peergroup
);
18953 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18955 /* Install bgp top node. */
18956 install_node(&bgp_node
);
18957 install_node(&bgp_ipv4_unicast_node
);
18958 install_node(&bgp_ipv4_multicast_node
);
18959 install_node(&bgp_ipv4_labeled_unicast_node
);
18960 install_node(&bgp_ipv6_unicast_node
);
18961 install_node(&bgp_ipv6_multicast_node
);
18962 install_node(&bgp_ipv6_labeled_unicast_node
);
18963 install_node(&bgp_vpnv4_node
);
18964 install_node(&bgp_vpnv6_node
);
18965 install_node(&bgp_evpn_node
);
18966 install_node(&bgp_evpn_vni_node
);
18967 install_node(&bgp_flowspecv4_node
);
18968 install_node(&bgp_flowspecv6_node
);
18969 install_node(&bgp_srv6_node
);
18971 /* Install default VTY commands to new nodes. */
18972 install_default(BGP_NODE
);
18973 install_default(BGP_IPV4_NODE
);
18974 install_default(BGP_IPV4M_NODE
);
18975 install_default(BGP_IPV4L_NODE
);
18976 install_default(BGP_IPV6_NODE
);
18977 install_default(BGP_IPV6M_NODE
);
18978 install_default(BGP_IPV6L_NODE
);
18979 install_default(BGP_VPNV4_NODE
);
18980 install_default(BGP_VPNV6_NODE
);
18981 install_default(BGP_FLOWSPECV4_NODE
);
18982 install_default(BGP_FLOWSPECV6_NODE
);
18983 install_default(BGP_EVPN_NODE
);
18984 install_default(BGP_EVPN_VNI_NODE
);
18985 install_default(BGP_SRV6_NODE
);
18987 /* "global bgp inq-limit command */
18988 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18989 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18990 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18991 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18993 /* "bgp local-mac" hidden commands. */
18994 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18995 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18997 /* "bgp suppress-fib-pending" global */
18998 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
19000 /* bgp route-map delay-timer commands. */
19001 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
19002 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
19004 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
19006 /* bgp fast-convergence command */
19007 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
19008 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
19010 /* global bgp update-delay command */
19011 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
19012 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
19014 /* global bgp graceful-shutdown command */
19015 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
19016 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
19018 /* Dummy commands (Currently not supported) */
19019 install_element(BGP_NODE
, &no_synchronization_cmd
);
19020 install_element(BGP_NODE
, &no_auto_summary_cmd
);
19022 /* "router bgp" commands. */
19023 install_element(CONFIG_NODE
, &router_bgp_cmd
);
19025 /* "no router bgp" commands. */
19026 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
19028 /* "bgp session-dscp command */
19029 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
19030 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
19032 /* "bgp router-id" commands. */
19033 install_element(BGP_NODE
, &bgp_router_id_cmd
);
19034 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
19036 /* "bgp suppress-fib-pending" command */
19037 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
19039 /* "bgp cluster-id" commands. */
19040 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
19041 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
19043 /* "bgp no-rib" commands. */
19044 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
19045 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
19047 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
19049 /* "bgp confederation" commands. */
19050 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
19051 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
19053 /* "bgp confederation peers" commands. */
19054 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
19055 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
19057 /* bgp max-med command */
19058 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
19059 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
19060 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
19061 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
19062 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
19064 /* "neighbor role" commands. */
19065 install_element(BGP_NODE
, &neighbor_role_cmd
);
19066 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
19067 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
19069 /* "neighbor aigp" commands. */
19070 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
19072 /* "neighbor graceful-shutdown" command */
19073 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
19075 /* bgp disable-ebgp-connected-nh-check */
19076 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
19077 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
19079 /* bgp update-delay command */
19080 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
19081 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
19083 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
19084 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
19086 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
19087 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
19089 /* "maximum-paths" commands. */
19090 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
19091 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
19092 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
19093 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
19094 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
19095 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
19096 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
19097 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
19098 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
19099 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
19100 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
19101 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
19102 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
19103 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
19104 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
19106 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
19107 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
19108 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
19109 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
19110 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
19111 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
19112 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
19113 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
19114 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
19115 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
19117 /* "timers bgp" commands. */
19118 install_element(BGP_NODE
, &bgp_timers_cmd
);
19119 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
19121 /* "minimum-holdtime" commands. */
19122 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
19123 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
19125 /* route-map delay-timer commands - per instance for backwards compat.
19127 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
19128 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
19130 /* "bgp client-to-client reflection" commands */
19131 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
19132 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
19134 /* "bgp always-compare-med" commands */
19135 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
19136 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
19138 /* bgp ebgp-requires-policy */
19139 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
19140 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
19142 /* bgp suppress-duplicates */
19143 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
19144 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
19146 /* bgp reject-as-sets */
19147 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
19148 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
19150 /* "bgp deterministic-med" commands */
19151 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
19152 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
19154 /* "bgp graceful-restart" command */
19155 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
19156 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
19158 /* "bgp graceful-restart-disable" command */
19159 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
19160 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
19162 /* "neighbor a:b:c:d graceful-restart" command */
19163 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
19164 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
19166 /* "neighbor a:b:c:d graceful-restart-disable" command */
19167 install_element(BGP_NODE
,
19168 &bgp_neighbor_graceful_restart_disable_set_cmd
);
19169 install_element(BGP_NODE
,
19170 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
19172 /* "neighbor a:b:c:d graceful-restart-helper" command */
19173 install_element(BGP_NODE
,
19174 &bgp_neighbor_graceful_restart_helper_set_cmd
);
19175 install_element(BGP_NODE
,
19176 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
19178 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
19179 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
19180 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
19181 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
19182 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
19183 install_element(BGP_NODE
,
19184 &no_bgp_graceful_restart_select_defer_time_cmd
);
19185 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
19186 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
19187 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
19189 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
19190 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
19191 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
19192 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
19194 /* "bgp graceful-shutdown" commands */
19195 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
19196 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
19198 /* "bgp hard-administrative-reset" commands */
19199 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
19201 /* "bgp long-lived-graceful-restart" commands */
19202 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
19203 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
19205 /* "bgp fast-external-failover" commands */
19206 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
19207 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
19209 /* "bgp bestpath aigp" commands */
19210 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
19212 /* "bgp bestpath compare-routerid" commands */
19213 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
19214 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
19216 /* "bgp bestpath as-path ignore" commands */
19217 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
19218 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
19220 /* "bgp bestpath as-path confed" commands */
19221 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
19222 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
19224 /* "bgp bestpath as-path multipath-relax" commands */
19225 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
19226 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
19228 /* "bgp bestpath peer-type multipath-relax" commands */
19229 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
19230 install_element(BGP_NODE
,
19231 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
19233 /* "bgp log-neighbor-changes" commands */
19234 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
19235 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
19237 /* "bgp bestpath med" commands */
19238 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
19239 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
19241 /* "bgp bestpath bandwidth" commands */
19242 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
19243 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
19245 /* "no bgp default <afi>-<safi>" commands. */
19246 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
19248 /* "bgp network import-check" commands. */
19249 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
19250 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
19251 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
19253 /* "bgp default local-preference" commands. */
19254 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19255 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19257 /* bgp default show-hostname */
19258 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19259 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19261 /* bgp default show-nexthop-hostname */
19262 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19263 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19265 /* "bgp default subgroup-pkt-queue-max" commands. */
19266 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19267 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19269 /* bgp ibgp-allow-policy-mods command */
19270 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19271 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19273 /* "bgp listen limit" commands. */
19274 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19275 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19277 /* "bgp listen range" commands. */
19278 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19279 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19281 /* "bgp default shutdown" command */
19282 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19284 /* "bgp shutdown" commands */
19285 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19286 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19287 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19288 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19290 /* "neighbor remote-as" commands. */
19291 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19292 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19293 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19294 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19295 install_element(BGP_NODE
,
19296 &neighbor_interface_v6only_config_remote_as_cmd
);
19297 install_element(BGP_NODE
, &no_neighbor_cmd
);
19298 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19300 /* "neighbor peer-group" commands. */
19301 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19302 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19303 install_element(BGP_NODE
,
19304 &no_neighbor_interface_peer_group_remote_as_cmd
);
19306 /* "neighbor local-as" commands. */
19307 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19308 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19309 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19310 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19312 /* "neighbor solo" commands. */
19313 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19314 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19316 /* "neighbor password" commands. */
19317 install_element(BGP_NODE
, &neighbor_password_cmd
);
19318 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19320 /* "neighbor activate" commands. */
19321 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19322 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19323 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19324 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19325 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19326 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19327 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19328 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19329 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19330 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19331 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19332 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19334 /* "no neighbor activate" commands. */
19335 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19336 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19337 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19338 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19339 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19340 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19341 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19342 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19343 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19344 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19345 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19346 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19348 /* "neighbor peer-group" set commands. */
19349 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19350 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19351 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19352 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19353 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19354 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19355 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19356 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19357 install_element(BGP_FLOWSPECV4_NODE
,
19358 &neighbor_set_peer_group_hidden_cmd
);
19359 install_element(BGP_FLOWSPECV6_NODE
,
19360 &neighbor_set_peer_group_hidden_cmd
);
19362 /* "no neighbor peer-group unset" commands. */
19363 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19364 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19365 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19366 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19367 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19368 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19369 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19370 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19371 install_element(BGP_FLOWSPECV4_NODE
,
19372 &no_neighbor_set_peer_group_hidden_cmd
);
19373 install_element(BGP_FLOWSPECV6_NODE
,
19374 &no_neighbor_set_peer_group_hidden_cmd
);
19376 /* "neighbor softreconfiguration inbound" commands.*/
19377 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19378 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19379 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19380 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19381 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19382 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19383 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19384 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19385 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19386 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19387 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19388 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19389 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19390 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19391 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19392 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19393 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19394 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19395 install_element(BGP_FLOWSPECV4_NODE
,
19396 &neighbor_soft_reconfiguration_cmd
);
19397 install_element(BGP_FLOWSPECV4_NODE
,
19398 &no_neighbor_soft_reconfiguration_cmd
);
19399 install_element(BGP_FLOWSPECV6_NODE
,
19400 &neighbor_soft_reconfiguration_cmd
);
19401 install_element(BGP_FLOWSPECV6_NODE
,
19402 &no_neighbor_soft_reconfiguration_cmd
);
19403 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19404 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19406 /* "neighbor attribute-unchanged" commands. */
19407 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19408 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19409 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19410 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19411 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19412 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19413 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19414 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19415 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19416 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19417 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19418 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19419 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19420 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19421 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19422 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19423 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19424 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19426 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19427 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19429 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19430 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19431 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19432 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19434 /* "nexthop-local unchanged" commands */
19435 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19436 install_element(BGP_IPV6_NODE
,
19437 &no_neighbor_nexthop_local_unchanged_cmd
);
19439 /* "neighbor next-hop-self" commands. */
19440 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19441 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19442 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19443 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19444 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19445 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19446 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19447 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19448 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19449 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19450 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19451 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19452 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19453 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19454 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19455 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19456 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19457 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19458 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19459 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19461 /* "neighbor next-hop-self force" commands. */
19462 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19463 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19464 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19465 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19466 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19467 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19468 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19469 install_element(BGP_IPV4_NODE
,
19470 &no_neighbor_nexthop_self_all_hidden_cmd
);
19471 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19472 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19473 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19474 install_element(BGP_IPV4M_NODE
,
19475 &no_neighbor_nexthop_self_all_hidden_cmd
);
19476 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19477 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19478 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19479 install_element(BGP_IPV4L_NODE
,
19480 &no_neighbor_nexthop_self_all_hidden_cmd
);
19481 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19482 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19483 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19484 install_element(BGP_IPV6_NODE
,
19485 &no_neighbor_nexthop_self_all_hidden_cmd
);
19486 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19487 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19488 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19489 install_element(BGP_IPV6M_NODE
,
19490 &no_neighbor_nexthop_self_all_hidden_cmd
);
19491 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19492 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19493 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19494 install_element(BGP_IPV6L_NODE
,
19495 &no_neighbor_nexthop_self_all_hidden_cmd
);
19496 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19497 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19498 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19499 install_element(BGP_VPNV4_NODE
,
19500 &no_neighbor_nexthop_self_all_hidden_cmd
);
19501 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19502 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19503 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19504 install_element(BGP_VPNV6_NODE
,
19505 &no_neighbor_nexthop_self_all_hidden_cmd
);
19506 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19507 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19509 /* "neighbor as-override" commands. */
19510 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19511 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19512 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19513 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19514 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19515 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19516 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19517 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19518 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19519 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19520 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19521 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19522 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19523 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19524 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19525 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19526 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19527 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19529 /* "neighbor remove-private-AS" commands. */
19530 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19531 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19532 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19533 install_element(BGP_NODE
,
19534 &no_neighbor_remove_private_as_all_hidden_cmd
);
19535 install_element(BGP_NODE
,
19536 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19537 install_element(BGP_NODE
,
19538 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19539 install_element(BGP_NODE
,
19540 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19543 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19544 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19545 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19546 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19547 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19548 install_element(BGP_IPV4_NODE
,
19549 &neighbor_remove_private_as_replace_as_cmd
);
19550 install_element(BGP_IPV4_NODE
,
19551 &no_neighbor_remove_private_as_replace_as_cmd
);
19552 install_element(BGP_IPV4_NODE
,
19553 &neighbor_remove_private_as_all_replace_as_cmd
);
19554 install_element(BGP_IPV4_NODE
,
19555 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19556 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19557 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19558 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19559 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19560 install_element(BGP_IPV4M_NODE
,
19561 &neighbor_remove_private_as_replace_as_cmd
);
19562 install_element(BGP_IPV4M_NODE
,
19563 &no_neighbor_remove_private_as_replace_as_cmd
);
19564 install_element(BGP_IPV4M_NODE
,
19565 &neighbor_remove_private_as_all_replace_as_cmd
);
19566 install_element(BGP_IPV4M_NODE
,
19567 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19568 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19569 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19570 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19571 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19572 install_element(BGP_IPV4L_NODE
,
19573 &neighbor_remove_private_as_replace_as_cmd
);
19574 install_element(BGP_IPV4L_NODE
,
19575 &no_neighbor_remove_private_as_replace_as_cmd
);
19576 install_element(BGP_IPV4L_NODE
,
19577 &neighbor_remove_private_as_all_replace_as_cmd
);
19578 install_element(BGP_IPV4L_NODE
,
19579 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19580 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19581 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19582 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19583 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19584 install_element(BGP_IPV6_NODE
,
19585 &neighbor_remove_private_as_replace_as_cmd
);
19586 install_element(BGP_IPV6_NODE
,
19587 &no_neighbor_remove_private_as_replace_as_cmd
);
19588 install_element(BGP_IPV6_NODE
,
19589 &neighbor_remove_private_as_all_replace_as_cmd
);
19590 install_element(BGP_IPV6_NODE
,
19591 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19592 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19593 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19594 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19595 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19596 install_element(BGP_IPV6M_NODE
,
19597 &neighbor_remove_private_as_replace_as_cmd
);
19598 install_element(BGP_IPV6M_NODE
,
19599 &no_neighbor_remove_private_as_replace_as_cmd
);
19600 install_element(BGP_IPV6M_NODE
,
19601 &neighbor_remove_private_as_all_replace_as_cmd
);
19602 install_element(BGP_IPV6M_NODE
,
19603 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19604 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19605 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19606 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19607 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19608 install_element(BGP_IPV6L_NODE
,
19609 &neighbor_remove_private_as_replace_as_cmd
);
19610 install_element(BGP_IPV6L_NODE
,
19611 &no_neighbor_remove_private_as_replace_as_cmd
);
19612 install_element(BGP_IPV6L_NODE
,
19613 &neighbor_remove_private_as_all_replace_as_cmd
);
19614 install_element(BGP_IPV6L_NODE
,
19615 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19616 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19617 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19618 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19619 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19620 install_element(BGP_VPNV4_NODE
,
19621 &neighbor_remove_private_as_replace_as_cmd
);
19622 install_element(BGP_VPNV4_NODE
,
19623 &no_neighbor_remove_private_as_replace_as_cmd
);
19624 install_element(BGP_VPNV4_NODE
,
19625 &neighbor_remove_private_as_all_replace_as_cmd
);
19626 install_element(BGP_VPNV4_NODE
,
19627 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19628 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19629 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19630 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19631 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19632 install_element(BGP_VPNV6_NODE
,
19633 &neighbor_remove_private_as_replace_as_cmd
);
19634 install_element(BGP_VPNV6_NODE
,
19635 &no_neighbor_remove_private_as_replace_as_cmd
);
19636 install_element(BGP_VPNV6_NODE
,
19637 &neighbor_remove_private_as_all_replace_as_cmd
);
19638 install_element(BGP_VPNV6_NODE
,
19639 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19641 /* "neighbor send-community" commands.*/
19642 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19643 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19644 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19645 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19646 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19647 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19648 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19649 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19650 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19651 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19652 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19653 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19654 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19655 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19656 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19657 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19658 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19659 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19660 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19661 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19662 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19663 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19664 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19665 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19666 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19667 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19668 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19669 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19670 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19671 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19672 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19673 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19674 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19675 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19676 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19677 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19679 /* "neighbor route-reflector" commands.*/
19680 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19681 install_element(BGP_NODE
,
19682 &no_neighbor_route_reflector_client_hidden_cmd
);
19683 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19684 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19685 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19686 install_element(BGP_IPV4M_NODE
,
19687 &no_neighbor_route_reflector_client_cmd
);
19688 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19689 install_element(BGP_IPV4L_NODE
,
19690 &no_neighbor_route_reflector_client_cmd
);
19691 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19692 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19693 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19694 install_element(BGP_IPV6M_NODE
,
19695 &no_neighbor_route_reflector_client_cmd
);
19696 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19697 install_element(BGP_IPV6L_NODE
,
19698 &no_neighbor_route_reflector_client_cmd
);
19699 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19700 install_element(BGP_VPNV4_NODE
,
19701 &no_neighbor_route_reflector_client_cmd
);
19702 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19703 install_element(BGP_VPNV6_NODE
,
19704 &no_neighbor_route_reflector_client_cmd
);
19705 install_element(BGP_FLOWSPECV4_NODE
,
19706 &neighbor_route_reflector_client_cmd
);
19707 install_element(BGP_FLOWSPECV4_NODE
,
19708 &no_neighbor_route_reflector_client_cmd
);
19709 install_element(BGP_FLOWSPECV6_NODE
,
19710 &neighbor_route_reflector_client_cmd
);
19711 install_element(BGP_FLOWSPECV6_NODE
,
19712 &no_neighbor_route_reflector_client_cmd
);
19713 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19714 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19716 /* "neighbor route-server" commands.*/
19717 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19718 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19719 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19720 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19721 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19722 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19723 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19724 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19725 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19726 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19727 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19728 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19729 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19730 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19731 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19732 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19733 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19734 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19735 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19736 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19737 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19738 install_element(BGP_FLOWSPECV4_NODE
,
19739 &no_neighbor_route_server_client_cmd
);
19740 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19741 install_element(BGP_FLOWSPECV6_NODE
,
19742 &no_neighbor_route_server_client_cmd
);
19744 /* "neighbor disable-addpath-rx" commands. */
19745 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19746 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19747 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19748 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19749 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19750 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19751 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19752 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19753 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19754 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19755 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19756 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19757 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19758 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19759 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19760 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19762 /* "neighbor addpath-tx-all-paths" commands.*/
19763 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19764 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19765 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19766 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19767 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19768 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19769 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19770 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19771 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19772 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19773 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19774 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19775 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19776 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19777 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19778 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19779 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19780 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19782 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19783 install_element(BGP_NODE
,
19784 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19785 install_element(BGP_NODE
,
19786 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19787 install_element(BGP_IPV4_NODE
,
19788 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19789 install_element(BGP_IPV4_NODE
,
19790 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19791 install_element(BGP_IPV4M_NODE
,
19792 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19793 install_element(BGP_IPV4M_NODE
,
19794 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19795 install_element(BGP_IPV4L_NODE
,
19796 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19797 install_element(BGP_IPV4L_NODE
,
19798 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19799 install_element(BGP_IPV6_NODE
,
19800 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19801 install_element(BGP_IPV6_NODE
,
19802 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19803 install_element(BGP_IPV6M_NODE
,
19804 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19805 install_element(BGP_IPV6M_NODE
,
19806 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19807 install_element(BGP_IPV6L_NODE
,
19808 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19809 install_element(BGP_IPV6L_NODE
,
19810 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19811 install_element(BGP_VPNV4_NODE
,
19812 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19813 install_element(BGP_VPNV4_NODE
,
19814 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19815 install_element(BGP_VPNV6_NODE
,
19816 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19817 install_element(BGP_VPNV6_NODE
,
19818 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19820 /* "neighbor sender-as-path-loop-detection" commands. */
19821 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19822 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19824 /* "neighbor path-attribute discard" commands. */
19825 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19826 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19828 /* "neighbor path-attribute treat-as-withdraw" commands. */
19829 install_element(BGP_NODE
,
19830 &neighbor_path_attribute_treat_as_withdraw_cmd
);
19831 install_element(BGP_NODE
,
19832 &no_neighbor_path_attribute_treat_as_withdraw_cmd
);
19834 /* "neighbor passive" commands. */
19835 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19836 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19839 /* "neighbor shutdown" commands. */
19840 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19841 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19842 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19843 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19844 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19845 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19847 /* "neighbor capability extended-nexthop" commands.*/
19848 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19849 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19851 /* "neighbor capability software-version" commands.*/
19852 install_element(BGP_NODE
, &neighbor_capability_software_version_cmd
);
19854 /* "neighbor capability orf prefix-list" commands.*/
19855 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19856 install_element(BGP_NODE
,
19857 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19858 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19859 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19860 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19861 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19862 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19863 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19864 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19865 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19866 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19867 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19868 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19869 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19871 /* "neighbor capability dynamic" commands.*/
19872 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19873 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19875 /* "neighbor dont-capability-negotiate" commands. */
19876 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19877 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19879 /* "neighbor ebgp-multihop" commands. */
19880 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19881 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19882 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19884 /* "neighbor disable-connected-check" commands. */
19885 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19886 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19888 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19889 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19890 install_element(BGP_NODE
,
19891 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19893 /* "neighbor extended-optional-parameters" commands. */
19894 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19895 install_element(BGP_NODE
,
19896 &no_neighbor_extended_optional_parameters_cmd
);
19898 /* "neighbor enforce-first-as" commands. */
19899 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19900 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19902 /* "neighbor description" commands. */
19903 install_element(BGP_NODE
, &neighbor_description_cmd
);
19904 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19905 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19907 /* "neighbor update-source" commands. "*/
19908 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19909 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19911 /* "neighbor default-originate" commands. */
19912 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19913 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19914 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19915 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19916 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19917 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19918 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19919 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19920 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19921 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19922 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19923 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19924 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19925 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19926 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19927 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19928 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19929 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19930 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19931 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19932 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19934 /* "neighbor port" commands. */
19935 install_element(BGP_NODE
, &neighbor_port_cmd
);
19936 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19938 /* "neighbor weight" commands. */
19939 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19940 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19942 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19943 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19944 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19945 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19946 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19947 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19948 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19949 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19950 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19951 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19952 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19953 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19954 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19955 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19956 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19957 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19959 /* "neighbor override-capability" commands. */
19960 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19961 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19963 /* "neighbor strict-capability-match" commands. */
19964 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19965 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19967 /* "neighbor timers" commands. */
19968 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19969 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19971 /* "neighbor timers connect" commands. */
19972 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19973 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19975 /* "neighbor timers delayopen" commands. */
19976 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19977 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19979 /* "neighbor advertisement-interval" commands. */
19980 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19981 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19983 /* "neighbor interface" commands. */
19984 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19985 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19987 /* "neighbor distribute" commands. */
19988 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19989 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19990 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19991 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19992 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19993 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19994 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19995 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19996 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19997 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19998 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19999 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
20000 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
20001 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
20002 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
20003 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
20004 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
20005 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
20007 /* "neighbor prefix-list" commands. */
20008 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
20009 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
20010 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
20011 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
20012 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
20013 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
20014 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
20015 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
20016 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
20017 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
20018 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
20019 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
20020 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
20021 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
20022 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
20023 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
20024 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
20025 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
20026 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
20027 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
20028 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
20029 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
20031 /* "neighbor filter-list" commands. */
20032 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
20033 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
20034 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
20035 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
20036 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
20037 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
20038 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
20039 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
20040 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
20041 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
20042 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
20043 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
20044 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
20045 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
20046 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
20047 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
20048 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
20049 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
20050 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
20051 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
20052 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
20053 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
20055 /* "neighbor route-map" commands. */
20056 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
20057 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
20058 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
20059 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
20060 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
20061 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
20062 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
20063 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
20064 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
20065 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
20066 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
20067 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
20068 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
20069 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
20070 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
20071 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
20072 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
20073 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
20074 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
20075 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
20076 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
20077 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
20078 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
20079 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
20081 /* "neighbor unsuppress-map" commands. */
20082 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
20083 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
20084 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
20085 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
20086 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
20087 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
20088 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
20089 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
20090 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
20091 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
20092 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
20093 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
20094 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
20095 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
20096 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
20097 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
20098 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
20099 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
20101 /* "neighbor advertise-map" commands. */
20102 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
20103 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
20104 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
20105 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
20106 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
20107 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
20108 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
20109 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
20110 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
20111 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
20113 /* neighbor maximum-prefix-out commands. */
20114 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
20115 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20116 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
20117 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20118 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
20119 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20120 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
20121 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20122 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
20123 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20124 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
20125 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20126 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
20127 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20128 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
20129 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20130 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
20131 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20133 /* "neighbor maximum-prefix" commands. */
20134 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
20135 install_element(BGP_NODE
,
20136 &neighbor_maximum_prefix_threshold_hidden_cmd
);
20137 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
20138 install_element(BGP_NODE
,
20139 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
20140 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
20141 install_element(BGP_NODE
,
20142 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
20143 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
20144 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
20145 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20146 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20147 install_element(BGP_IPV4_NODE
,
20148 &neighbor_maximum_prefix_threshold_warning_cmd
);
20149 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20150 install_element(BGP_IPV4_NODE
,
20151 &neighbor_maximum_prefix_threshold_restart_cmd
);
20152 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20153 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
20154 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20155 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20156 install_element(BGP_IPV4M_NODE
,
20157 &neighbor_maximum_prefix_threshold_warning_cmd
);
20158 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20159 install_element(BGP_IPV4M_NODE
,
20160 &neighbor_maximum_prefix_threshold_restart_cmd
);
20161 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
20162 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
20163 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20164 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20165 install_element(BGP_IPV4L_NODE
,
20166 &neighbor_maximum_prefix_threshold_warning_cmd
);
20167 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20168 install_element(BGP_IPV4L_NODE
,
20169 &neighbor_maximum_prefix_threshold_restart_cmd
);
20170 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20171 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
20172 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20173 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20174 install_element(BGP_IPV6_NODE
,
20175 &neighbor_maximum_prefix_threshold_warning_cmd
);
20176 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20177 install_element(BGP_IPV6_NODE
,
20178 &neighbor_maximum_prefix_threshold_restart_cmd
);
20179 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20180 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
20181 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20182 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20183 install_element(BGP_IPV6M_NODE
,
20184 &neighbor_maximum_prefix_threshold_warning_cmd
);
20185 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20186 install_element(BGP_IPV6M_NODE
,
20187 &neighbor_maximum_prefix_threshold_restart_cmd
);
20188 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
20189 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
20190 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20191 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20192 install_element(BGP_IPV6L_NODE
,
20193 &neighbor_maximum_prefix_threshold_warning_cmd
);
20194 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20195 install_element(BGP_IPV6L_NODE
,
20196 &neighbor_maximum_prefix_threshold_restart_cmd
);
20197 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20198 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
20199 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20200 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20201 install_element(BGP_VPNV4_NODE
,
20202 &neighbor_maximum_prefix_threshold_warning_cmd
);
20203 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20204 install_element(BGP_VPNV4_NODE
,
20205 &neighbor_maximum_prefix_threshold_restart_cmd
);
20206 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20207 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
20208 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20209 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20210 install_element(BGP_VPNV6_NODE
,
20211 &neighbor_maximum_prefix_threshold_warning_cmd
);
20212 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20213 install_element(BGP_VPNV6_NODE
,
20214 &neighbor_maximum_prefix_threshold_restart_cmd
);
20215 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20217 /* "neighbor allowas-in" */
20218 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
20219 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
20220 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
20221 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
20222 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
20223 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
20224 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
20225 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
20226 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
20227 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
20228 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
20229 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
20230 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
20231 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
20232 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
20233 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
20234 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
20235 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
20236 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
20237 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
20239 /* neighbor accept-own */
20240 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
20241 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
20243 /* "neighbor soo" */
20244 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
20245 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
20246 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
20247 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
20248 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
20249 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
20250 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
20251 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
20252 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
20253 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
20254 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
20255 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
20256 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
20257 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
20258 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
20259 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
20260 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
20261 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
20263 /* address-family commands. */
20264 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20265 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20266 #ifdef KEEP_OLD_VPN_COMMANDS
20267 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20268 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20269 #endif /* KEEP_OLD_VPN_COMMANDS */
20271 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20273 /* "exit-address-family" command. */
20274 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20275 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20276 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20277 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20278 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20279 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20280 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20281 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20282 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20283 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20284 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20286 /* BGP retain all route-target */
20287 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20288 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20290 /* "clear ip bgp commands" */
20291 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20293 /* clear ip bgp prefix */
20294 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20295 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20296 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20298 /* "show [ip] bgp summary" commands. */
20299 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20300 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20301 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20302 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20303 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20304 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20305 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20307 /* "show [ip] bgp neighbors" commands. */
20308 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20310 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20312 /* "show [ip] bgp peer-group" commands. */
20313 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20315 /* "show [ip] bgp paths" commands. */
20316 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20318 /* "show [ip] bgp community" commands. */
20319 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20321 /* "show ip bgp large-community" commands. */
20322 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20323 /* "show [ip] bgp attribute-info" commands. */
20324 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20325 /* "show [ip] bgp route-leak" command */
20326 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20328 /* "redistribute" commands. */
20329 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20330 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20331 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20332 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20333 install_element(BGP_NODE
,
20334 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20335 install_element(BGP_NODE
,
20336 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20337 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20338 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20339 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20340 install_element(BGP_NODE
,
20341 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20342 install_element(BGP_NODE
,
20343 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20344 install_element(BGP_NODE
,
20345 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20346 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20347 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20348 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20349 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20350 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20351 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20352 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20353 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20354 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20355 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20356 install_element(BGP_IPV4_NODE
,
20357 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20358 install_element(BGP_IPV4_NODE
,
20359 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20360 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20361 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20362 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20363 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20364 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20365 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20367 /* import|export vpn [route-map RMAP_NAME] */
20368 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20369 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20371 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20372 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20374 /* ttl_security commands */
20375 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20376 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20378 /* "bgp tcp-keepalive" commands */
20379 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20380 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20382 /* "show [ip] bgp memory" commands. */
20383 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20385 /* "show bgp martian next-hop" */
20386 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20388 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20390 /* "show [ip] bgp views" commands. */
20391 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20393 /* "show [ip] bgp vrfs" commands. */
20394 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20396 /* Community-list. */
20397 community_list_vty();
20399 community_alias_vty();
20401 /* vpn-policy commands */
20402 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20403 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20404 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20405 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20406 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20407 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20408 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20409 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20410 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20411 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20412 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20413 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20415 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20416 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20418 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20419 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20420 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20421 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20422 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20423 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20424 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20425 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20426 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20427 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20429 /* tcp-mss command */
20430 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20431 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20433 /* srv6 commands */
20434 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20435 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20436 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20437 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20438 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20439 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20440 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20441 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20442 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20447 #include "memory.h"
20448 #include "bgp_regex.h"
20449 #include "bgp_clist.h"
20450 #include "bgp_ecommunity.h"
20452 /* VTY functions. */
20454 /* Direction value to string conversion. */
20455 static const char *community_direct_str(int direct
)
20458 case COMMUNITY_DENY
:
20460 case COMMUNITY_PERMIT
:
20467 /* Display error string. */
20468 static void community_list_perror(struct vty
*vty
, int ret
)
20471 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20472 vty_out(vty
, "%% Can't find community-list\n");
20474 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20475 vty_out(vty
, "%% Malformed community-list value\n");
20477 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20479 "%% Community name conflict, previously defined as standard community\n");
20481 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20483 "%% Community name conflict, previously defined as expanded community\n");
20488 /* "community-list" keyword help string. */
20489 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20491 /*community-list standard */
20492 DEFUN (community_list_standard
,
20493 bgp_community_list_standard_cmd
,
20494 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20497 "Community list number (standard)\n"
20498 "Add an standard community-list entry\n"
20499 "Community list name\n"
20500 "Sequence number of an entry\n"
20501 "Sequence number\n"
20502 "Specify community to reject\n"
20503 "Specify community to accept\n"
20506 char *cl_name_or_number
= NULL
;
20509 int style
= COMMUNITY_LIST_STANDARD
;
20512 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20513 seq
= argv
[idx
]->arg
;
20516 argv_find(argv
, argc
, "(1-99)", &idx
);
20517 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20518 cl_name_or_number
= argv
[idx
]->arg
;
20519 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20521 argv_find(argv
, argc
, "AA:NN", &idx
);
20522 char *str
= argv_concat(argv
, argc
, idx
);
20524 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20527 XFREE(MTYPE_TMP
, str
);
20530 /* Display error string. */
20531 community_list_perror(vty
, ret
);
20532 return CMD_WARNING_CONFIG_FAILED
;
20535 return CMD_SUCCESS
;
20538 DEFUN (no_community_list_standard_all
,
20539 no_bgp_community_list_standard_all_cmd
,
20540 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20544 "Community list number (standard)\n"
20545 "Add an standard community-list entry\n"
20546 "Community list name\n"
20547 "Sequence number of an entry\n"
20548 "Sequence number\n"
20549 "Specify community to reject\n"
20550 "Specify community to accept\n"
20553 char *cl_name_or_number
= NULL
;
20556 int style
= COMMUNITY_LIST_STANDARD
;
20560 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20561 seq
= argv
[idx
]->arg
;
20564 argv_find(argv
, argc
, "permit", &idx
);
20565 argv_find(argv
, argc
, "deny", &idx
);
20568 direct
= argv_find(argv
, argc
, "permit", &idx
)
20573 argv_find(argv
, argc
, "AA:NN", &idx
);
20574 str
= argv_concat(argv
, argc
, idx
);
20578 argv_find(argv
, argc
, "(1-99)", &idx
);
20579 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20580 cl_name_or_number
= argv
[idx
]->arg
;
20582 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20585 XFREE(MTYPE_TMP
, str
);
20588 community_list_perror(vty
, ret
);
20589 return CMD_WARNING_CONFIG_FAILED
;
20592 return CMD_SUCCESS
;
20595 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20596 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20597 NO_STR BGP_STR COMMUNITY_LIST_STR
20598 "Community list number (standard)\n"
20599 "Add an standard community-list entry\n"
20600 "Community list name\n")
20602 /*community-list expanded */
20603 DEFUN (community_list_expanded_all
,
20604 bgp_community_list_expanded_all_cmd
,
20605 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20608 "Community list number (expanded)\n"
20609 "Add an expanded community-list entry\n"
20610 "Community list name\n"
20611 "Sequence number of an entry\n"
20612 "Sequence number\n"
20613 "Specify community to reject\n"
20614 "Specify community to accept\n"
20617 char *cl_name_or_number
= NULL
;
20620 int style
= COMMUNITY_LIST_EXPANDED
;
20623 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20624 seq
= argv
[idx
]->arg
;
20628 argv_find(argv
, argc
, "(100-500)", &idx
);
20629 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20630 cl_name_or_number
= argv
[idx
]->arg
;
20631 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20633 argv_find(argv
, argc
, "AA:NN", &idx
);
20634 char *str
= argv_concat(argv
, argc
, idx
);
20636 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20639 XFREE(MTYPE_TMP
, str
);
20642 /* Display error string. */
20643 community_list_perror(vty
, ret
);
20644 return CMD_WARNING_CONFIG_FAILED
;
20647 return CMD_SUCCESS
;
20650 DEFUN (no_community_list_expanded_all
,
20651 no_bgp_community_list_expanded_all_cmd
,
20652 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20656 "Community list number (expanded)\n"
20657 "Add an expanded community-list entry\n"
20658 "Community list name\n"
20659 "Sequence number of an entry\n"
20660 "Sequence number\n"
20661 "Specify community to reject\n"
20662 "Specify community to accept\n"
20665 char *cl_name_or_number
= NULL
;
20669 int style
= COMMUNITY_LIST_EXPANDED
;
20672 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20673 seq
= argv
[idx
]->arg
;
20676 argv_find(argv
, argc
, "permit", &idx
);
20677 argv_find(argv
, argc
, "deny", &idx
);
20680 direct
= argv_find(argv
, argc
, "permit", &idx
)
20685 argv_find(argv
, argc
, "AA:NN", &idx
);
20686 str
= argv_concat(argv
, argc
, idx
);
20690 argv_find(argv
, argc
, "(100-500)", &idx
);
20691 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20692 cl_name_or_number
= argv
[idx
]->arg
;
20694 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20697 XFREE(MTYPE_TMP
, str
);
20700 community_list_perror(vty
, ret
);
20701 return CMD_WARNING_CONFIG_FAILED
;
20704 return CMD_SUCCESS
;
20707 ALIAS(no_community_list_expanded_all
,
20708 no_bgp_community_list_expanded_all_list_cmd
,
20709 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20710 NO_STR BGP_STR COMMUNITY_LIST_STR
20711 "Community list number (expanded)\n"
20712 "Add an expanded community-list entry\n"
20713 "Community list name\n")
20715 /* Return configuration string of community-list entry. */
20716 static const char *community_list_config_str(struct community_entry
*entry
)
20723 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20724 str
= community_str(entry
->u
.com
, false, false);
20725 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20726 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20728 str
= entry
->config
;
20733 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20735 struct community_entry
*entry
;
20737 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20738 if (entry
== list
->head
) {
20739 if (all_digit(list
->name
))
20740 vty_out(vty
, "Community %s list %s\n",
20741 entry
->style
== COMMUNITY_LIST_STANDARD
20743 : "(expanded) access",
20746 vty_out(vty
, "Named Community %s list %s\n",
20747 entry
->style
== COMMUNITY_LIST_STANDARD
20753 vty_out(vty
, " %s\n",
20754 community_direct_str(entry
->direct
));
20756 vty_out(vty
, " %s %s\n",
20757 community_direct_str(entry
->direct
),
20758 community_list_config_str(entry
));
20762 DEFUN (show_community_list
,
20763 show_bgp_community_list_cmd
,
20764 "show bgp community-list",
20767 "List community-list\n")
20769 struct community_list
*list
;
20770 struct community_list_master
*cm
;
20772 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20774 return CMD_SUCCESS
;
20776 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20777 community_list_show(vty
, list
);
20779 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20780 community_list_show(vty
, list
);
20782 return CMD_SUCCESS
;
20785 DEFUN (show_community_list_arg
,
20786 show_bgp_community_list_arg_cmd
,
20787 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20790 "List community-list\n"
20791 "Community-list number\n"
20792 "Community-list name\n"
20793 "Detailed information on community-list\n")
20795 int idx_comm_list
= 3;
20796 struct community_list
*list
;
20798 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20799 COMMUNITY_LIST_MASTER
);
20801 vty_out(vty
, "%% Can't find community-list\n");
20802 return CMD_WARNING
;
20805 community_list_show(vty
, list
);
20807 return CMD_SUCCESS
;
20811 * Large Community code.
20813 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20814 struct cmd_token
**argv
, int style
,
20815 int reject_all_digit_name
)
20824 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20825 seq
= argv
[idx
]->arg
;
20828 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20831 /* All digit name check. */
20833 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20834 argv_find(argv
, argc
, "(1-99)", &idx
);
20835 argv_find(argv
, argc
, "(100-500)", &idx
);
20836 cl_name
= argv
[idx
]->arg
;
20837 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20838 vty_out(vty
, "%% Community name cannot have all digits\n");
20839 return CMD_WARNING_CONFIG_FAILED
;
20843 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20844 argv_find(argv
, argc
, "LINE", &idx
);
20845 /* Concat community string argument. */
20847 str
= argv_concat(argv
, argc
, idx
);
20851 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20853 /* Free temporary community list string allocated by
20855 XFREE(MTYPE_TMP
, str
);
20858 community_list_perror(vty
, ret
);
20859 return CMD_WARNING_CONFIG_FAILED
;
20861 return CMD_SUCCESS
;
20864 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20865 struct cmd_token
**argv
, int style
)
20873 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20874 seq
= argv
[idx
]->arg
;
20877 argv_find(argv
, argc
, "permit", &idx
);
20878 argv_find(argv
, argc
, "deny", &idx
);
20881 /* Check the list direct. */
20882 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20883 direct
= COMMUNITY_PERMIT
;
20885 direct
= COMMUNITY_DENY
;
20888 argv_find(argv
, argc
, "LINE", &idx
);
20889 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20890 /* Concat community string argument. */
20891 str
= argv_concat(argv
, argc
, idx
);
20895 argv_find(argv
, argc
, "(1-99)", &idx
);
20896 argv_find(argv
, argc
, "(100-500)", &idx
);
20897 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20899 /* Unset community list. */
20900 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20903 /* Free temporary community list string allocated by
20905 XFREE(MTYPE_TMP
, str
);
20908 community_list_perror(vty
, ret
);
20909 return CMD_WARNING_CONFIG_FAILED
;
20912 return CMD_SUCCESS
;
20915 /* "large-community-list" keyword help string. */
20916 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20917 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20919 DEFUN (lcommunity_list_standard
,
20920 bgp_lcommunity_list_standard_cmd
,
20921 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20923 LCOMMUNITY_LIST_STR
20924 "Large Community list number (standard)\n"
20925 "Sequence number of an entry\n"
20926 "Sequence number\n"
20927 "Specify large community to reject\n"
20928 "Specify large community to accept\n"
20929 LCOMMUNITY_VAL_STR
)
20931 return lcommunity_list_set_vty(vty
, argc
, argv
,
20932 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20935 DEFUN (lcommunity_list_expanded
,
20936 bgp_lcommunity_list_expanded_cmd
,
20937 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20939 LCOMMUNITY_LIST_STR
20940 "Large Community list number (expanded)\n"
20941 "Sequence number of an entry\n"
20942 "Sequence number\n"
20943 "Specify large community to reject\n"
20944 "Specify large community to accept\n"
20945 "An ordered list as a regular-expression\n")
20947 return lcommunity_list_set_vty(vty
, argc
, argv
,
20948 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20951 DEFUN (lcommunity_list_name_standard
,
20952 bgp_lcommunity_list_name_standard_cmd
,
20953 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20955 LCOMMUNITY_LIST_STR
20956 "Specify standard large-community-list\n"
20957 "Large Community list name\n"
20958 "Sequence number of an entry\n"
20959 "Sequence number\n"
20960 "Specify large community to reject\n"
20961 "Specify large community to accept\n"
20962 LCOMMUNITY_VAL_STR
)
20964 return lcommunity_list_set_vty(vty
, argc
, argv
,
20965 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20968 DEFUN (lcommunity_list_name_expanded
,
20969 bgp_lcommunity_list_name_expanded_cmd
,
20970 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20972 LCOMMUNITY_LIST_STR
20973 "Specify expanded large-community-list\n"
20974 "Large Community list name\n"
20975 "Sequence number of an entry\n"
20976 "Sequence number\n"
20977 "Specify large community to reject\n"
20978 "Specify large community to accept\n"
20979 "An ordered list as a regular-expression\n")
20981 return lcommunity_list_set_vty(vty
, argc
, argv
,
20982 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20985 DEFUN (no_lcommunity_list_all
,
20986 no_bgp_lcommunity_list_all_cmd
,
20987 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20990 LCOMMUNITY_LIST_STR
20991 "Large Community list number (standard)\n"
20992 "Large Community list number (expanded)\n"
20993 "Large Community list name\n")
20995 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20996 LARGE_COMMUNITY_LIST_STANDARD
);
20999 DEFUN (no_lcommunity_list_name_standard_all
,
21000 no_bgp_lcommunity_list_name_standard_all_cmd
,
21001 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
21004 LCOMMUNITY_LIST_STR
21005 "Specify standard large-community-list\n"
21006 "Large Community list name\n")
21008 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21009 LARGE_COMMUNITY_LIST_STANDARD
);
21012 DEFUN (no_lcommunity_list_name_expanded_all
,
21013 no_bgp_lcommunity_list_name_expanded_all_cmd
,
21014 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
21017 LCOMMUNITY_LIST_STR
21018 "Specify expanded large-community-list\n"
21019 "Large Community list name\n")
21021 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21022 LARGE_COMMUNITY_LIST_EXPANDED
);
21025 DEFUN (no_lcommunity_list_standard
,
21026 no_bgp_lcommunity_list_standard_cmd
,
21027 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
21030 LCOMMUNITY_LIST_STR
21031 "Large Community list number (standard)\n"
21032 "Sequence number of an entry\n"
21033 "Sequence number\n"
21034 "Specify large community to reject\n"
21035 "Specify large community to accept\n"
21036 LCOMMUNITY_VAL_STR
)
21038 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21039 LARGE_COMMUNITY_LIST_STANDARD
);
21042 DEFUN (no_lcommunity_list_expanded
,
21043 no_bgp_lcommunity_list_expanded_cmd
,
21044 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
21047 LCOMMUNITY_LIST_STR
21048 "Large Community list number (expanded)\n"
21049 "Sequence number of an entry\n"
21050 "Sequence number\n"
21051 "Specify large community to reject\n"
21052 "Specify large community to accept\n"
21053 "An ordered list as a regular-expression\n")
21055 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21056 LARGE_COMMUNITY_LIST_EXPANDED
);
21059 DEFUN (no_lcommunity_list_name_standard
,
21060 no_bgp_lcommunity_list_name_standard_cmd
,
21061 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
21064 LCOMMUNITY_LIST_STR
21065 "Specify standard large-community-list\n"
21066 "Large Community list name\n"
21067 "Sequence number of an entry\n"
21068 "Sequence number\n"
21069 "Specify large community to reject\n"
21070 "Specify large community to accept\n"
21071 LCOMMUNITY_VAL_STR
)
21073 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21074 LARGE_COMMUNITY_LIST_STANDARD
);
21077 DEFUN (no_lcommunity_list_name_expanded
,
21078 no_bgp_lcommunity_list_name_expanded_cmd
,
21079 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
21082 LCOMMUNITY_LIST_STR
21083 "Specify expanded large-community-list\n"
21084 "Large community list name\n"
21085 "Sequence number of an entry\n"
21086 "Sequence number\n"
21087 "Specify large community to reject\n"
21088 "Specify large community to accept\n"
21089 "An ordered list as a regular-expression\n")
21091 return lcommunity_list_unset_vty(vty
, argc
, argv
,
21092 LARGE_COMMUNITY_LIST_EXPANDED
);
21095 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21097 struct community_entry
*entry
;
21099 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21100 if (entry
== list
->head
) {
21101 if (all_digit(list
->name
))
21102 vty_out(vty
, "Large community %s list %s\n",
21104 LARGE_COMMUNITY_LIST_STANDARD
21106 : "(expanded) access",
21110 "Named large community %s list %s\n",
21112 LARGE_COMMUNITY_LIST_STANDARD
21118 vty_out(vty
, " %s\n",
21119 community_direct_str(entry
->direct
));
21121 vty_out(vty
, " %s %s\n",
21122 community_direct_str(entry
->direct
),
21123 community_list_config_str(entry
));
21127 DEFUN (show_lcommunity_list
,
21128 show_bgp_lcommunity_list_cmd
,
21129 "show bgp large-community-list",
21132 "List large-community list\n")
21134 struct community_list
*list
;
21135 struct community_list_master
*cm
;
21137 cm
= community_list_master_lookup(bgp_clist
,
21138 LARGE_COMMUNITY_LIST_MASTER
);
21140 return CMD_SUCCESS
;
21142 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21143 lcommunity_list_show(vty
, list
);
21145 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21146 lcommunity_list_show(vty
, list
);
21148 return CMD_SUCCESS
;
21151 DEFUN (show_lcommunity_list_arg
,
21152 show_bgp_lcommunity_list_arg_cmd
,
21153 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
21156 "List large-community list\n"
21157 "Large-community-list number\n"
21158 "Large-community-list name\n"
21159 "Detailed information on large-community-list\n")
21161 struct community_list
*list
;
21163 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
21164 LARGE_COMMUNITY_LIST_MASTER
);
21166 vty_out(vty
, "%% Can't find large-community-list\n");
21167 return CMD_WARNING
;
21170 lcommunity_list_show(vty
, list
);
21172 return CMD_SUCCESS
;
21175 /* "extcommunity-list" keyword help string. */
21176 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
21177 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
21179 DEFUN (extcommunity_list_standard
,
21180 bgp_extcommunity_list_standard_cmd
,
21181 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21183 EXTCOMMUNITY_LIST_STR
21184 "Extended Community list number (standard)\n"
21185 "Specify standard extcommunity-list\n"
21186 "Community list name\n"
21187 "Sequence number of an entry\n"
21188 "Sequence number\n"
21189 "Specify community to reject\n"
21190 "Specify community to accept\n"
21191 EXTCOMMUNITY_VAL_STR
)
21193 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21195 char *cl_number_or_name
= NULL
;
21200 argv_find(argv
, argc
, "(1-99)", &idx
);
21201 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21202 cl_number_or_name
= argv
[idx
]->arg
;
21204 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21205 seq
= argv
[idx
]->arg
;
21207 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21209 argv_find(argv
, argc
, "AA:NN", &idx
);
21210 char *str
= argv_concat(argv
, argc
, idx
);
21212 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21215 XFREE(MTYPE_TMP
, str
);
21218 community_list_perror(vty
, ret
);
21219 return CMD_WARNING_CONFIG_FAILED
;
21222 return CMD_SUCCESS
;
21225 DEFUN (extcommunity_list_name_expanded
,
21226 bgp_extcommunity_list_name_expanded_cmd
,
21227 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21229 EXTCOMMUNITY_LIST_STR
21230 "Extended Community list number (expanded)\n"
21231 "Specify expanded extcommunity-list\n"
21232 "Extended Community list name\n"
21233 "Sequence number of an entry\n"
21234 "Sequence number\n"
21235 "Specify community to reject\n"
21236 "Specify community to accept\n"
21237 "An ordered list as a regular-expression\n")
21239 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21241 char *cl_number_or_name
= NULL
;
21245 argv_find(argv
, argc
, "(100-500)", &idx
);
21246 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21247 cl_number_or_name
= argv
[idx
]->arg
;
21249 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21250 seq
= argv
[idx
]->arg
;
21252 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21254 argv_find(argv
, argc
, "LINE", &idx
);
21255 char *str
= argv_concat(argv
, argc
, idx
);
21257 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21260 XFREE(MTYPE_TMP
, str
);
21263 community_list_perror(vty
, ret
);
21264 return CMD_WARNING_CONFIG_FAILED
;
21267 return CMD_SUCCESS
;
21270 DEFUN (no_extcommunity_list_standard_all
,
21271 no_bgp_extcommunity_list_standard_all_cmd
,
21272 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21275 EXTCOMMUNITY_LIST_STR
21276 "Extended Community list number (standard)\n"
21277 "Specify standard extcommunity-list\n"
21278 "Community list name\n"
21279 "Sequence number of an entry\n"
21280 "Sequence number\n"
21281 "Specify community to reject\n"
21282 "Specify community to accept\n"
21283 EXTCOMMUNITY_VAL_STR
)
21285 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21287 char *cl_number_or_name
= NULL
;
21292 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21293 seq
= argv
[idx
]->arg
;
21296 argv_find(argv
, argc
, "permit", &idx
);
21297 argv_find(argv
, argc
, "deny", &idx
);
21299 direct
= argv_find(argv
, argc
, "permit", &idx
)
21304 argv_find(argv
, argc
, "AA:NN", &idx
);
21305 str
= argv_concat(argv
, argc
, idx
);
21309 argv_find(argv
, argc
, "(1-99)", &idx
);
21310 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21311 cl_number_or_name
= argv
[idx
]->arg
;
21313 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21314 seq
, direct
, style
);
21316 XFREE(MTYPE_TMP
, str
);
21319 community_list_perror(vty
, ret
);
21320 return CMD_WARNING_CONFIG_FAILED
;
21323 return CMD_SUCCESS
;
21326 ALIAS(no_extcommunity_list_standard_all
,
21327 no_bgp_extcommunity_list_standard_all_list_cmd
,
21328 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21329 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21330 "Extended Community list number (standard)\n"
21331 "Specify standard extcommunity-list\n"
21332 "Community list name\n")
21334 DEFUN (no_extcommunity_list_expanded_all
,
21335 no_bgp_extcommunity_list_expanded_all_cmd
,
21336 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21339 EXTCOMMUNITY_LIST_STR
21340 "Extended Community list number (expanded)\n"
21341 "Specify expanded extcommunity-list\n"
21342 "Extended Community list name\n"
21343 "Sequence number of an entry\n"
21344 "Sequence number\n"
21345 "Specify community to reject\n"
21346 "Specify community to accept\n"
21347 "An ordered list as a regular-expression\n")
21349 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21351 char *cl_number_or_name
= NULL
;
21356 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21357 seq
= argv
[idx
]->arg
;
21360 argv_find(argv
, argc
, "permit", &idx
);
21361 argv_find(argv
, argc
, "deny", &idx
);
21364 direct
= argv_find(argv
, argc
, "permit", &idx
)
21369 argv_find(argv
, argc
, "LINE", &idx
);
21370 str
= argv_concat(argv
, argc
, idx
);
21374 argv_find(argv
, argc
, "(100-500)", &idx
);
21375 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21376 cl_number_or_name
= argv
[idx
]->arg
;
21378 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21379 seq
, direct
, style
);
21381 XFREE(MTYPE_TMP
, str
);
21384 community_list_perror(vty
, ret
);
21385 return CMD_WARNING_CONFIG_FAILED
;
21388 return CMD_SUCCESS
;
21391 ALIAS(no_extcommunity_list_expanded_all
,
21392 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21393 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21394 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21395 "Extended Community list number (expanded)\n"
21396 "Specify expanded extcommunity-list\n"
21397 "Extended Community list name\n")
21399 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21401 struct community_entry
*entry
;
21403 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21404 if (entry
== list
->head
) {
21405 if (all_digit(list
->name
))
21406 vty_out(vty
, "Extended community %s list %s\n",
21407 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21409 : "(expanded) access",
21413 "Named extended community %s list %s\n",
21414 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21420 vty_out(vty
, " %s\n",
21421 community_direct_str(entry
->direct
));
21423 vty_out(vty
, " %s %s\n",
21424 community_direct_str(entry
->direct
),
21425 community_list_config_str(entry
));
21429 DEFUN (show_extcommunity_list
,
21430 show_bgp_extcommunity_list_cmd
,
21431 "show bgp extcommunity-list",
21434 "List extended-community list\n")
21436 struct community_list
*list
;
21437 struct community_list_master
*cm
;
21439 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21441 return CMD_SUCCESS
;
21443 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21444 extcommunity_list_show(vty
, list
);
21446 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21447 extcommunity_list_show(vty
, list
);
21449 return CMD_SUCCESS
;
21452 DEFUN (show_extcommunity_list_arg
,
21453 show_bgp_extcommunity_list_arg_cmd
,
21454 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21457 "List extended-community list\n"
21458 "Extcommunity-list number\n"
21459 "Extcommunity-list name\n"
21460 "Detailed information on extcommunity-list\n")
21462 int idx_comm_list
= 3;
21463 struct community_list
*list
;
21465 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21466 EXTCOMMUNITY_LIST_MASTER
);
21468 vty_out(vty
, "%% Can't find extcommunity-list\n");
21469 return CMD_WARNING
;
21472 extcommunity_list_show(vty
, list
);
21474 return CMD_SUCCESS
;
21477 /* Display community-list and extcommunity-list configuration. */
21478 static int community_list_config_write(struct vty
*vty
)
21480 struct community_list
*list
;
21481 struct community_entry
*entry
;
21482 struct community_list_master
*cm
;
21485 /* Community-list. */
21486 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21488 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21489 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21491 "bgp community-list %s seq %" PRId64
" %s %s\n",
21492 list
->name
, entry
->seq
,
21493 community_direct_str(entry
->direct
),
21494 community_list_config_str(entry
));
21497 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21498 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21500 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21501 entry
->style
== COMMUNITY_LIST_STANDARD
21504 list
->name
, entry
->seq
,
21505 community_direct_str(entry
->direct
),
21506 community_list_config_str(entry
));
21510 /* Extcommunity-list. */
21511 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21513 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21514 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21516 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21517 list
->name
, entry
->seq
,
21518 community_direct_str(entry
->direct
),
21519 community_list_config_str(entry
));
21522 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21523 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21525 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21526 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21529 list
->name
, entry
->seq
,
21530 community_direct_str(entry
->direct
),
21531 community_list_config_str(entry
));
21536 /* lcommunity-list. */
21537 cm
= community_list_master_lookup(bgp_clist
,
21538 LARGE_COMMUNITY_LIST_MASTER
);
21540 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21541 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21543 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21544 list
->name
, entry
->seq
,
21545 community_direct_str(entry
->direct
),
21546 community_list_config_str(entry
));
21549 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21550 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21552 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21554 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21557 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21558 community_list_config_str(entry
));
21565 static int community_list_config_write(struct vty
*vty
);
21566 static struct cmd_node community_list_node
= {
21567 .name
= "community list",
21568 .node
= COMMUNITY_LIST_NODE
,
21570 .config_write
= community_list_config_write
,
21573 static void community_list_vty(void)
21575 install_node(&community_list_node
);
21577 /* Community-list. */
21578 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21579 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21580 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21581 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21582 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21583 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21584 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21585 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21587 /* Extcommunity-list. */
21588 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21589 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21590 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21591 install_element(CONFIG_NODE
,
21592 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21593 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21594 install_element(CONFIG_NODE
,
21595 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21596 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21597 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21599 /* Large Community List */
21600 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21601 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21602 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21603 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21604 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21605 install_element(CONFIG_NODE
,
21606 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21607 install_element(CONFIG_NODE
,
21608 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21609 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21610 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21611 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21612 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21613 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21614 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21616 bgp_community_list_command_completion_setup();
21619 static struct cmd_node community_alias_node
= {
21620 .name
= "community alias",
21621 .node
= COMMUNITY_ALIAS_NODE
,
21623 .config_write
= bgp_community_alias_write
,
21626 void community_alias_vty(void)
21628 install_node(&community_alias_node
);
21630 /* Community-list. */
21631 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21633 bgp_community_alias_command_completion_setup();