2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
163 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
166 afi_t afi
, bool use_json
);
168 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
174 return BGP_IPV4_NODE
;
176 return BGP_IPV4M_NODE
;
177 case SAFI_LABELED_UNICAST
:
178 return BGP_IPV4L_NODE
;
180 return BGP_VPNV4_NODE
;
182 return BGP_FLOWSPECV4_NODE
;
185 return BGP_IPV4_NODE
;
190 return BGP_IPV6_NODE
;
192 return BGP_IPV6M_NODE
;
193 case SAFI_LABELED_UNICAST
:
194 return BGP_IPV6L_NODE
;
196 return BGP_VPNV6_NODE
;
198 return BGP_FLOWSPECV6_NODE
;
201 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* unset srv6 locator */
294 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
297 struct listnode
*node
, *nnode
;
298 struct srv6_locator_chunk
*chunk
;
299 struct bgp_srv6_function
*func
;
301 struct in6_addr
*tovpn_sid
;
303 /* release chunk notification via ZAPI */
304 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
305 bgp
->srv6_locator_name
);
310 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
311 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
312 srv6_locator_chunk_free(chunk
);
315 /* refresh functions */
316 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
317 listnode_delete(bgp
->srv6_functions
, func
);
318 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
321 /* refresh tovpn_sid */
322 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
323 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
326 /* refresh vpnv4 tovpn_sid */
327 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
;
329 XFREE(MTYPE_BGP_SRV6_SID
,
330 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
332 /* refresh vpnv6 tovpn_sid */
333 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
;
335 XFREE(MTYPE_BGP_SRV6_SID
,
336 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
339 /* update vpn bgp processes */
340 vpn_leak_postchange_all();
342 /* refresh tovpn_sid_locator */
343 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
344 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
347 /* refresh vpnv4 tovpn_sid_locator */
348 XFREE(MTYPE_BGP_SRV6_SID
,
349 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
351 /* refresh vpnv6 tovpn_sid_locator */
352 XFREE(MTYPE_BGP_SRV6_SID
,
353 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
356 /* clear locator name */
357 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
362 /* Utility function to get address family from current node. */
363 afi_t
bgp_node_afi(struct vty
*vty
)
371 case BGP_FLOWSPECV6_NODE
:
384 /* Utility function to get subsequent address family from current
386 safi_t
bgp_node_safi(struct vty
*vty
)
392 safi
= SAFI_MPLS_VPN
;
396 safi
= SAFI_MULTICAST
;
403 safi
= SAFI_LABELED_UNICAST
;
405 case BGP_FLOWSPECV4_NODE
:
406 case BGP_FLOWSPECV6_NODE
:
407 safi
= SAFI_FLOWSPEC
;
417 * Converts an AFI in string form to afi_t
419 * @param afi string, one of
423 * @return the corresponding afi_t
425 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
427 afi_t afi
= AFI_MAX
; /* unknown */
428 if (strmatch(afi_str
, "ipv4"))
430 else if (strmatch(afi_str
, "ipv6"))
432 else if (strmatch(afi_str
, "l2vpn"))
437 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
441 if (argv_find(argv
, argc
, "ipv4", index
)) {
445 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
449 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
457 /* supports <unicast|multicast|vpn|labeled-unicast> */
458 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
460 safi_t safi
= SAFI_MAX
; /* unknown */
461 if (strmatch(safi_str
, "multicast"))
462 safi
= SAFI_MULTICAST
;
463 else if (strmatch(safi_str
, "unicast"))
465 else if (strmatch(safi_str
, "vpn"))
466 safi
= SAFI_MPLS_VPN
;
467 else if (strmatch(safi_str
, "evpn"))
469 else if (strmatch(safi_str
, "labeled-unicast"))
470 safi
= SAFI_LABELED_UNICAST
;
471 else if (strmatch(safi_str
, "flowspec"))
472 safi
= SAFI_FLOWSPEC
;
476 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
480 if (argv_find(argv
, argc
, "unicast", index
)) {
483 *safi
= SAFI_UNICAST
;
484 } else if (argv_find(argv
, argc
, "multicast", index
)) {
487 *safi
= SAFI_MULTICAST
;
488 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
491 *safi
= SAFI_LABELED_UNICAST
;
492 } else if (argv_find(argv
, argc
, "vpn", index
)) {
495 *safi
= SAFI_MPLS_VPN
;
496 } else if (argv_find(argv
, argc
, "evpn", index
)) {
500 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
503 *safi
= SAFI_FLOWSPEC
;
509 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
512 * address-family identifier
515 * subsequent address-family identifier
518 * default_af string corresponding to the supplied afi/safi pair.
519 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
522 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
528 return "ipv4-unicast";
530 return "ipv4-multicast";
535 case SAFI_LABELED_UNICAST
:
536 return "ipv4-labeled-unicast";
538 return "ipv4-flowspec";
540 return "unknown-afi/safi";
546 return "ipv6-unicast";
548 return "ipv6-multicast";
553 case SAFI_LABELED_UNICAST
:
554 return "ipv6-labeled-unicast";
556 return "ipv6-flowspec";
558 return "unknown-afi/safi";
566 return "unknown-afi/safi";
570 return "unknown-afi/safi";
572 /* all AFIs are accounted for above, so this shouldn't happen */
573 return "unknown-afi/safi";
576 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
577 enum bgp_instance_type inst_type
)
579 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
581 if (ret
== BGP_CREATED
) {
582 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
583 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
585 if (DFLT_BGP_IMPORT_CHECK
)
586 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
587 if (DFLT_BGP_SHOW_HOSTNAME
)
588 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
589 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
590 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
591 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
592 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
593 if (DFLT_BGP_DETERMINISTIC_MED
)
594 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
595 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
596 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
597 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
598 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
599 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
600 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
601 if (DFLT_BGP_HARD_ADMIN_RESET
)
602 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
610 * bgp_vty_find_and_parse_afi_safi_bgp
612 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
613 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
614 * to appropriate values for the calling function. This is to allow the
615 * calling function to make decisions appropriate for the show command
616 * that is being parsed.
618 * The show commands are generally of the form:
619 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
620 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
622 * Since we use argv_find if the show command in particular doesn't have:
624 * [<view|vrf> VIEWVRFNAME]
625 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
626 * The command parsing should still be ok.
628 * vty -> The vty for the command so we can output some useful data in
629 * the event of a parse error in the vrf.
630 * argv -> The command tokens
631 * argc -> How many command tokens we have
632 * idx -> The current place in the command, generally should be 0 for this
634 * afi -> The parsed afi if it was included in the show command, returned here
635 * safi -> The parsed safi if it was included in the show command, returned here
636 * bgp -> Pointer to the bgp data structure we need to fill in.
637 * use_json -> json is configured or not
639 * The function returns the correct location in the parse tree for the
642 * Returns 0 for failure to parse correctly, else the idx position of where
643 * it found the last token.
645 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
646 struct cmd_token
**argv
, int argc
,
647 int *idx
, afi_t
*afi
, safi_t
*safi
,
648 struct bgp
**bgp
, bool use_json
)
650 char *vrf_name
= NULL
;
656 if (argv_find(argv
, argc
, "ip", idx
))
659 if (argv_find(argv
, argc
, "view", idx
))
660 vrf_name
= argv
[*idx
+ 1]->arg
;
661 else if (argv_find(argv
, argc
, "vrf", idx
)) {
662 vrf_name
= argv
[*idx
+ 1]->arg
;
663 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
667 if (strmatch(vrf_name
, "all"))
670 *bgp
= bgp_lookup_by_name(vrf_name
);
673 json_object
*json
= NULL
;
674 json
= json_object_new_object();
675 json_object_string_add(
677 "View/Vrf is unknown");
681 vty_out(vty
, "View/Vrf %s is unknown\n",
688 *bgp
= bgp_get_default();
691 json_object
*json
= NULL
;
692 json
= json_object_new_object();
693 json_object_string_add(
695 "Default BGP instance not found");
700 "Default BGP instance not found\n");
706 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
707 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
713 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
715 struct interface
*ifp
= NULL
;
716 struct listnode
*node
;
717 struct bgp_listener
*listener
;
718 union sockunion all_su
;
720 if (su
->sa
.sa_family
== AF_INET
) {
721 (void)str2sockunion("0.0.0.0", &all_su
);
722 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
723 } else if (su
->sa
.sa_family
== AF_INET6
) {
724 (void)str2sockunion("::", &all_su
);
725 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
726 su
->sin6
.sin6_scope_id
,
731 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
732 if (sockunion_family(su
) !=
733 sockunion_family(&listener
->su
))
736 /* If 0.0.0.0/:: is a listener, then treat as self and
739 if (!sockunion_cmp(&listener
->su
, su
) ||
740 !sockunion_cmp(&listener
->su
, &all_su
))
748 /* Utility function for looking up peer from VTY. */
749 /* This is used only for configuration, so disallow if attempted on
750 * a dynamic neighbor.
752 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
754 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
763 ret
= str2sockunion(ip_str
, &su
);
765 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
767 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
770 "%% Malformed address or name: %s\n",
776 peer
= peer_lookup(bgp
, &su
);
779 "%% Specify remote-as or peer-group commands first\n");
782 if (peer_dynamic_neighbor(peer
)) {
784 "%% Operation not allowed on a dynamic neighbor\n");
791 /* Utility function for looking up peer or peer group. */
792 /* This is used only for configuration, so disallow if attempted on
793 * a dynamic neighbor.
795 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
797 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
800 struct peer
*peer
= NULL
;
801 struct peer_group
*group
= NULL
;
807 ret
= str2sockunion(peer_str
, &su
);
809 /* IP address, locate peer. */
810 peer
= peer_lookup(bgp
, &su
);
812 /* Not IP, could match either peer configured on interface or a
814 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
816 group
= peer_group_lookup(bgp
, peer_str
);
820 if (peer_dynamic_neighbor(peer
)) {
822 "%% Operation not allowed on a dynamic neighbor\n");
832 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
837 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
839 const char *str
= NULL
;
844 case BGP_GR_NO_OPERATION
:
846 case BGP_ERR_INVALID_VALUE
:
847 str
= "Invalid value";
849 case BGP_ERR_INVALID_FLAG
:
850 str
= "Invalid flag";
852 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
853 str
= "Peer-group has been shutdown. Activate the peer-group first";
855 case BGP_ERR_PEER_FLAG_CONFLICT
:
856 str
= "Can't set override-capability and strict-capability-match at the same time";
858 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
859 str
= "Specify remote-as or peer-group remote AS first";
861 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
862 str
= "Cannot change the peer-group. Deconfigure first";
864 case BGP_ERR_PEER_GROUP_MISMATCH
:
865 str
= "Peer is not a member of this peer-group";
867 case BGP_ERR_PEER_FILTER_CONFLICT
:
868 str
= "Prefix/distribute list can not co-exist";
870 case BGP_ERR_NOT_INTERNAL_PEER
:
871 str
= "Invalid command. Not an internal neighbor";
873 case BGP_ERR_REMOVE_PRIVATE_AS
:
874 str
= "remove-private-AS cannot be configured for IBGP peers";
876 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
877 str
= "Cannot have local-as same as BGP AS number";
879 case BGP_ERR_TCPSIG_FAILED
:
880 str
= "Error while applying TCP-Sig to session(s)";
882 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
883 str
= "ebgp-multihop and ttl-security cannot be configured together";
885 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
886 str
= "ttl-security only allowed for EBGP peers";
888 case BGP_ERR_AS_OVERRIDE
:
889 str
= "as-override cannot be configured for IBGP peers";
891 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
892 str
= "Invalid limit for number of dynamic neighbors";
894 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
895 str
= "Dynamic neighbor listen range already exists";
897 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
898 str
= "Operation not allowed on a dynamic neighbor";
900 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
901 str
= "Operation not allowed on a directly connected neighbor";
903 case BGP_ERR_PEER_SAFI_CONFLICT
:
904 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
906 case BGP_ERR_GR_INVALID_CMD
:
907 str
= "The Graceful Restart command used is not valid at this moment.";
909 case BGP_ERR_GR_OPERATION_FAILED
:
910 str
= "The Graceful Restart Operation failed due to an err.";
912 case BGP_ERR_PEER_GROUP_MEMBER
:
913 str
= "Peer-group member cannot override remote-as of peer-group.";
915 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
916 str
= "Peer-group members must be all internal or all external.";
918 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
919 str
= "Range specified cannot be deleted because it is not part of current config.";
921 case BGP_ERR_INSTANCE_MISMATCH
:
922 str
= "Instance specified does not match the current instance.";
924 case BGP_ERR_NO_INTERFACE_CONFIG
:
925 str
= "Interface specified is not being used for interface based peer.";
927 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
928 str
= "No configuration already specified for soft reconfiguration.";
930 case BGP_ERR_AS_MISMATCH
:
931 str
= "BGP is already running.";
933 case BGP_ERR_AF_UNCONFIGURED
:
934 str
= "AFI/SAFI specified is not currently configured.";
936 case BGP_ERR_INVALID_AS
:
937 str
= "Confederation AS specified is the same AS as our AS.";
939 case BGP_ERR_INVALID_ROLE_NAME
:
940 str
= "Invalid role name";
942 case BGP_ERR_INVALID_INTERNAL_ROLE
:
943 str
= "External roles can be set only on eBGP session";
947 vty_out(vty
, "%% %s\n", str
);
948 return CMD_WARNING_CONFIG_FAILED
;
953 /* BGP clear sort. */
962 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
963 safi_t safi
, int error
)
966 case BGP_ERR_AF_UNCONFIGURED
:
969 "%% BGP: Enable %s address family for the neighbor %s\n",
970 get_afi_safi_str(afi
, safi
, false), peer
->host
);
973 "%% BGP: Enable %s address family for the neighbor %s",
974 get_afi_safi_str(afi
, safi
, false), peer
->host
);
976 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
979 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
983 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
991 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
992 struct listnode
**nnode
, enum bgp_clear_type stype
)
997 /* if afi/.safi not specified, spin thru all of them */
998 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1001 enum bgp_af_index index
;
1003 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1004 paf
= peer
->peer_af_array
[index
];
1008 if (paf
&& paf
->subgroup
)
1009 SET_FLAG(paf
->subgroup
->sflags
,
1010 SUBGRP_STATUS_FORCE_UPDATES
);
1013 tmp_safi
= paf
->safi
;
1014 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1017 if (stype
== BGP_CLEAR_SOFT_NONE
)
1018 ret
= peer_clear(peer
, nnode
);
1020 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1023 /* if afi specified and safi not, spin thru safis on this afi */
1024 } else if (safi
== SAFI_UNSPEC
) {
1027 for (tmp_safi
= SAFI_UNICAST
;
1028 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1029 if (!peer
->afc
[afi
][tmp_safi
])
1032 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1033 if (paf
&& paf
->subgroup
)
1034 SET_FLAG(paf
->subgroup
->sflags
,
1035 SUBGRP_STATUS_FORCE_UPDATES
);
1037 if (stype
== BGP_CLEAR_SOFT_NONE
)
1038 ret
= peer_clear(peer
, nnode
);
1040 ret
= peer_clear_soft(peer
, afi
,
1043 /* both afi/safi specified, let the caller know if not defined */
1045 if (!peer
->afc
[afi
][safi
])
1048 paf
= peer_af_find(peer
, afi
, safi
);
1049 if (paf
&& paf
->subgroup
)
1050 SET_FLAG(paf
->subgroup
->sflags
,
1051 SUBGRP_STATUS_FORCE_UPDATES
);
1053 if (stype
== BGP_CLEAR_SOFT_NONE
)
1054 ret
= peer_clear(peer
, nnode
);
1056 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1062 /* `clear ip bgp' functions. */
1063 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1064 enum clear_sort sort
, enum bgp_clear_type stype
,
1071 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1073 /* Clear all neighbors. */
1075 * Pass along pointer to next node to peer_clear() when walking all
1076 * nodes on the BGP instance as that may get freed if it is a
1079 if (sort
== clear_all
) {
1080 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1082 bgp_peer_gr_flags_update(peer
);
1084 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1085 gr_router_detected
= true;
1087 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1091 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1094 if (gr_router_detected
1095 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1096 bgp_zebra_send_capabilities(bgp
, false);
1097 } else if (!gr_router_detected
1098 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1099 bgp_zebra_send_capabilities(bgp
, true);
1102 /* This is to apply read-only mode on this clear. */
1103 if (stype
== BGP_CLEAR_SOFT_NONE
)
1104 bgp
->update_delay_over
= 0;
1109 /* Clear specified neighbor. */
1110 if (sort
== clear_peer
) {
1113 /* Make sockunion for lookup. */
1114 ret
= str2sockunion(arg
, &su
);
1116 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1118 peer
= peer_lookup_by_hostname(bgp
, arg
);
1121 "Malformed address or name: %s\n",
1127 peer
= peer_lookup(bgp
, &su
);
1130 "%% BGP: Unknown neighbor - \"%s\"\n",
1136 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1137 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1139 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1141 /* if afi/safi not defined for this peer, let caller know */
1143 ret
= BGP_ERR_AF_UNCONFIGURED
;
1146 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1151 /* Clear all neighbors belonging to a specific peer-group. */
1152 if (sort
== clear_group
) {
1153 struct peer_group
*group
;
1155 group
= peer_group_lookup(bgp
, arg
);
1157 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1161 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1162 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1165 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1172 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1173 get_afi_safi_str(afi
, safi
, false), arg
);
1178 /* Clear all external (eBGP) neighbors. */
1179 if (sort
== clear_external
) {
1180 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1181 if (peer
->sort
== BGP_PEER_IBGP
)
1184 bgp_peer_gr_flags_update(peer
);
1186 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1187 gr_router_detected
= true;
1189 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1192 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1197 if (gr_router_detected
1198 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1199 bgp_zebra_send_capabilities(bgp
, false);
1200 } else if (!gr_router_detected
1201 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1202 bgp_zebra_send_capabilities(bgp
, true);
1207 "%% BGP: No external %s peer is configured\n",
1208 get_afi_safi_str(afi
, safi
, false));
1213 /* Clear all neighbors belonging to a specific AS. */
1214 if (sort
== clear_as
) {
1215 as_t as
= strtoul(arg
, NULL
, 10);
1217 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1221 bgp_peer_gr_flags_update(peer
);
1223 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1224 gr_router_detected
= true;
1226 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1229 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1234 if (gr_router_detected
1235 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1236 bgp_zebra_send_capabilities(bgp
, false);
1237 } else if (!gr_router_detected
1238 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1239 bgp_zebra_send_capabilities(bgp
, true);
1244 "%% BGP: No %s peer is configured with AS %s\n",
1245 get_afi_safi_str(afi
, safi
, false), arg
);
1253 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1254 safi_t safi
, enum clear_sort sort
,
1255 enum bgp_clear_type stype
, const char *arg
)
1259 /* BGP structure lookup. */
1261 bgp
= bgp_lookup_by_name(name
);
1263 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1267 bgp
= bgp_get_default();
1269 vty_out(vty
, "No BGP process is configured\n");
1274 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1277 /* clear soft inbound */
1278 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1283 FOREACH_AFI_SAFI (afi
, safi
)
1284 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1285 BGP_CLEAR_SOFT_IN
, NULL
);
1288 /* clear soft outbound */
1289 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1294 FOREACH_AFI_SAFI (afi
, safi
)
1295 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1296 BGP_CLEAR_SOFT_OUT
, NULL
);
1300 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1302 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1305 #ifndef VTYSH_EXTRACT_PL
1306 #include "bgpd/bgp_vty_clippy.c"
1309 DEFUN_HIDDEN (bgp_local_mac
,
1311 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1313 "Local MAC config\n"
1314 "VxLAN Network Identifier\n"
1318 "mac-mobility sequence\n"
1328 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1329 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1330 vty_out(vty
, "%% Malformed MAC address\n");
1333 memset(&ip
, 0, sizeof(ip
));
1334 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1336 bgp
= bgp_get_default();
1338 vty_out(vty
, "Default BGP instance is not there\n");
1342 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1345 vty_out(vty
, "Internal error\n");
1352 DEFUN_HIDDEN (no_bgp_local_mac
,
1353 no_bgp_local_mac_cmd
,
1354 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1357 "Local MAC config\n"
1358 "VxLAN Network Identifier\n"
1369 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1370 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1371 vty_out(vty
, "%% Malformed MAC address\n");
1374 memset(&ip
, 0, sizeof(ip
));
1376 bgp
= bgp_get_default();
1378 vty_out(vty
, "Default BGP instance is not there\n");
1382 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1384 vty_out(vty
, "Internal error\n");
1391 DEFUN (no_synchronization
,
1392 no_synchronization_cmd
,
1393 "no synchronization",
1395 "Perform IGP synchronization\n")
1400 DEFUN (no_auto_summary
,
1401 no_auto_summary_cmd
,
1404 "Enable automatic network number summarization\n")
1409 /* "router bgp" commands. */
1410 DEFUN_NOSH (router_bgp
,
1412 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1416 BGP_INSTANCE_HELP_STR
)
1419 int idx_view_vrf
= 3;
1425 const char *name
= NULL
;
1426 enum bgp_instance_type inst_type
;
1428 // "router bgp" without an ASN
1430 // Pending: Make VRF option available for ASN less config
1431 bgp
= bgp_get_default();
1434 vty_out(vty
, "%% No BGP process is configured\n");
1435 return CMD_WARNING_CONFIG_FAILED
;
1438 if (listcount(bm
->bgp
) > 1) {
1439 vty_out(vty
, "%% Please specify ASN and VRF\n");
1440 return CMD_WARNING_CONFIG_FAILED
;
1446 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1448 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1449 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1450 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1452 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1454 name
= argv
[idx_vrf
]->arg
;
1456 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1457 if (strmatch(name
, VRF_DEFAULT_NAME
))
1460 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1461 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1462 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1465 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1466 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1468 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1470 case BGP_ERR_AS_MISMATCH
:
1471 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1472 return CMD_WARNING_CONFIG_FAILED
;
1473 case BGP_ERR_INSTANCE_MISMATCH
:
1475 "BGP instance name and AS number mismatch\n");
1477 "BGP instance is already running; AS is %u\n",
1479 return CMD_WARNING_CONFIG_FAILED
;
1483 * If we just instantiated the default instance, complete
1484 * any pending VRF-VPN leaking that was configured via
1485 * earlier "router bgp X vrf FOO" blocks.
1487 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1488 vpn_leak_postchange_all();
1490 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1491 bgp_vpn_leak_export(bgp
);
1492 /* Pending: handle when user tries to change a view to vrf n vv.
1496 /* unset the auto created flag as the user config is now present */
1497 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1498 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1503 /* "no router bgp" commands. */
1504 DEFUN (no_router_bgp
,
1506 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1511 BGP_INSTANCE_HELP_STR
)
1517 const char *name
= NULL
;
1519 // "no router bgp" without an ASN
1521 // Pending: Make VRF option available for ASN less config
1522 bgp
= bgp_get_default();
1525 vty_out(vty
, "%% No BGP process is configured\n");
1526 return CMD_WARNING_CONFIG_FAILED
;
1529 if (listcount(bm
->bgp
) > 1) {
1530 vty_out(vty
, "%% Please specify ASN and VRF\n");
1531 return CMD_WARNING_CONFIG_FAILED
;
1535 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1537 return CMD_WARNING_CONFIG_FAILED
;
1540 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1543 name
= argv
[idx_vrf
]->arg
;
1544 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1545 && strmatch(name
, VRF_DEFAULT_NAME
))
1549 /* Lookup bgp structure. */
1550 bgp
= bgp_lookup(as
, name
);
1552 vty_out(vty
, "%% Can't find BGP instance\n");
1553 return CMD_WARNING_CONFIG_FAILED
;
1557 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1559 return CMD_WARNING_CONFIG_FAILED
;
1562 /* Cannot delete default instance if vrf instances exist */
1563 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1564 struct listnode
*node
;
1565 struct bgp
*tmp_bgp
;
1567 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1568 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1570 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1571 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1572 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1573 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1574 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1575 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1576 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1577 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1578 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1579 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1581 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1582 (bgp
== bgp_get_evpn() &&
1583 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1584 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1585 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1586 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1587 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1588 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1589 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1590 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1591 (hashcount(tmp_bgp
->vnihash
))) {
1593 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1594 return CMD_WARNING_CONFIG_FAILED
;
1605 /* bgp session-dscp */
1607 DEFPY (bgp_session_dscp
,
1608 bgp_session_dscp_cmd
,
1609 "bgp session-dscp (0-63)$dscp",
1611 "Override default (C6) bgp TCP session DSCP value\n"
1612 "Manually configured dscp parameter\n")
1614 bm
->tcp_dscp
= dscp
<< 2;
1619 DEFPY (no_bgp_session_dscp
,
1620 no_bgp_session_dscp_cmd
,
1621 "no bgp session-dscp [(0-63)]",
1624 "Override default (C6) bgp TCP session DSCP value\n"
1625 "Manually configured dscp parameter\n")
1627 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1632 /* BGP router-id. */
1634 DEFPY (bgp_router_id
,
1636 "bgp router-id A.B.C.D",
1638 "Override configured router identifier\n"
1639 "Manually configured router identifier\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1642 bgp_router_id_static_set(bgp
, router_id
);
1646 DEFPY (no_bgp_router_id
,
1647 no_bgp_router_id_cmd
,
1648 "no bgp router-id [A.B.C.D]",
1651 "Override configured router identifier\n"
1652 "Manually configured router identifier\n")
1654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1656 if (router_id_str
) {
1657 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1658 vty_out(vty
, "%% BGP router-id doesn't match\n");
1659 return CMD_WARNING_CONFIG_FAILED
;
1663 router_id
.s_addr
= 0;
1664 bgp_router_id_static_set(bgp
, router_id
);
1669 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1670 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1672 "Add community specific parameters\n"
1673 "Create an alias for a community\n"
1674 "Community (AA:BB or AA:BB:CC)\n"
1677 struct community_alias ca
= {};
1678 struct community_alias
*lookup_community
;
1679 struct community_alias
*lookup_alias
;
1680 struct community
*comm
;
1681 struct lcommunity
*lcomm
;
1682 uint8_t invalid
= 0;
1684 comm
= community_str2com(community
);
1687 community_free(&comm
);
1689 lcomm
= lcommunity_str2com(community
);
1692 lcommunity_free(&lcomm
);
1695 vty_out(vty
, "Invalid community format\n");
1699 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1700 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1702 lookup_community
= bgp_ca_community_lookup(&ca
);
1703 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1706 bgp_ca_alias_delete(&ca
);
1707 bgp_ca_community_delete(&ca
);
1710 /* Lookup if community hash table has an item
1711 * with the same alias name.
1713 strlcpy(ca
.community
, lookup_alias
->community
,
1714 sizeof(ca
.community
));
1715 if (bgp_ca_community_lookup(&ca
)) {
1717 "community (%s) already has this alias (%s)\n",
1718 lookup_alias
->community
,
1719 lookup_alias
->alias
);
1722 bgp_ca_alias_delete(&ca
);
1725 if (lookup_community
) {
1726 /* Lookup if alias hash table has an item
1727 * with the same community.
1729 strlcpy(ca
.alias
, lookup_community
->alias
,
1731 if (bgp_ca_alias_lookup(&ca
)) {
1733 "alias (%s) already has this community (%s)\n",
1734 lookup_community
->alias
,
1735 lookup_community
->community
);
1738 bgp_ca_community_delete(&ca
);
1741 bgp_ca_alias_insert(&ca
);
1742 bgp_ca_community_insert(&ca
);
1748 DEFPY (bgp_global_suppress_fib_pending
,
1749 bgp_global_suppress_fib_pending_cmd
,
1750 "[no] bgp suppress-fib-pending",
1753 "Advertise only routes that are programmed in kernel to peers globally\n")
1755 bm_wait_for_fib_set(!no
);
1760 DEFPY (bgp_suppress_fib_pending
,
1761 bgp_suppress_fib_pending_cmd
,
1762 "[no] bgp suppress-fib-pending",
1765 "Advertise only routes that are programmed in kernel to peers\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1769 bgp_suppress_fib_pending_set(bgp
, !no
);
1774 /* BGP Cluster ID. */
1775 DEFUN (bgp_cluster_id
,
1777 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1779 "Configure Route-Reflector Cluster-id\n"
1780 "Route-Reflector Cluster-id in IP address format\n"
1781 "Route-Reflector Cluster-id as 32 bit quantity\n")
1783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1786 struct in_addr cluster
;
1788 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1790 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1791 return CMD_WARNING_CONFIG_FAILED
;
1794 bgp_cluster_id_set(bgp
, &cluster
);
1795 bgp_clear_star_soft_out(vty
, bgp
->name
);
1800 DEFUN (no_bgp_cluster_id
,
1801 no_bgp_cluster_id_cmd
,
1802 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1805 "Configure Route-Reflector Cluster-id\n"
1806 "Route-Reflector Cluster-id in IP address format\n"
1807 "Route-Reflector Cluster-id as 32 bit quantity\n")
1809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1810 bgp_cluster_id_unset(bgp
);
1811 bgp_clear_star_soft_out(vty
, bgp
->name
);
1820 "Disable BGP route installation to RIB (Zebra)\n")
1822 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1824 "%% No-RIB option is already set, nothing to do here.\n");
1828 bgp_option_norib_set_runtime();
1833 DEFPY (no_bgp_norib
,
1838 "Disable BGP route installation to RIB (Zebra)\n")
1840 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1842 "%% No-RIB option is not set, nothing to do here.\n");
1846 bgp_option_norib_unset_runtime();
1851 DEFPY (no_bgp_send_extra_data
,
1852 no_bgp_send_extra_data_cmd
,
1853 "[no] bgp send-extra-data zebra",
1856 "Extra data to Zebra for display/use\n"
1860 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1862 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1867 DEFUN (bgp_confederation_identifier
,
1868 bgp_confederation_identifier_cmd
,
1869 "bgp confederation identifier (1-4294967295)",
1871 "AS confederation parameters\n"
1873 "Set routing domain confederation AS\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1879 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1881 bgp_confederation_id_set(bgp
, as
);
1886 DEFUN (no_bgp_confederation_identifier
,
1887 no_bgp_confederation_identifier_cmd
,
1888 "no bgp confederation identifier [(1-4294967295)]",
1891 "AS confederation parameters\n"
1893 "Set routing domain confederation AS\n")
1895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1896 bgp_confederation_id_unset(bgp
);
1901 DEFUN (bgp_confederation_peers
,
1902 bgp_confederation_peers_cmd
,
1903 "bgp confederation peers (1-4294967295)...",
1905 "AS confederation parameters\n"
1906 "Peer ASs in BGP confederation\n"
1909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1914 for (i
= idx_asn
; i
< argc
; i
++) {
1915 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1917 if (bgp
->as
== as
) {
1919 "%% Local member-AS not allowed in confed peer list\n");
1923 bgp_confederation_peers_add(bgp
, as
);
1928 DEFUN (no_bgp_confederation_peers
,
1929 no_bgp_confederation_peers_cmd
,
1930 "no bgp confederation peers (1-4294967295)...",
1933 "AS confederation parameters\n"
1934 "Peer ASs in BGP confederation\n"
1937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1942 for (i
= idx_asn
; i
< argc
; i
++) {
1943 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1945 bgp_confederation_peers_remove(bgp
, as
);
1951 * Central routine for maximum-paths configuration.
1952 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1953 * @set: 1 for setting values, 0 for removing the max-paths config.
1955 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1956 const char *mpaths
, uint16_t options
,
1959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1960 uint16_t maxpaths
= 0;
1965 afi
= bgp_node_afi(vty
);
1966 safi
= bgp_node_safi(vty
);
1969 maxpaths
= strtol(mpaths
, NULL
, 10);
1970 if (maxpaths
> multipath_num
) {
1972 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1973 maxpaths
, multipath_num
);
1974 return CMD_WARNING_CONFIG_FAILED
;
1976 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1979 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1983 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1984 (set
== 1) ? "" : "un",
1985 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1986 maxpaths
, afi
, safi
);
1987 return CMD_WARNING_CONFIG_FAILED
;
1990 bgp_recalculate_all_bestpaths(bgp
);
1995 DEFUN (bgp_maxmed_admin
,
1996 bgp_maxmed_admin_cmd
,
1997 "bgp max-med administrative ",
1999 "Advertise routes with max-med\n"
2000 "Administratively applied, for an indefinite period\n")
2002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp
->v_maxmed_admin
= 1;
2005 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2007 bgp_maxmed_update(bgp
);
2012 DEFUN (bgp_maxmed_admin_medv
,
2013 bgp_maxmed_admin_medv_cmd
,
2014 "bgp max-med administrative (0-4294967295)",
2016 "Advertise routes with max-med\n"
2017 "Administratively applied, for an indefinite period\n"
2018 "Max MED value to be used\n")
2020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2023 bgp
->v_maxmed_admin
= 1;
2024 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2026 bgp_maxmed_update(bgp
);
2031 DEFUN (no_bgp_maxmed_admin
,
2032 no_bgp_maxmed_admin_cmd
,
2033 "no bgp max-med administrative [(0-4294967295)]",
2036 "Advertise routes with max-med\n"
2037 "Administratively applied, for an indefinite period\n"
2038 "Max MED value to be used\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2041 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2042 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2043 bgp_maxmed_update(bgp
);
2048 DEFUN (bgp_maxmed_onstartup
,
2049 bgp_maxmed_onstartup_cmd
,
2050 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2052 "Advertise routes with max-med\n"
2053 "Effective on a startup\n"
2054 "Time (seconds) period for max-med\n"
2055 "Max MED value to be used\n")
2057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2061 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2062 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2063 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2065 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2067 bgp_maxmed_update(bgp
);
2072 DEFUN (no_bgp_maxmed_onstartup
,
2073 no_bgp_maxmed_onstartup_cmd
,
2074 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2077 "Advertise routes with max-med\n"
2078 "Effective on a startup\n"
2079 "Time (seconds) period for max-med\n"
2080 "Max MED value to be used\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2084 /* Cancel max-med onstartup if its on */
2085 if (bgp
->t_maxmed_onstartup
) {
2086 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2087 bgp
->maxmed_onstartup_over
= 1;
2090 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2091 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2093 bgp_maxmed_update(bgp
);
2098 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2099 uint16_t update_delay
,
2100 uint16_t establish_wait
)
2102 struct listnode
*node
, *nnode
;
2104 bool vrf_cfg
= false;
2107 * See if update-delay is set per-vrf and warn user to delete it
2108 * Note that we only need to check this if this is the first time
2109 * setting the global config.
2111 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2112 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2113 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2115 "%% update-delay configuration found in vrf %s\n",
2116 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2126 "%%Failed: global update-delay config not permitted\n");
2130 if (!establish_wait
) { /* update-delay <delay> */
2131 bm
->v_update_delay
= update_delay
;
2132 bm
->v_establish_wait
= bm
->v_update_delay
;
2134 /* update-delay <delay> <establish-wait> */
2135 if (update_delay
< establish_wait
) {
2137 "%%Failed: update-delay less than the establish-wait!\n");
2138 return CMD_WARNING_CONFIG_FAILED
;
2141 bm
->v_update_delay
= update_delay
;
2142 bm
->v_establish_wait
= establish_wait
;
2145 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2146 bgp
->v_update_delay
= bm
->v_update_delay
;
2147 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2153 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2155 struct listnode
*node
, *nnode
;
2158 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2159 bm
->v_establish_wait
= bm
->v_update_delay
;
2161 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2162 bgp
->v_update_delay
= bm
->v_update_delay
;
2163 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2169 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2170 uint16_t establish_wait
)
2172 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2174 /* if configured globally, per-instance config is not allowed */
2175 if (bm
->v_update_delay
) {
2177 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2178 return CMD_WARNING_CONFIG_FAILED
;
2182 if (!establish_wait
) /* update-delay <delay> */
2184 bgp
->v_update_delay
= update_delay
;
2185 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2189 /* update-delay <delay> <establish-wait> */
2190 if (update_delay
< establish_wait
) {
2192 "%%Failed: update-delay less than the establish-wait!\n");
2193 return CMD_WARNING_CONFIG_FAILED
;
2196 bgp
->v_update_delay
= update_delay
;
2197 bgp
->v_establish_wait
= establish_wait
;
2202 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2206 /* If configured globally, cannot remove from one bgp instance */
2207 if (bm
->v_update_delay
) {
2209 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2210 return CMD_WARNING_CONFIG_FAILED
;
2212 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2213 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2218 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2220 /* If configured globally, no need to display per-instance value */
2221 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2222 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2223 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2224 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2229 /* Global update-delay configuration */
2230 DEFPY (bgp_global_update_delay
,
2231 bgp_global_update_delay_cmd
,
2232 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2234 "Force initial delay for best-path and updates for all bgp instances\n"
2235 "Max delay in seconds\n"
2236 "Establish wait in seconds\n")
2238 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2241 /* Global update-delay deconfiguration */
2242 DEFPY (no_bgp_global_update_delay
,
2243 no_bgp_global_update_delay_cmd
,
2244 "no bgp update-delay [(0-3600) [(1-3600)]]",
2247 "Force initial delay for best-path and updates\n"
2248 "Max delay in seconds\n"
2249 "Establish wait in seconds\n")
2251 return bgp_global_update_delay_deconfig_vty(vty
);
2254 /* Update-delay configuration */
2256 DEFPY (bgp_update_delay
,
2257 bgp_update_delay_cmd
,
2258 "update-delay (0-3600)$delay [(1-3600)$wait]",
2259 "Force initial delay for best-path and updates\n"
2260 "Max delay in seconds\n"
2261 "Establish wait in seconds\n")
2263 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2266 /* Update-delay deconfiguration */
2267 DEFPY (no_bgp_update_delay
,
2268 no_bgp_update_delay_cmd
,
2269 "no update-delay [(0-3600) [(1-3600)]]",
2271 "Force initial delay for best-path and updates\n"
2272 "Max delay in seconds\n"
2273 "Establish wait in seconds\n")
2275 return bgp_update_delay_deconfig_vty(vty
);
2279 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2284 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2285 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2290 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2295 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2296 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2301 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2304 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2305 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2306 vty_out(vty
, " write-quanta %d\n", quanta
);
2309 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2312 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2313 if (quanta
!= BGP_READ_PACKET_MAX
)
2314 vty_out(vty
, " read-quanta %d\n", quanta
);
2317 /* Packet quanta configuration
2319 * XXX: The value set here controls the size of a stack buffer in the IO
2320 * thread. When changing these limits be careful to prevent stack overflow.
2322 * Furthermore, the maximums used here should correspond to
2323 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2325 DEFPY (bgp_wpkt_quanta
,
2326 bgp_wpkt_quanta_cmd
,
2327 "[no] write-quanta (1-64)$quanta",
2329 "How many packets to write to peer socket per run\n"
2330 "Number of packets\n")
2332 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2335 DEFPY (bgp_rpkt_quanta
,
2336 bgp_rpkt_quanta_cmd
,
2337 "[no] read-quanta (1-10)$quanta",
2339 "How many packets to read from peer socket per I/O cycle\n"
2340 "Number of packets\n")
2342 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2345 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2347 if (!bgp
->heuristic_coalesce
)
2348 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2352 DEFUN (bgp_coalesce_time
,
2353 bgp_coalesce_time_cmd
,
2354 "coalesce-time (0-4294967295)",
2355 "Subgroup coalesce timer\n"
2356 "Subgroup coalesce timer value (in ms)\n")
2358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2362 bgp
->heuristic_coalesce
= false;
2364 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2365 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2370 DEFUN (no_bgp_coalesce_time
,
2371 no_bgp_coalesce_time_cmd
,
2372 "no coalesce-time (0-4294967295)",
2374 "Subgroup coalesce timer\n"
2375 "Subgroup coalesce timer value (in ms)\n")
2377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2379 bgp
->heuristic_coalesce
= true;
2380 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2384 /* Maximum-paths configuration */
2385 DEFUN (bgp_maxpaths
,
2387 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2388 "Forward packets over multiple paths\n"
2389 "Number of paths\n")
2392 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2393 argv
[idx_number
]->arg
, 0, 1);
2396 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2397 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2398 "Forward packets over multiple paths\n"
2399 "Number of paths\n")
2401 DEFUN (bgp_maxpaths_ibgp
,
2402 bgp_maxpaths_ibgp_cmd
,
2403 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2404 "Forward packets over multiple paths\n"
2406 "Number of paths\n")
2409 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2410 argv
[idx_number
]->arg
, 0, 1);
2413 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2414 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2415 "Forward packets over multiple paths\n"
2417 "Number of paths\n")
2419 DEFUN (bgp_maxpaths_ibgp_cluster
,
2420 bgp_maxpaths_ibgp_cluster_cmd
,
2421 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2422 "Forward packets over multiple paths\n"
2425 "Match the cluster length\n")
2428 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2429 argv
[idx_number
]->arg
, true, 1);
2432 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2433 "maximum-paths ibgp " CMD_RANGE_STR(
2434 1, MULTIPATH_NUM
) " equal-cluster-length",
2435 "Forward packets over multiple paths\n"
2438 "Match the cluster length\n")
2440 DEFUN (no_bgp_maxpaths
,
2441 no_bgp_maxpaths_cmd
,
2442 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2444 "Forward packets over multiple paths\n"
2445 "Number of paths\n")
2447 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2450 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2451 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2452 "Forward packets over multiple paths\n"
2453 "Number of paths\n")
2455 DEFUN (no_bgp_maxpaths_ibgp
,
2456 no_bgp_maxpaths_ibgp_cmd
,
2457 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2459 "Forward packets over multiple paths\n"
2462 "Match the cluster length\n")
2464 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2467 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2468 "no maximum-paths ibgp [" CMD_RANGE_STR(
2469 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2471 "Forward packets over multiple paths\n"
2474 "Match the cluster length\n")
2476 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2477 afi_t afi
, safi_t safi
)
2479 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2480 vty_out(vty
, " maximum-paths %d\n",
2481 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2484 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2485 vty_out(vty
, " maximum-paths ibgp %d",
2486 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2487 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2488 vty_out(vty
, " equal-cluster-length");
2497 "timers bgp (0-65535) (0-65535)",
2498 "Adjust routing timers\n"
2500 "Keepalive interval\n"
2503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2505 int idx_number_2
= 3;
2506 unsigned long keepalive
= 0;
2507 unsigned long holdtime
= 0;
2509 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2510 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2512 /* Holdtime value check. */
2513 if (holdtime
< 3 && holdtime
!= 0) {
2515 "%% hold time value must be either 0 or greater than 3\n");
2516 return CMD_WARNING_CONFIG_FAILED
;
2519 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2520 BGP_DEFAULT_DELAYOPEN
);
2525 DEFUN (no_bgp_timers
,
2527 "no timers bgp [(0-65535) (0-65535)]",
2529 "Adjust routing timers\n"
2531 "Keepalive interval\n"
2534 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2535 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2536 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2541 /* BGP minimum holdtime. */
2543 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2544 "bgp minimum-holdtime (1-65535)",
2545 "BGP specific commands\n"
2546 "BGP minimum holdtime\n"
2549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2551 unsigned long min_holdtime
;
2553 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2555 bgp
->default_min_holdtime
= min_holdtime
;
2560 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2561 "no bgp minimum-holdtime [(1-65535)]",
2563 "BGP specific commands\n"
2564 "BGP minimum holdtime\n"
2567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2569 bgp
->default_min_holdtime
= 0;
2574 DEFUN (bgp_client_to_client_reflection
,
2575 bgp_client_to_client_reflection_cmd
,
2576 "bgp client-to-client reflection",
2578 "Configure client to client route reflection\n"
2579 "reflection of routes allowed\n")
2581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2582 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2583 bgp_clear_star_soft_out(vty
, bgp
->name
);
2588 DEFUN (no_bgp_client_to_client_reflection
,
2589 no_bgp_client_to_client_reflection_cmd
,
2590 "no bgp client-to-client reflection",
2593 "Configure client to client route reflection\n"
2594 "reflection of routes allowed\n")
2596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2597 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2598 bgp_clear_star_soft_out(vty
, bgp
->name
);
2603 /* "bgp always-compare-med" configuration. */
2604 DEFUN (bgp_always_compare_med
,
2605 bgp_always_compare_med_cmd
,
2606 "bgp always-compare-med",
2608 "Allow comparing MED from different neighbors\n")
2610 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2611 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2612 bgp_recalculate_all_bestpaths(bgp
);
2617 DEFUN (no_bgp_always_compare_med
,
2618 no_bgp_always_compare_med_cmd
,
2619 "no bgp always-compare-med",
2622 "Allow comparing MED from different neighbors\n")
2624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2625 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2626 bgp_recalculate_all_bestpaths(bgp
);
2632 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2633 "bgp ebgp-requires-policy",
2635 "Require in and out policy for eBGP peers (RFC8212)\n")
2637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2638 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2642 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2643 "no bgp ebgp-requires-policy",
2646 "Require in and out policy for eBGP peers (RFC8212)\n")
2648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2649 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2653 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2654 "bgp suppress-duplicates",
2656 "Suppress duplicate updates if the route actually not changed\n")
2658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2659 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2663 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2664 "no bgp suppress-duplicates",
2667 "Suppress duplicate updates if the route actually not changed\n")
2669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2670 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2674 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2675 "bgp reject-as-sets",
2677 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2680 struct listnode
*node
, *nnode
;
2683 bgp
->reject_as_sets
= true;
2685 /* Reset existing BGP sessions to reject routes
2686 * with aspath containing AS_SET or AS_CONFED_SET.
2688 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2689 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2690 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2691 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2692 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2699 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2700 "no bgp reject-as-sets",
2703 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 struct listnode
*node
, *nnode
;
2709 bgp
->reject_as_sets
= false;
2711 /* Reset existing BGP sessions to reject routes
2712 * with aspath containing AS_SET or AS_CONFED_SET.
2714 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2715 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2716 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2717 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2718 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2725 /* "bgp deterministic-med" configuration. */
2726 DEFUN (bgp_deterministic_med
,
2727 bgp_deterministic_med_cmd
,
2728 "bgp deterministic-med",
2730 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2732 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2734 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2735 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2736 bgp_recalculate_all_bestpaths(bgp
);
2742 DEFUN (no_bgp_deterministic_med
,
2743 no_bgp_deterministic_med_cmd
,
2744 "no bgp deterministic-med",
2747 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2750 int bestpath_per_as_used
;
2754 struct listnode
*node
, *nnode
;
2756 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2757 bestpath_per_as_used
= 0;
2759 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2760 FOREACH_AFI_SAFI (afi
, safi
)
2761 if (bgp_addpath_dmed_required(
2762 peer
->addpath_type
[afi
][safi
])) {
2763 bestpath_per_as_used
= 1;
2767 if (bestpath_per_as_used
)
2771 if (bestpath_per_as_used
) {
2773 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2774 return CMD_WARNING_CONFIG_FAILED
;
2776 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2777 bgp_recalculate_all_bestpaths(bgp
);
2784 /* "bgp graceful-restart mode" configuration. */
2785 DEFUN (bgp_graceful_restart
,
2786 bgp_graceful_restart_cmd
,
2787 "bgp graceful-restart",
2792 int ret
= BGP_GR_FAILURE
;
2794 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2795 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2799 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2801 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2804 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2805 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2807 "Graceful restart configuration changed, reset all peers to take effect\n");
2808 return bgp_vty_return(vty
, ret
);
2811 DEFUN (no_bgp_graceful_restart
,
2812 no_bgp_graceful_restart_cmd
,
2813 "no bgp graceful-restart",
2819 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2821 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2822 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2824 int ret
= BGP_GR_FAILURE
;
2826 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2828 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2831 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2832 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2834 "Graceful restart configuration changed, reset all peers to take effect\n");
2836 return bgp_vty_return(vty
, ret
);
2839 DEFUN (bgp_graceful_restart_stalepath_time
,
2840 bgp_graceful_restart_stalepath_time_cmd
,
2841 "bgp graceful-restart stalepath-time (1-4095)",
2843 "Graceful restart capability parameters\n"
2844 "Set the max time to hold onto restarting peer's stale paths\n"
2845 "Delay value (seconds)\n")
2847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2851 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2852 bgp
->stalepath_time
= stalepath
;
2856 DEFUN (bgp_graceful_restart_restart_time
,
2857 bgp_graceful_restart_restart_time_cmd
,
2858 "bgp graceful-restart restart-time (0-4095)",
2860 "Graceful restart capability parameters\n"
2861 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2862 "Delay value (seconds)\n")
2864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2868 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2869 bgp
->restart_time
= restart
;
2873 DEFUN (bgp_graceful_restart_select_defer_time
,
2874 bgp_graceful_restart_select_defer_time_cmd
,
2875 "bgp graceful-restart select-defer-time (0-3600)",
2877 "Graceful restart capability parameters\n"
2878 "Set the time to defer the BGP route selection after restart\n"
2879 "Delay value (seconds, 0 - disable)\n")
2881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2883 uint32_t defer_time
;
2885 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2886 bgp
->select_defer_time
= defer_time
;
2887 if (defer_time
== 0)
2888 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2890 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2895 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2896 no_bgp_graceful_restart_stalepath_time_cmd
,
2897 "no bgp graceful-restart stalepath-time [(1-4095)]",
2900 "Graceful restart capability parameters\n"
2901 "Set the max time to hold onto restarting peer's stale paths\n"
2902 "Delay value (seconds)\n")
2904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2910 DEFUN (no_bgp_graceful_restart_restart_time
,
2911 no_bgp_graceful_restart_restart_time_cmd
,
2912 "no bgp graceful-restart restart-time [(0-4095)]",
2915 "Graceful restart capability parameters\n"
2916 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2917 "Delay value (seconds)\n")
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2921 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2925 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2926 no_bgp_graceful_restart_select_defer_time_cmd
,
2927 "no bgp graceful-restart select-defer-time [(0-3600)]",
2930 "Graceful restart capability parameters\n"
2931 "Set the time to defer the BGP route selection after restart\n"
2932 "Delay value (seconds)\n")
2934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2936 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2937 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2942 DEFUN (bgp_graceful_restart_preserve_fw
,
2943 bgp_graceful_restart_preserve_fw_cmd
,
2944 "bgp graceful-restart preserve-fw-state",
2946 "Graceful restart capability parameters\n"
2947 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2954 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2955 no_bgp_graceful_restart_preserve_fw_cmd
,
2956 "no bgp graceful-restart preserve-fw-state",
2959 "Graceful restart capability parameters\n"
2960 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2963 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2967 DEFPY (bgp_graceful_restart_notification
,
2968 bgp_graceful_restart_notification_cmd
,
2969 "[no$no] bgp graceful-restart notification",
2972 "Graceful restart capability parameters\n"
2973 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
2975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2978 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2980 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2985 DEFPY (bgp_administrative_reset
,
2986 bgp_administrative_reset_cmd
,
2987 "[no$no] bgp hard-administrative-reset",
2990 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
2992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2995 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2997 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3002 DEFUN (bgp_graceful_restart_disable
,
3003 bgp_graceful_restart_disable_cmd
,
3004 "bgp graceful-restart-disable",
3008 int ret
= BGP_GR_FAILURE
;
3010 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3012 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3016 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3018 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3021 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3023 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3025 "Graceful restart configuration changed, reset all peers to take effect\n");
3027 return bgp_vty_return(vty
, ret
);
3030 DEFUN (no_bgp_graceful_restart_disable
,
3031 no_bgp_graceful_restart_disable_cmd
,
3032 "no bgp graceful-restart-disable",
3038 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3040 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3042 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3044 int ret
= BGP_GR_FAILURE
;
3046 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3048 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3051 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3053 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3055 "Graceful restart configuration changed, reset all peers to take effect\n");
3057 return bgp_vty_return(vty
, ret
);
3060 DEFUN (bgp_neighbor_graceful_restart_set
,
3061 bgp_neighbor_graceful_restart_set_cmd
,
3062 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3070 int ret
= BGP_GR_FAILURE
;
3072 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3074 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3076 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3078 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3080 return CMD_WARNING_CONFIG_FAILED
;
3082 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3084 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3085 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3091 "Graceful restart configuration changed, reset this peer to take effect\n");
3093 return bgp_vty_return(vty
, ret
);
3096 DEFUN (no_bgp_neighbor_graceful_restart
,
3097 no_bgp_neighbor_graceful_restart_set_cmd
,
3098 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3106 int ret
= BGP_GR_FAILURE
;
3109 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3111 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3113 return CMD_WARNING_CONFIG_FAILED
;
3115 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3117 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3119 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3121 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3122 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3124 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3126 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3128 "Graceful restart configuration changed, reset this peer to take effect\n");
3130 return bgp_vty_return(vty
, ret
);
3133 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3134 bgp_neighbor_graceful_restart_helper_set_cmd
,
3135 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3138 GR_NEIGHBOR_HELPER_CMD
3143 int ret
= BGP_GR_FAILURE
;
3145 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3147 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3149 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3151 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3154 return CMD_WARNING_CONFIG_FAILED
;
3157 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3159 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3160 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3162 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3164 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3166 "Graceful restart configuration changed, reset this peer to take effect\n");
3168 return bgp_vty_return(vty
, ret
);
3171 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3172 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3173 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3177 NO_GR_NEIGHBOR_HELPER_CMD
3181 int ret
= BGP_GR_FAILURE
;
3184 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3186 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3188 return CMD_WARNING_CONFIG_FAILED
;
3190 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3192 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3194 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3196 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3197 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3199 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3201 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3203 "Graceful restart configuration changed, reset this peer to take effect\n");
3205 return bgp_vty_return(vty
, ret
);
3208 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3209 bgp_neighbor_graceful_restart_disable_set_cmd
,
3210 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3213 GR_NEIGHBOR_DISABLE_CMD
3218 int ret
= BGP_GR_FAILURE
;
3220 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3222 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3224 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3226 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3228 return CMD_WARNING_CONFIG_FAILED
;
3230 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3232 if (peer
->bgp
->t_startup
)
3233 bgp_peer_gr_flags_update(peer
);
3235 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3236 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3238 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3240 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3242 "Graceful restart configuration changed, reset this peer to take effect\n");
3244 return bgp_vty_return(vty
, ret
);
3247 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3248 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3249 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3253 NO_GR_NEIGHBOR_DISABLE_CMD
3257 int ret
= BGP_GR_FAILURE
;
3260 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3262 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3264 return CMD_WARNING_CONFIG_FAILED
;
3266 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3268 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3270 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3272 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3273 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3275 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3277 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3279 "Graceful restart configuration changed, reset this peer to take effect\n");
3281 return bgp_vty_return(vty
, ret
);
3284 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3285 bgp_graceful_restart_disable_eor_cmd
,
3286 "bgp graceful-restart disable-eor",
3288 "Graceful restart configuration parameters\n"
3289 "Disable EOR Check\n")
3291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3292 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3297 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3298 no_bgp_graceful_restart_disable_eor_cmd
,
3299 "no bgp graceful-restart disable-eor",
3302 "Graceful restart configuration parameters\n"
3303 "Disable EOR Check\n")
3305 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3306 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3311 DEFUN (bgp_graceful_restart_rib_stale_time
,
3312 bgp_graceful_restart_rib_stale_time_cmd
,
3313 "bgp graceful-restart rib-stale-time (1-3600)",
3315 "Graceful restart configuration parameters\n"
3316 "Specify the stale route removal timer in rib\n"
3317 "Delay value (seconds)\n")
3319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3321 uint32_t stale_time
;
3323 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3324 bgp
->rib_stale_time
= stale_time
;
3325 /* Send the stale timer update message to RIB */
3326 if (bgp_zebra_stale_timer_update(bgp
))
3332 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3333 no_bgp_graceful_restart_rib_stale_time_cmd
,
3334 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3337 "Graceful restart configuration parameters\n"
3338 "Specify the stale route removal timer in rib\n"
3339 "Delay value (seconds)\n")
3341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3343 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3344 /* Send the stale timer update message to RIB */
3345 if (bgp_zebra_stale_timer_update(bgp
))
3351 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3352 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3354 "Enable Long-lived Graceful Restart\n"
3355 "Specifies maximum time to wait before purging long-lived stale routes\n"
3356 "Stale time value (seconds)\n")
3358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3360 uint32_t llgr_stale_time
;
3362 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3363 bgp
->llgr_stale_time
= llgr_stale_time
;
3368 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3369 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3371 "Enable Long-lived Graceful Restart\n"
3372 "Specifies maximum time to wait before purging long-lived stale routes\n"
3373 "Stale time value (seconds)\n")
3375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3377 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3382 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3385 bgp_static_redo_import_check(bgp
);
3386 bgp_redistribute_redo(bgp
);
3387 bgp_clear_star_soft_out(vty
, bgp
->name
);
3388 bgp_clear_star_soft_in(vty
, bgp
->name
);
3391 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3393 struct listnode
*node
, *nnode
;
3395 bool vrf_cfg
= false;
3397 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3400 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3401 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3402 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3404 "%% graceful-shutdown configuration found in vrf %s\n",
3405 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3406 VRF_DEFAULT_NAME
: bgp
->name
);
3413 "%%Failed: global graceful-shutdown not permitted\n");
3417 /* Set flag globally */
3418 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3420 /* Initiate processing for all BGP instances. */
3421 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3422 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3427 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3429 struct listnode
*node
, *nnode
;
3432 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3435 /* Unset flag globally */
3436 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3438 /* Initiate processing for all BGP instances. */
3439 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3440 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3445 /* "bgp graceful-shutdown" configuration */
3446 DEFUN (bgp_graceful_shutdown
,
3447 bgp_graceful_shutdown_cmd
,
3448 "bgp graceful-shutdown",
3450 "Graceful shutdown parameters\n")
3452 if (vty
->node
== CONFIG_NODE
)
3453 return bgp_global_graceful_shutdown_config_vty(vty
);
3455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3457 /* if configured globally, per-instance config is not allowed */
3458 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3460 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3461 return CMD_WARNING_CONFIG_FAILED
;
3464 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3465 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3466 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3472 DEFUN (no_bgp_graceful_shutdown
,
3473 no_bgp_graceful_shutdown_cmd
,
3474 "no bgp graceful-shutdown",
3477 "Graceful shutdown parameters\n")
3479 if (vty
->node
== CONFIG_NODE
)
3480 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3482 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3484 /* If configured globally, cannot remove from one bgp instance */
3485 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3487 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3488 return CMD_WARNING_CONFIG_FAILED
;
3491 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3492 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3493 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3499 /* "bgp fast-external-failover" configuration. */
3500 DEFUN (bgp_fast_external_failover
,
3501 bgp_fast_external_failover_cmd
,
3502 "bgp fast-external-failover",
3504 "Immediately reset session if a link to a directly connected external peer goes down\n")
3506 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3507 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3511 DEFUN (no_bgp_fast_external_failover
,
3512 no_bgp_fast_external_failover_cmd
,
3513 "no bgp fast-external-failover",
3516 "Immediately reset session if a link to a directly connected external peer goes down\n")
3518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3519 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3523 /* "bgp bestpath compare-routerid" configuration. */
3524 DEFUN (bgp_bestpath_compare_router_id
,
3525 bgp_bestpath_compare_router_id_cmd
,
3526 "bgp bestpath compare-routerid",
3528 "Change the default bestpath selection\n"
3529 "Compare router-id for identical EBGP paths\n")
3531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3532 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3533 bgp_recalculate_all_bestpaths(bgp
);
3538 DEFUN (no_bgp_bestpath_compare_router_id
,
3539 no_bgp_bestpath_compare_router_id_cmd
,
3540 "no bgp bestpath compare-routerid",
3543 "Change the default bestpath selection\n"
3544 "Compare router-id for identical EBGP paths\n")
3546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3547 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3548 bgp_recalculate_all_bestpaths(bgp
);
3553 /* "bgp bestpath as-path ignore" configuration. */
3554 DEFUN (bgp_bestpath_aspath_ignore
,
3555 bgp_bestpath_aspath_ignore_cmd
,
3556 "bgp bestpath as-path ignore",
3558 "Change the default bestpath selection\n"
3559 "AS-path attribute\n"
3560 "Ignore as-path length in selecting a route\n")
3562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3563 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3564 bgp_recalculate_all_bestpaths(bgp
);
3569 DEFUN (no_bgp_bestpath_aspath_ignore
,
3570 no_bgp_bestpath_aspath_ignore_cmd
,
3571 "no bgp bestpath as-path ignore",
3574 "Change the default bestpath selection\n"
3575 "AS-path attribute\n"
3576 "Ignore as-path length in selecting a route\n")
3578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3580 bgp_recalculate_all_bestpaths(bgp
);
3585 /* "bgp bestpath as-path confed" configuration. */
3586 DEFUN (bgp_bestpath_aspath_confed
,
3587 bgp_bestpath_aspath_confed_cmd
,
3588 "bgp bestpath as-path confed",
3590 "Change the default bestpath selection\n"
3591 "AS-path attribute\n"
3592 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3595 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3596 bgp_recalculate_all_bestpaths(bgp
);
3601 DEFUN (no_bgp_bestpath_aspath_confed
,
3602 no_bgp_bestpath_aspath_confed_cmd
,
3603 "no bgp bestpath as-path confed",
3606 "Change the default bestpath selection\n"
3607 "AS-path attribute\n"
3608 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3610 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3611 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3612 bgp_recalculate_all_bestpaths(bgp
);
3617 /* "bgp bestpath as-path multipath-relax" configuration. */
3618 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3619 bgp_bestpath_aspath_multipath_relax_cmd
,
3620 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3622 "Change the default bestpath selection\n"
3623 "AS-path attribute\n"
3624 "Allow load sharing across routes that have different AS paths (but same length)\n"
3625 "Generate an AS_SET\n"
3626 "Do not generate an AS_SET\n")
3628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3630 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3632 /* no-as-set is now the default behavior so we can silently
3634 if (argv_find(argv
, argc
, "as-set", &idx
))
3635 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3637 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3639 bgp_recalculate_all_bestpaths(bgp
);
3644 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3645 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3646 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3649 "Change the default bestpath selection\n"
3650 "AS-path attribute\n"
3651 "Allow load sharing across routes that have different AS paths (but same length)\n"
3652 "Generate an AS_SET\n"
3653 "Do not generate an AS_SET\n")
3655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3656 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3657 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3658 bgp_recalculate_all_bestpaths(bgp
);
3663 /* "bgp bestpath peer-type multipath-relax" configuration. */
3664 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3665 bgp_bestpath_peer_type_multipath_relax_cmd
,
3666 "bgp bestpath peer-type multipath-relax",
3668 "Change the default bestpath selection\n"
3670 "Allow load sharing across routes learned from different peer types\n")
3672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3673 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3674 bgp_recalculate_all_bestpaths(bgp
);
3679 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3680 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3681 "no bgp bestpath peer-type multipath-relax",
3683 "Change the default bestpath selection\n"
3685 "Allow load sharing across routes learned from different peer types\n")
3687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3688 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3689 bgp_recalculate_all_bestpaths(bgp
);
3694 /* "bgp log-neighbor-changes" configuration. */
3695 DEFUN (bgp_log_neighbor_changes
,
3696 bgp_log_neighbor_changes_cmd
,
3697 "bgp log-neighbor-changes",
3699 "Log neighbor up/down and reset reason\n")
3701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3702 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3706 DEFUN (no_bgp_log_neighbor_changes
,
3707 no_bgp_log_neighbor_changes_cmd
,
3708 "no bgp log-neighbor-changes",
3711 "Log neighbor up/down and reset reason\n")
3713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3714 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3718 /* "bgp bestpath med" configuration. */
3719 DEFUN (bgp_bestpath_med
,
3720 bgp_bestpath_med_cmd
,
3721 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3723 "Change the default bestpath selection\n"
3725 "Compare MED among confederation paths\n"
3726 "Treat missing MED as the least preferred one\n"
3727 "Treat missing MED as the least preferred one\n"
3728 "Compare MED among confederation paths\n")
3730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3733 if (argv_find(argv
, argc
, "confed", &idx
))
3734 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3736 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3737 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3739 bgp_recalculate_all_bestpaths(bgp
);
3744 DEFUN (no_bgp_bestpath_med
,
3745 no_bgp_bestpath_med_cmd
,
3746 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3749 "Change the default bestpath selection\n"
3751 "Compare MED among confederation paths\n"
3752 "Treat missing MED as the least preferred one\n"
3753 "Treat missing MED as the least preferred one\n"
3754 "Compare MED among confederation paths\n")
3756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3759 if (argv_find(argv
, argc
, "confed", &idx
))
3760 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3762 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3763 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3765 bgp_recalculate_all_bestpaths(bgp
);
3770 /* "bgp bestpath bandwidth" configuration. */
3771 DEFPY (bgp_bestpath_bw
,
3772 bgp_bestpath_bw_cmd
,
3773 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3775 "Change the default bestpath selection\n"
3776 "Link Bandwidth attribute\n"
3777 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3778 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3779 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3786 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3787 return CMD_ERR_INCOMPLETE
;
3789 if (!strcmp(bw_cfg
, "ignore"))
3790 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3791 else if (!strcmp(bw_cfg
, "skip-missing"))
3792 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3793 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3794 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3796 return CMD_ERR_NO_MATCH
;
3798 /* This config is used in route install, so redo that. */
3799 FOREACH_AFI_SAFI (afi
, safi
) {
3800 if (!bgp_fibupd_safi(safi
))
3802 bgp_zebra_announce_table(bgp
, afi
, safi
);
3808 DEFPY (no_bgp_bestpath_bw
,
3809 no_bgp_bestpath_bw_cmd
,
3810 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3813 "Change the default bestpath selection\n"
3814 "Link Bandwidth attribute\n"
3815 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3816 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3817 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3819 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3823 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3825 /* This config is used in route install, so redo that. */
3826 FOREACH_AFI_SAFI (afi
, safi
) {
3827 if (!bgp_fibupd_safi(safi
))
3829 bgp_zebra_announce_table(bgp
, afi
, safi
);
3834 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3835 "[no] bgp default <ipv4-unicast|"
3838 "ipv4-labeled-unicast|"
3843 "ipv6-labeled-unicast|"
3845 "l2vpn-evpn>$afi_safi",
3848 "Configure BGP defaults\n"
3849 "Activate ipv4-unicast for a peer by default\n"
3850 "Activate ipv4-multicast for a peer by default\n"
3851 "Activate ipv4-vpn for a peer by default\n"
3852 "Activate ipv4-labeled-unicast for a peer by default\n"
3853 "Activate ipv4-flowspec for a peer by default\n"
3854 "Activate ipv6-unicast for a peer by default\n"
3855 "Activate ipv6-multicast for a peer by default\n"
3856 "Activate ipv6-vpn for a peer by default\n"
3857 "Activate ipv6-labeled-unicast for a peer by default\n"
3858 "Activate ipv6-flowspec for a peer by default\n"
3859 "Activate l2vpn-evpn for a peer by default\n")
3861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3862 char afi_safi_str
[strlen(afi_safi
) + 1];
3863 char *afi_safi_str_tok
;
3865 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3866 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3867 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3868 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3872 * Impossible situation but making coverity happy
3874 assert(afi
!= AFI_MAX
);
3876 if (strmatch(safi_str
, "labeled"))
3877 safi
= bgp_vty_safi_from_str("labeled-unicast");
3879 safi
= bgp_vty_safi_from_str(safi_str
);
3881 assert(safi
!= SAFI_MAX
);
3883 bgp
->default_af
[afi
][safi
] = false;
3885 if ((safi
== SAFI_LABELED_UNICAST
3886 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3887 || (safi
== SAFI_UNICAST
3888 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3889 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3891 bgp
->default_af
[afi
][safi
] = true;
3897 /* Display hostname in certain command outputs */
3898 DEFUN (bgp_default_show_hostname
,
3899 bgp_default_show_hostname_cmd
,
3900 "bgp default show-hostname",
3902 "Configure BGP defaults\n"
3903 "Show hostname in certain command outputs\n")
3905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3906 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3910 DEFUN (no_bgp_default_show_hostname
,
3911 no_bgp_default_show_hostname_cmd
,
3912 "no bgp default show-hostname",
3915 "Configure BGP defaults\n"
3916 "Show hostname in certain command outputs\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3919 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3923 /* Display hostname in certain command outputs */
3924 DEFUN (bgp_default_show_nexthop_hostname
,
3925 bgp_default_show_nexthop_hostname_cmd
,
3926 "bgp default show-nexthop-hostname",
3928 "Configure BGP defaults\n"
3929 "Show hostname for nexthop in certain command outputs\n")
3931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3932 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3936 DEFUN (no_bgp_default_show_nexthop_hostname
,
3937 no_bgp_default_show_nexthop_hostname_cmd
,
3938 "no bgp default show-nexthop-hostname",
3941 "Configure BGP defaults\n"
3942 "Show hostname for nexthop in certain command outputs\n")
3944 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3945 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3949 /* "bgp network import-check" configuration. */
3950 DEFUN (bgp_network_import_check
,
3951 bgp_network_import_check_cmd
,
3952 "bgp network import-check",
3954 "BGP network command\n"
3955 "Check BGP network route exists in IGP\n")
3957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3958 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3959 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3960 bgp_static_redo_import_check(bgp
);
3966 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3967 "bgp network import-check exact",
3969 "BGP network command\n"
3970 "Check BGP network route exists in IGP\n"
3971 "Match route precisely\n")
3973 DEFUN (no_bgp_network_import_check
,
3974 no_bgp_network_import_check_cmd
,
3975 "no bgp network import-check",
3978 "BGP network command\n"
3979 "Check BGP network route exists in IGP\n")
3981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3982 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3983 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3984 bgp_static_redo_import_check(bgp
);
3990 DEFUN (bgp_default_local_preference
,
3991 bgp_default_local_preference_cmd
,
3992 "bgp default local-preference (0-4294967295)",
3994 "Configure BGP defaults\n"
3995 "local preference (higher=more preferred)\n"
3996 "Configure default local preference value\n")
3998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4000 uint32_t local_pref
;
4002 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4004 bgp_default_local_preference_set(bgp
, local_pref
);
4005 bgp_clear_star_soft_in(vty
, bgp
->name
);
4010 DEFUN (no_bgp_default_local_preference
,
4011 no_bgp_default_local_preference_cmd
,
4012 "no bgp default local-preference [(0-4294967295)]",
4015 "Configure BGP defaults\n"
4016 "local preference (higher=more preferred)\n"
4017 "Configure default local preference value\n")
4019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4020 bgp_default_local_preference_unset(bgp
);
4021 bgp_clear_star_soft_in(vty
, bgp
->name
);
4027 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4028 bgp_default_subgroup_pkt_queue_max_cmd
,
4029 "bgp default subgroup-pkt-queue-max (20-100)",
4031 "Configure BGP defaults\n"
4032 "subgroup-pkt-queue-max\n"
4033 "Configure subgroup packet queue max\n")
4035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4039 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4041 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4046 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4047 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4048 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4051 "Configure BGP defaults\n"
4052 "subgroup-pkt-queue-max\n"
4053 "Configure subgroup packet queue max\n")
4055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4056 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4061 DEFUN (bgp_rr_allow_outbound_policy
,
4062 bgp_rr_allow_outbound_policy_cmd
,
4063 "bgp route-reflector allow-outbound-policy",
4065 "Allow modifications made by out route-map\n"
4066 "on ibgp neighbors\n")
4068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4070 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4071 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4072 update_group_announce_rrclients(bgp
);
4073 bgp_clear_star_soft_out(vty
, bgp
->name
);
4079 DEFUN (no_bgp_rr_allow_outbound_policy
,
4080 no_bgp_rr_allow_outbound_policy_cmd
,
4081 "no bgp route-reflector allow-outbound-policy",
4084 "Allow modifications made by out route-map\n"
4085 "on ibgp neighbors\n")
4087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4089 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4090 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4091 update_group_announce_rrclients(bgp
);
4092 bgp_clear_star_soft_out(vty
, bgp
->name
);
4098 DEFUN (bgp_listen_limit
,
4099 bgp_listen_limit_cmd
,
4100 "bgp listen limit (1-65535)",
4102 "BGP Dynamic Neighbors listen commands\n"
4103 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4104 "Configure Dynamic Neighbors listen limit value\n")
4106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4110 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4112 bgp_listen_limit_set(bgp
, listen_limit
);
4117 DEFUN (no_bgp_listen_limit
,
4118 no_bgp_listen_limit_cmd
,
4119 "no bgp listen limit [(1-65535)]",
4122 "BGP Dynamic Neighbors listen commands\n"
4123 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4124 "Configure Dynamic Neighbors listen limit value\n")
4126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4127 bgp_listen_limit_unset(bgp
);
4133 * Check if this listen range is already configured. Check for exact
4134 * match or overlap based on input.
4136 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4137 struct prefix
*range
, int exact
)
4139 struct listnode
*node
, *nnode
;
4140 struct listnode
*node1
, *nnode1
;
4141 struct peer_group
*group
;
4146 afi
= family2afi(range
->family
);
4147 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4148 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4151 match
= prefix_same(range
, lr
);
4153 match
= (prefix_match(range
, lr
)
4154 || prefix_match(lr
, range
));
4163 DEFUN (bgp_listen_range
,
4164 bgp_listen_range_cmd
,
4165 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4167 "Configure BGP dynamic neighbors listen range\n"
4168 "Configure BGP dynamic neighbors listen range\n"
4170 "Member of the peer-group\n"
4171 "Peer-group name\n")
4173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4174 struct prefix range
;
4175 struct peer_group
*group
, *existing_group
;
4180 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4181 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4182 char *prefix
= argv
[idx
]->arg
;
4183 argv_find(argv
, argc
, "PGNAME", &idx
);
4184 char *peergroup
= argv
[idx
]->arg
;
4186 /* Convert IP prefix string to struct prefix. */
4187 ret
= str2prefix(prefix
, &range
);
4189 vty_out(vty
, "%% Malformed listen range\n");
4190 return CMD_WARNING_CONFIG_FAILED
;
4193 afi
= family2afi(range
.family
);
4195 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4197 "%% Malformed listen range (link-local address)\n");
4198 return CMD_WARNING_CONFIG_FAILED
;
4203 /* Check if same listen range is already configured. */
4204 existing_group
= listen_range_exists(bgp
, &range
, 1);
4205 if (existing_group
) {
4206 if (strcmp(existing_group
->name
, peergroup
) == 0)
4210 "%% Same listen range is attached to peer-group %s\n",
4211 existing_group
->name
);
4212 return CMD_WARNING_CONFIG_FAILED
;
4216 /* Check if an overlapping listen range exists. */
4217 if (listen_range_exists(bgp
, &range
, 0)) {
4219 "%% Listen range overlaps with existing listen range\n");
4220 return CMD_WARNING_CONFIG_FAILED
;
4223 group
= peer_group_lookup(bgp
, peergroup
);
4225 vty_out(vty
, "%% Configure the peer-group first\n");
4226 return CMD_WARNING_CONFIG_FAILED
;
4229 ret
= peer_group_listen_range_add(group
, &range
);
4230 return bgp_vty_return(vty
, ret
);
4233 DEFUN (no_bgp_listen_range
,
4234 no_bgp_listen_range_cmd
,
4235 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4238 "Unconfigure BGP dynamic neighbors listen range\n"
4239 "Unconfigure BGP dynamic neighbors listen range\n"
4241 "Member of the peer-group\n"
4242 "Peer-group name\n")
4244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4245 struct prefix range
;
4246 struct peer_group
*group
;
4251 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4252 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4253 char *prefix
= argv
[idx
]->arg
;
4254 argv_find(argv
, argc
, "PGNAME", &idx
);
4255 char *peergroup
= argv
[idx
]->arg
;
4257 /* Convert IP prefix string to struct prefix. */
4258 ret
= str2prefix(prefix
, &range
);
4260 vty_out(vty
, "%% Malformed listen range\n");
4261 return CMD_WARNING_CONFIG_FAILED
;
4264 afi
= family2afi(range
.family
);
4266 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4268 "%% Malformed listen range (link-local address)\n");
4269 return CMD_WARNING_CONFIG_FAILED
;
4274 group
= peer_group_lookup(bgp
, peergroup
);
4276 vty_out(vty
, "%% Peer-group does not exist\n");
4277 return CMD_WARNING_CONFIG_FAILED
;
4280 ret
= peer_group_listen_range_del(group
, &range
);
4281 return bgp_vty_return(vty
, ret
);
4284 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4286 struct peer_group
*group
;
4287 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4288 struct prefix
*range
;
4291 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4292 vty_out(vty
, " bgp listen limit %d\n",
4293 bgp
->dynamic_neighbors_limit
);
4295 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4296 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4297 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4300 " bgp listen range %pFX peer-group %s\n",
4301 range
, group
->name
);
4308 DEFUN (bgp_disable_connected_route_check
,
4309 bgp_disable_connected_route_check_cmd
,
4310 "bgp disable-ebgp-connected-route-check",
4312 "Disable checking if nexthop is connected on ebgp sessions\n")
4314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4315 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4316 bgp_clear_star_soft_in(vty
, bgp
->name
);
4321 DEFUN (no_bgp_disable_connected_route_check
,
4322 no_bgp_disable_connected_route_check_cmd
,
4323 "no bgp disable-ebgp-connected-route-check",
4326 "Disable checking if nexthop is connected on ebgp sessions\n")
4328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4329 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4330 bgp_clear_star_soft_in(vty
, bgp
->name
);
4336 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4339 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4342 int as_type
= AS_SPECIFIED
;
4345 if (as_str
[0] == 'i') {
4347 as_type
= AS_INTERNAL
;
4348 } else if (as_str
[0] == 'e') {
4350 as_type
= AS_EXTERNAL
;
4352 /* Get AS number. */
4353 as
= strtoul(as_str
, NULL
, 10);
4356 /* If peer is peer group or interface peer, call proper function. */
4357 ret
= str2sockunion(peer_str
, &su
);
4361 /* Check if existing interface peer */
4362 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4364 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4366 /* if not interface peer, check peer-group settings */
4367 if (ret
< 0 && !peer
) {
4368 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4371 "%% Create the peer-group or interface first\n");
4372 return CMD_WARNING_CONFIG_FAILED
;
4377 if (peer_address_self_check(bgp
, &su
)) {
4379 "%% Can not configure the local system as neighbor\n");
4380 return CMD_WARNING_CONFIG_FAILED
;
4382 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4385 return bgp_vty_return(vty
, ret
);
4388 DEFUN (bgp_default_shutdown
,
4389 bgp_default_shutdown_cmd
,
4390 "[no] bgp default shutdown",
4393 "Configure BGP defaults\n"
4394 "Apply administrative shutdown to newly configured peers\n")
4396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4397 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4401 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4403 "Administrative shutdown of the BGP instance\n"
4404 "Add a shutdown message (RFC 8203)\n"
4405 "Shutdown message\n")
4407 char *msgstr
= NULL
;
4409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4412 msgstr
= argv_concat(argv
, argc
, 3);
4414 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4415 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4416 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4417 return CMD_WARNING_CONFIG_FAILED
;
4420 bgp_shutdown_enable(bgp
, msgstr
);
4421 XFREE(MTYPE_TMP
, msgstr
);
4426 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4427 BGP_STR
"Administrative shutdown of the BGP instance\n")
4429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4431 bgp_shutdown_enable(bgp
, NULL
);
4436 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4437 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4439 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4441 bgp_shutdown_disable(bgp
);
4446 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4447 "no bgp shutdown message MSG...", NO_STR BGP_STR
4448 "Administrative shutdown of the BGP instance\n"
4449 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4451 DEFUN (neighbor_remote_as
,
4452 neighbor_remote_as_cmd
,
4453 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4456 "Specify a BGP neighbor\n"
4458 "Internal BGP peer\n"
4459 "External BGP peer\n")
4462 int idx_remote_as
= 3;
4463 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4464 argv
[idx_remote_as
]->arg
);
4467 DEFPY (bgp_allow_martian
,
4468 bgp_allow_martian_cmd
,
4469 "[no]$no bgp allow-martian-nexthop",
4472 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4477 bgp
->allow_martian
= false;
4479 bgp
->allow_martian
= true;
4484 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4485 * sessions do not wait for hold timer expiry to bring down the sessions
4486 * when nexthop becomes unreachable
4488 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4489 BGP_STR
"Fast convergence for bgp sessions\n")
4491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4492 bgp
->fast_convergence
= true;
4497 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4498 "no bgp fast-convergence",
4499 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4502 bgp
->fast_convergence
= false;
4507 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4509 const char *peer_group_name
,
4512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4514 int as_type
= AS_UNSPECIFIED
;
4516 struct peer_group
*group
;
4519 group
= peer_group_lookup(bgp
, conf_if
);
4522 vty_out(vty
, "%% Name conflict with peer-group \n");
4523 return CMD_WARNING_CONFIG_FAILED
;
4527 if (as_str
[0] == 'i') {
4528 as_type
= AS_INTERNAL
;
4529 } else if (as_str
[0] == 'e') {
4530 as_type
= AS_EXTERNAL
;
4532 /* Get AS number. */
4533 as
= strtoul(as_str
, NULL
, 10);
4534 as_type
= AS_SPECIFIED
;
4538 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4541 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4543 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4547 vty_out(vty
, "%% BGP failed to create peer\n");
4548 return CMD_WARNING_CONFIG_FAILED
;
4552 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4554 /* Request zebra to initiate IPv6 RAs on this interface. We do
4556 * any unnumbered peer in order to not worry about run-time
4558 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4560 * gets deleted later etc.)
4563 bgp_zebra_initiate_radv(bgp
, peer
);
4566 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4567 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4569 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4571 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4573 /* v6only flag changed. Reset bgp seesion */
4574 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4575 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4576 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4577 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4579 bgp_session_reset(peer
);
4582 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4583 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4584 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4585 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4588 if (peer_group_name
) {
4589 group
= peer_group_lookup(bgp
, peer_group_name
);
4591 vty_out(vty
, "%% Configure the peer-group first\n");
4592 return CMD_WARNING_CONFIG_FAILED
;
4595 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4598 return bgp_vty_return(vty
, ret
);
4601 DEFUN (neighbor_interface_config
,
4602 neighbor_interface_config_cmd
,
4603 "neighbor WORD interface [peer-group PGNAME]",
4605 "Interface name or neighbor tag\n"
4606 "Enable BGP on interface\n"
4607 "Member of the peer-group\n"
4608 "Peer-group name\n")
4611 int idx_peer_group_word
= 4;
4613 if (argc
> idx_peer_group_word
)
4614 return peer_conf_interface_get(
4615 vty
, argv
[idx_word
]->arg
, 0,
4616 argv
[idx_peer_group_word
]->arg
, NULL
);
4618 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4622 DEFUN (neighbor_interface_config_v6only
,
4623 neighbor_interface_config_v6only_cmd
,
4624 "neighbor WORD interface v6only [peer-group PGNAME]",
4626 "Interface name or neighbor tag\n"
4627 "Enable BGP on interface\n"
4628 "Enable BGP with v6 link-local only\n"
4629 "Member of the peer-group\n"
4630 "Peer-group name\n")
4633 int idx_peer_group_word
= 5;
4635 if (argc
> idx_peer_group_word
)
4636 return peer_conf_interface_get(
4637 vty
, argv
[idx_word
]->arg
, 1,
4638 argv
[idx_peer_group_word
]->arg
, NULL
);
4640 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4644 DEFUN (neighbor_interface_config_remote_as
,
4645 neighbor_interface_config_remote_as_cmd
,
4646 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4648 "Interface name or neighbor tag\n"
4649 "Enable BGP on interface\n"
4650 "Specify a BGP neighbor\n"
4652 "Internal BGP peer\n"
4653 "External BGP peer\n")
4656 int idx_remote_as
= 4;
4657 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4658 argv
[idx_remote_as
]->arg
);
4661 DEFUN (neighbor_interface_v6only_config_remote_as
,
4662 neighbor_interface_v6only_config_remote_as_cmd
,
4663 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4665 "Interface name or neighbor tag\n"
4666 "Enable BGP with v6 link-local only\n"
4667 "Enable BGP on interface\n"
4668 "Specify a BGP neighbor\n"
4670 "Internal BGP peer\n"
4671 "External BGP peer\n")
4674 int idx_remote_as
= 5;
4675 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4676 argv
[idx_remote_as
]->arg
);
4679 DEFUN (neighbor_peer_group
,
4680 neighbor_peer_group_cmd
,
4681 "neighbor WORD peer-group",
4683 "Interface name or neighbor tag\n"
4684 "Configure peer-group\n")
4686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4689 struct peer_group
*group
;
4691 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4693 vty_out(vty
, "%% Name conflict with interface: \n");
4694 return CMD_WARNING_CONFIG_FAILED
;
4697 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4699 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4700 return CMD_WARNING_CONFIG_FAILED
;
4708 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4712 "Specify a BGP neighbor\n"
4714 "Internal BGP peer\n"
4715 "External BGP peer\n")
4717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4721 struct peer_group
*group
;
4725 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4727 /* look up for neighbor by interface name config. */
4728 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4730 /* Request zebra to terminate IPv6 RAs on this
4733 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4734 peer_notify_unconfig(peer
);
4739 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4741 peer_group_notify_unconfig(group
);
4742 peer_group_delete(group
);
4744 vty_out(vty
, "%% Create the peer-group first\n");
4745 return CMD_WARNING_CONFIG_FAILED
;
4748 peer
= peer_lookup(bgp
, &su
);
4750 if (peer_dynamic_neighbor(peer
)) {
4752 "%% Operation not allowed on a dynamic neighbor\n");
4753 return CMD_WARNING_CONFIG_FAILED
;
4756 other
= peer
->doppelganger
;
4758 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4759 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4761 peer_notify_unconfig(peer
);
4763 if (other
&& other
->status
!= Deleted
) {
4764 peer_notify_unconfig(other
);
4773 DEFUN (no_neighbor_interface_config
,
4774 no_neighbor_interface_config_cmd
,
4775 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4779 "Configure BGP on interface\n"
4780 "Enable BGP with v6 link-local only\n"
4781 "Member of the peer-group\n"
4783 "Specify a BGP neighbor\n"
4785 "Internal BGP peer\n"
4786 "External BGP peer\n")
4788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4792 /* look up for neighbor by interface name config. */
4793 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4795 /* Request zebra to terminate IPv6 RAs on this interface. */
4797 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4798 peer_notify_unconfig(peer
);
4801 vty_out(vty
, "%% Create the bgp interface first\n");
4802 return CMD_WARNING_CONFIG_FAILED
;
4807 DEFUN (no_neighbor_peer_group
,
4808 no_neighbor_peer_group_cmd
,
4809 "no neighbor WORD peer-group",
4813 "Configure peer-group\n")
4815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4817 struct peer_group
*group
;
4819 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4821 peer_group_notify_unconfig(group
);
4822 peer_group_delete(group
);
4824 vty_out(vty
, "%% Create the peer-group first\n");
4825 return CMD_WARNING_CONFIG_FAILED
;
4830 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4831 no_neighbor_interface_peer_group_remote_as_cmd
,
4832 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4835 "Interface name or neighbor tag\n"
4836 "Specify a BGP neighbor\n"
4838 "Internal BGP peer\n"
4839 "External BGP peer\n")
4841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4843 struct peer_group
*group
;
4846 /* look up for neighbor by interface name config. */
4847 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4849 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4853 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4855 peer_group_remote_as_delete(group
);
4857 vty_out(vty
, "%% Create the peer-group or interface first\n");
4858 return CMD_WARNING_CONFIG_FAILED
;
4863 DEFUN (neighbor_local_as
,
4864 neighbor_local_as_cmd
,
4865 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4868 "Specify a local-as number\n"
4869 "AS number used as local AS\n")
4877 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4879 return CMD_WARNING_CONFIG_FAILED
;
4881 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4882 ret
= peer_local_as_set(peer
, as
, 0, 0);
4883 return bgp_vty_return(vty
, ret
);
4886 DEFUN (neighbor_local_as_no_prepend
,
4887 neighbor_local_as_no_prepend_cmd
,
4888 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4891 "Specify a local-as number\n"
4892 "AS number used as local AS\n"
4893 "Do not prepend local-as to updates from ebgp peers\n")
4901 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4903 return CMD_WARNING_CONFIG_FAILED
;
4905 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4906 ret
= peer_local_as_set(peer
, as
, 1, 0);
4907 return bgp_vty_return(vty
, ret
);
4910 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4911 neighbor_local_as_no_prepend_replace_as_cmd
,
4912 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4915 "Specify a local-as number\n"
4916 "AS number used as local AS\n"
4917 "Do not prepend local-as to updates from ebgp peers\n"
4918 "Do not prepend local-as to updates from ibgp peers\n")
4926 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4928 return CMD_WARNING_CONFIG_FAILED
;
4930 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4931 ret
= peer_local_as_set(peer
, as
, 1, 1);
4932 return bgp_vty_return(vty
, ret
);
4935 DEFUN (no_neighbor_local_as
,
4936 no_neighbor_local_as_cmd
,
4937 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4941 "Specify a local-as number\n"
4942 "AS number used as local AS\n"
4943 "Do not prepend local-as to updates from ebgp peers\n"
4944 "Do not prepend local-as to updates from ibgp peers\n")
4950 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4952 return CMD_WARNING_CONFIG_FAILED
;
4954 ret
= peer_local_as_unset(peer
);
4955 return bgp_vty_return(vty
, ret
);
4959 DEFUN (neighbor_solo
,
4961 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4964 "Solo peer - part of its own update group\n")
4970 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4972 return CMD_WARNING_CONFIG_FAILED
;
4974 ret
= update_group_adjust_soloness(peer
, 1);
4975 return bgp_vty_return(vty
, ret
);
4978 DEFUN (no_neighbor_solo
,
4979 no_neighbor_solo_cmd
,
4980 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4984 "Solo peer - part of its own update group\n")
4990 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4992 return CMD_WARNING_CONFIG_FAILED
;
4994 ret
= update_group_adjust_soloness(peer
, 0);
4995 return bgp_vty_return(vty
, ret
);
4998 DEFUN (neighbor_password
,
4999 neighbor_password_cmd
,
5000 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5011 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5013 return CMD_WARNING_CONFIG_FAILED
;
5015 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5016 return bgp_vty_return(vty
, ret
);
5019 DEFUN (no_neighbor_password
,
5020 no_neighbor_password_cmd
,
5021 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5032 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5034 return CMD_WARNING_CONFIG_FAILED
;
5036 ret
= peer_password_unset(peer
);
5037 return bgp_vty_return(vty
, ret
);
5040 DEFUN (neighbor_activate
,
5041 neighbor_activate_cmd
,
5042 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5045 "Enable the Address Family for this Neighbor\n")
5051 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5053 return CMD_WARNING_CONFIG_FAILED
;
5055 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5056 return bgp_vty_return(vty
, ret
);
5059 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5060 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5061 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5062 "Enable the Address Family for this Neighbor\n")
5064 DEFUN (no_neighbor_activate
,
5065 no_neighbor_activate_cmd
,
5066 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5070 "Enable the Address Family for this Neighbor\n")
5077 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5079 return CMD_WARNING_CONFIG_FAILED
;
5081 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5082 return bgp_vty_return(vty
, ret
);
5085 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5086 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5087 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5088 "Enable the Address Family for this Neighbor\n")
5090 DEFUN (neighbor_set_peer_group
,
5091 neighbor_set_peer_group_cmd
,
5092 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5095 "Member of the peer-group\n"
5096 "Peer-group name\n")
5098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5105 struct peer_group
*group
;
5107 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5109 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5111 vty_out(vty
, "%% Malformed address or name: %s\n",
5112 argv
[idx_peer
]->arg
);
5113 return CMD_WARNING_CONFIG_FAILED
;
5116 if (peer_address_self_check(bgp
, &su
)) {
5118 "%% Can not configure the local system as neighbor\n");
5119 return CMD_WARNING_CONFIG_FAILED
;
5122 /* Disallow for dynamic neighbor. */
5123 peer
= peer_lookup(bgp
, &su
);
5124 if (peer
&& peer_dynamic_neighbor(peer
)) {
5126 "%% Operation not allowed on a dynamic neighbor\n");
5127 return CMD_WARNING_CONFIG_FAILED
;
5131 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5133 vty_out(vty
, "%% Configure the peer-group first\n");
5134 return CMD_WARNING_CONFIG_FAILED
;
5137 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5139 return bgp_vty_return(vty
, ret
);
5142 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5143 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5144 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5145 "Member of the peer-group\n"
5146 "Peer-group name\n")
5148 DEFUN (no_neighbor_set_peer_group
,
5149 no_neighbor_set_peer_group_cmd
,
5150 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5154 "Member of the peer-group\n"
5155 "Peer-group name\n")
5157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5162 struct peer_group
*group
;
5164 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5166 return CMD_WARNING_CONFIG_FAILED
;
5168 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5170 vty_out(vty
, "%% Configure the peer-group first\n");
5171 return CMD_WARNING_CONFIG_FAILED
;
5174 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5175 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5177 peer_notify_unconfig(peer
);
5178 ret
= peer_delete(peer
);
5180 return bgp_vty_return(vty
, ret
);
5183 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5184 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5185 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5186 "Member of the peer-group\n"
5187 "Peer-group name\n")
5189 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5190 uint64_t flag
, int set
)
5195 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5197 return CMD_WARNING_CONFIG_FAILED
;
5200 * If 'neighbor <interface>', then this is for directly connected peers,
5201 * we should not accept disable-connected-check.
5203 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5205 "%s is directly connected peer, cannot accept disable-connected-check\n",
5207 return CMD_WARNING_CONFIG_FAILED
;
5210 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5211 peer_tx_shutdown_message_unset(peer
);
5214 ret
= peer_flag_set(peer
, flag
);
5216 ret
= peer_flag_unset(peer
, flag
);
5218 return bgp_vty_return(vty
, ret
);
5221 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5223 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5226 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5229 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5232 /* neighbor passive. */
5233 DEFUN (neighbor_passive
,
5234 neighbor_passive_cmd
,
5235 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5238 "Don't send open messages to this neighbor\n")
5241 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5244 DEFUN (no_neighbor_passive
,
5245 no_neighbor_passive_cmd
,
5246 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5250 "Don't send open messages to this neighbor\n")
5253 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5256 /* neighbor shutdown. */
5257 DEFUN (neighbor_shutdown_msg
,
5258 neighbor_shutdown_msg_cmd
,
5259 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5262 "Administratively shut down this neighbor\n"
5263 "Add a shutdown message (RFC 8203)\n"
5264 "Shutdown message\n")
5270 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5274 return CMD_WARNING_CONFIG_FAILED
;
5275 message
= argv_concat(argv
, argc
, 4);
5276 peer_tx_shutdown_message_set(peer
, message
);
5277 XFREE(MTYPE_TMP
, message
);
5280 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5283 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5284 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5285 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5286 "Administratively shut down this neighbor\n")
5288 DEFUN (no_neighbor_shutdown_msg
,
5289 no_neighbor_shutdown_msg_cmd
,
5290 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5294 "Administratively shut down this neighbor\n"
5295 "Remove a shutdown message (RFC 8203)\n"
5296 "Shutdown message\n")
5300 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5301 PEER_FLAG_SHUTDOWN
);
5304 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5305 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5306 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5307 "Administratively shut down this neighbor\n")
5309 DEFUN(neighbor_shutdown_rtt
,
5310 neighbor_shutdown_rtt_cmd
,
5311 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5314 "Administratively shut down this neighbor\n"
5315 "Shutdown if round-trip-time is higher than expected\n"
5316 "Round-trip-time in milliseconds\n"
5317 "Specify the number of keepalives before shutdown\n"
5318 "The number of keepalives with higher RTT to shutdown\n")
5325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5328 return CMD_WARNING_CONFIG_FAILED
;
5330 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5332 if (argv_find(argv
, argc
, "count", &idx_count
))
5333 peer
->rtt_keepalive_conf
=
5334 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5336 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5337 PEER_FLAG_RTT_SHUTDOWN
);
5340 DEFUN(no_neighbor_shutdown_rtt
,
5341 no_neighbor_shutdown_rtt_cmd
,
5342 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5346 "Administratively shut down this neighbor\n"
5347 "Shutdown if round-trip-time is higher than expected\n"
5348 "Round-trip-time in milliseconds\n"
5349 "Specify the number of keepalives before shutdown\n"
5350 "The number of keepalives with higher RTT to shutdown\n")
5355 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5358 return CMD_WARNING_CONFIG_FAILED
;
5360 peer
->rtt_expected
= 0;
5361 peer
->rtt_keepalive_conf
= 1;
5363 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5364 PEER_FLAG_RTT_SHUTDOWN
);
5367 /* neighbor capability dynamic. */
5368 DEFUN (neighbor_capability_dynamic
,
5369 neighbor_capability_dynamic_cmd
,
5370 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5373 "Advertise capability to the peer\n"
5374 "Advertise dynamic capability to this neighbor\n")
5377 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5378 PEER_FLAG_DYNAMIC_CAPABILITY
);
5381 DEFUN (no_neighbor_capability_dynamic
,
5382 no_neighbor_capability_dynamic_cmd
,
5383 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5387 "Advertise capability to the peer\n"
5388 "Advertise dynamic capability to this neighbor\n")
5391 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5392 PEER_FLAG_DYNAMIC_CAPABILITY
);
5395 /* neighbor dont-capability-negotiate */
5396 DEFUN (neighbor_dont_capability_negotiate
,
5397 neighbor_dont_capability_negotiate_cmd
,
5398 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5401 "Do not perform capability negotiation\n")
5404 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5405 PEER_FLAG_DONT_CAPABILITY
);
5408 DEFUN (no_neighbor_dont_capability_negotiate
,
5409 no_neighbor_dont_capability_negotiate_cmd
,
5410 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5414 "Do not perform capability negotiation\n")
5417 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5418 PEER_FLAG_DONT_CAPABILITY
);
5421 /* neighbor capability extended next hop encoding */
5422 DEFUN (neighbor_capability_enhe
,
5423 neighbor_capability_enhe_cmd
,
5424 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5427 "Advertise capability to the peer\n"
5428 "Advertise extended next-hop capability to the peer\n")
5433 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5434 if (peer
&& peer
->conf_if
)
5437 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5438 PEER_FLAG_CAPABILITY_ENHE
);
5441 DEFUN (no_neighbor_capability_enhe
,
5442 no_neighbor_capability_enhe_cmd
,
5443 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5447 "Advertise capability to the peer\n"
5448 "Advertise extended next-hop capability to the peer\n")
5453 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5454 if (peer
&& peer
->conf_if
) {
5456 "Peer %s cannot have capability extended-nexthop turned off\n",
5457 argv
[idx_peer
]->arg
);
5458 return CMD_WARNING_CONFIG_FAILED
;
5461 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5462 PEER_FLAG_CAPABILITY_ENHE
);
5465 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5466 afi_t afi
, safi_t safi
, uint32_t flag
,
5472 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5474 return CMD_WARNING_CONFIG_FAILED
;
5477 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5479 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5481 return bgp_vty_return(vty
, ret
);
5484 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5485 afi_t afi
, safi_t safi
, uint32_t flag
)
5487 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5490 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5491 afi_t afi
, safi_t safi
, uint32_t flag
)
5493 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5496 /* neighbor capability orf prefix-list. */
5497 DEFUN (neighbor_capability_orf_prefix
,
5498 neighbor_capability_orf_prefix_cmd
,
5499 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5502 "Advertise capability to the peer\n"
5503 "Advertise ORF capability to the peer\n"
5504 "Advertise prefixlist ORF capability to this neighbor\n"
5505 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5506 "Capability to RECEIVE the ORF from this neighbor\n"
5507 "Capability to SEND the ORF to this neighbor\n")
5509 int idx_send_recv
= 5;
5510 char *peer_str
= argv
[1]->arg
;
5512 afi_t afi
= bgp_node_afi(vty
);
5513 safi_t safi
= bgp_node_safi(vty
);
5515 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5517 return CMD_WARNING_CONFIG_FAILED
;
5519 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5520 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5521 PEER_FLAG_ORF_PREFIX_SM
);
5523 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5524 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5525 PEER_FLAG_ORF_PREFIX_RM
);
5527 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5528 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5529 PEER_FLAG_ORF_PREFIX_SM
)
5530 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5531 PEER_FLAG_ORF_PREFIX_RM
);
5533 return CMD_WARNING_CONFIG_FAILED
;
5537 neighbor_capability_orf_prefix
,
5538 neighbor_capability_orf_prefix_hidden_cmd
,
5539 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5540 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5541 "Advertise capability to the peer\n"
5542 "Advertise ORF capability to the peer\n"
5543 "Advertise prefixlist ORF capability to this neighbor\n"
5544 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5545 "Capability to RECEIVE the ORF from this neighbor\n"
5546 "Capability to SEND the ORF to this neighbor\n")
5548 DEFUN (no_neighbor_capability_orf_prefix
,
5549 no_neighbor_capability_orf_prefix_cmd
,
5550 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5554 "Advertise capability to the peer\n"
5555 "Advertise ORF capability to the peer\n"
5556 "Advertise prefixlist ORF capability to this neighbor\n"
5557 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5558 "Capability to RECEIVE the ORF from this neighbor\n"
5559 "Capability to SEND the ORF to this neighbor\n")
5561 int idx_send_recv
= 6;
5562 char *peer_str
= argv
[2]->arg
;
5564 afi_t afi
= bgp_node_afi(vty
);
5565 safi_t safi
= bgp_node_safi(vty
);
5567 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5569 return CMD_WARNING_CONFIG_FAILED
;
5571 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5572 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5573 PEER_FLAG_ORF_PREFIX_SM
);
5575 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5576 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5577 PEER_FLAG_ORF_PREFIX_RM
);
5579 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5580 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5581 PEER_FLAG_ORF_PREFIX_SM
)
5582 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5583 PEER_FLAG_ORF_PREFIX_RM
);
5585 return CMD_WARNING_CONFIG_FAILED
;
5589 no_neighbor_capability_orf_prefix
,
5590 no_neighbor_capability_orf_prefix_hidden_cmd
,
5591 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5592 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5593 "Advertise capability to the peer\n"
5594 "Advertise ORF capability to the peer\n"
5595 "Advertise prefixlist ORF capability to this neighbor\n"
5596 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5597 "Capability to RECEIVE the ORF from this neighbor\n"
5598 "Capability to SEND the ORF to this neighbor\n")
5600 /* neighbor next-hop-self. */
5601 DEFUN (neighbor_nexthop_self
,
5602 neighbor_nexthop_self_cmd
,
5603 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5606 "Disable the next hop calculation for this neighbor\n")
5609 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5610 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5613 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5614 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5615 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5616 "Disable the next hop calculation for this neighbor\n")
5618 /* neighbor next-hop-self. */
5619 DEFUN (neighbor_nexthop_self_force
,
5620 neighbor_nexthop_self_force_cmd
,
5621 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5624 "Disable the next hop calculation for this neighbor\n"
5625 "Set the next hop to self for reflected routes\n")
5628 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5630 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5633 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5634 neighbor_nexthop_self_force_hidden_cmd
,
5635 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5636 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Disable the next hop calculation for this neighbor\n"
5638 "Set the next hop to self for reflected routes\n")
5640 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5641 neighbor_nexthop_self_all_hidden_cmd
,
5642 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5643 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5644 "Disable the next hop calculation for this neighbor\n"
5645 "Set the next hop to self for reflected routes\n")
5647 DEFUN (no_neighbor_nexthop_self
,
5648 no_neighbor_nexthop_self_cmd
,
5649 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5653 "Disable the next hop calculation for this neighbor\n")
5656 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5657 bgp_node_afi(vty
), bgp_node_safi(vty
),
5658 PEER_FLAG_NEXTHOP_SELF
);
5661 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5662 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5663 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5664 "Disable the next hop calculation for this neighbor\n")
5666 DEFUN (no_neighbor_nexthop_self_force
,
5667 no_neighbor_nexthop_self_force_cmd
,
5668 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5672 "Disable the next hop calculation for this neighbor\n"
5673 "Set the next hop to self for reflected routes\n")
5676 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5677 bgp_node_afi(vty
), bgp_node_safi(vty
),
5678 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5681 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5682 no_neighbor_nexthop_self_force_hidden_cmd
,
5683 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5684 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5685 "Disable the next hop calculation for this neighbor\n"
5686 "Set the next hop to self for reflected routes\n")
5688 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5689 no_neighbor_nexthop_self_all_hidden_cmd
,
5690 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5691 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5692 "Disable the next hop calculation for this neighbor\n"
5693 "Set the next hop to self for reflected routes\n")
5695 /* neighbor as-override */
5696 DEFUN (neighbor_as_override
,
5697 neighbor_as_override_cmd
,
5698 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5701 "Override ASNs in outbound updates if aspath equals remote-as\n")
5704 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5705 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5708 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5709 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5710 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5711 "Override ASNs in outbound updates if aspath equals remote-as\n")
5713 DEFUN (no_neighbor_as_override
,
5714 no_neighbor_as_override_cmd
,
5715 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5719 "Override ASNs in outbound updates if aspath equals remote-as\n")
5722 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5723 bgp_node_afi(vty
), bgp_node_safi(vty
),
5724 PEER_FLAG_AS_OVERRIDE
);
5727 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5728 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5729 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5730 "Override ASNs in outbound updates if aspath equals remote-as\n")
5732 /* neighbor remove-private-AS. */
5733 DEFUN (neighbor_remove_private_as
,
5734 neighbor_remove_private_as_cmd
,
5735 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5738 "Remove private ASNs in outbound updates\n")
5741 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5743 PEER_FLAG_REMOVE_PRIVATE_AS
);
5746 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5748 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5749 "Remove private ASNs in outbound updates\n")
5751 DEFUN (neighbor_remove_private_as_all
,
5752 neighbor_remove_private_as_all_cmd
,
5753 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5756 "Remove private ASNs in outbound updates\n"
5757 "Apply to all AS numbers\n")
5760 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5762 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5765 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5766 neighbor_remove_private_as_all_hidden_cmd
,
5767 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5768 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5769 "Remove private ASNs in outbound updates\n"
5770 "Apply to all AS numbers")
5772 DEFUN (neighbor_remove_private_as_replace_as
,
5773 neighbor_remove_private_as_replace_as_cmd
,
5774 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5777 "Remove private ASNs in outbound updates\n"
5778 "Replace private ASNs with our ASN in outbound updates\n")
5781 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5783 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5786 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5787 neighbor_remove_private_as_replace_as_hidden_cmd
,
5788 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5789 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5790 "Remove private ASNs in outbound updates\n"
5791 "Replace private ASNs with our ASN in outbound updates\n")
5793 DEFUN (neighbor_remove_private_as_all_replace_as
,
5794 neighbor_remove_private_as_all_replace_as_cmd
,
5795 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5798 "Remove private ASNs in outbound updates\n"
5799 "Apply to all AS numbers\n"
5800 "Replace private ASNs with our ASN in outbound updates\n")
5803 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5805 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5809 neighbor_remove_private_as_all_replace_as
,
5810 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5813 "Remove private ASNs in outbound updates\n"
5814 "Apply to all AS numbers\n"
5815 "Replace private ASNs with our ASN in outbound updates\n")
5817 DEFUN (no_neighbor_remove_private_as
,
5818 no_neighbor_remove_private_as_cmd
,
5819 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5823 "Remove private ASNs in outbound updates\n")
5826 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5827 bgp_node_afi(vty
), bgp_node_safi(vty
),
5828 PEER_FLAG_REMOVE_PRIVATE_AS
);
5831 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5832 no_neighbor_remove_private_as_hidden_cmd
,
5833 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5834 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5835 "Remove private ASNs in outbound updates\n")
5837 DEFUN (no_neighbor_remove_private_as_all
,
5838 no_neighbor_remove_private_as_all_cmd
,
5839 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5843 "Remove private ASNs in outbound updates\n"
5844 "Apply to all AS numbers\n")
5847 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5848 bgp_node_afi(vty
), bgp_node_safi(vty
),
5849 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5852 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5853 no_neighbor_remove_private_as_all_hidden_cmd
,
5854 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5855 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5856 "Remove private ASNs in outbound updates\n"
5857 "Apply to all AS numbers\n")
5859 DEFUN (no_neighbor_remove_private_as_replace_as
,
5860 no_neighbor_remove_private_as_replace_as_cmd
,
5861 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5865 "Remove private ASNs in outbound updates\n"
5866 "Replace private ASNs with our ASN in outbound updates\n")
5869 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5870 bgp_node_afi(vty
), bgp_node_safi(vty
),
5871 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5874 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5875 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5876 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5877 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5878 "Remove private ASNs in outbound updates\n"
5879 "Replace private ASNs with our ASN in outbound updates\n")
5881 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5882 no_neighbor_remove_private_as_all_replace_as_cmd
,
5883 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5887 "Remove private ASNs in outbound updates\n"
5888 "Apply to all AS numbers\n"
5889 "Replace private ASNs with our ASN in outbound updates\n")
5892 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5893 bgp_node_afi(vty
), bgp_node_safi(vty
),
5894 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5898 no_neighbor_remove_private_as_all_replace_as
,
5899 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5900 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5901 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5902 "Remove private ASNs in outbound updates\n"
5903 "Apply to all AS numbers\n"
5904 "Replace private ASNs with our ASN in outbound updates\n")
5907 /* neighbor send-community. */
5908 DEFUN (neighbor_send_community
,
5909 neighbor_send_community_cmd
,
5910 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5913 "Send Community attribute to this neighbor\n")
5917 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5919 PEER_FLAG_SEND_COMMUNITY
);
5922 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5925 "Send Community attribute to this neighbor\n")
5927 DEFUN (no_neighbor_send_community
,
5928 no_neighbor_send_community_cmd
,
5929 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5933 "Send Community attribute to this neighbor\n")
5937 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5938 bgp_node_afi(vty
), bgp_node_safi(vty
),
5939 PEER_FLAG_SEND_COMMUNITY
);
5942 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5943 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5944 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5945 "Send Community attribute to this neighbor\n")
5947 /* neighbor send-community extended. */
5948 DEFUN (neighbor_send_community_type
,
5949 neighbor_send_community_type_cmd
,
5950 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5953 "Send Community attribute to this neighbor\n"
5954 "Send Standard and Extended Community attributes\n"
5955 "Send Standard, Large and Extended Community attributes\n"
5956 "Send Extended Community attributes\n"
5957 "Send Standard Community attributes\n"
5958 "Send Large Community attributes\n")
5960 const char *type
= argv
[argc
- 1]->text
;
5961 char *peer_str
= argv
[1]->arg
;
5963 afi_t afi
= bgp_node_afi(vty
);
5964 safi_t safi
= bgp_node_safi(vty
);
5966 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5968 return CMD_WARNING_CONFIG_FAILED
;
5970 if (strmatch(type
, "standard"))
5971 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5972 PEER_FLAG_SEND_COMMUNITY
);
5974 if (strmatch(type
, "extended"))
5975 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5976 PEER_FLAG_SEND_EXT_COMMUNITY
);
5978 if (strmatch(type
, "large"))
5979 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5980 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5982 if (strmatch(type
, "both")) {
5983 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5984 PEER_FLAG_SEND_COMMUNITY
)
5985 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5986 PEER_FLAG_SEND_EXT_COMMUNITY
);
5988 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5989 PEER_FLAG_SEND_COMMUNITY
)
5990 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5991 PEER_FLAG_SEND_EXT_COMMUNITY
)
5992 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5993 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5997 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5998 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5999 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6000 "Send Community attribute to this neighbor\n"
6001 "Send Standard and Extended Community attributes\n"
6002 "Send Standard, Large and Extended Community attributes\n"
6003 "Send Extended Community attributes\n"
6004 "Send Standard Community attributes\n"
6005 "Send Large Community attributes\n")
6007 DEFUN (no_neighbor_send_community_type
,
6008 no_neighbor_send_community_type_cmd
,
6009 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6013 "Send Community attribute to this neighbor\n"
6014 "Send Standard and Extended Community attributes\n"
6015 "Send Standard, Large and Extended Community attributes\n"
6016 "Send Extended Community attributes\n"
6017 "Send Standard Community attributes\n"
6018 "Send Large Community attributes\n")
6020 const char *type
= argv
[argc
- 1]->text
;
6021 char *peer_str
= argv
[2]->arg
;
6023 afi_t afi
= bgp_node_afi(vty
);
6024 safi_t safi
= bgp_node_safi(vty
);
6026 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6028 return CMD_WARNING_CONFIG_FAILED
;
6030 if (strmatch(type
, "standard"))
6031 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6032 PEER_FLAG_SEND_COMMUNITY
);
6034 if (strmatch(type
, "extended"))
6035 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6036 PEER_FLAG_SEND_EXT_COMMUNITY
);
6038 if (strmatch(type
, "large"))
6039 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6040 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6042 if (strmatch(type
, "both")) {
6044 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6045 PEER_FLAG_SEND_COMMUNITY
)
6046 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6047 PEER_FLAG_SEND_EXT_COMMUNITY
);
6050 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6051 PEER_FLAG_SEND_COMMUNITY
)
6052 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6053 PEER_FLAG_SEND_EXT_COMMUNITY
)
6054 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6055 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6059 no_neighbor_send_community_type
,
6060 no_neighbor_send_community_type_hidden_cmd
,
6061 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6063 "Send Community attribute to this neighbor\n"
6064 "Send Standard and Extended Community attributes\n"
6065 "Send Standard, Large and Extended Community attributes\n"
6066 "Send Extended Community attributes\n"
6067 "Send Standard Community attributes\n"
6068 "Send Large Community attributes\n")
6070 /* neighbor soft-reconfig. */
6071 DEFUN (neighbor_soft_reconfiguration
,
6072 neighbor_soft_reconfiguration_cmd
,
6073 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6076 "Per neighbor soft reconfiguration\n"
6077 "Allow inbound soft reconfiguration for this neighbor\n")
6080 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6082 PEER_FLAG_SOFT_RECONFIG
);
6085 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6086 neighbor_soft_reconfiguration_hidden_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6089 "Per neighbor soft reconfiguration\n"
6090 "Allow inbound soft reconfiguration for this neighbor\n")
6092 DEFUN (no_neighbor_soft_reconfiguration
,
6093 no_neighbor_soft_reconfiguration_cmd
,
6094 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6098 "Per neighbor soft reconfiguration\n"
6099 "Allow inbound soft reconfiguration for this neighbor\n")
6102 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6103 bgp_node_afi(vty
), bgp_node_safi(vty
),
6104 PEER_FLAG_SOFT_RECONFIG
);
6107 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6108 no_neighbor_soft_reconfiguration_hidden_cmd
,
6109 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6110 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6111 "Per neighbor soft reconfiguration\n"
6112 "Allow inbound soft reconfiguration for this neighbor\n")
6114 DEFUN (neighbor_route_reflector_client
,
6115 neighbor_route_reflector_client_cmd
,
6116 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6119 "Configure a neighbor as Route Reflector client\n")
6125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6127 return CMD_WARNING_CONFIG_FAILED
;
6129 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6131 PEER_FLAG_REFLECTOR_CLIENT
);
6134 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6135 neighbor_route_reflector_client_hidden_cmd
,
6136 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6138 "Configure a neighbor as Route Reflector client\n")
6140 DEFUN (no_neighbor_route_reflector_client
,
6141 no_neighbor_route_reflector_client_cmd
,
6142 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6146 "Configure a neighbor as Route Reflector client\n")
6149 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6150 bgp_node_afi(vty
), bgp_node_safi(vty
),
6151 PEER_FLAG_REFLECTOR_CLIENT
);
6154 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6155 no_neighbor_route_reflector_client_hidden_cmd
,
6156 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6157 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6158 "Configure a neighbor as Route Reflector client\n")
6160 /* neighbor route-server-client. */
6161 DEFUN (neighbor_route_server_client
,
6162 neighbor_route_server_client_cmd
,
6163 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6166 "Configure a neighbor as Route Server client\n")
6171 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6173 return CMD_WARNING_CONFIG_FAILED
;
6174 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6176 PEER_FLAG_RSERVER_CLIENT
);
6179 ALIAS_HIDDEN(neighbor_route_server_client
,
6180 neighbor_route_server_client_hidden_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6183 "Configure a neighbor as Route Server client\n")
6185 DEFUN (no_neighbor_route_server_client
,
6186 no_neighbor_route_server_client_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6191 "Configure a neighbor as Route Server client\n")
6194 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6195 bgp_node_afi(vty
), bgp_node_safi(vty
),
6196 PEER_FLAG_RSERVER_CLIENT
);
6199 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6200 no_neighbor_route_server_client_hidden_cmd
,
6201 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6203 "Configure a neighbor as Route Server client\n")
6205 DEFUN (neighbor_nexthop_local_unchanged
,
6206 neighbor_nexthop_local_unchanged_cmd
,
6207 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6210 "Configure treatment of outgoing link-local nexthop attribute\n"
6211 "Leave link-local nexthop unchanged for this peer\n")
6214 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6216 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6219 DEFUN (no_neighbor_nexthop_local_unchanged
,
6220 no_neighbor_nexthop_local_unchanged_cmd
,
6221 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6225 "Configure treatment of outgoing link-local-nexthop attribute\n"
6226 "Leave link-local nexthop unchanged for this peer\n")
6229 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6230 bgp_node_afi(vty
), bgp_node_safi(vty
),
6231 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6234 DEFUN (neighbor_attr_unchanged
,
6235 neighbor_attr_unchanged_cmd
,
6236 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6239 "BGP attribute is propagated unchanged to this neighbor\n"
6240 "As-path attribute\n"
6241 "Nexthop attribute\n"
6245 char *peer_str
= argv
[1]->arg
;
6247 bool aspath
= false;
6248 bool nexthop
= false;
6250 afi_t afi
= bgp_node_afi(vty
);
6251 safi_t safi
= bgp_node_safi(vty
);
6254 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6256 return CMD_WARNING_CONFIG_FAILED
;
6258 if (argv_find(argv
, argc
, "as-path", &idx
))
6262 if (argv_find(argv
, argc
, "next-hop", &idx
))
6266 if (argv_find(argv
, argc
, "med", &idx
))
6269 /* no flags means all of them! */
6270 if (!aspath
&& !nexthop
&& !med
) {
6271 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6272 PEER_FLAG_AS_PATH_UNCHANGED
);
6273 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6274 PEER_FLAG_NEXTHOP_UNCHANGED
);
6275 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6276 PEER_FLAG_MED_UNCHANGED
);
6279 if (peer_af_flag_check(peer
, afi
, safi
,
6280 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6281 ret
|= peer_af_flag_unset_vty(
6282 vty
, peer_str
, afi
, safi
,
6283 PEER_FLAG_AS_PATH_UNCHANGED
);
6286 ret
|= peer_af_flag_set_vty(
6287 vty
, peer_str
, afi
, safi
,
6288 PEER_FLAG_AS_PATH_UNCHANGED
);
6291 if (peer_af_flag_check(peer
, afi
, safi
,
6292 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6293 ret
|= peer_af_flag_unset_vty(
6294 vty
, peer_str
, afi
, safi
,
6295 PEER_FLAG_NEXTHOP_UNCHANGED
);
6298 ret
|= peer_af_flag_set_vty(
6299 vty
, peer_str
, afi
, safi
,
6300 PEER_FLAG_NEXTHOP_UNCHANGED
);
6303 if (peer_af_flag_check(peer
, afi
, safi
,
6304 PEER_FLAG_MED_UNCHANGED
)) {
6305 ret
|= peer_af_flag_unset_vty(
6306 vty
, peer_str
, afi
, safi
,
6307 PEER_FLAG_MED_UNCHANGED
);
6310 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6311 PEER_FLAG_MED_UNCHANGED
);
6318 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6319 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6320 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6321 "BGP attribute is propagated unchanged to this neighbor\n"
6322 "As-path attribute\n"
6323 "Nexthop attribute\n"
6326 DEFUN (no_neighbor_attr_unchanged
,
6327 no_neighbor_attr_unchanged_cmd
,
6328 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6332 "BGP attribute is propagated unchanged to this neighbor\n"
6333 "As-path attribute\n"
6334 "Nexthop attribute\n"
6338 char *peer_str
= argv
[2]->arg
;
6340 bool aspath
= false;
6341 bool nexthop
= false;
6343 afi_t afi
= bgp_node_afi(vty
);
6344 safi_t safi
= bgp_node_safi(vty
);
6347 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6349 return CMD_WARNING_CONFIG_FAILED
;
6351 if (argv_find(argv
, argc
, "as-path", &idx
))
6355 if (argv_find(argv
, argc
, "next-hop", &idx
))
6359 if (argv_find(argv
, argc
, "med", &idx
))
6362 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6363 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6364 PEER_FLAG_AS_PATH_UNCHANGED
)
6365 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6366 PEER_FLAG_NEXTHOP_UNCHANGED
)
6367 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6368 PEER_FLAG_MED_UNCHANGED
);
6371 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6372 PEER_FLAG_AS_PATH_UNCHANGED
);
6375 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6376 PEER_FLAG_NEXTHOP_UNCHANGED
);
6379 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6380 PEER_FLAG_MED_UNCHANGED
);
6386 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6387 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6388 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6389 "BGP attribute is propagated unchanged to this neighbor\n"
6390 "As-path attribute\n"
6391 "Nexthop attribute\n"
6394 /* EBGP multihop configuration. */
6395 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6396 const char *ttl_str
)
6401 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6403 return CMD_WARNING_CONFIG_FAILED
;
6406 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6411 ttl
= strtoul(ttl_str
, NULL
, 10);
6413 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6416 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6420 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6422 return CMD_WARNING_CONFIG_FAILED
;
6424 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6427 /* neighbor ebgp-multihop. */
6428 DEFUN (neighbor_ebgp_multihop
,
6429 neighbor_ebgp_multihop_cmd
,
6430 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6433 "Allow EBGP neighbors not on directly connected networks\n")
6436 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6439 DEFUN (neighbor_ebgp_multihop_ttl
,
6440 neighbor_ebgp_multihop_ttl_cmd
,
6441 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6444 "Allow EBGP neighbors not on directly connected networks\n"
6445 "maximum hop count\n")
6449 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6450 argv
[idx_number
]->arg
);
6453 DEFUN (no_neighbor_ebgp_multihop
,
6454 no_neighbor_ebgp_multihop_cmd
,
6455 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6459 "Allow EBGP neighbors not on directly connected networks\n"
6460 "maximum hop count\n")
6463 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6466 static uint8_t get_role_by_name(const char *role_str
)
6468 if (strncmp(role_str
, "peer", 2) == 0)
6470 if (strncmp(role_str
, "provider", 2) == 0)
6471 return ROLE_PROVIDER
;
6472 if (strncmp(role_str
, "customer", 2) == 0)
6473 return ROLE_CUSTOMER
;
6474 if (strncmp(role_str
, "rs-server", 4) == 0)
6475 return ROLE_RS_SERVER
;
6476 if (strncmp(role_str
, "rs-client", 4) == 0)
6477 return ROLE_RS_CLIENT
;
6478 return ROLE_UNDEFINED
;
6481 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6482 const char *role_str
, bool strict_mode
)
6486 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6488 return CMD_WARNING_CONFIG_FAILED
;
6489 uint8_t role
= get_role_by_name(role_str
);
6491 if (role
== ROLE_UNDEFINED
)
6492 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6493 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6496 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6500 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6502 return CMD_WARNING_CONFIG_FAILED
;
6503 return bgp_vty_return(vty
, peer_role_unset(peer
));
6506 DEFPY(neighbor_role
,
6508 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6511 "Set session role\n"
6517 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6521 DEFPY(neighbor_role_strict
,
6522 neighbor_role_strict_cmd
,
6523 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6526 "Set session role\n"
6528 "Use additional restriction on peer\n")
6533 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6537 DEFPY(no_neighbor_role
,
6538 no_neighbor_role_cmd
,
6539 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6543 "Set session role\n"
6545 "Use additional restriction on peer\n")
6549 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6552 /* disable-connected-check */
6553 DEFUN (neighbor_disable_connected_check
,
6554 neighbor_disable_connected_check_cmd
,
6555 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6558 "one-hop away EBGP peer using loopback address\n"
6559 "Enforce EBGP neighbors perform multihop\n")
6562 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6563 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6566 DEFUN (no_neighbor_disable_connected_check
,
6567 no_neighbor_disable_connected_check_cmd
,
6568 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6572 "one-hop away EBGP peer using loopback address\n"
6573 "Enforce EBGP neighbors perform multihop\n")
6576 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6577 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6580 /* disable-link-bw-encoding-ieee */
6581 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6582 neighbor_disable_link_bw_encoding_ieee_cmd
,
6583 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6584 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6585 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6589 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6590 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6593 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6594 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6595 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6596 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6597 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6601 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6602 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6605 /* extended-optional-parameters */
6606 DEFUN(neighbor_extended_optional_parameters
,
6607 neighbor_extended_optional_parameters_cmd
,
6608 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6609 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6610 "Force the extended optional parameters format for OPEN messages\n")
6614 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6615 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6618 DEFUN(no_neighbor_extended_optional_parameters
,
6619 no_neighbor_extended_optional_parameters_cmd
,
6620 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6621 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6622 "Force the extended optional parameters format for OPEN messages\n")
6626 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6627 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6630 /* enforce-first-as */
6631 DEFUN (neighbor_enforce_first_as
,
6632 neighbor_enforce_first_as_cmd
,
6633 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6636 "Enforce the first AS for EBGP routes\n")
6640 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6641 PEER_FLAG_ENFORCE_FIRST_AS
);
6644 DEFUN (no_neighbor_enforce_first_as
,
6645 no_neighbor_enforce_first_as_cmd
,
6646 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6650 "Enforce the first AS for EBGP routes\n")
6654 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6655 PEER_FLAG_ENFORCE_FIRST_AS
);
6659 DEFUN (neighbor_description
,
6660 neighbor_description_cmd
,
6661 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6664 "Neighbor specific description\n"
6665 "Up to 80 characters describing this neighbor\n")
6672 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6674 return CMD_WARNING_CONFIG_FAILED
;
6676 str
= argv_concat(argv
, argc
, idx_line
);
6678 peer_description_set(peer
, str
);
6680 XFREE(MTYPE_TMP
, str
);
6685 DEFUN (no_neighbor_description
,
6686 no_neighbor_description_cmd
,
6687 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6691 "Neighbor specific description\n")
6696 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6698 return CMD_WARNING_CONFIG_FAILED
;
6700 peer_description_unset(peer
);
6705 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6706 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6708 "Neighbor specific description\n"
6709 "Up to 80 characters describing this neighbor\n")
6711 /* Neighbor update-source. */
6712 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6713 const char *source_str
)
6719 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6721 return CMD_WARNING_CONFIG_FAILED
;
6727 if (str2sockunion(source_str
, &su
) == 0)
6728 peer_update_source_addr_set(peer
, &su
);
6730 if (str2prefix(source_str
, &p
)) {
6732 "%% Invalid update-source, remove prefix length \n");
6733 return CMD_WARNING_CONFIG_FAILED
;
6735 peer_update_source_if_set(peer
, source_str
);
6738 peer_update_source_unset(peer
);
6743 #define BGP_UPDATE_SOURCE_HELP_STR \
6746 "Interface name (requires zebra to be running)\n"
6748 DEFUN (neighbor_update_source
,
6749 neighbor_update_source_cmd
,
6750 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6753 "Source of routing updates\n"
6754 BGP_UPDATE_SOURCE_HELP_STR
)
6758 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6759 argv
[idx_peer_2
]->arg
);
6762 DEFUN (no_neighbor_update_source
,
6763 no_neighbor_update_source_cmd
,
6764 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6768 "Source of routing updates\n"
6769 BGP_UPDATE_SOURCE_HELP_STR
)
6772 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6775 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6776 afi_t afi
, safi_t safi
,
6777 const char *rmap
, int set
)
6781 struct route_map
*route_map
= NULL
;
6783 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6785 return CMD_WARNING_CONFIG_FAILED
;
6789 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6790 ret
= peer_default_originate_set(peer
, afi
, safi
,
6793 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6795 return bgp_vty_return(vty
, ret
);
6798 /* neighbor default-originate. */
6799 DEFUN (neighbor_default_originate
,
6800 neighbor_default_originate_cmd
,
6801 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6804 "Originate default route to this neighbor\n")
6807 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6809 bgp_node_safi(vty
), NULL
, 1);
6812 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6813 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6814 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6815 "Originate default route to this neighbor\n")
6817 DEFUN (neighbor_default_originate_rmap
,
6818 neighbor_default_originate_rmap_cmd
,
6819 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6822 "Originate default route to this neighbor\n"
6823 "Route-map to specify criteria to originate default\n"
6828 return peer_default_originate_set_vty(
6829 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6830 argv
[idx_word
]->arg
, 1);
6834 neighbor_default_originate_rmap
,
6835 neighbor_default_originate_rmap_hidden_cmd
,
6836 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6837 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6838 "Originate default route to this neighbor\n"
6839 "Route-map to specify criteria to originate default\n"
6842 DEFUN (no_neighbor_default_originate
,
6843 no_neighbor_default_originate_cmd
,
6844 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6848 "Originate default route to this neighbor\n"
6849 "Route-map to specify criteria to originate default\n"
6853 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6855 bgp_node_safi(vty
), NULL
, 0);
6859 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6860 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6861 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6862 "Originate default route to this neighbor\n"
6863 "Route-map to specify criteria to originate default\n"
6867 /* Set neighbor's BGP port. */
6868 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6869 const char *port_str
)
6875 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6877 return CMD_WARNING_CONFIG_FAILED
;
6880 sp
= getservbyname("bgp", "tcp");
6881 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6883 port
= strtoul(port_str
, NULL
, 10);
6886 peer_port_set(peer
, port
);
6891 /* Set specified peer's BGP port. */
6892 DEFUN (neighbor_port
,
6894 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6897 "Neighbor's BGP port\n"
6898 "TCP port number\n")
6902 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6903 argv
[idx_number
]->arg
);
6906 DEFUN (no_neighbor_port
,
6907 no_neighbor_port_cmd
,
6908 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6912 "Neighbor's BGP port\n"
6913 "TCP port number\n")
6916 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6920 /* neighbor weight. */
6921 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6922 safi_t safi
, const char *weight_str
)
6926 unsigned long weight
;
6928 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6930 return CMD_WARNING_CONFIG_FAILED
;
6932 weight
= strtoul(weight_str
, NULL
, 10);
6934 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6935 return bgp_vty_return(vty
, ret
);
6938 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6944 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6946 return CMD_WARNING_CONFIG_FAILED
;
6948 ret
= peer_weight_unset(peer
, afi
, safi
);
6949 return bgp_vty_return(vty
, ret
);
6952 DEFUN (neighbor_weight
,
6953 neighbor_weight_cmd
,
6954 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6957 "Set default weight for routes from this neighbor\n"
6962 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6963 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6966 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6967 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6969 "Set default weight for routes from this neighbor\n"
6972 DEFUN (no_neighbor_weight
,
6973 no_neighbor_weight_cmd
,
6974 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6978 "Set default weight for routes from this neighbor\n"
6982 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6983 bgp_node_afi(vty
), bgp_node_safi(vty
));
6986 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6987 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6988 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6989 "Set default weight for routes from this neighbor\n"
6993 /* Override capability negotiation. */
6994 DEFUN (neighbor_override_capability
,
6995 neighbor_override_capability_cmd
,
6996 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6999 "Override capability negotiation result\n")
7002 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7003 PEER_FLAG_OVERRIDE_CAPABILITY
);
7006 DEFUN (no_neighbor_override_capability
,
7007 no_neighbor_override_capability_cmd
,
7008 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7012 "Override capability negotiation result\n")
7015 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7016 PEER_FLAG_OVERRIDE_CAPABILITY
);
7019 DEFUN (neighbor_strict_capability
,
7020 neighbor_strict_capability_cmd
,
7021 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7024 "Strict capability negotiation match\n")
7028 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7029 PEER_FLAG_STRICT_CAP_MATCH
);
7032 DEFUN (no_neighbor_strict_capability
,
7033 no_neighbor_strict_capability_cmd
,
7034 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7038 "Strict capability negotiation match\n")
7042 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7043 PEER_FLAG_STRICT_CAP_MATCH
);
7046 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7047 const char *keep_str
, const char *hold_str
)
7054 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7056 return CMD_WARNING_CONFIG_FAILED
;
7058 keepalive
= strtoul(keep_str
, NULL
, 10);
7059 holdtime
= strtoul(hold_str
, NULL
, 10);
7061 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7063 return bgp_vty_return(vty
, ret
);
7066 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7071 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7073 return CMD_WARNING_CONFIG_FAILED
;
7075 ret
= peer_timers_unset(peer
);
7077 return bgp_vty_return(vty
, ret
);
7080 DEFUN (neighbor_timers
,
7081 neighbor_timers_cmd
,
7082 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7085 "BGP per neighbor timers\n"
7086 "Keepalive interval\n"
7091 int idx_number_2
= 4;
7092 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7093 argv
[idx_number
]->arg
,
7094 argv
[idx_number_2
]->arg
);
7097 DEFUN (no_neighbor_timers
,
7098 no_neighbor_timers_cmd
,
7099 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7103 "BGP per neighbor timers\n"
7104 "Keepalive interval\n"
7108 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7112 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7113 const char *time_str
)
7119 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7121 return CMD_WARNING_CONFIG_FAILED
;
7123 connect
= strtoul(time_str
, NULL
, 10);
7125 ret
= peer_timers_connect_set(peer
, connect
);
7127 return bgp_vty_return(vty
, ret
);
7130 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7135 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7137 return CMD_WARNING_CONFIG_FAILED
;
7139 ret
= peer_timers_connect_unset(peer
);
7141 return bgp_vty_return(vty
, ret
);
7144 DEFUN (neighbor_timers_connect
,
7145 neighbor_timers_connect_cmd
,
7146 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7149 "BGP per neighbor timers\n"
7150 "BGP connect timer\n"
7155 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7156 argv
[idx_number
]->arg
);
7159 DEFUN (no_neighbor_timers_connect
,
7160 no_neighbor_timers_connect_cmd
,
7161 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7165 "BGP per neighbor timers\n"
7166 "BGP connect timer\n"
7170 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7173 DEFPY (neighbor_timers_delayopen
,
7174 neighbor_timers_delayopen_cmd
,
7175 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7178 "BGP per neighbor timers\n"
7179 "RFC 4271 DelayOpenTimer\n"
7180 "DelayOpenTime timer interval\n")
7184 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7186 return CMD_WARNING_CONFIG_FAILED
;
7189 if (peer_timers_delayopen_unset(peer
))
7190 return CMD_WARNING_CONFIG_FAILED
;
7192 if (peer_timers_delayopen_set(peer
, interval
))
7193 return CMD_WARNING_CONFIG_FAILED
;
7199 DEFPY (no_neighbor_timers_delayopen
,
7200 no_neighbor_timers_delayopen_cmd
,
7201 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7205 "BGP per neighbor timers\n"
7206 "RFC 4271 DelayOpenTimer\n"
7207 "DelayOpenTime timer interval\n")
7211 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7213 return CMD_WARNING_CONFIG_FAILED
;
7215 if (peer_timers_delayopen_unset(peer
))
7216 return CMD_WARNING_CONFIG_FAILED
;
7221 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7222 const char *time_str
, int set
)
7226 uint32_t routeadv
= 0;
7228 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7230 return CMD_WARNING_CONFIG_FAILED
;
7233 routeadv
= strtoul(time_str
, NULL
, 10);
7236 ret
= peer_advertise_interval_set(peer
, routeadv
);
7238 ret
= peer_advertise_interval_unset(peer
);
7240 return bgp_vty_return(vty
, ret
);
7243 DEFUN (neighbor_advertise_interval
,
7244 neighbor_advertise_interval_cmd
,
7245 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7248 "Minimum interval between sending BGP routing updates\n"
7249 "time in seconds\n")
7253 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7254 argv
[idx_number
]->arg
, 1);
7257 DEFUN (no_neighbor_advertise_interval
,
7258 no_neighbor_advertise_interval_cmd
,
7259 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7263 "Minimum interval between sending BGP routing updates\n"
7264 "time in seconds\n")
7267 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7271 /* Time to wait before processing route-map updates */
7272 DEFUN (bgp_set_route_map_delay_timer
,
7273 bgp_set_route_map_delay_timer_cmd
,
7274 "bgp route-map delay-timer (0-600)",
7276 "BGP route-map delay timer\n"
7277 "Time in secs to wait before processing route-map changes\n"
7278 "0 disables the timer, no route updates happen when route-maps change\n")
7281 uint32_t rmap_delay_timer
;
7283 if (argv
[idx_number
]->arg
) {
7284 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7285 bm
->rmap_update_timer
= rmap_delay_timer
;
7287 /* if the dynamic update handling is being disabled, and a timer
7289 * running, stop the timer and act as if the timer has already
7292 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7293 THREAD_OFF(bm
->t_rmap_update
);
7294 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7299 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7300 return CMD_WARNING_CONFIG_FAILED
;
7304 DEFUN (no_bgp_set_route_map_delay_timer
,
7305 no_bgp_set_route_map_delay_timer_cmd
,
7306 "no bgp route-map delay-timer [(0-600)]",
7309 "Default BGP route-map delay timer\n"
7310 "Reset to default time to wait for processing route-map changes\n"
7311 "0 disables the timer, no route updates happen when route-maps change\n")
7314 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7319 /* neighbor interface */
7320 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7325 peer
= peer_lookup_vty(vty
, ip_str
);
7326 if (!peer
|| peer
->conf_if
) {
7327 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7328 return CMD_WARNING_CONFIG_FAILED
;
7332 peer_interface_set(peer
, str
);
7334 peer_interface_unset(peer
);
7339 DEFUN (neighbor_interface
,
7340 neighbor_interface_cmd
,
7341 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7350 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7353 DEFUN (no_neighbor_interface
,
7354 no_neighbor_interface_cmd
,
7355 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7364 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7367 DEFUN (neighbor_distribute_list
,
7368 neighbor_distribute_list_cmd
,
7369 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7372 "Filter updates to/from this neighbor\n"
7373 "IP Access-list name\n"
7374 "Filter incoming updates\n"
7375 "Filter outgoing updates\n")
7382 const char *pstr
= argv
[idx_peer
]->arg
;
7383 const char *acl
= argv
[idx_acl
]->arg
;
7384 const char *inout
= argv
[argc
- 1]->text
;
7386 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7388 return CMD_WARNING_CONFIG_FAILED
;
7390 /* Check filter direction. */
7391 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7392 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7395 return bgp_vty_return(vty
, ret
);
7399 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7400 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7401 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7402 "Filter updates to/from this neighbor\n"
7403 "IP Access-list name\n"
7404 "Filter incoming updates\n"
7405 "Filter outgoing updates\n")
7407 DEFUN (no_neighbor_distribute_list
,
7408 no_neighbor_distribute_list_cmd
,
7409 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7413 "Filter updates to/from this neighbor\n"
7414 "IP Access-list name\n"
7415 "Filter incoming updates\n"
7416 "Filter outgoing updates\n")
7422 const char *pstr
= argv
[idx_peer
]->arg
;
7423 const char *inout
= argv
[argc
- 1]->text
;
7425 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7427 return CMD_WARNING_CONFIG_FAILED
;
7429 /* Check filter direction. */
7430 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7431 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7434 return bgp_vty_return(vty
, ret
);
7438 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7439 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7440 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7441 "Filter updates to/from this neighbor\n"
7442 "IP Access-list name\n"
7443 "Filter incoming updates\n"
7444 "Filter outgoing updates\n")
7446 /* Set prefix list to the peer. */
7447 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7448 afi_t afi
, safi_t safi
,
7449 const char *name_str
,
7450 const char *direct_str
)
7453 int direct
= FILTER_IN
;
7456 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7458 return CMD_WARNING_CONFIG_FAILED
;
7460 /* Check filter direction. */
7461 if (strncmp(direct_str
, "i", 1) == 0)
7463 else if (strncmp(direct_str
, "o", 1) == 0)
7464 direct
= FILTER_OUT
;
7466 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7468 return bgp_vty_return(vty
, ret
);
7471 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7472 afi_t afi
, safi_t safi
,
7473 const char *direct_str
)
7477 int direct
= FILTER_IN
;
7479 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7481 return CMD_WARNING_CONFIG_FAILED
;
7483 /* Check filter direction. */
7484 if (strncmp(direct_str
, "i", 1) == 0)
7486 else if (strncmp(direct_str
, "o", 1) == 0)
7487 direct
= FILTER_OUT
;
7489 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7491 return bgp_vty_return(vty
, ret
);
7494 DEFUN (neighbor_prefix_list
,
7495 neighbor_prefix_list_cmd
,
7496 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7499 "Filter updates to/from this neighbor\n"
7500 "Name of a prefix list\n"
7501 "Filter incoming updates\n"
7502 "Filter outgoing updates\n")
7507 return peer_prefix_list_set_vty(
7508 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7509 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7512 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7513 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7514 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7515 "Filter updates to/from this neighbor\n"
7516 "Name of a prefix list\n"
7517 "Filter incoming updates\n"
7518 "Filter outgoing updates\n")
7520 DEFUN (no_neighbor_prefix_list
,
7521 no_neighbor_prefix_list_cmd
,
7522 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7526 "Filter updates to/from this neighbor\n"
7527 "Name of a prefix list\n"
7528 "Filter incoming updates\n"
7529 "Filter outgoing updates\n")
7533 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7534 bgp_node_afi(vty
), bgp_node_safi(vty
),
7535 argv
[idx_in_out
]->arg
);
7538 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7539 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7540 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7541 "Filter updates to/from this neighbor\n"
7542 "Name of a prefix list\n"
7543 "Filter incoming updates\n"
7544 "Filter outgoing updates\n")
7546 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7547 safi_t safi
, const char *name_str
,
7548 const char *direct_str
)
7552 int direct
= FILTER_IN
;
7554 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7556 return CMD_WARNING_CONFIG_FAILED
;
7558 /* Check filter direction. */
7559 if (strncmp(direct_str
, "i", 1) == 0)
7561 else if (strncmp(direct_str
, "o", 1) == 0)
7562 direct
= FILTER_OUT
;
7564 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7566 return bgp_vty_return(vty
, ret
);
7569 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7570 safi_t safi
, const char *direct_str
)
7574 int direct
= FILTER_IN
;
7576 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7578 return CMD_WARNING_CONFIG_FAILED
;
7580 /* Check filter direction. */
7581 if (strncmp(direct_str
, "i", 1) == 0)
7583 else if (strncmp(direct_str
, "o", 1) == 0)
7584 direct
= FILTER_OUT
;
7586 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7588 return bgp_vty_return(vty
, ret
);
7591 DEFUN (neighbor_filter_list
,
7592 neighbor_filter_list_cmd
,
7593 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7596 "Establish BGP filters\n"
7597 "AS path access-list name\n"
7598 "Filter incoming routes\n"
7599 "Filter outgoing routes\n")
7604 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7605 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7606 argv
[idx_in_out
]->arg
);
7609 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7610 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7611 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7612 "Establish BGP filters\n"
7613 "AS path access-list name\n"
7614 "Filter incoming routes\n"
7615 "Filter outgoing routes\n")
7617 DEFUN (no_neighbor_filter_list
,
7618 no_neighbor_filter_list_cmd
,
7619 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7623 "Establish BGP filters\n"
7624 "AS path access-list name\n"
7625 "Filter incoming routes\n"
7626 "Filter outgoing routes\n")
7630 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7631 bgp_node_afi(vty
), bgp_node_safi(vty
),
7632 argv
[idx_in_out
]->arg
);
7635 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7636 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7637 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7638 "Establish BGP filters\n"
7639 "AS path access-list name\n"
7640 "Filter incoming routes\n"
7641 "Filter outgoing routes\n")
7643 /* Set advertise-map to the peer. */
7644 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7645 afi_t afi
, safi_t safi
,
7646 const char *advertise_str
,
7647 const char *condition_str
, bool condition
,
7650 int ret
= CMD_WARNING_CONFIG_FAILED
;
7652 struct route_map
*advertise_map
;
7653 struct route_map
*condition_map
;
7655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7659 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7660 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7663 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7664 advertise_map
, condition_str
,
7665 condition_map
, condition
);
7667 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7668 advertise_map
, condition_str
,
7669 condition_map
, condition
);
7671 return bgp_vty_return(vty
, ret
);
7674 DEFPY (bgp_condadv_period
,
7675 bgp_condadv_period_cmd
,
7676 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7679 "Conditional advertisement settings\n"
7680 "Set period to rescan BGP table to check if condition is met\n"
7681 "Period between BGP table scans, in seconds; default 60\n")
7683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7685 bgp
->condition_check_period
=
7686 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7691 DEFPY (neighbor_advertise_map
,
7692 neighbor_advertise_map_cmd
,
7693 "[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",
7697 "Route-map to conditionally advertise routes\n"
7698 "Name of advertise map\n"
7699 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7700 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7701 "Name of the exist or non exist map\n")
7703 bool condition
= CONDITION_EXIST
;
7705 if (!strcmp(exist
, "non-exist-map"))
7706 condition
= CONDITION_NON_EXIST
;
7708 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7709 bgp_node_safi(vty
), advertise_str
,
7710 condition_str
, condition
, !no
);
7713 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7714 "[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",
7715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7716 "Route-map to conditionally advertise routes\n"
7717 "Name of advertise map\n"
7718 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7719 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7720 "Name of the exist or non exist map\n")
7722 /* Set route-map to the peer. */
7723 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7724 afi_t afi
, safi_t safi
, const char *name_str
,
7725 const char *direct_str
)
7729 int direct
= RMAP_IN
;
7730 struct route_map
*route_map
;
7732 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7734 return CMD_WARNING_CONFIG_FAILED
;
7736 /* Check filter direction. */
7737 if (strncmp(direct_str
, "in", 2) == 0)
7739 else if (strncmp(direct_str
, "o", 1) == 0)
7742 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7743 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7745 return bgp_vty_return(vty
, ret
);
7748 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7749 afi_t afi
, safi_t safi
,
7750 const char *direct_str
)
7754 int direct
= RMAP_IN
;
7756 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7758 return CMD_WARNING_CONFIG_FAILED
;
7760 /* Check filter direction. */
7761 if (strncmp(direct_str
, "in", 2) == 0)
7763 else if (strncmp(direct_str
, "o", 1) == 0)
7766 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7768 return bgp_vty_return(vty
, ret
);
7771 DEFUN (neighbor_route_map
,
7772 neighbor_route_map_cmd
,
7773 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7776 "Apply route map to neighbor\n"
7777 "Name of route map\n"
7778 "Apply map to incoming routes\n"
7779 "Apply map to outbound routes\n")
7784 return peer_route_map_set_vty(
7785 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7786 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7789 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7790 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7791 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7792 "Apply route map to neighbor\n"
7793 "Name of route map\n"
7794 "Apply map to incoming routes\n"
7795 "Apply map to outbound routes\n")
7797 DEFUN (no_neighbor_route_map
,
7798 no_neighbor_route_map_cmd
,
7799 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7803 "Apply route map to neighbor\n"
7804 "Name of route map\n"
7805 "Apply map to incoming routes\n"
7806 "Apply map to outbound routes\n")
7810 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7811 bgp_node_afi(vty
), bgp_node_safi(vty
),
7812 argv
[idx_in_out
]->arg
);
7815 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7816 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7817 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7818 "Apply route map to neighbor\n"
7819 "Name of route map\n"
7820 "Apply map to incoming routes\n"
7821 "Apply map to outbound routes\n")
7823 /* Set unsuppress-map to the peer. */
7824 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7825 afi_t afi
, safi_t safi
,
7826 const char *name_str
)
7830 struct route_map
*route_map
;
7832 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7834 return CMD_WARNING_CONFIG_FAILED
;
7836 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7837 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7839 return bgp_vty_return(vty
, ret
);
7842 /* Unset route-map from the peer. */
7843 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7844 afi_t afi
, safi_t safi
)
7849 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7851 return CMD_WARNING_CONFIG_FAILED
;
7853 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7855 return bgp_vty_return(vty
, ret
);
7858 DEFUN (neighbor_unsuppress_map
,
7859 neighbor_unsuppress_map_cmd
,
7860 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7863 "Route-map to selectively unsuppress suppressed routes\n"
7864 "Name of route map\n")
7868 return peer_unsuppress_map_set_vty(
7869 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7870 argv
[idx_word
]->arg
);
7873 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7874 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7875 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7876 "Route-map to selectively unsuppress suppressed routes\n"
7877 "Name of route map\n")
7879 DEFUN (no_neighbor_unsuppress_map
,
7880 no_neighbor_unsuppress_map_cmd
,
7881 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7885 "Route-map to selectively unsuppress suppressed routes\n"
7886 "Name of route map\n")
7889 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7891 bgp_node_safi(vty
));
7894 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7895 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7896 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7897 "Route-map to selectively unsuppress suppressed routes\n"
7898 "Name of route map\n")
7900 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7901 afi_t afi
, safi_t safi
,
7902 const char *num_str
,
7903 const char *threshold_str
, int warning
,
7904 const char *restart_str
,
7905 const char *force_str
)
7913 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7915 return CMD_WARNING_CONFIG_FAILED
;
7917 max
= strtoul(num_str
, NULL
, 10);
7919 threshold
= atoi(threshold_str
);
7921 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7924 restart
= atoi(restart_str
);
7928 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7929 restart
, force_str
? true : false);
7931 return bgp_vty_return(vty
, ret
);
7934 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7935 afi_t afi
, safi_t safi
)
7940 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7942 return CMD_WARNING_CONFIG_FAILED
;
7944 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7946 return bgp_vty_return(vty
, ret
);
7949 /* Maximum number of prefix to be sent to the neighbor. */
7950 DEFUN(neighbor_maximum_prefix_out
,
7951 neighbor_maximum_prefix_out_cmd
,
7952 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7955 "Maximum number of prefixes to be sent to this peer\n"
7956 "Maximum no. of prefix limit\n")
7963 afi_t afi
= bgp_node_afi(vty
);
7964 safi_t safi
= bgp_node_safi(vty
);
7966 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7968 return CMD_WARNING_CONFIG_FAILED
;
7970 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7972 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7974 return bgp_vty_return(vty
, ret
);
7977 DEFUN(no_neighbor_maximum_prefix_out
,
7978 no_neighbor_maximum_prefix_out_cmd
,
7979 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7983 "Maximum number of prefixes to be sent to this peer\n"
7984 "Maximum no. of prefix limit\n")
7989 afi_t afi
= bgp_node_afi(vty
);
7990 safi_t safi
= bgp_node_safi(vty
);
7992 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7994 return CMD_WARNING_CONFIG_FAILED
;
7996 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
7998 return bgp_vty_return(vty
, ret
);
8001 /* Maximum number of prefix configuration. Prefix count is different
8002 for each peer configuration. So this configuration can be set for
8003 each peer configuration. */
8004 DEFUN (neighbor_maximum_prefix
,
8005 neighbor_maximum_prefix_cmd
,
8006 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8009 "Maximum number of prefix accept from this peer\n"
8010 "maximum no. of prefix limit\n"
8011 "Force checking all received routes not only accepted\n")
8018 if (argv_find(argv
, argc
, "force", &idx_force
))
8019 force
= argv
[idx_force
]->arg
;
8021 return peer_maximum_prefix_set_vty(
8022 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8023 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8026 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8027 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8028 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8029 "Maximum number of prefix accept from this peer\n"
8030 "maximum no. of prefix limit\n"
8031 "Force checking all received routes not only accepted\n")
8033 DEFUN (neighbor_maximum_prefix_threshold
,
8034 neighbor_maximum_prefix_threshold_cmd
,
8035 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8038 "Maximum number of prefix accept from this peer\n"
8039 "maximum no. of prefix limit\n"
8040 "Threshold value (%) at which to generate a warning msg\n"
8041 "Force checking all received routes not only accepted\n")
8045 int idx_number_2
= 4;
8049 if (argv_find(argv
, argc
, "force", &idx_force
))
8050 force
= argv
[idx_force
]->arg
;
8052 return peer_maximum_prefix_set_vty(
8053 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8054 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8058 neighbor_maximum_prefix_threshold
,
8059 neighbor_maximum_prefix_threshold_hidden_cmd
,
8060 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8061 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8062 "Maximum number of prefix accept from this peer\n"
8063 "maximum no. of prefix limit\n"
8064 "Threshold value (%) at which to generate a warning msg\n"
8065 "Force checking all received routes not only accepted\n")
8067 DEFUN (neighbor_maximum_prefix_warning
,
8068 neighbor_maximum_prefix_warning_cmd
,
8069 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8072 "Maximum number of prefix accept from this peer\n"
8073 "maximum no. of prefix limit\n"
8074 "Only give warning message when limit is exceeded\n"
8075 "Force checking all received routes not only accepted\n")
8082 if (argv_find(argv
, argc
, "force", &idx_force
))
8083 force
= argv
[idx_force
]->arg
;
8085 return peer_maximum_prefix_set_vty(
8086 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8087 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8091 neighbor_maximum_prefix_warning
,
8092 neighbor_maximum_prefix_warning_hidden_cmd
,
8093 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8094 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8095 "Maximum number of prefix accept from this peer\n"
8096 "maximum no. of prefix limit\n"
8097 "Only give warning message when limit is exceeded\n"
8098 "Force checking all received routes not only accepted\n")
8100 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8101 neighbor_maximum_prefix_threshold_warning_cmd
,
8102 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8105 "Maximum number of prefix accept from this peer\n"
8106 "maximum no. of prefix limit\n"
8107 "Threshold value (%) at which to generate a warning msg\n"
8108 "Only give warning message when limit is exceeded\n"
8109 "Force checking all received routes not only accepted\n")
8113 int idx_number_2
= 4;
8117 if (argv_find(argv
, argc
, "force", &idx_force
))
8118 force
= argv
[idx_force
]->arg
;
8120 return peer_maximum_prefix_set_vty(
8121 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8122 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8126 neighbor_maximum_prefix_threshold_warning
,
8127 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8128 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8130 "Maximum number of prefix accept from this peer\n"
8131 "maximum no. of prefix limit\n"
8132 "Threshold value (%) at which to generate a warning msg\n"
8133 "Only give warning message when limit is exceeded\n"
8134 "Force checking all received routes not only accepted\n")
8136 DEFUN (neighbor_maximum_prefix_restart
,
8137 neighbor_maximum_prefix_restart_cmd
,
8138 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8141 "Maximum number of prefix accept from this peer\n"
8142 "maximum no. of prefix limit\n"
8143 "Restart bgp connection after limit is exceeded\n"
8144 "Restart interval in minutes\n"
8145 "Force checking all received routes not only accepted\n")
8149 int idx_number_2
= 5;
8153 if (argv_find(argv
, argc
, "force", &idx_force
))
8154 force
= argv
[idx_force
]->arg
;
8156 return peer_maximum_prefix_set_vty(
8157 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8158 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8162 neighbor_maximum_prefix_restart
,
8163 neighbor_maximum_prefix_restart_hidden_cmd
,
8164 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8165 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8166 "Maximum number of prefix accept from this peer\n"
8167 "maximum no. of prefix limit\n"
8168 "Restart bgp connection after limit is exceeded\n"
8169 "Restart interval in minutes\n"
8170 "Force checking all received routes not only accepted\n")
8172 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8173 neighbor_maximum_prefix_threshold_restart_cmd
,
8174 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8177 "Maximum number of prefixes to accept from this peer\n"
8178 "maximum no. of prefix limit\n"
8179 "Threshold value (%) at which to generate a warning msg\n"
8180 "Restart bgp connection after limit is exceeded\n"
8181 "Restart interval in minutes\n"
8182 "Force checking all received routes not only accepted\n")
8186 int idx_number_2
= 4;
8187 int idx_number_3
= 6;
8191 if (argv_find(argv
, argc
, "force", &idx_force
))
8192 force
= argv
[idx_force
]->arg
;
8194 return peer_maximum_prefix_set_vty(
8195 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8196 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8197 argv
[idx_number_3
]->arg
, force
);
8201 neighbor_maximum_prefix_threshold_restart
,
8202 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8203 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8204 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8205 "Maximum number of prefixes to accept from this peer\n"
8206 "maximum no. of prefix limit\n"
8207 "Threshold value (%) at which to generate a warning msg\n"
8208 "Restart bgp connection after limit is exceeded\n"
8209 "Restart interval in minutes\n"
8210 "Force checking all received routes not only accepted\n")
8212 DEFUN (no_neighbor_maximum_prefix
,
8213 no_neighbor_maximum_prefix_cmd
,
8214 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8218 "Maximum number of prefixes to accept from this peer\n"
8219 "maximum no. of prefix limit\n"
8220 "Threshold value (%) at which to generate a warning msg\n"
8221 "Restart bgp connection after limit is exceeded\n"
8222 "Restart interval in minutes\n"
8223 "Only give warning message when limit is exceeded\n"
8224 "Force checking all received routes not only accepted\n")
8227 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8229 bgp_node_safi(vty
));
8233 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8234 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8235 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8236 "Maximum number of prefixes to accept from this peer\n"
8237 "maximum no. of prefix limit\n"
8238 "Threshold value (%) at which to generate a warning msg\n"
8239 "Restart bgp connection after limit is exceeded\n"
8240 "Restart interval in minutes\n"
8241 "Only give warning message when limit is exceeded\n"
8242 "Force checking all received routes not only accepted\n")
8244 /* "neighbor soo" */
8245 DEFPY (neighbor_soo
,
8247 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8250 "Set the Site-of-Origin (SoO) extended community\n"
8251 "VPN extended community\n")
8254 afi_t afi
= bgp_node_afi(vty
);
8255 safi_t safi
= bgp_node_safi(vty
);
8256 struct ecommunity
*ecomm_soo
;
8258 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8260 return CMD_WARNING_CONFIG_FAILED
;
8262 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8264 vty_out(vty
, "%% Malformed SoO extended community\n");
8267 ecommunity_str(ecomm_soo
);
8269 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8270 ecommunity_free(&peer
->soo
[afi
][safi
]);
8271 peer
->soo
[afi
][safi
] = ecomm_soo
;
8272 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8275 return bgp_vty_return(vty
,
8276 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8279 DEFPY (no_neighbor_soo
,
8280 no_neighbor_soo_cmd
,
8281 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8285 "Set the Site-of-Origin (SoO) extended community\n"
8286 "VPN extended community\n")
8289 afi_t afi
= bgp_node_afi(vty
);
8290 safi_t safi
= bgp_node_safi(vty
);
8292 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8294 return CMD_WARNING_CONFIG_FAILED
;
8296 ecommunity_free(&peer
->soo
[afi
][safi
]);
8298 return bgp_vty_return(
8299 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8302 /* "neighbor allowas-in" */
8303 DEFUN (neighbor_allowas_in
,
8304 neighbor_allowas_in_cmd
,
8305 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8308 "Accept as-path with my AS present in it\n"
8309 "Number of occurrences of AS number\n"
8310 "Only accept my AS in the as-path if the route was originated in my AS\n")
8313 int idx_number_origin
= 3;
8319 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8321 return CMD_WARNING_CONFIG_FAILED
;
8323 if (argc
<= idx_number_origin
)
8326 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8329 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8332 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8335 return bgp_vty_return(vty
, ret
);
8339 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8340 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8341 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8342 "Accept as-path with my AS present in it\n"
8343 "Number of occurrences of AS number\n"
8344 "Only accept my AS in the as-path if the route was originated in my AS\n")
8346 DEFUN (no_neighbor_allowas_in
,
8347 no_neighbor_allowas_in_cmd
,
8348 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8352 "allow local ASN appears in aspath attribute\n"
8353 "Number of occurrences of AS number\n"
8354 "Only accept my AS in the as-path if the route was originated in my AS\n")
8360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8362 return CMD_WARNING_CONFIG_FAILED
;
8364 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8365 bgp_node_safi(vty
));
8367 return bgp_vty_return(vty
, ret
);
8371 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8372 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8373 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8374 "allow local ASN appears in aspath attribute\n"
8375 "Number of occurrences of AS number\n"
8376 "Only accept my AS in the as-path if the route was originated in my AS\n")
8378 DEFUN (neighbor_ttl_security
,
8379 neighbor_ttl_security_cmd
,
8380 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8383 "BGP ttl-security parameters\n"
8384 "Specify the maximum number of hops to the BGP peer\n"
8385 "Number of hops to BGP peer\n")
8392 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8394 return CMD_WARNING_CONFIG_FAILED
;
8396 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8399 * If 'neighbor swpX', then this is for directly connected peers,
8400 * we should not accept a ttl-security hops value greater than 1.
8402 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8404 "%s is directly connected peer, hops cannot exceed 1\n",
8405 argv
[idx_peer
]->arg
);
8406 return CMD_WARNING_CONFIG_FAILED
;
8409 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8412 DEFUN (no_neighbor_ttl_security
,
8413 no_neighbor_ttl_security_cmd
,
8414 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8418 "BGP ttl-security parameters\n"
8419 "Specify the maximum number of hops to the BGP peer\n"
8420 "Number of hops to BGP peer\n")
8425 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8427 return CMD_WARNING_CONFIG_FAILED
;
8429 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8432 /* disable-addpath-rx */
8433 DEFUN(neighbor_disable_addpath_rx
,
8434 neighbor_disable_addpath_rx_cmd
,
8435 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8438 "Do not accept additional paths\n")
8440 char *peer_str
= argv
[1]->arg
;
8442 afi_t afi
= bgp_node_afi(vty
);
8443 safi_t safi
= bgp_node_safi(vty
);
8445 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8447 return CMD_WARNING_CONFIG_FAILED
;
8449 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8450 PEER_FLAG_DISABLE_ADDPATH_RX
);
8453 DEFUN(no_neighbor_disable_addpath_rx
,
8454 no_neighbor_disable_addpath_rx_cmd
,
8455 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8459 "Do not accept additional paths\n")
8461 char *peer_str
= argv
[2]->arg
;
8463 afi_t afi
= bgp_node_afi(vty
);
8464 safi_t safi
= bgp_node_safi(vty
);
8466 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8468 return CMD_WARNING_CONFIG_FAILED
;
8470 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8471 PEER_FLAG_DISABLE_ADDPATH_RX
);
8474 DEFUN (neighbor_addpath_tx_all_paths
,
8475 neighbor_addpath_tx_all_paths_cmd
,
8476 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8479 "Use addpath to advertise all paths to a neighbor\n")
8484 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8486 return CMD_WARNING_CONFIG_FAILED
;
8488 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8493 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8494 neighbor_addpath_tx_all_paths_hidden_cmd
,
8495 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8496 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8497 "Use addpath to advertise all paths to a neighbor\n")
8499 DEFUN (no_neighbor_addpath_tx_all_paths
,
8500 no_neighbor_addpath_tx_all_paths_cmd
,
8501 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8505 "Use addpath to advertise all paths to a neighbor\n")
8510 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8512 return CMD_WARNING_CONFIG_FAILED
;
8514 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8515 != BGP_ADDPATH_ALL
) {
8517 "%% Peer not currently configured to transmit all paths.");
8518 return CMD_WARNING_CONFIG_FAILED
;
8521 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8527 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8528 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8529 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8530 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8531 "Use addpath to advertise all paths to a neighbor\n")
8533 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8534 neighbor_addpath_tx_bestpath_per_as_cmd
,
8535 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8538 "Use addpath to advertise the bestpath per each neighboring AS\n")
8543 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8545 return CMD_WARNING_CONFIG_FAILED
;
8547 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8548 BGP_ADDPATH_BEST_PER_AS
);
8553 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8554 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8555 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8556 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8557 "Use addpath to advertise the bestpath per each neighboring AS\n")
8559 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8560 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8561 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8565 "Use addpath to advertise the bestpath per each neighboring AS\n")
8570 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8572 return CMD_WARNING_CONFIG_FAILED
;
8574 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8575 != BGP_ADDPATH_BEST_PER_AS
) {
8577 "%% Peer not currently configured to transmit all best path per as.");
8578 return CMD_WARNING_CONFIG_FAILED
;
8581 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8587 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8588 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8589 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8590 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8591 "Use addpath to advertise the bestpath per each neighboring AS\n")
8594 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8595 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8598 "Detect AS loops before sending to neighbor\n")
8602 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8604 return CMD_WARNING_CONFIG_FAILED
;
8606 peer
->as_path_loop_detection
= true;
8612 no_neighbor_aspath_loop_detection
,
8613 no_neighbor_aspath_loop_detection_cmd
,
8614 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8618 "Detect AS loops before sending to neighbor\n")
8622 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8624 return CMD_WARNING_CONFIG_FAILED
;
8626 peer
->as_path_loop_detection
= false;
8631 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8632 struct ecommunity
**list
, bool is_rt6
)
8634 struct ecommunity
*ecom
= NULL
;
8635 struct ecommunity
*ecomadd
;
8637 for (; argc
; --argc
, ++argv
) {
8639 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8640 ECOMMUNITY_ROUTE_TARGET
,
8643 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8644 ECOMMUNITY_ROUTE_TARGET
,
8647 vty_out(vty
, "Malformed community-list value\n");
8649 ecommunity_free(&ecom
);
8650 return CMD_WARNING_CONFIG_FAILED
;
8654 ecommunity_merge(ecom
, ecomadd
);
8655 ecommunity_free(&ecomadd
);
8662 ecommunity_free(&*list
);
8670 * v2vimport is true if we are handling a `import vrf ...` command
8672 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8676 switch (vty
->node
) {
8685 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8690 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8691 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8692 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8693 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8695 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8699 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8700 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8701 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8702 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8704 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8711 DEFPY (af_rd_vpn_export
,
8712 af_rd_vpn_export_cmd
,
8713 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8715 "Specify route distinguisher\n"
8716 "Between current address-family and vpn\n"
8717 "For routes leaked from current address-family to vpn\n"
8718 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8721 struct prefix_rd prd
;
8727 if (argv_find(argv
, argc
, "no", &idx
))
8731 ret
= str2prefix_rd(rd_str
, &prd
);
8733 vty_out(vty
, "%% Malformed rd\n");
8734 return CMD_WARNING_CONFIG_FAILED
;
8738 afi
= vpn_policy_getafi(vty
, bgp
, false);
8740 return CMD_WARNING_CONFIG_FAILED
;
8743 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8745 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8746 bgp_get_default(), bgp
);
8749 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8750 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8751 BGP_VPN_POLICY_TOVPN_RD_SET
);
8753 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8754 BGP_VPN_POLICY_TOVPN_RD_SET
);
8757 /* post-change: re-export vpn routes */
8758 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8759 bgp_get_default(), bgp
);
8764 ALIAS (af_rd_vpn_export
,
8765 af_no_rd_vpn_export_cmd
,
8768 "Specify route distinguisher\n"
8769 "Between current address-family and vpn\n"
8770 "For routes leaked from current address-family to vpn\n")
8772 DEFPY (af_label_vpn_export
,
8773 af_label_vpn_export_cmd
,
8774 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8776 "label value for VRF\n"
8777 "Between current address-family and vpn\n"
8778 "For routes leaked from current address-family to vpn\n"
8779 "Label Value <0-1048575>\n"
8780 "Automatically assign a label\n")
8782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8783 mpls_label_t label
= MPLS_LABEL_NONE
;
8788 if (argv_find(argv
, argc
, "no", &idx
))
8791 /* If "no ...", squash trailing parameter */
8797 label
= label_val
; /* parser should force unsigned */
8800 afi
= vpn_policy_getafi(vty
, bgp
, false);
8802 return CMD_WARNING_CONFIG_FAILED
;
8805 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8806 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8811 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8813 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8814 bgp_get_default(), bgp
);
8816 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8817 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8819 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8822 * label has previously been automatically
8823 * assigned by labelpool: release it
8825 * NB if tovpn_label == MPLS_LABEL_NONE it
8826 * means the automatic assignment is in flight
8827 * and therefore the labelpool callback must
8828 * detect that the auto label is not needed.
8831 bgp_lp_release(LP_TYPE_VRF
,
8832 &bgp
->vpn_policy
[afi
],
8833 bgp
->vpn_policy
[afi
].tovpn_label
);
8835 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8836 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8839 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8841 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8842 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8843 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8844 vpn_leak_label_callback
);
8847 /* post-change: re-export vpn routes */
8848 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8849 bgp_get_default(), bgp
);
8851 hook_call(bgp_snmp_update_last_changed
, bgp
);
8855 DEFPY (af_sid_vpn_export
,
8856 af_sid_vpn_export_cmd
,
8857 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8859 "sid value for VRF\n"
8860 "Between current address-family and vpn\n"
8861 "For routes leaked from current address-family to vpn\n"
8862 "Sid allocation index\n"
8863 "Automatically assign a label\n")
8865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8871 if (argv_find(argv
, argc
, "no", &idx
))
8873 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8874 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8876 afi
= vpn_policy_getafi(vty
, bgp
, false);
8878 return CMD_WARNING_CONFIG_FAILED
;
8882 vty_out(vty
, "It's not implemented\n");
8883 return CMD_WARNING_CONFIG_FAILED
;
8886 /* skip when it's already configured */
8887 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8888 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8889 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8893 * mode change between sid_idx and sid_auto isn't supported.
8894 * user must negate sid vpn export when they want to change the mode
8896 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8897 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8898 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8899 vty_out(vty
, "it's already configured as %s.\n",
8900 sid_auto
? "auto-mode" : "idx-mode");
8901 return CMD_WARNING_CONFIG_FAILED
;
8905 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8906 bgp_get_default(), bgp
);
8909 /* SID allocation auto-mode */
8911 zlog_debug("%s: auto sid alloc.", __func__
);
8912 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8913 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8915 /* SID allocation index-mode */
8917 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8918 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8922 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8923 bgp_get_default(), bgp
);
8927 ALIAS (af_label_vpn_export
,
8928 af_no_label_vpn_export_cmd
,
8929 "no label vpn export",
8931 "label value for VRF\n"
8932 "Between current address-family and vpn\n"
8933 "For routes leaked from current address-family to vpn\n")
8935 DEFPY (af_nexthop_vpn_export
,
8936 af_nexthop_vpn_export_cmd
,
8937 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8939 "Specify next hop to use for VRF advertised prefixes\n"
8940 "Between current address-family and vpn\n"
8941 "For routes leaked from current address-family to vpn\n"
8945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8951 vty_out(vty
, "%% Nexthop required\n");
8952 return CMD_WARNING_CONFIG_FAILED
;
8954 if (!sockunion2hostprefix(nexthop_su
, &p
))
8955 return CMD_WARNING_CONFIG_FAILED
;
8958 afi
= vpn_policy_getafi(vty
, bgp
, false);
8960 return CMD_WARNING_CONFIG_FAILED
;
8963 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8965 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8966 bgp_get_default(), bgp
);
8969 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8970 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8971 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8973 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8974 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8977 /* post-change: re-export vpn routes */
8978 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8979 bgp_get_default(), bgp
);
8984 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8986 if (!strcmp(dstr
, "import")) {
8987 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8988 } else if (!strcmp(dstr
, "export")) {
8989 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8990 } else if (!strcmp(dstr
, "both")) {
8991 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8992 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8994 vty_out(vty
, "%% direction parse error\n");
8995 return CMD_WARNING_CONFIG_FAILED
;
9000 DEFPY (af_rt_vpn_imexport
,
9001 af_rt_vpn_imexport_cmd
,
9002 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9004 "Specify route target list\n"
9005 "Specify route target list\n"
9006 "Between current address-family and vpn\n"
9007 "For routes leaked from vpn to current address-family: match any\n"
9008 "For routes leaked from current address-family to vpn: set\n"
9009 "both import: match any and export: set\n"
9010 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9014 struct ecommunity
*ecom
= NULL
;
9015 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9016 enum vpn_policy_direction dir
;
9021 if (argv_find(argv
, argc
, "no", &idx
))
9024 afi
= vpn_policy_getafi(vty
, bgp
, false);
9026 return CMD_WARNING_CONFIG_FAILED
;
9028 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9029 if (ret
!= CMD_SUCCESS
)
9033 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9034 vty_out(vty
, "%% Missing RTLIST\n");
9035 return CMD_WARNING_CONFIG_FAILED
;
9037 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9038 if (ret
!= CMD_SUCCESS
) {
9043 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9047 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9050 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9052 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9053 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9054 ecommunity_dup(ecom
);
9056 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9058 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9059 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9062 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9066 ecommunity_free(&ecom
);
9071 ALIAS (af_rt_vpn_imexport
,
9072 af_no_rt_vpn_imexport_cmd
,
9073 "no <rt|route-target> vpn <import|export|both>$direction_str",
9075 "Specify route target list\n"
9076 "Specify route target list\n"
9077 "Between current address-family and vpn\n"
9078 "For routes leaked from vpn to current address-family\n"
9079 "For routes leaked from current address-family to vpn\n"
9080 "both import and export\n")
9082 DEFPY (af_route_map_vpn_imexport
,
9083 af_route_map_vpn_imexport_cmd
,
9084 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9085 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9087 "Specify route map\n"
9088 "Between current address-family and vpn\n"
9089 "For routes leaked from vpn to current address-family\n"
9090 "For routes leaked from current address-family to vpn\n"
9091 "name of route-map\n")
9093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9095 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9096 enum vpn_policy_direction dir
;
9101 if (argv_find(argv
, argc
, "no", &idx
))
9104 afi
= vpn_policy_getafi(vty
, bgp
, false);
9106 return CMD_WARNING_CONFIG_FAILED
;
9108 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9109 if (ret
!= CMD_SUCCESS
)
9112 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9116 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9119 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9120 XFREE(MTYPE_ROUTE_MAP_NAME
,
9121 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9122 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9123 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9124 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9125 route_map_lookup_warn_noexist(vty
, rmap_str
);
9126 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9129 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9130 XFREE(MTYPE_ROUTE_MAP_NAME
,
9131 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9132 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9133 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9136 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9142 ALIAS (af_route_map_vpn_imexport
,
9143 af_no_route_map_vpn_imexport_cmd
,
9144 "no route-map vpn <import|export>$direction_str",
9146 "Specify route map\n"
9147 "Between current address-family and vpn\n"
9148 "For routes leaked from vpn to current address-family\n"
9149 "For routes leaked from current address-family to vpn\n")
9151 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9152 "import vrf route-map RMAP$rmap_str",
9153 "Import routes from another VRF\n"
9154 "Vrf routes being filtered\n"
9155 "Specify route map\n"
9156 "name of route-map\n")
9158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9159 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9161 struct bgp
*bgp_default
;
9163 afi
= vpn_policy_getafi(vty
, bgp
, true);
9165 return CMD_WARNING_CONFIG_FAILED
;
9167 bgp_default
= bgp_get_default();
9172 /* Auto-create assuming the same AS */
9173 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9174 BGP_INSTANCE_TYPE_DEFAULT
);
9178 "VRF default is not configured as a bgp instance\n");
9183 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9185 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9186 XFREE(MTYPE_ROUTE_MAP_NAME
,
9187 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9188 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9189 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9190 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9191 route_map_lookup_warn_noexist(vty
, rmap_str
);
9192 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9195 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9196 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9198 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9203 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9204 "no import vrf route-map [RMAP$rmap_str]",
9206 "Import routes from another VRF\n"
9207 "Vrf routes being filtered\n"
9208 "Specify route map\n"
9209 "name of route-map\n")
9211 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9212 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9215 afi
= vpn_policy_getafi(vty
, bgp
, true);
9217 return CMD_WARNING_CONFIG_FAILED
;
9219 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9221 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9222 XFREE(MTYPE_ROUTE_MAP_NAME
,
9223 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9224 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9225 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9227 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9228 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9229 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9231 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9236 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9237 "[no] import vrf VIEWVRFNAME$import_name",
9239 "Import routes from another VRF\n"
9240 "VRF to import from\n"
9241 "The name of the VRF\n")
9243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9244 struct listnode
*node
;
9245 struct bgp
*vrf_bgp
, *bgp_default
;
9248 bool remove
= false;
9251 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9255 if (import_name
== NULL
) {
9256 vty_out(vty
, "%% Missing import name\n");
9260 if (strcmp(import_name
, "route-map") == 0) {
9261 vty_out(vty
, "%% Must include route-map name\n");
9265 if (argv_find(argv
, argc
, "no", &idx
))
9268 afi
= vpn_policy_getafi(vty
, bgp
, true);
9270 return CMD_WARNING_CONFIG_FAILED
;
9272 safi
= bgp_node_safi(vty
);
9274 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9275 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9276 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9277 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9278 remove
? "unimport" : "import", import_name
);
9282 bgp_default
= bgp_get_default();
9284 /* Auto-create assuming the same AS */
9285 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9286 BGP_INSTANCE_TYPE_DEFAULT
);
9290 "VRF default is not configured as a bgp instance\n");
9295 vrf_bgp
= bgp_lookup_by_name(import_name
);
9297 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9298 vrf_bgp
= bgp_default
;
9300 /* Auto-create assuming the same AS */
9301 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9305 "VRF %s is not configured as a bgp instance\n",
9312 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9314 /* Already importing from "import_vrf"? */
9315 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9317 if (strcmp(vname
, import_name
) == 0)
9321 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9327 /* This command is valid only in a bgp vrf instance or the default instance */
9328 DEFPY (bgp_imexport_vpn
,
9329 bgp_imexport_vpn_cmd
,
9330 "[no] <import|export>$direction_str vpn",
9332 "Import routes to this address-family\n"
9333 "Export routes from this address-family\n"
9334 "to/from default instance VPN RIB\n")
9336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9343 enum vpn_policy_direction dir
;
9345 if (argv_find(argv
, argc
, "no", &idx
))
9348 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9349 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9351 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9352 return CMD_WARNING_CONFIG_FAILED
;
9355 afi
= bgp_node_afi(vty
);
9356 safi
= bgp_node_safi(vty
);
9357 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9358 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9359 return CMD_WARNING_CONFIG_FAILED
;
9362 if (!strcmp(direction_str
, "import")) {
9363 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9364 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9365 } else if (!strcmp(direction_str
, "export")) {
9366 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9367 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9369 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9370 return CMD_WARNING_CONFIG_FAILED
;
9373 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9376 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9377 if (!previous_state
) {
9378 /* trigger export current vrf */
9379 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9382 if (previous_state
) {
9383 /* trigger un-export current vrf */
9384 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9386 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9389 hook_call(bgp_snmp_init_stats
, bgp
);
9394 DEFPY (af_routetarget_import
,
9395 af_routetarget_import_cmd
,
9396 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9398 "Specify route target list\n"
9399 "Specify route target list\n"
9400 "Specify route target list\n"
9401 "Specify route target list\n"
9402 "Flow-spec redirect type route target\n"
9403 "Import routes to this address-family\n"
9404 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9406 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9408 struct ecommunity
*ecom
= NULL
;
9410 int idx
= 0, idx_unused
= 0;
9414 if (argv_find(argv
, argc
, "no", &idx
))
9417 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9418 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9421 afi
= vpn_policy_getafi(vty
, bgp
, false);
9423 return CMD_WARNING_CONFIG_FAILED
;
9425 if (rt6
&& afi
!= AFI_IP6
)
9426 return CMD_WARNING_CONFIG_FAILED
;
9429 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9430 vty_out(vty
, "%% Missing RTLIST\n");
9431 return CMD_WARNING_CONFIG_FAILED
;
9433 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9434 if (ret
!= CMD_SUCCESS
)
9439 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9440 ecommunity_free(&bgp
->vpn_policy
[afi
]
9441 .import_redirect_rtlist
);
9442 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9443 ecommunity_dup(ecom
);
9445 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9446 ecommunity_free(&bgp
->vpn_policy
[afi
]
9447 .import_redirect_rtlist
);
9448 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9452 ecommunity_free(&ecom
);
9457 DEFUN_NOSH (address_family_ipv4_safi
,
9458 address_family_ipv4_safi_cmd
,
9459 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9460 "Enter Address Family command mode\n"
9462 BGP_SAFI_WITH_LABEL_HELP_STR
)
9466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9467 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9468 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9469 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9470 && safi
!= SAFI_EVPN
) {
9472 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9473 return CMD_WARNING_CONFIG_FAILED
;
9475 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9477 vty
->node
= BGP_IPV4_NODE
;
9482 DEFUN_NOSH (address_family_ipv6_safi
,
9483 address_family_ipv6_safi_cmd
,
9484 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9485 "Enter Address Family command mode\n"
9487 BGP_SAFI_WITH_LABEL_HELP_STR
)
9490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9491 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9492 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9493 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9494 && safi
!= SAFI_EVPN
) {
9496 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9497 return CMD_WARNING_CONFIG_FAILED
;
9499 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9501 vty
->node
= BGP_IPV6_NODE
;
9506 #ifdef KEEP_OLD_VPN_COMMANDS
9507 DEFUN_NOSH (address_family_vpnv4
,
9508 address_family_vpnv4_cmd
,
9509 "address-family vpnv4 [unicast]",
9510 "Enter Address Family command mode\n"
9512 BGP_AF_MODIFIER_STR
)
9514 vty
->node
= BGP_VPNV4_NODE
;
9518 DEFUN_NOSH (address_family_vpnv6
,
9519 address_family_vpnv6_cmd
,
9520 "address-family vpnv6 [unicast]",
9521 "Enter Address Family command mode\n"
9523 BGP_AF_MODIFIER_STR
)
9525 vty
->node
= BGP_VPNV6_NODE
;
9528 #endif /* KEEP_OLD_VPN_COMMANDS */
9530 DEFUN_NOSH (address_family_evpn
,
9531 address_family_evpn_cmd
,
9532 "address-family l2vpn evpn",
9533 "Enter Address Family command mode\n"
9535 BGP_AF_MODIFIER_STR
)
9537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9538 vty
->node
= BGP_EVPN_NODE
;
9542 DEFUN_NOSH (bgp_segment_routing_srv6
,
9543 bgp_segment_routing_srv6_cmd
,
9544 "segment-routing srv6",
9545 "Segment-Routing configuration\n"
9546 "Segment-Routing SRv6 configuration\n")
9548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9549 bgp
->srv6_enabled
= true;
9550 vty
->node
= BGP_SRV6_NODE
;
9554 DEFUN (no_bgp_segment_routing_srv6
,
9555 no_bgp_segment_routing_srv6_cmd
,
9556 "no segment-routing srv6",
9558 "Segment-Routing configuration\n"
9559 "Segment-Routing SRv6 configuration\n")
9561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9563 if (strlen(bgp
->srv6_locator_name
) > 0)
9564 if (bgp_srv6_locator_unset(bgp
) < 0)
9565 return CMD_WARNING_CONFIG_FAILED
;
9567 bgp
->srv6_enabled
= false;
9571 DEFPY (bgp_srv6_locator
,
9572 bgp_srv6_locator_cmd
,
9573 "locator NAME$name",
9574 "Specify SRv6 locator\n"
9575 "Specify SRv6 locator\n")
9577 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9580 if (strlen(bgp
->srv6_locator_name
) > 0
9581 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9582 vty_out(vty
, "srv6 locator is already configured\n");
9583 return CMD_WARNING_CONFIG_FAILED
;
9586 snprintf(bgp
->srv6_locator_name
,
9587 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9589 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9591 return CMD_WARNING_CONFIG_FAILED
;
9596 DEFPY (no_bgp_srv6_locator
,
9597 no_bgp_srv6_locator_cmd
,
9598 "no locator NAME$name",
9600 "Specify SRv6 locator\n"
9601 "Specify SRv6 locator\n")
9603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9605 /* when locator isn't configured, do nothing */
9606 if (strlen(bgp
->srv6_locator_name
) < 1)
9609 /* name validation */
9610 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9611 vty_out(vty
, "%% No srv6 locator is configured\n");
9612 return CMD_WARNING_CONFIG_FAILED
;
9616 if (bgp_srv6_locator_unset(bgp
) < 0)
9617 return CMD_WARNING_CONFIG_FAILED
;
9622 DEFPY (show_bgp_srv6
,
9624 "show bgp segment-routing srv6",
9627 "BGP Segment Routing\n"
9628 "BGP Segment Routing SRv6\n")
9631 struct listnode
*node
;
9632 struct srv6_locator_chunk
*chunk
;
9633 struct bgp_srv6_function
*func
;
9634 struct in6_addr
*tovpn4_sid
;
9635 struct in6_addr
*tovpn6_sid
;
9637 char buf_tovpn4_sid
[256];
9638 char buf_tovpn6_sid
[256];
9640 bgp
= bgp_get_default();
9644 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9645 vty_out(vty
, "locator_chunks:\n");
9646 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9647 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9649 vty_out(vty
, "functions:\n");
9650 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9651 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9652 vty_out(vty
, "- sid: %s\n", buf
);
9653 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9656 vty_out(vty
, "bgps:\n");
9657 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9658 vty_out(vty
, "- name: %s\n",
9659 bgp
->name
? bgp
->name
: "default");
9661 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9662 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9664 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9665 sizeof(buf_tovpn4_sid
));
9667 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9668 sizeof(buf_tovpn6_sid
));
9670 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9671 tovpn4_sid
? buf_tovpn4_sid
: "none");
9672 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9673 tovpn6_sid
? buf_tovpn6_sid
: "none");
9679 DEFUN_NOSH (exit_address_family
,
9680 exit_address_family_cmd
,
9681 "exit-address-family",
9682 "Exit from Address Family configuration mode\n")
9684 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9685 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9686 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9687 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9688 || vty
->node
== BGP_EVPN_NODE
9689 || vty
->node
== BGP_FLOWSPECV4_NODE
9690 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9691 vty
->node
= BGP_NODE
;
9695 /* Recalculate bestpath and re-advertise a prefix */
9696 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9697 const char *ip_str
, afi_t afi
, safi_t safi
,
9698 struct prefix_rd
*prd
)
9701 struct prefix match
;
9702 struct bgp_dest
*dest
;
9703 struct bgp_dest
*rm
;
9705 struct bgp_table
*table
;
9706 struct bgp_table
*rib
;
9708 /* BGP structure lookup. */
9710 bgp
= bgp_lookup_by_name(view_name
);
9712 vty_out(vty
, "%% Can't find BGP instance %s\n",
9717 bgp
= bgp_get_default();
9719 vty_out(vty
, "%% No BGP process is configured\n");
9724 /* Check IP address argument. */
9725 ret
= str2prefix(ip_str
, &match
);
9727 vty_out(vty
, "%% address is malformed\n");
9731 match
.family
= afi2family(afi
);
9732 rib
= bgp
->rib
[afi
][safi
];
9734 if (safi
== SAFI_MPLS_VPN
) {
9735 for (dest
= bgp_table_top(rib
); dest
;
9736 dest
= bgp_route_next(dest
)) {
9737 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9739 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9742 table
= bgp_dest_get_bgp_table_info(dest
);
9746 rm
= bgp_node_match(table
, &match
);
9748 const struct prefix
*rm_p
=
9749 bgp_dest_get_prefix(rm
);
9751 if (rm_p
->prefixlen
== match
.prefixlen
) {
9753 BGP_NODE_USER_CLEAR
);
9754 bgp_process(bgp
, rm
, afi
, safi
);
9756 bgp_dest_unlock_node(rm
);
9760 dest
= bgp_node_match(rib
, &match
);
9762 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9764 if (dest_p
->prefixlen
== match
.prefixlen
) {
9765 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9766 bgp_process(bgp
, dest
, afi
, safi
);
9768 bgp_dest_unlock_node(dest
);
9775 /* one clear bgp command to rule them all */
9776 DEFUN (clear_ip_bgp_all
,
9777 clear_ip_bgp_all_cmd
,
9778 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]",
9782 BGP_INSTANCE_HELP_STR
9785 BGP_SAFI_WITH_LABEL_HELP_STR
9788 "BGP IPv4 neighbor to clear\n"
9789 "BGP IPv6 neighbor to clear\n"
9790 "BGP neighbor on interface to clear\n"
9791 "Clear peers with the AS number\n"
9792 "Clear all external peers\n"
9793 "Clear all members of peer-group\n"
9794 "BGP peer-group name\n"
9799 "Push out prefix-list ORF and do inbound soft reconfig\n"
9801 "Reset message statistics\n")
9805 afi_t afi
= AFI_UNSPEC
;
9806 safi_t safi
= SAFI_UNSPEC
;
9807 enum clear_sort clr_sort
= clear_peer
;
9808 enum bgp_clear_type clr_type
;
9809 char *clr_arg
= NULL
;
9813 /* clear [ip] bgp */
9814 if (argv_find(argv
, argc
, "ip", &idx
))
9817 /* [<vrf> VIEWVRFNAME] */
9818 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9819 vrf
= argv
[idx
+ 1]->arg
;
9821 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9823 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9824 /* [<view> VIEWVRFNAME] */
9825 vrf
= argv
[idx
+ 1]->arg
;
9828 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9829 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9830 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9832 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9833 if (argv_find(argv
, argc
, "*", &idx
)) {
9834 clr_sort
= clear_all
;
9835 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9836 clr_sort
= clear_peer
;
9837 clr_arg
= argv
[idx
]->arg
;
9838 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9839 clr_sort
= clear_peer
;
9840 clr_arg
= argv
[idx
]->arg
;
9841 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9842 clr_sort
= clear_group
;
9844 clr_arg
= argv
[idx
]->arg
;
9845 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9846 clr_sort
= clear_peer
;
9847 clr_arg
= argv
[idx
]->arg
;
9848 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9849 clr_sort
= clear_peer
;
9850 clr_arg
= argv
[idx
]->arg
;
9851 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9852 clr_sort
= clear_as
;
9853 clr_arg
= argv
[idx
]->arg
;
9854 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9855 clr_sort
= clear_external
;
9858 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9859 if (argv_find(argv
, argc
, "soft", &idx
)) {
9860 if (argv_find(argv
, argc
, "in", &idx
)
9861 || argv_find(argv
, argc
, "out", &idx
))
9862 clr_type
= strmatch(argv
[idx
]->text
, "in")
9864 : BGP_CLEAR_SOFT_OUT
;
9866 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9867 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9868 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9869 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9870 : BGP_CLEAR_SOFT_IN
;
9871 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9872 clr_type
= BGP_CLEAR_SOFT_OUT
;
9873 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9874 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9876 clr_type
= BGP_CLEAR_SOFT_NONE
;
9878 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9881 DEFUN (clear_ip_bgp_prefix
,
9882 clear_ip_bgp_prefix_cmd
,
9883 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9887 BGP_INSTANCE_HELP_STR
9888 "Clear bestpath and re-advertise\n"
9892 char *prefix
= NULL
;
9896 /* [<view|vrf> VIEWVRFNAME] */
9897 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9898 vrf
= argv
[idx
+ 1]->arg
;
9900 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9902 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9903 /* [<view> VIEWVRFNAME] */
9904 vrf
= argv
[idx
+ 1]->arg
;
9908 prefix
= argv
[argc
- 1]->arg
;
9910 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9913 DEFUN (clear_bgp_ipv6_safi_prefix
,
9914 clear_bgp_ipv6_safi_prefix_cmd
,
9915 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9921 "Clear bestpath and re-advertise\n"
9925 int idx_ipv6_prefix
= 0;
9926 safi_t safi
= SAFI_UNICAST
;
9927 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9928 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9930 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9931 return bgp_clear_prefix(
9932 vty
, NULL
, prefix
, AFI_IP6
,
9936 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9937 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9938 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9942 BGP_INSTANCE_HELP_STR
9945 "Clear bestpath and re-advertise\n"
9949 int idx_vrfview
= 0;
9950 int idx_ipv6_prefix
= 0;
9951 safi_t safi
= SAFI_UNICAST
;
9952 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9953 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9954 char *vrfview
= NULL
;
9956 /* [<view|vrf> VIEWVRFNAME] */
9957 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9958 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9959 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9961 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9962 /* [<view> VIEWVRFNAME] */
9963 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9965 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9967 return bgp_clear_prefix(
9968 vty
, vrfview
, prefix
,
9969 AFI_IP6
, safi
, NULL
);
9972 DEFUN (show_bgp_views
,
9974 "show [ip] bgp views",
9978 "Show the defined BGP views\n")
9980 struct list
*inst
= bm
->bgp
;
9981 struct listnode
*node
;
9984 vty_out(vty
, "Defined BGP views:\n");
9985 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9987 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9989 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9996 DEFUN (show_bgp_vrfs
,
9998 "show [ip] bgp vrfs [json]",
10005 char buf
[ETHER_ADDR_STRLEN
];
10006 struct list
*inst
= bm
->bgp
;
10007 struct listnode
*node
;
10009 bool uj
= use_json(argc
, argv
);
10010 json_object
*json
= NULL
;
10011 json_object
*json_vrfs
= NULL
;
10015 json
= json_object_new_object();
10016 json_vrfs
= json_object_new_object();
10019 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10020 const char *name
, *type
;
10022 struct listnode
*node2
, *nnode2
;
10023 int peers_cfg
, peers_estb
;
10024 json_object
*json_vrf
= NULL
;
10027 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10031 if (!uj
&& count
== 1) {
10033 "%4s %-5s %-16s %9s %10s %-37s\n",
10034 "Type", "Id", "routerId", "#PeersCfg",
10035 "#PeersEstb", "Name");
10036 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10037 "L3-VNI", "RouterMAC", "Interface");
10040 peers_cfg
= peers_estb
= 0;
10042 json_vrf
= json_object_new_object();
10045 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10046 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10049 if (peer_established(peer
))
10053 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10054 name
= VRF_DEFAULT_NAME
;
10063 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10065 : (int64_t)bgp
->vrf_id
;
10066 char buf
[BUFSIZ
] = {0};
10068 json_object_string_add(json_vrf
, "type", type
);
10069 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10070 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10072 json_object_int_add(json_vrf
, "numConfiguredPeers",
10074 json_object_int_add(json_vrf
, "numEstablishedPeers",
10077 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10078 json_object_string_add(
10080 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10081 json_object_string_add(json_vrf
, "interface",
10082 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10084 json_object_object_add(json_vrfs
, name
, json_vrf
);
10086 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10088 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10089 : (int)bgp
->vrf_id
,
10090 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10091 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10093 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10094 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10100 json_object_object_add(json
, "vrfs", json_vrfs
);
10102 json_object_int_add(json
, "totalVrfs", count
);
10104 vty_json(vty
, json
);
10108 "\nTotal number of VRFs (including default): %d\n",
10112 return CMD_SUCCESS
;
10115 DEFUN (show_bgp_mac_hash
,
10116 show_bgp_mac_hash_cmd
,
10117 "show bgp mac hash",
10121 "Mac Address database\n")
10123 bgp_mac_dump_table(vty
);
10125 return CMD_SUCCESS
;
10128 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10130 struct vty
*vty
= (struct vty
*)args
;
10131 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10133 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10136 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10138 vty_out(vty
, "self nexthop database:\n");
10139 bgp_nexthop_show_address_hash(vty
, bgp
);
10141 vty_out(vty
, "Tunnel-ip database:\n");
10142 hash_iterate(bgp
->tip_hash
,
10143 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10147 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10148 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10149 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10150 "martian next-hops\n"
10151 "martian next-hop database\n")
10153 struct bgp
*bgp
= NULL
;
10157 /* [<vrf> VIEWVRFNAME] */
10158 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10159 name
= argv
[idx
+ 1]->arg
;
10160 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10162 } else if (argv_find(argv
, argc
, "view", &idx
))
10163 /* [<view> VIEWVRFNAME] */
10164 name
= argv
[idx
+ 1]->arg
;
10166 bgp
= bgp_lookup_by_name(name
);
10168 bgp
= bgp_get_default();
10171 vty_out(vty
, "%% No BGP process is configured\n");
10172 return CMD_WARNING
;
10174 bgp_show_martian_nexthops(vty
, bgp
);
10176 return CMD_SUCCESS
;
10179 DEFUN (show_bgp_memory
,
10180 show_bgp_memory_cmd
,
10181 "show [ip] bgp memory",
10185 "Global BGP memory statistics\n")
10187 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10188 unsigned long count
;
10190 /* RIB related usage stats */
10191 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10192 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10193 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10194 count
* sizeof(struct bgp_dest
)));
10196 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10197 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10198 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10199 count
* sizeof(struct bgp_path_info
)));
10200 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10201 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10204 memstrbuf
, sizeof(memstrbuf
),
10205 count
* sizeof(struct bgp_path_info_extra
)));
10207 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10208 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10209 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10210 count
* sizeof(struct bgp_static
)));
10212 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10213 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10214 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10215 count
* sizeof(struct bpacket
)));
10218 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10219 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10220 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10221 count
* sizeof(struct bgp_adj_in
)));
10222 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10223 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10224 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10225 count
* sizeof(struct bgp_adj_out
)));
10227 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10228 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10230 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10231 count
* sizeof(struct bgp_nexthop_cache
)));
10233 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10234 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10236 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10237 count
* sizeof(struct bgp_damp_info
)));
10240 count
= attr_count();
10241 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10242 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10243 count
* sizeof(struct attr
)));
10245 if ((count
= attr_unknown_count()))
10246 vty_out(vty
, "%ld unknown attributes\n", count
);
10248 /* AS_PATH attributes */
10249 count
= aspath_count();
10250 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10251 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10252 count
* sizeof(struct aspath
)));
10254 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10255 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10256 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10257 count
* sizeof(struct assegment
)));
10259 /* Other attributes */
10260 if ((count
= community_count()))
10261 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10262 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10263 count
* sizeof(struct community
)));
10264 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10266 "%ld BGP ext-community entries, using %s of memory\n",
10268 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10269 count
* sizeof(struct ecommunity
)));
10270 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10272 "%ld BGP large-community entries, using %s of memory\n",
10273 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10274 count
* sizeof(struct lcommunity
)));
10276 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10277 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10278 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10279 count
* sizeof(struct cluster_list
)));
10281 /* Peer related usage */
10282 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10283 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10284 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10285 count
* sizeof(struct peer
)));
10287 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10288 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10289 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10290 count
* sizeof(struct peer_group
)));
10293 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10294 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10295 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10296 count
* sizeof(regex_t
)));
10297 return CMD_SUCCESS
;
10300 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10302 json_object
*bestpath
= json_object_new_object();
10304 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10305 json_object_string_add(bestpath
, "asPath", "ignore");
10307 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10308 json_object_string_add(bestpath
, "asPath", "confed");
10310 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10311 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10312 json_object_string_add(bestpath
, "multiPathRelax",
10315 json_object_string_add(bestpath
, "multiPathRelax",
10318 json_object_string_add(bestpath
, "multiPathRelax", "false");
10320 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10321 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10323 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10324 json_object_string_add(bestpath
, "compareRouterId", "true");
10325 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10326 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10327 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10328 json_object_string_add(bestpath
, "med", "confed");
10329 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10330 json_object_string_add(bestpath
, "med",
10331 "missing-as-worst");
10333 json_object_string_add(bestpath
, "med", "true");
10336 json_object_object_add(json
, "bestPath", bestpath
);
10339 /* Print the error code/subcode for why the peer is down */
10340 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10341 json_object
*json_peer
, bool use_json
)
10343 const char *code_str
;
10344 const char *subcode_str
;
10347 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10348 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10349 char errorcodesubcode_hexstr
[5];
10350 char errorcodesubcode_str
[256];
10352 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10353 subcode_str
= bgp_notify_subcode_str(
10355 peer
->notify
.subcode
);
10357 snprintf(errorcodesubcode_hexstr
,
10358 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10359 peer
->notify
.code
, peer
->notify
.subcode
);
10360 json_object_string_add(json_peer
,
10361 "lastErrorCodeSubcode",
10362 errorcodesubcode_hexstr
);
10363 snprintf(errorcodesubcode_str
, 255, "%s%s",
10364 code_str
, subcode_str
);
10365 json_object_string_add(json_peer
,
10366 "lastNotificationReason",
10367 errorcodesubcode_str
);
10368 json_object_boolean_add(json_peer
,
10369 "lastNotificationHardReset",
10370 peer
->notify
.hard_reset
);
10371 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10372 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10373 && (peer
->notify
.subcode
10374 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10375 || peer
->notify
.subcode
10376 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10377 && peer
->notify
.length
) {
10379 const char *msg_str
;
10381 msg_str
= bgp_notify_admin_message(
10382 msgbuf
, sizeof(msgbuf
),
10383 (uint8_t *)peer
->notify
.data
,
10384 peer
->notify
.length
);
10386 json_object_string_add(
10388 "lastShutdownDescription",
10393 json_object_string_add(json_peer
, "lastResetDueTo",
10394 peer_down_str
[(int)peer
->last_reset
]);
10395 json_object_int_add(json_peer
, "lastResetCode",
10398 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10399 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10400 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10402 bgp_notify_subcode_str(peer
->notify
.code
,
10403 peer
->notify
.subcode
);
10404 vty_out(vty
, " Notification %s (%s%s%s)\n",
10405 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10408 code_str
, subcode_str
,
10409 peer
->notify
.hard_reset
10410 ? bgp_notify_subcode_str(
10412 BGP_NOTIFY_CEASE_HARD_RESET
)
10415 vty_out(vty
, " %s\n",
10416 peer_down_str
[(int)peer
->last_reset
]);
10421 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10424 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10427 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10428 struct peer
*peer
, json_object
*json_peer
,
10429 int max_neighbor_width
, bool use_json
)
10431 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10435 if (peer_dynamic_neighbor(peer
))
10436 json_object_boolean_true_add(json_peer
,
10438 if (peer
->hostname
)
10439 json_object_string_add(json_peer
, "hostname",
10442 if (peer
->domainname
)
10443 json_object_string_add(json_peer
, "domainname",
10445 json_object_int_add(json_peer
, "connectionsEstablished",
10446 peer
->established
);
10447 json_object_int_add(json_peer
, "connectionsDropped",
10449 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10450 use_json
, json_peer
);
10451 if (peer_established(peer
))
10452 json_object_string_add(json_peer
, "lastResetDueTo",
10453 "AFI/SAFI Not Negotiated");
10455 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10458 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10460 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10461 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10462 peer
->hostname
, peer
->host
);
10464 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10466 /* pad the neighbor column with spaces */
10467 if (len
< max_neighbor_width
)
10468 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10470 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10472 peer_uptime(peer
->uptime
, timebuf
,
10473 BGP_UPTIME_LEN
, 0, NULL
));
10474 if (peer_established(peer
))
10475 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10477 bgp_show_peer_reset(vty
, peer
, NULL
,
10482 /* Strip peer's description to the given size. */
10483 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10485 static char stripped
[BUFSIZ
];
10487 uint32_t last_space
= 0;
10490 if (*(desc
+ i
) == 0) {
10491 stripped
[i
] = '\0';
10494 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10496 stripped
[i
] = *(desc
+ i
);
10500 if (last_space
> size
)
10501 stripped
[size
+ 1] = '\0';
10503 stripped
[last_space
] = '\0';
10508 /* Determine whether var peer should be filtered out of the summary. */
10509 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10510 struct peer
*fpeer
, int as_type
,
10514 /* filter neighbor XXXX */
10515 if (fpeer
&& fpeer
!= peer
)
10518 /* filter remote-as (internal|external) */
10519 if (as_type
!= AS_UNSPECIFIED
) {
10520 if (peer
->as_type
== AS_SPECIFIED
) {
10521 if (as_type
== AS_INTERNAL
) {
10522 if (peer
->as
!= peer
->local_as
)
10524 } else if (peer
->as
== peer
->local_as
)
10526 } else if (as_type
!= peer
->as_type
)
10528 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10534 /* Show BGP peer's summary information.
10536 * Peer's description is stripped according to if `wide` option is given
10539 * When adding new columns to `show bgp summary` output, please make
10540 * sure `Desc` is the lastest column to show because it can contain
10541 * whitespaces and the whole output will be tricky.
10543 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10544 struct peer
*fpeer
, int as_type
, as_t as
,
10545 uint16_t show_flags
)
10548 struct listnode
*node
, *nnode
;
10549 unsigned int count
= 0, dn_count
= 0;
10550 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10551 char neighbor_buf
[VTY_BUFSIZ
];
10552 int neighbor_col_default_width
= 16;
10553 int len
, failed_count
= 0;
10554 unsigned int filtered_count
= 0;
10555 int max_neighbor_width
= 0;
10557 json_object
*json
= NULL
;
10558 json_object
*json_peer
= NULL
;
10559 json_object
*json_peers
= NULL
;
10560 struct peer_af
*paf
;
10561 struct bgp_filter
*filter
;
10562 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10563 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10564 bool show_established
=
10565 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10566 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10567 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10569 /* labeled-unicast routes are installed in the unicast table so in order
10571 * display the correct PfxRcd value we must look at SAFI_UNICAST
10574 if (safi
== SAFI_LABELED_UNICAST
)
10575 pfx_rcd_safi
= SAFI_UNICAST
;
10577 pfx_rcd_safi
= safi
;
10580 json
= json_object_new_object();
10581 json_peers
= json_object_new_object();
10582 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10583 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10590 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10593 if (peer
->afc
[afi
][safi
]) {
10594 /* See if we have at least a single failed peer */
10595 if (bgp_has_peer_failed(peer
, afi
, safi
))
10599 if (peer_dynamic_neighbor(peer
))
10604 /* Loop over all neighbors that will be displayed to determine
10606 * characters are needed for the Neighbor column
10608 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10609 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10616 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10619 if (peer
->afc
[afi
][safi
]) {
10620 memset(dn_flag
, '\0', sizeof(dn_flag
));
10621 if (peer_dynamic_neighbor(peer
))
10625 && CHECK_FLAG(bgp
->flags
,
10626 BGP_FLAG_SHOW_HOSTNAME
))
10627 snprintf(neighbor_buf
,
10628 sizeof(neighbor_buf
),
10629 "%s%s(%s) ", dn_flag
,
10630 peer
->hostname
, peer
->host
);
10632 snprintf(neighbor_buf
,
10633 sizeof(neighbor_buf
), "%s%s ",
10634 dn_flag
, peer
->host
);
10636 len
= strlen(neighbor_buf
);
10638 if (len
> max_neighbor_width
)
10639 max_neighbor_width
= len
;
10641 /* See if we have at least a single failed peer */
10642 if (bgp_has_peer_failed(peer
, afi
, safi
))
10648 /* Originally we displayed the Neighbor column as 16
10649 * characters wide so make that the default
10651 if (max_neighbor_width
< neighbor_col_default_width
)
10652 max_neighbor_width
= neighbor_col_default_width
;
10655 if (show_failed
&& !failed_count
) {
10657 json_object_int_add(json
, "failedPeersCount", 0);
10658 json_object_int_add(json
, "dynamicPeers", dn_count
);
10659 json_object_int_add(json
, "totalPeers", count
);
10661 vty_json(vty
, json
);
10663 vty_out(vty
, "%% No failed BGP neighbors found\n");
10665 return CMD_SUCCESS
;
10668 count
= 0; /* Reset the value as its used again */
10669 filtered_count
= 0;
10671 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10672 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10675 if (!peer
->afc
[afi
][safi
])
10679 unsigned long ents
;
10680 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10683 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10685 : (int64_t)bgp
->vrf_id
;
10687 /* Usage summary and header */
10689 json_object_string_addf(json
, "routerId",
10692 json_object_int_add(json
, "as", bgp
->as
);
10693 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10694 json_object_string_add(
10697 == BGP_INSTANCE_TYPE_DEFAULT
)
10702 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10703 &bgp
->router_id
, bgp
->as
,
10704 bgp
->vrf_id
== VRF_UNKNOWN
10706 : (int)bgp
->vrf_id
);
10707 vty_out(vty
, "\n");
10710 if (bgp_update_delay_configured(bgp
)) {
10712 json_object_int_add(
10713 json
, "updateDelayLimit",
10714 bgp
->v_update_delay
);
10716 if (bgp
->v_update_delay
10717 != bgp
->v_establish_wait
)
10718 json_object_int_add(
10720 "updateDelayEstablishWait",
10721 bgp
->v_establish_wait
);
10723 if (bgp_update_delay_active(bgp
)) {
10724 json_object_string_add(
10726 "updateDelayFirstNeighbor",
10727 bgp
->update_delay_begin_time
);
10728 json_object_boolean_true_add(
10730 "updateDelayInProgress");
10732 if (bgp
->update_delay_over
) {
10733 json_object_string_add(
10735 "updateDelayFirstNeighbor",
10736 bgp
->update_delay_begin_time
);
10737 json_object_string_add(
10739 "updateDelayBestpathResumed",
10740 bgp
->update_delay_end_time
);
10741 json_object_string_add(
10743 "updateDelayZebraUpdateResume",
10744 bgp
->update_delay_zebra_resume_time
);
10745 json_object_string_add(
10747 "updateDelayPeerUpdateResume",
10748 bgp
->update_delay_peers_resume_time
);
10753 "Read-only mode update-delay limit: %d seconds\n",
10754 bgp
->v_update_delay
);
10755 if (bgp
->v_update_delay
10756 != bgp
->v_establish_wait
)
10758 " Establish wait: %d seconds\n",
10759 bgp
->v_establish_wait
);
10761 if (bgp_update_delay_active(bgp
)) {
10763 " First neighbor established: %s\n",
10764 bgp
->update_delay_begin_time
);
10766 " Delay in progress\n");
10768 if (bgp
->update_delay_over
) {
10770 " First neighbor established: %s\n",
10771 bgp
->update_delay_begin_time
);
10773 " Best-paths resumed: %s\n",
10774 bgp
->update_delay_end_time
);
10776 " zebra update resumed: %s\n",
10777 bgp
->update_delay_zebra_resume_time
);
10779 " peers update resumed: %s\n",
10780 bgp
->update_delay_peers_resume_time
);
10787 if (bgp_maxmed_onstartup_configured(bgp
)
10788 && bgp
->maxmed_active
)
10789 json_object_boolean_true_add(
10790 json
, "maxMedOnStartup");
10791 if (bgp
->v_maxmed_admin
)
10792 json_object_boolean_true_add(
10793 json
, "maxMedAdministrative");
10795 json_object_int_add(
10796 json
, "tableVersion",
10797 bgp_table_version(bgp
->rib
[afi
][safi
]));
10799 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10800 json_object_int_add(json
, "ribCount", ents
);
10801 json_object_int_add(
10803 ents
* sizeof(struct bgp_dest
));
10805 ents
= bgp
->af_peer_count
[afi
][safi
];
10806 json_object_int_add(json
, "peerCount", ents
);
10807 json_object_int_add(json
, "peerMemory",
10808 ents
* sizeof(struct peer
));
10810 if ((ents
= listcount(bgp
->group
))) {
10811 json_object_int_add(
10812 json
, "peerGroupCount", ents
);
10813 json_object_int_add(
10814 json
, "peerGroupMemory",
10815 ents
* sizeof(struct
10819 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10820 BGP_CONFIG_DAMPENING
))
10821 json_object_boolean_true_add(
10822 json
, "dampeningEnabled");
10825 if (bgp_maxmed_onstartup_configured(bgp
)
10826 && bgp
->maxmed_active
)
10828 "Max-med on-startup active\n");
10829 if (bgp
->v_maxmed_admin
)
10831 "Max-med administrative active\n");
10834 "BGP table version %" PRIu64
10837 bgp
->rib
[afi
][safi
]));
10839 ents
= bgp_table_count(
10840 bgp
->rib
[afi
][safi
]);
10842 "RIB entries %ld, using %s of memory\n",
10852 /* Peer related usage */
10853 ents
= bgp
->af_peer_count
[afi
][safi
];
10855 "Peers %ld, using %s of memory\n",
10865 if ((ents
= listcount(bgp
->group
)))
10867 "Peer groups %ld, using %s of memory\n",
10877 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10878 BGP_CONFIG_DAMPENING
))
10880 "Dampening enabled.\n");
10883 vty_out(vty
, "\n");
10885 /* Subtract 8 here because 'Neighbor' is
10887 vty_out(vty
, "Neighbor");
10888 vty_out(vty
, "%*s",
10889 max_neighbor_width
- 8, " ");
10891 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10896 paf
= peer_af_find(peer
, afi
, safi
);
10897 filter
= &peer
->filter
[afi
][safi
];
10900 /* Works for both failed & successful cases */
10901 if (peer_dynamic_neighbor(peer
))
10906 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10912 bgp_has_peer_failed(peer
, afi
, safi
)) {
10913 json_peer
= json_object_new_object();
10914 bgp_show_failed_summary(vty
, bgp
, peer
,
10915 json_peer
, 0, use_json
);
10916 } else if (!show_failed
) {
10917 if (show_established
10918 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10923 json_peer
= json_object_new_object();
10924 if (peer_dynamic_neighbor(peer
)) {
10925 json_object_boolean_true_add(json_peer
,
10929 if (peer
->hostname
)
10930 json_object_string_add(json_peer
, "hostname",
10933 if (peer
->domainname
)
10934 json_object_string_add(json_peer
, "domainname",
10937 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10938 json_object_int_add(
10939 json_peer
, "localAs",
10940 peer
->change_local_as
10941 ? peer
->change_local_as
10943 json_object_int_add(json_peer
, "version", 4);
10944 json_object_int_add(json_peer
, "msgRcvd",
10945 PEER_TOTAL_RX(peer
));
10946 json_object_int_add(json_peer
, "msgSent",
10947 PEER_TOTAL_TX(peer
));
10949 atomic_size_t outq_count
, inq_count
;
10950 outq_count
= atomic_load_explicit(
10951 &peer
->obuf
->count
,
10952 memory_order_relaxed
);
10953 inq_count
= atomic_load_explicit(
10954 &peer
->ibuf
->count
,
10955 memory_order_relaxed
);
10957 json_object_int_add(json_peer
, "tableVersion",
10958 peer
->version
[afi
][safi
]);
10959 json_object_int_add(json_peer
, "outq",
10961 json_object_int_add(json_peer
, "inq",
10963 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10964 use_json
, json_peer
);
10966 json_object_int_add(json_peer
, "pfxRcd",
10967 peer
->pcount
[afi
][pfx_rcd_safi
]);
10969 if (paf
&& PAF_SUBGRP(paf
))
10970 json_object_int_add(
10971 json_peer
, "pfxSnt",
10972 (PAF_SUBGRP(paf
))->scount
);
10974 json_object_int_add(json_peer
, "pfxSnt",
10977 /* BGP FSM state */
10978 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10979 || CHECK_FLAG(peer
->bgp
->flags
,
10980 BGP_FLAG_SHUTDOWN
))
10981 json_object_string_add(json_peer
,
10984 else if (peer
->afc_recv
[afi
][safi
])
10985 json_object_string_add(
10986 json_peer
, "state",
10987 lookup_msg(bgp_status_msg
,
10988 peer
->status
, NULL
));
10989 else if (CHECK_FLAG(
10991 PEER_STATUS_PREFIX_OVERFLOW
))
10992 json_object_string_add(json_peer
,
10996 json_object_string_add(
10997 json_peer
, "state",
10998 lookup_msg(bgp_status_msg
,
10999 peer
->status
, NULL
));
11001 /* BGP peer state */
11002 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11003 || CHECK_FLAG(peer
->bgp
->flags
,
11004 BGP_FLAG_SHUTDOWN
))
11005 json_object_string_add(json_peer
,
11008 else if (CHECK_FLAG(
11010 PEER_STATUS_PREFIX_OVERFLOW
))
11011 json_object_string_add(json_peer
,
11014 else if (CHECK_FLAG(peer
->flags
,
11015 PEER_FLAG_PASSIVE
))
11016 json_object_string_add(json_peer
,
11019 else if (CHECK_FLAG(peer
->sflags
,
11020 PEER_STATUS_NSF_WAIT
))
11021 json_object_string_add(json_peer
,
11024 else if (CHECK_FLAG(
11026 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11027 && (!bgp_inbound_policy_exists(peer
,
11029 || !bgp_outbound_policy_exists(
11031 json_object_string_add(json_peer
,
11035 json_object_string_add(
11036 json_peer
, "peerState", "OK");
11038 json_object_int_add(json_peer
, "connectionsEstablished",
11039 peer
->established
);
11040 json_object_int_add(json_peer
, "connectionsDropped",
11043 json_object_string_add(
11044 json_peer
, "desc", peer
->desc
);
11046 /* Avoid creating empty peer dicts in JSON */
11047 if (json_peer
== NULL
)
11051 json_object_string_add(json_peer
, "idType",
11053 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11054 json_object_string_add(json_peer
, "idType",
11056 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11057 json_object_string_add(json_peer
, "idType",
11059 json_object_object_add(json_peers
, peer
->host
,
11062 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11068 bgp_has_peer_failed(peer
, afi
, safi
)) {
11069 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11070 max_neighbor_width
,
11072 } else if (!show_failed
) {
11073 if (show_established
11074 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11079 if ((count
- filtered_count
) == 1) {
11080 /* display headline before the first
11082 vty_out(vty
, "\n");
11084 /* Subtract 8 here because 'Neighbor' is
11086 vty_out(vty
, "Neighbor");
11087 vty_out(vty
, "%*s",
11088 max_neighbor_width
- 8, " ");
11091 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11092 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11095 memset(dn_flag
, '\0', sizeof(dn_flag
));
11096 if (peer_dynamic_neighbor(peer
)) {
11101 && CHECK_FLAG(bgp
->flags
,
11102 BGP_FLAG_SHOW_HOSTNAME
))
11103 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11107 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11109 /* pad the neighbor column with spaces */
11110 if (len
< max_neighbor_width
)
11111 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11114 atomic_size_t outq_count
, inq_count
;
11115 outq_count
= atomic_load_explicit(
11116 &peer
->obuf
->count
,
11117 memory_order_relaxed
);
11118 inq_count
= atomic_load_explicit(
11119 &peer
->ibuf
->count
,
11120 memory_order_relaxed
);
11124 "4 %10u %10u %9u %9u %8" PRIu64
11127 peer
->change_local_as
11128 ? peer
->change_local_as
11130 PEER_TOTAL_RX(peer
),
11131 PEER_TOTAL_TX(peer
),
11132 peer
->version
[afi
][safi
],
11133 inq_count
, outq_count
,
11134 peer_uptime(peer
->uptime
,
11139 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11141 peer
->as
, PEER_TOTAL_RX(peer
),
11142 PEER_TOTAL_TX(peer
),
11143 peer
->version
[afi
][safi
],
11144 inq_count
, outq_count
,
11145 peer_uptime(peer
->uptime
,
11150 if (peer_established(peer
)) {
11151 if (peer
->afc_recv
[afi
][safi
]) {
11154 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11155 && !bgp_inbound_policy_exists(
11157 vty_out(vty
, " %12s",
11166 vty_out(vty
, " NoNeg");
11169 if (paf
&& PAF_SUBGRP(paf
)) {
11172 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11173 && !bgp_outbound_policy_exists(
11175 vty_out(vty
, " %8s",
11184 vty_out(vty
, " NoNeg");
11187 if (CHECK_FLAG(peer
->flags
,
11188 PEER_FLAG_SHUTDOWN
)
11189 || CHECK_FLAG(peer
->bgp
->flags
,
11190 BGP_FLAG_SHUTDOWN
))
11191 vty_out(vty
, " Idle (Admin)");
11192 else if (CHECK_FLAG(
11194 PEER_STATUS_PREFIX_OVERFLOW
))
11195 vty_out(vty
, " Idle (PfxCt)");
11197 vty_out(vty
, " %12s",
11198 lookup_msg(bgp_status_msg
,
11199 peer
->status
, NULL
));
11201 vty_out(vty
, " %8u", 0);
11203 /* Make sure `Desc` column is the lastest in
11207 vty_out(vty
, " %s",
11208 bgp_peer_description_stripped(
11210 show_wide
? 64 : 20));
11212 vty_out(vty
, " N/A");
11213 vty_out(vty
, "\n");
11220 json_object_object_add(json
, "peers", json_peers
);
11221 json_object_int_add(json
, "failedPeers", failed_count
);
11222 json_object_int_add(json
, "displayedPeers",
11223 count
- filtered_count
);
11224 json_object_int_add(json
, "totalPeers", count
);
11225 json_object_int_add(json
, "dynamicPeers", dn_count
);
11228 bgp_show_bestpath_json(bgp
, json
);
11230 vty_json(vty
, json
);
11233 if (filtered_count
== count
)
11234 vty_out(vty
, "\n%% No matching neighbor\n");
11237 vty_out(vty
, "\nDisplayed neighbors %d",
11239 else if (as_type
!= AS_UNSPECIFIED
|| as
11240 || fpeer
|| show_established
)
11241 vty_out(vty
, "\nDisplayed neighbors %d",
11242 count
- filtered_count
);
11244 vty_out(vty
, "\nTotal number of neighbors %d\n",
11248 vty_out(vty
, "No %s neighbor is configured\n",
11249 get_afi_safi_str(afi
, safi
, false));
11253 vty_out(vty
, "* - dynamic neighbor\n");
11254 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11255 dn_count
, bgp
->dynamic_neighbors_limit
);
11259 return CMD_SUCCESS
;
11262 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11263 int safi
, struct peer
*fpeer
, int as_type
,
11264 as_t as
, uint16_t show_flags
)
11267 int afi_wildcard
= (afi
== AFI_MAX
);
11268 int safi_wildcard
= (safi
== SAFI_MAX
);
11269 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11270 bool nbr_output
= false;
11271 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11273 if (use_json
&& is_wildcard
)
11274 vty_out(vty
, "{\n");
11276 afi
= 1; /* AFI_IP */
11277 while (afi
< AFI_MAX
) {
11279 safi
= 1; /* SAFI_UNICAST */
11280 while (safi
< SAFI_MAX
) {
11281 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11286 * So limit output to those afi/safi
11288 * actualy have something interesting in
11293 vty_out(vty
, ",\n");
11297 vty_out(vty
, "\"%s\":",
11298 get_afi_safi_str(afi
,
11303 "\n%s Summary (%s):\n",
11304 get_afi_safi_str(afi
,
11310 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11311 as_type
, as
, show_flags
);
11314 if (!safi_wildcard
)
11322 if (use_json
&& is_wildcard
)
11323 vty_out(vty
, "}\n");
11324 else if (!nbr_output
) {
11326 vty_out(vty
, "{}\n");
11328 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11333 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11335 const char *neighbor
,
11336 int as_type
, as_t as
,
11337 uint16_t show_flags
)
11339 struct listnode
*node
, *nnode
;
11341 struct peer
*fpeer
= NULL
;
11343 bool nbr_output
= false;
11344 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11347 vty_out(vty
, "{\n");
11349 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11353 vty_out(vty
, ",\n");
11357 vty_out(vty
, "\"%s\":",
11358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11363 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11368 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11373 vty_out(vty
, "}\n");
11374 else if (!nbr_output
)
11375 vty_out(vty
, "%% BGP instance not found\n");
11378 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11379 safi_t safi
, const char *neighbor
, int as_type
,
11380 as_t as
, uint16_t show_flags
)
11383 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11384 struct peer
*fpeer
= NULL
;
11387 if (strmatch(name
, "all")) {
11388 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11391 return CMD_SUCCESS
;
11393 bgp
= bgp_lookup_by_name(name
);
11397 vty_out(vty
, "{}\n");
11400 "%% BGP instance not found\n");
11401 return CMD_WARNING
;
11405 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11408 return CMD_WARNING
;
11410 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11411 as_type
, as
, show_flags
);
11412 return CMD_SUCCESS
;
11416 bgp
= bgp_get_default();
11420 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11423 return CMD_WARNING
;
11425 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11429 vty_out(vty
, "{}\n");
11431 vty_out(vty
, "%% BGP instance not found\n");
11432 return CMD_WARNING
;
11435 return CMD_SUCCESS
;
11438 /* `show [ip] bgp summary' commands. */
11439 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11440 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11441 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11442 "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <(1-4294967295)|internal|external>>] [terse] [wide] [json$uj]",
11443 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11444 BGP_SAFI_WITH_LABEL_HELP_STR
11445 "Display the entries for all address families\n"
11446 "Summary of BGP neighbor status\n"
11447 "Show only sessions in Established state\n"
11448 "Show only sessions not in Established state\n"
11449 "Show only the specified neighbor session\n"
11450 "Neighbor to display information about\n"
11451 "Neighbor to display information about\n"
11452 "Neighbor on BGP configured interface\n"
11453 "Show only the specified remote AS sessions\n"
11455 "Internal (iBGP) AS sessions\n"
11456 "External (eBGP) AS sessions\n"
11457 "Shorten the information on BGP instances\n"
11458 "Increase table width for longer output\n" JSON_STR
)
11461 afi_t afi
= AFI_MAX
;
11462 safi_t safi
= SAFI_MAX
;
11463 as_t as
= 0; /* 0 means AS filter not set */
11464 int as_type
= AS_UNSPECIFIED
;
11465 uint16_t show_flags
= 0;
11469 /* show [ip] bgp */
11470 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11472 /* [<vrf> VIEWVRFNAME] */
11473 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11474 vrf
= argv
[idx
+ 1]->arg
;
11475 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11477 } else if (argv_find(argv
, argc
, "view", &idx
))
11478 /* [<view> VIEWVRFNAME] */
11479 vrf
= argv
[idx
+ 1]->arg
;
11480 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11481 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11482 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11485 if (argv_find(argv
, argc
, "failed", &idx
))
11486 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11488 if (argv_find(argv
, argc
, "established", &idx
))
11489 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11491 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11492 if (argv
[idx
+ 1]->arg
[0] == 'i')
11493 as_type
= AS_INTERNAL
;
11494 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11495 as_type
= AS_EXTERNAL
;
11497 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11500 if (argv_find(argv
, argc
, "terse", &idx
))
11501 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11503 if (argv_find(argv
, argc
, "wide", &idx
))
11504 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11506 if (argv_find(argv
, argc
, "json", &idx
))
11507 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11509 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11513 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11516 return get_afi_safi_json_str(afi
, safi
);
11518 return get_afi_safi_vty_str(afi
, safi
);
11522 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11523 afi_t afi
, safi_t safi
,
11524 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11525 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11526 bool use_json
, json_object
*json_pref
)
11529 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11530 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11532 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11533 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11534 json_object_string_add(json_pref
, "sendMode",
11535 "advertisedAndReceived");
11536 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11537 json_object_string_add(json_pref
, "sendMode",
11539 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11540 json_object_string_add(json_pref
, "sendMode",
11543 vty_out(vty
, " Send-mode: ");
11544 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11545 vty_out(vty
, "advertised");
11546 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11547 vty_out(vty
, "%sreceived",
11548 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11552 vty_out(vty
, "\n");
11557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11558 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11560 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11561 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11562 json_object_string_add(json_pref
, "recvMode",
11563 "advertisedAndReceived");
11564 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11565 json_object_string_add(json_pref
, "recvMode",
11567 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11568 json_object_string_add(json_pref
, "recvMode",
11571 vty_out(vty
, " Receive-mode: ");
11572 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11573 vty_out(vty
, "advertised");
11574 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11575 vty_out(vty
, "%sreceived",
11576 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11580 vty_out(vty
, "\n");
11585 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11593 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11594 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11595 && (peer_established(p
))) {
11596 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11597 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11601 json_object_boolean_add(json
, "rBit", rbit
);
11602 json_object_boolean_add(json
, "nBit", nbit
);
11604 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11605 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11609 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11614 const char *mode
= "NotApplicable";
11617 vty_out(vty
, "\n Remote GR Mode: ");
11619 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11620 && (peer_established(peer
))) {
11622 if ((peer
->nsf_af_count
== 0)
11623 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11627 } else if (peer
->nsf_af_count
== 0
11628 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11632 } else if (peer
->nsf_af_count
!= 0
11633 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11640 json_object_string_add(json
, "remoteGrMode", mode
);
11642 vty_out(vty
, mode
, "\n");
11645 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11650 const char *mode
= "Invalid";
11653 vty_out(vty
, " Local GR Mode: ");
11655 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11657 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11659 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11661 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11662 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11664 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11666 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11673 json_object_string_add(json
, "localGrMode", mode
);
11675 vty_out(vty
, mode
, "\n");
11679 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11680 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11684 json_object
*json_afi_safi
= NULL
;
11685 json_object
*json_timer
= NULL
;
11686 json_object
*json_endofrib_status
= NULL
;
11687 bool eor_flag
= false;
11689 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11690 if (!peer
->afc
[afi
][safi
])
11693 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11694 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11698 json_afi_safi
= json_object_new_object();
11699 json_endofrib_status
= json_object_new_object();
11700 json_timer
= json_object_new_object();
11703 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11709 vty_out(vty
, " %s:\n",
11710 get_afi_safi_str(afi
, safi
, false));
11712 vty_out(vty
, " F bit: ");
11715 if (peer
->nsf
[afi
][safi
] &&
11716 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11717 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11720 json_object_boolean_true_add(json_afi_safi
,
11723 vty_out(vty
, "True\n");
11726 json_object_boolean_false_add(json_afi_safi
,
11729 vty_out(vty
, "False\n");
11733 vty_out(vty
, " End-of-RIB sent: ");
11735 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11736 PEER_STATUS_EOR_SEND
)) {
11738 json_object_boolean_true_add(
11739 json_endofrib_status
, "endOfRibSend");
11741 PRINT_EOR_JSON(eor_flag
);
11743 vty_out(vty
, "Yes\n");
11745 " End-of-RIB sent after update: ");
11747 PRINT_EOR(eor_flag
);
11751 json_object_boolean_false_add(
11752 json_endofrib_status
, "endOfRibSend");
11753 json_object_boolean_false_add(
11754 json_endofrib_status
,
11755 "endOfRibSentAfterUpdate");
11757 vty_out(vty
, "No\n");
11759 " End-of-RIB sent after update: ");
11760 vty_out(vty
, "No\n");
11765 vty_out(vty
, " End-of-RIB received: ");
11767 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11768 PEER_STATUS_EOR_RECEIVED
)) {
11770 json_object_boolean_true_add(
11771 json_endofrib_status
, "endOfRibRecv");
11773 vty_out(vty
, "Yes\n");
11776 json_object_boolean_false_add(
11777 json_endofrib_status
, "endOfRibRecv");
11779 vty_out(vty
, "No\n");
11783 json_object_int_add(json_timer
, "stalePathTimer",
11784 peer
->bgp
->stalepath_time
);
11786 if (peer
->t_gr_stale
!= NULL
) {
11787 json_object_int_add(json_timer
,
11788 "stalePathTimerRemaining",
11789 thread_timer_remain_second(
11790 peer
->t_gr_stale
));
11793 /* Display Configured Selection
11794 * Deferral only when when
11795 * Gr mode is enabled.
11797 if (CHECK_FLAG(peer
->flags
,
11798 PEER_FLAG_GRACEFUL_RESTART
)) {
11799 json_object_int_add(json_timer
,
11800 "selectionDeferralTimer",
11801 peer
->bgp
->stalepath_time
);
11804 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11807 json_object_int_add(
11809 "selectionDeferralTimerRemaining",
11810 thread_timer_remain_second(
11811 peer
->bgp
->gr_info
[afi
][safi
]
11812 .t_select_deferral
));
11815 vty_out(vty
, " Timers:\n");
11817 " Configured Stale Path Time(sec): %u\n",
11818 peer
->bgp
->stalepath_time
);
11820 if (peer
->t_gr_stale
!= NULL
)
11822 " Stale Path Remaining(sec): %ld\n",
11823 thread_timer_remain_second(
11824 peer
->t_gr_stale
));
11825 /* Display Configured Selection
11826 * Deferral only when when
11827 * Gr mode is enabled.
11829 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11831 " Configured Selection Deferral Time(sec): %u\n",
11832 peer
->bgp
->select_defer_time
);
11834 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11837 " Selection Deferral Time Remaining(sec): %ld\n",
11838 thread_timer_remain_second(
11839 peer
->bgp
->gr_info
[afi
][safi
]
11840 .t_select_deferral
));
11843 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11844 json_endofrib_status
);
11845 json_object_object_add(json_afi_safi
, "timers",
11847 json_object_object_add(
11848 json
, get_afi_safi_str(afi
, safi
, true),
11854 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11860 json_object
*json_timer
= NULL
;
11862 json_timer
= json_object_new_object();
11864 json_object_int_add(json_timer
, "configuredRestartTimer",
11865 p
->bgp
->restart_time
);
11867 json_object_int_add(json_timer
, "receivedRestartTimer",
11870 if (p
->t_gr_restart
!= NULL
)
11871 json_object_int_add(
11872 json_timer
, "restartTimerRemaining",
11873 thread_timer_remain_second(p
->t_gr_restart
));
11875 json_object_object_add(json
, "timers", json_timer
);
11878 vty_out(vty
, " Timers:\n");
11879 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11880 p
->bgp
->restart_time
);
11882 vty_out(vty
, " Received Restart Time(sec): %u\n",
11884 if (p
->t_gr_restart
!= NULL
)
11885 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11886 thread_timer_remain_second(p
->t_gr_restart
));
11887 if (p
->t_gr_restart
!= NULL
) {
11888 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11889 thread_timer_remain_second(p
->t_gr_restart
));
11894 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11895 bool use_json
, json_object
*json
)
11897 char dn_flag
[2] = {0};
11898 /* '*' + v6 address of neighbor */
11899 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11901 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11906 json_object_string_addf(json
, "neighborAddr", "%pSU",
11909 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11912 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11916 json_object_string_add(json
, "neighborAddr",
11919 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11922 /* more gr info in new format */
11923 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11926 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11927 safi_t safi
, bool use_json
,
11928 json_object
*json_neigh
)
11930 struct bgp_filter
*filter
;
11931 struct peer_af
*paf
;
11932 char orf_pfx_name
[BUFSIZ
];
11934 json_object
*json_af
= NULL
;
11935 json_object
*json_prefA
= NULL
;
11936 json_object
*json_prefB
= NULL
;
11937 json_object
*json_addr
= NULL
;
11938 json_object
*json_advmap
= NULL
;
11941 json_addr
= json_object_new_object();
11942 json_af
= json_object_new_object();
11943 filter
= &p
->filter
[afi
][safi
];
11945 if (peer_group_active(p
))
11946 json_object_string_add(json_addr
, "peerGroupMember",
11949 paf
= peer_af_find(p
, afi
, safi
);
11950 if (paf
&& PAF_SUBGRP(paf
)) {
11951 json_object_int_add(json_addr
, "updateGroupId",
11952 PAF_UPDGRP(paf
)->id
);
11953 json_object_int_add(json_addr
, "subGroupId",
11954 PAF_SUBGRP(paf
)->id
);
11955 json_object_int_add(json_addr
, "packetQueueLength",
11956 bpacket_queue_virtual_length(paf
));
11959 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11960 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11961 PEER_CAP_ORF_PREFIX_SM_RCV
)
11962 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11963 PEER_CAP_ORF_PREFIX_RM_ADV
)
11964 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11965 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11966 json_object_int_add(json_af
, "orfType",
11968 json_prefA
= json_object_new_object();
11969 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11970 PEER_CAP_ORF_PREFIX_SM_ADV
,
11971 PEER_CAP_ORF_PREFIX_RM_ADV
,
11972 PEER_CAP_ORF_PREFIX_SM_RCV
,
11973 PEER_CAP_ORF_PREFIX_RM_RCV
,
11974 use_json
, json_prefA
);
11975 json_object_object_add(json_af
, "orfPrefixList",
11979 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11980 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11981 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11982 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11983 PEER_CAP_ORF_PREFIX_RM_ADV
)
11984 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11985 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11986 json_object_int_add(json_af
, "orfOldType",
11987 ORF_TYPE_PREFIX_OLD
);
11988 json_prefB
= json_object_new_object();
11989 bgp_show_peer_afi_orf_cap(
11990 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11991 PEER_CAP_ORF_PREFIX_RM_ADV
,
11992 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11993 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11995 json_object_object_add(json_af
, "orfOldPrefixList",
11999 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12000 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12001 PEER_CAP_ORF_PREFIX_SM_RCV
)
12002 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12003 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12004 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12005 PEER_CAP_ORF_PREFIX_RM_ADV
)
12006 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12007 PEER_CAP_ORF_PREFIX_RM_RCV
)
12008 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12009 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12010 json_object_object_add(json_addr
, "afDependentCap",
12013 json_object_free(json_af
);
12015 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12016 p
->host
, afi
, safi
);
12017 orf_pfx_count
= prefix_bgp_show_prefix_list(
12018 NULL
, afi
, orf_pfx_name
, use_json
);
12020 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12021 PEER_STATUS_ORF_PREFIX_SEND
)
12022 || orf_pfx_count
) {
12023 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12024 PEER_STATUS_ORF_PREFIX_SEND
))
12025 json_object_boolean_true_add(json_neigh
,
12028 json_object_int_add(json_addr
, "orfRecvCounter",
12031 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12032 PEER_STATUS_ORF_WAIT_REFRESH
))
12033 json_object_string_add(
12034 json_addr
, "orfFirstUpdate",
12035 "deferredUntilORFOrRouteRefreshRecvd");
12037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12038 PEER_FLAG_REFLECTOR_CLIENT
))
12039 json_object_boolean_true_add(json_addr
,
12040 "routeReflectorClient");
12041 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12042 PEER_FLAG_RSERVER_CLIENT
))
12043 json_object_boolean_true_add(json_addr
,
12044 "routeServerClient");
12045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12046 json_object_boolean_true_add(json_addr
,
12047 "inboundSoftConfigPermit");
12049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12050 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12051 json_object_boolean_true_add(
12053 "privateAsNumsAllReplacedInUpdatesToNbr");
12054 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12055 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12056 json_object_boolean_true_add(
12058 "privateAsNumsReplacedInUpdatesToNbr");
12059 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12060 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12061 json_object_boolean_true_add(
12063 "privateAsNumsAllRemovedInUpdatesToNbr");
12064 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12065 PEER_FLAG_REMOVE_PRIVATE_AS
))
12066 json_object_boolean_true_add(
12068 "privateAsNumsRemovedInUpdatesToNbr");
12070 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12071 json_object_boolean_true_add(
12073 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12076 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12077 json_object_string_add(json_addr
,
12078 "overrideASNsInOutboundUpdates",
12079 "ifAspathEqualRemoteAs");
12081 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12082 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12083 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12084 json_object_boolean_true_add(json_addr
,
12085 "routerAlwaysNextHop");
12086 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12087 PEER_FLAG_AS_PATH_UNCHANGED
))
12088 json_object_boolean_true_add(
12089 json_addr
, "unchangedAsPathPropogatedToNbr");
12090 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12091 PEER_FLAG_NEXTHOP_UNCHANGED
))
12092 json_object_boolean_true_add(
12093 json_addr
, "unchangedNextHopPropogatedToNbr");
12094 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12095 json_object_boolean_true_add(
12096 json_addr
, "unchangedMedPropogatedToNbr");
12097 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12098 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12099 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12100 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12101 PEER_FLAG_SEND_COMMUNITY
)
12102 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12103 PEER_FLAG_SEND_EXT_COMMUNITY
))
12104 json_object_string_add(json_addr
,
12105 "commAttriSentToNbr",
12106 "extendedAndStandard");
12107 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12108 PEER_FLAG_SEND_EXT_COMMUNITY
))
12109 json_object_string_add(json_addr
,
12110 "commAttriSentToNbr",
12113 json_object_string_add(json_addr
,
12114 "commAttriSentToNbr",
12117 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12118 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12119 if (p
->default_rmap
[afi
][safi
].name
)
12120 json_object_string_add(
12121 json_addr
, "defaultRouteMap",
12122 p
->default_rmap
[afi
][safi
].name
);
12124 if (paf
&& PAF_SUBGRP(paf
)
12125 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12126 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12127 json_object_boolean_true_add(json_addr
,
12130 json_object_boolean_true_add(json_addr
,
12134 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12135 if (is_evpn_enabled())
12136 json_object_boolean_true_add(
12137 json_addr
, "advertiseAllVnis");
12140 if (filter
->plist
[FILTER_IN
].name
12141 || filter
->dlist
[FILTER_IN
].name
12142 || filter
->aslist
[FILTER_IN
].name
12143 || filter
->map
[RMAP_IN
].name
)
12144 json_object_boolean_true_add(json_addr
,
12145 "inboundPathPolicyConfig");
12146 if (filter
->plist
[FILTER_OUT
].name
12147 || filter
->dlist
[FILTER_OUT
].name
12148 || filter
->aslist
[FILTER_OUT
].name
12149 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12150 json_object_boolean_true_add(
12151 json_addr
, "outboundPathPolicyConfig");
12154 if (filter
->plist
[FILTER_IN
].name
)
12155 json_object_string_add(json_addr
,
12156 "incomingUpdatePrefixFilterList",
12157 filter
->plist
[FILTER_IN
].name
);
12158 if (filter
->plist
[FILTER_OUT
].name
)
12159 json_object_string_add(json_addr
,
12160 "outgoingUpdatePrefixFilterList",
12161 filter
->plist
[FILTER_OUT
].name
);
12163 /* distribute-list */
12164 if (filter
->dlist
[FILTER_IN
].name
)
12165 json_object_string_add(
12166 json_addr
, "incomingUpdateNetworkFilterList",
12167 filter
->dlist
[FILTER_IN
].name
);
12168 if (filter
->dlist
[FILTER_OUT
].name
)
12169 json_object_string_add(
12170 json_addr
, "outgoingUpdateNetworkFilterList",
12171 filter
->dlist
[FILTER_OUT
].name
);
12174 if (filter
->aslist
[FILTER_IN
].name
)
12175 json_object_string_add(json_addr
,
12176 "incomingUpdateAsPathFilterList",
12177 filter
->aslist
[FILTER_IN
].name
);
12178 if (filter
->aslist
[FILTER_OUT
].name
)
12179 json_object_string_add(json_addr
,
12180 "outgoingUpdateAsPathFilterList",
12181 filter
->aslist
[FILTER_OUT
].name
);
12184 if (filter
->map
[RMAP_IN
].name
)
12185 json_object_string_add(
12186 json_addr
, "routeMapForIncomingAdvertisements",
12187 filter
->map
[RMAP_IN
].name
);
12188 if (filter
->map
[RMAP_OUT
].name
)
12189 json_object_string_add(
12190 json_addr
, "routeMapForOutgoingAdvertisements",
12191 filter
->map
[RMAP_OUT
].name
);
12193 /* ebgp-requires-policy (inbound) */
12194 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12195 && !bgp_inbound_policy_exists(p
, filter
))
12196 json_object_string_add(
12197 json_addr
, "inboundEbgpRequiresPolicy",
12198 "Inbound updates discarded due to missing policy");
12200 /* ebgp-requires-policy (outbound) */
12201 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12202 && (!bgp_outbound_policy_exists(p
, filter
)))
12203 json_object_string_add(
12204 json_addr
, "outboundEbgpRequiresPolicy",
12205 "Outbound updates discarded due to missing policy");
12207 /* unsuppress-map */
12208 if (filter
->usmap
.name
)
12209 json_object_string_add(json_addr
,
12210 "selectiveUnsuppressRouteMap",
12211 filter
->usmap
.name
);
12213 /* advertise-map */
12214 if (filter
->advmap
.aname
) {
12215 json_advmap
= json_object_new_object();
12216 json_object_string_add(json_advmap
, "condition",
12217 filter
->advmap
.condition
12220 json_object_string_add(json_advmap
, "conditionMap",
12221 filter
->advmap
.cname
);
12222 json_object_string_add(json_advmap
, "advertiseMap",
12223 filter
->advmap
.aname
);
12224 json_object_string_add(
12225 json_advmap
, "advertiseStatus",
12226 filter
->advmap
.update_type
==
12227 UPDATE_TYPE_ADVERTISE
12230 json_object_object_add(json_addr
, "advertiseMap",
12234 /* Receive prefix count */
12235 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12236 p
->pcount
[afi
][safi
]);
12237 if (paf
&& PAF_SUBGRP(paf
))
12238 json_object_int_add(json_addr
, "sentPrefixCounter",
12239 (PAF_SUBGRP(paf
))->scount
);
12241 /* Maximum prefix */
12242 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12243 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12244 p
->pmax_out
[afi
][safi
]);
12246 /* Maximum prefix */
12247 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12248 json_object_int_add(json_addr
, "prefixAllowedMax",
12249 p
->pmax
[afi
][safi
]);
12250 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12251 PEER_FLAG_MAX_PREFIX_WARNING
))
12252 json_object_boolean_true_add(
12253 json_addr
, "prefixAllowedMaxWarning");
12254 json_object_int_add(json_addr
,
12255 "prefixAllowedWarningThresh",
12256 p
->pmax_threshold
[afi
][safi
]);
12257 if (p
->pmax_restart
[afi
][safi
])
12258 json_object_int_add(
12260 "prefixAllowedRestartIntervalMsecs",
12261 p
->pmax_restart
[afi
][safi
] * 60000);
12263 json_object_object_add(json_neigh
,
12264 get_afi_safi_str(afi
, safi
, true),
12268 filter
= &p
->filter
[afi
][safi
];
12270 vty_out(vty
, " For address family: %s\n",
12271 get_afi_safi_str(afi
, safi
, false));
12273 if (peer_group_active(p
))
12274 vty_out(vty
, " %s peer-group member\n",
12277 paf
= peer_af_find(p
, afi
, safi
);
12278 if (paf
&& PAF_SUBGRP(paf
)) {
12279 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12280 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12281 vty_out(vty
, " Packet Queue length %d\n",
12282 bpacket_queue_virtual_length(paf
));
12284 vty_out(vty
, " Not part of any update group\n");
12286 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12287 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12288 PEER_CAP_ORF_PREFIX_SM_RCV
)
12289 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12290 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12291 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12292 PEER_CAP_ORF_PREFIX_RM_ADV
)
12293 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12294 PEER_CAP_ORF_PREFIX_RM_RCV
)
12295 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12296 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12297 vty_out(vty
, " AF-dependant capabilities:\n");
12299 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12300 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12301 PEER_CAP_ORF_PREFIX_SM_RCV
)
12302 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12303 PEER_CAP_ORF_PREFIX_RM_ADV
)
12304 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12305 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12307 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12309 bgp_show_peer_afi_orf_cap(
12310 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12311 PEER_CAP_ORF_PREFIX_RM_ADV
,
12312 PEER_CAP_ORF_PREFIX_SM_RCV
,
12313 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12315 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12316 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12317 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12318 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12319 PEER_CAP_ORF_PREFIX_RM_ADV
)
12320 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12321 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12323 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12324 ORF_TYPE_PREFIX_OLD
);
12325 bgp_show_peer_afi_orf_cap(
12326 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12327 PEER_CAP_ORF_PREFIX_RM_ADV
,
12328 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12329 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12332 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12333 p
->host
, afi
, safi
);
12334 orf_pfx_count
= prefix_bgp_show_prefix_list(
12335 NULL
, afi
, orf_pfx_name
, use_json
);
12337 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12338 PEER_STATUS_ORF_PREFIX_SEND
)
12339 || orf_pfx_count
) {
12340 vty_out(vty
, " Outbound Route Filter (ORF):");
12341 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12342 PEER_STATUS_ORF_PREFIX_SEND
))
12343 vty_out(vty
, " sent;");
12345 vty_out(vty
, " received (%d entries)",
12347 vty_out(vty
, "\n");
12349 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12350 PEER_STATUS_ORF_WAIT_REFRESH
))
12352 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12354 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12355 PEER_FLAG_REFLECTOR_CLIENT
))
12356 vty_out(vty
, " Route-Reflector Client\n");
12357 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12358 PEER_FLAG_RSERVER_CLIENT
))
12359 vty_out(vty
, " Route-Server Client\n");
12360 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12362 " Inbound soft reconfiguration allowed\n");
12364 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12365 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12367 " Private AS numbers (all) replaced in updates to this neighbor\n");
12368 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12369 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12371 " Private AS numbers replaced in updates to this neighbor\n");
12372 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12373 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12375 " Private AS numbers (all) removed in updates to this neighbor\n");
12376 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12377 PEER_FLAG_REMOVE_PRIVATE_AS
))
12379 " Private AS numbers removed in updates to this neighbor\n");
12381 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12382 vty_out(vty
, " %s\n",
12383 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12384 ->human_description
);
12386 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12388 " Override ASNs in outbound updates if aspath equals remote-as\n");
12390 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12391 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12392 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12393 vty_out(vty
, " NEXT_HOP is always this router\n");
12394 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12395 PEER_FLAG_AS_PATH_UNCHANGED
))
12397 " AS_PATH is propagated unchanged to this neighbor\n");
12398 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12399 PEER_FLAG_NEXTHOP_UNCHANGED
))
12401 " NEXT_HOP is propagated unchanged to this neighbor\n");
12402 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12404 " MED is propagated unchanged to this neighbor\n");
12405 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12406 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12407 PEER_FLAG_SEND_EXT_COMMUNITY
)
12408 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12409 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12411 " Community attribute sent to this neighbor");
12412 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12413 PEER_FLAG_SEND_COMMUNITY
)
12414 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_SEND_EXT_COMMUNITY
)
12416 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12417 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12418 vty_out(vty
, "(all)\n");
12419 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12420 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12421 vty_out(vty
, "(large)\n");
12422 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_SEND_EXT_COMMUNITY
))
12424 vty_out(vty
, "(extended)\n");
12426 vty_out(vty
, "(standard)\n");
12428 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12429 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12430 vty_out(vty
, " Default information originate,");
12432 if (p
->default_rmap
[afi
][safi
].name
)
12433 vty_out(vty
, " default route-map %s%s,",
12434 p
->default_rmap
[afi
][safi
].map
? "*"
12436 p
->default_rmap
[afi
][safi
].name
);
12437 if (paf
&& PAF_SUBGRP(paf
)
12438 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12439 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12440 vty_out(vty
, " default sent\n");
12442 vty_out(vty
, " default not sent\n");
12445 /* advertise-vni-all */
12446 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12447 if (is_evpn_enabled())
12448 vty_out(vty
, " advertise-all-vni\n");
12451 if (filter
->plist
[FILTER_IN
].name
12452 || filter
->dlist
[FILTER_IN
].name
12453 || filter
->aslist
[FILTER_IN
].name
12454 || filter
->map
[RMAP_IN
].name
)
12455 vty_out(vty
, " Inbound path policy configured\n");
12456 if (filter
->plist
[FILTER_OUT
].name
12457 || filter
->dlist
[FILTER_OUT
].name
12458 || filter
->aslist
[FILTER_OUT
].name
12459 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12460 vty_out(vty
, " Outbound path policy configured\n");
12463 if (filter
->plist
[FILTER_IN
].name
)
12465 " Incoming update prefix filter list is %s%s\n",
12466 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12467 filter
->plist
[FILTER_IN
].name
);
12468 if (filter
->plist
[FILTER_OUT
].name
)
12470 " Outgoing update prefix filter list is %s%s\n",
12471 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12472 filter
->plist
[FILTER_OUT
].name
);
12474 /* distribute-list */
12475 if (filter
->dlist
[FILTER_IN
].name
)
12477 " Incoming update network filter list is %s%s\n",
12478 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12479 filter
->dlist
[FILTER_IN
].name
);
12480 if (filter
->dlist
[FILTER_OUT
].name
)
12482 " Outgoing update network filter list is %s%s\n",
12483 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12484 filter
->dlist
[FILTER_OUT
].name
);
12487 if (filter
->aslist
[FILTER_IN
].name
)
12489 " Incoming update AS path filter list is %s%s\n",
12490 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12491 filter
->aslist
[FILTER_IN
].name
);
12492 if (filter
->aslist
[FILTER_OUT
].name
)
12494 " Outgoing update AS path filter list is %s%s\n",
12495 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12496 filter
->aslist
[FILTER_OUT
].name
);
12499 if (filter
->map
[RMAP_IN
].name
)
12501 " Route map for incoming advertisements is %s%s\n",
12502 filter
->map
[RMAP_IN
].map
? "*" : "",
12503 filter
->map
[RMAP_IN
].name
);
12504 if (filter
->map
[RMAP_OUT
].name
)
12506 " Route map for outgoing advertisements is %s%s\n",
12507 filter
->map
[RMAP_OUT
].map
? "*" : "",
12508 filter
->map
[RMAP_OUT
].name
);
12510 /* ebgp-requires-policy (inbound) */
12511 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12512 && !bgp_inbound_policy_exists(p
, filter
))
12514 " Inbound updates discarded due to missing policy\n");
12516 /* ebgp-requires-policy (outbound) */
12517 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12518 && !bgp_outbound_policy_exists(p
, filter
))
12520 " Outbound updates discarded due to missing policy\n");
12522 /* unsuppress-map */
12523 if (filter
->usmap
.name
)
12525 " Route map for selective unsuppress is %s%s\n",
12526 filter
->usmap
.map
? "*" : "",
12527 filter
->usmap
.name
);
12529 /* advertise-map */
12530 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12532 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12533 filter
->advmap
.condition
? "EXIST"
12535 filter
->advmap
.cmap
? "*" : "",
12536 filter
->advmap
.cname
,
12537 filter
->advmap
.amap
? "*" : "",
12538 filter
->advmap
.aname
,
12539 filter
->advmap
.update_type
==
12540 UPDATE_TYPE_ADVERTISE
12544 /* Receive prefix count */
12545 vty_out(vty
, " %u accepted prefixes\n",
12546 p
->pcount
[afi
][safi
]);
12548 /* maximum-prefix-out */
12549 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12550 PEER_FLAG_MAX_PREFIX_OUT
))
12552 " Maximum allowed prefixes sent %u\n",
12553 p
->pmax_out
[afi
][safi
]);
12555 /* Maximum prefix */
12556 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12558 " Maximum prefixes allowed %u%s\n",
12559 p
->pmax
[afi
][safi
],
12560 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12561 PEER_FLAG_MAX_PREFIX_WARNING
)
12562 ? " (warning-only)"
12564 vty_out(vty
, " Threshold for warning message %d%%",
12565 p
->pmax_threshold
[afi
][safi
]);
12566 if (p
->pmax_restart
[afi
][safi
])
12567 vty_out(vty
, ", restart interval %d min",
12568 p
->pmax_restart
[afi
][safi
]);
12569 vty_out(vty
, "\n");
12572 vty_out(vty
, "\n");
12576 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12580 char buf1
[PREFIX2STR_BUFFER
];
12581 char timebuf
[BGP_UPTIME_LEN
];
12587 json_object
*json_neigh
= NULL
;
12589 uint32_t sync_tcp_mss
;
12594 json_neigh
= json_object_new_object();
12596 memset(dn_flag
, '\0', sizeof(dn_flag
));
12597 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12601 if (p
->conf_if
) /* Configured interface name. */
12602 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12604 else /* Configured IP address. */
12605 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12610 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12611 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12613 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12614 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12617 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12619 if (p
->change_local_as
)
12620 json_object_int_add(json_neigh
, "localAs",
12621 p
->change_local_as
);
12623 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12625 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12626 json_object_boolean_true_add(json_neigh
,
12627 "localAsNoPrepend");
12629 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12630 json_object_boolean_true_add(json_neigh
,
12631 "localAsReplaceAs");
12633 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12634 || (p
->as_type
== AS_INTERNAL
))
12635 vty_out(vty
, "remote AS %u, ", p
->as
);
12637 vty_out(vty
, "remote AS Unspecified, ");
12638 vty_out(vty
, "local AS %u%s%s, ",
12639 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12640 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12643 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12647 /* peer type internal or confed-internal */
12648 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12650 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12651 json_object_boolean_true_add(
12652 json_neigh
, "nbrConfedInternalLink");
12654 json_object_boolean_true_add(json_neigh
,
12655 "nbrInternalLink");
12657 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12658 vty_out(vty
, "confed-internal link\n");
12660 vty_out(vty
, "internal link\n");
12662 /* peer type external or confed-external */
12663 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12665 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12666 json_object_boolean_true_add(
12667 json_neigh
, "nbrConfedExternalLink");
12669 json_object_boolean_true_add(json_neigh
,
12670 "nbrExternalLink");
12672 if (bgp_confederation_peers_check(bgp
, p
->as
))
12673 vty_out(vty
, "confed-external link\n");
12675 vty_out(vty
, "external link\n");
12679 json_object_boolean_true_add(json_neigh
,
12680 "nbrUnspecifiedLink");
12682 vty_out(vty
, "unspecified link\n");
12687 json_object_string_add(json_neigh
, "localRole",
12688 bgp_get_name_by_role(p
->local_role
));
12689 json_object_string_add(json_neigh
, "remoteRole",
12690 bgp_get_name_by_role(p
->remote_role
));
12692 vty_out(vty
, " Local Role: %s\n",
12693 bgp_get_name_by_role(p
->local_role
));
12694 vty_out(vty
, " Remote Role: %s\n",
12695 bgp_get_name_by_role(p
->remote_role
));
12702 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12704 vty_out(vty
, " Description: %s\n", p
->desc
);
12710 json_object_string_add(json_neigh
, "hostname",
12714 json_object_string_add(json_neigh
, "domainname",
12717 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12718 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12721 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12728 json_object_string_add(json_neigh
, "peerGroup",
12732 struct prefix prefix
, *range
= NULL
;
12734 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12735 range
= peer_group_lookup_dynamic_neighbor_range(
12736 p
->group
, &prefix
);
12739 json_object_string_addf(
12741 "peerSubnetRangeGroup", "%pFX",
12747 " Member of peer-group %s for session parameters\n",
12751 struct prefix prefix
, *range
= NULL
;
12753 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12754 range
= peer_group_lookup_dynamic_neighbor_range(
12755 p
->group
, &prefix
);
12759 " Belongs to the subnet range group: %pFX\n",
12767 /* Administrative shutdown. */
12768 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12769 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12770 json_object_boolean_true_add(json_neigh
,
12774 json_object_int_add(json_neigh
, "bgpVersion", 4);
12775 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12777 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12780 /* Confederation */
12781 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12782 && bgp_confederation_peers_check(bgp
, p
->as
))
12783 json_object_boolean_true_add(json_neigh
,
12787 json_object_string_add(
12788 json_neigh
, "bgpState",
12789 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12791 if (peer_established(p
)) {
12794 uptime
= monotime(NULL
);
12795 uptime
-= p
->uptime
;
12796 epoch_tbuf
= time(NULL
) - uptime
;
12798 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12800 json_object_string_add(json_neigh
, "bgpTimerUpString",
12801 peer_uptime(p
->uptime
, timebuf
,
12804 json_object_int_add(json_neigh
,
12805 "bgpTimerUpEstablishedEpoch",
12809 else if (p
->status
== Active
) {
12810 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12811 json_object_string_add(json_neigh
, "bgpStateIs",
12813 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12814 json_object_string_add(json_neigh
, "bgpStateIs",
12822 uptime
= monotime(NULL
);
12823 uptime
-= p
->readtime
;
12824 gmtime_r(&uptime
, &tm
);
12826 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12827 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12828 + (tm
.tm_hour
* 3600000));
12830 uptime
= monotime(NULL
);
12831 uptime
-= p
->last_write
;
12832 gmtime_r(&uptime
, &tm
);
12834 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12835 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12836 + (tm
.tm_hour
* 3600000));
12838 uptime
= monotime(NULL
);
12839 uptime
-= p
->update_time
;
12840 gmtime_r(&uptime
, &tm
);
12842 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12843 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12844 + (tm
.tm_hour
* 3600000));
12846 /* Configured timer values. */
12847 json_object_int_add(json_neigh
,
12848 "bgpTimerConfiguredHoldTimeMsecs",
12849 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12850 ? p
->holdtime
* 1000
12851 : bgp
->default_holdtime
* 1000);
12852 json_object_int_add(json_neigh
,
12853 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12854 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12855 ? p
->keepalive
* 1000
12856 : bgp
->default_keepalive
* 1000);
12857 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12858 p
->v_holdtime
* 1000);
12859 json_object_int_add(json_neigh
,
12860 "bgpTimerKeepAliveIntervalMsecs",
12861 p
->v_keepalive
* 1000);
12862 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12863 json_object_int_add(json_neigh
,
12864 "bgpTimerDelayOpenTimeMsecs",
12865 p
->v_delayopen
* 1000);
12868 /* Configured and Synced tcp-mss value for peer */
12869 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12870 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12871 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12873 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12877 /* Extended Optional Parameters Length for BGP OPEN Message */
12878 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12879 json_object_boolean_true_add(
12880 json_neigh
, "extendedOptionalParametersLength");
12882 json_object_boolean_false_add(
12883 json_neigh
, "extendedOptionalParametersLength");
12885 /* Conditional advertisements */
12886 json_object_int_add(
12888 "bgpTimerConfiguredConditionalAdvertisementsSec",
12889 bgp
->condition_check_period
);
12890 if (thread_is_scheduled(bgp
->t_condition_check
))
12891 json_object_int_add(
12893 "bgpTimerUntilConditionalAdvertisementsSec",
12894 thread_timer_remain_second(
12895 bgp
->t_condition_check
));
12897 /* Administrative shutdown. */
12898 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12899 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12900 vty_out(vty
, " Administratively shut down\n");
12903 vty_out(vty
, " BGP version 4");
12904 vty_out(vty
, ", remote router ID %s",
12905 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12906 vty_out(vty
, ", local router ID %s\n",
12907 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12910 /* Confederation */
12911 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12912 && bgp_confederation_peers_check(bgp
, p
->as
))
12914 " Neighbor under common administration\n");
12917 vty_out(vty
, " BGP state = %s",
12918 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12920 if (peer_established(p
))
12921 vty_out(vty
, ", up for %8s",
12922 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12925 else if (p
->status
== Active
) {
12926 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12927 vty_out(vty
, " (passive)");
12928 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12929 vty_out(vty
, " (NSF passive)");
12931 vty_out(vty
, "\n");
12934 vty_out(vty
, " Last read %s",
12935 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12937 vty_out(vty
, ", Last write %s\n",
12938 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12941 /* Configured timer values. */
12943 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12944 p
->v_holdtime
, p
->v_keepalive
);
12945 vty_out(vty
, " Configured hold time is %d seconds",
12946 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12948 : bgp
->default_holdtime
);
12949 vty_out(vty
, ", keepalive interval is %d seconds\n",
12950 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12952 : bgp
->default_keepalive
);
12953 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12955 " Configured DelayOpenTime is %d seconds\n",
12958 /* Configured and synced tcp-mss value for peer */
12959 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12960 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12961 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12962 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12965 /* Extended Optional Parameters Length for BGP OPEN Message */
12966 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12968 " Extended Optional Parameters Length is enabled\n");
12970 /* Conditional advertisements */
12972 " Configured conditional advertisements interval is %d seconds\n",
12973 bgp
->condition_check_period
);
12974 if (thread_is_scheduled(bgp
->t_condition_check
))
12976 " Time until conditional advertisements begin is %lu seconds\n",
12977 thread_timer_remain_second(
12978 bgp
->t_condition_check
));
12981 if (peer_established(p
) &&
12982 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12984 json_object
*json_cap
= NULL
;
12986 json_cap
= json_object_new_object();
12989 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12990 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12991 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12992 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12993 json_object_string_add(
12994 json_cap
, "4byteAs",
12995 "advertisedAndReceived");
12996 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12997 json_object_string_add(json_cap
,
13000 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13001 json_object_string_add(json_cap
,
13006 /* Extended Message Support */
13007 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13008 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13009 json_object_string_add(json_cap
,
13011 "advertisedAndReceived");
13012 else if (CHECK_FLAG(p
->cap
,
13013 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13014 json_object_string_add(json_cap
,
13017 else if (CHECK_FLAG(p
->cap
,
13018 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13019 json_object_string_add(json_cap
,
13024 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13025 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13026 json_object
*json_add
= NULL
;
13027 const char *print_store
;
13029 json_add
= json_object_new_object();
13031 FOREACH_AFI_SAFI (afi
, safi
) {
13032 json_object
*json_sub
= NULL
;
13033 json_sub
= json_object_new_object();
13034 print_store
= get_afi_safi_str(
13038 p
->af_cap
[afi
][safi
],
13039 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13041 p
->af_cap
[afi
][safi
],
13042 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13046 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13050 PEER_CAP_ADDPATH_AF_TX_RCV
))
13051 json_object_boolean_true_add(
13053 "txAdvertisedAndReceived");
13058 PEER_CAP_ADDPATH_AF_TX_ADV
))
13059 json_object_boolean_true_add(
13066 PEER_CAP_ADDPATH_AF_TX_RCV
))
13067 json_object_boolean_true_add(
13073 p
->af_cap
[afi
][safi
],
13074 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13076 p
->af_cap
[afi
][safi
],
13077 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13081 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13085 PEER_CAP_ADDPATH_AF_RX_RCV
))
13086 json_object_boolean_true_add(
13088 "rxAdvertisedAndReceived");
13093 PEER_CAP_ADDPATH_AF_RX_ADV
))
13094 json_object_boolean_true_add(
13101 PEER_CAP_ADDPATH_AF_RX_RCV
))
13102 json_object_boolean_true_add(
13108 p
->af_cap
[afi
][safi
],
13109 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13111 p
->af_cap
[afi
][safi
],
13112 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13114 p
->af_cap
[afi
][safi
],
13115 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13117 p
->af_cap
[afi
][safi
],
13118 PEER_CAP_ADDPATH_AF_RX_RCV
))
13119 json_object_object_add(
13120 json_add
, print_store
,
13123 json_object_free(json_sub
);
13126 json_object_object_add(json_cap
, "addPath",
13131 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13132 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13133 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13134 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13135 json_object_string_add(
13136 json_cap
, "dynamic",
13137 "advertisedAndReceived");
13138 else if (CHECK_FLAG(p
->cap
,
13139 PEER_CAP_DYNAMIC_ADV
))
13140 json_object_string_add(json_cap
,
13143 else if (CHECK_FLAG(p
->cap
,
13144 PEER_CAP_DYNAMIC_RCV
))
13145 json_object_string_add(json_cap
,
13151 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13152 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13153 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13154 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13155 json_object_string_add(
13157 "advertisedAndReceived");
13158 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13159 json_object_string_add(json_cap
, "role",
13161 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13162 json_object_string_add(json_cap
, "role",
13166 /* Extended nexthop */
13167 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13168 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13169 json_object
*json_nxt
= NULL
;
13170 const char *print_store
;
13173 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13174 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13175 json_object_string_add(
13176 json_cap
, "extendedNexthop",
13177 "advertisedAndReceived");
13178 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13179 json_object_string_add(
13180 json_cap
, "extendedNexthop",
13182 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13183 json_object_string_add(
13184 json_cap
, "extendedNexthop",
13187 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13188 json_nxt
= json_object_new_object();
13190 for (safi
= SAFI_UNICAST
;
13191 safi
< SAFI_MAX
; safi
++) {
13195 PEER_CAP_ENHE_AF_RCV
)) {
13201 json_object_string_add(
13204 "recieved"); /* misspelled for compatibility */
13207 json_object_object_add(
13209 "extendedNexthopFamililesByPeer",
13214 /* Long-lived Graceful Restart */
13215 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13216 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13217 json_object
*json_llgr
= NULL
;
13218 const char *afi_safi_str
;
13220 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13221 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13222 json_object_string_add(
13224 "longLivedGracefulRestart",
13225 "advertisedAndReceived");
13226 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13227 json_object_string_add(
13229 "longLivedGracefulRestart",
13231 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13232 json_object_string_add(
13234 "longLivedGracefulRestart",
13237 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13238 json_llgr
= json_object_new_object();
13240 FOREACH_AFI_SAFI (afi
, safi
) {
13244 PEER_CAP_ENHE_AF_RCV
)) {
13250 json_object_string_add(
13256 json_object_object_add(
13258 "longLivedGracefulRestartByPeer",
13263 /* Route Refresh */
13264 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13265 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13266 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13267 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13268 (CHECK_FLAG(p
->cap
,
13269 PEER_CAP_REFRESH_NEW_RCV
) ||
13271 PEER_CAP_REFRESH_OLD_RCV
))) {
13274 PEER_CAP_REFRESH_OLD_RCV
) &&
13277 PEER_CAP_REFRESH_NEW_RCV
))
13278 json_object_string_add(
13281 "advertisedAndReceivedOldNew");
13285 PEER_CAP_REFRESH_OLD_RCV
))
13286 json_object_string_add(
13289 "advertisedAndReceivedOld");
13291 json_object_string_add(
13294 "advertisedAndReceivedNew");
13296 } else if (CHECK_FLAG(p
->cap
,
13297 PEER_CAP_REFRESH_ADV
))
13298 json_object_string_add(json_cap
,
13301 else if (CHECK_FLAG(p
->cap
,
13302 PEER_CAP_REFRESH_NEW_RCV
) ||
13304 PEER_CAP_REFRESH_OLD_RCV
))
13305 json_object_string_add(json_cap
,
13310 /* Enhanced Route Refresh */
13311 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13312 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13313 if (CHECK_FLAG(p
->cap
,
13314 PEER_CAP_ENHANCED_RR_ADV
) &&
13316 PEER_CAP_ENHANCED_RR_RCV
))
13317 json_object_string_add(
13319 "enhancedRouteRefresh",
13320 "advertisedAndReceived");
13321 else if (CHECK_FLAG(p
->cap
,
13322 PEER_CAP_ENHANCED_RR_ADV
))
13323 json_object_string_add(
13325 "enhancedRouteRefresh",
13327 else if (CHECK_FLAG(p
->cap
,
13328 PEER_CAP_ENHANCED_RR_RCV
))
13329 json_object_string_add(
13331 "enhancedRouteRefresh",
13335 /* Multiprotocol Extensions */
13336 json_object
*json_multi
= NULL
;
13338 json_multi
= json_object_new_object();
13340 FOREACH_AFI_SAFI (afi
, safi
) {
13341 if (p
->afc_adv
[afi
][safi
] ||
13342 p
->afc_recv
[afi
][safi
]) {
13343 json_object
*json_exten
= NULL
;
13344 json_exten
= json_object_new_object();
13346 if (p
->afc_adv
[afi
][safi
] &&
13347 p
->afc_recv
[afi
][safi
])
13348 json_object_boolean_true_add(
13350 "advertisedAndReceived");
13351 else if (p
->afc_adv
[afi
][safi
])
13352 json_object_boolean_true_add(
13355 else if (p
->afc_recv
[afi
][safi
])
13356 json_object_boolean_true_add(
13357 json_exten
, "received");
13359 json_object_object_add(
13361 get_afi_safi_str(afi
, safi
,
13366 json_object_object_add(json_cap
,
13367 "multiprotocolExtensions",
13370 /* Hostname capabilities */
13371 json_object
*json_hname
= NULL
;
13373 json_hname
= json_object_new_object();
13375 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13376 json_object_string_add(
13377 json_hname
, "advHostName",
13378 bgp
->peer_self
->hostname
13379 ? bgp
->peer_self
->hostname
13381 json_object_string_add(
13382 json_hname
, "advDomainName",
13383 bgp
->peer_self
->domainname
13384 ? bgp
->peer_self
->domainname
13389 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13390 json_object_string_add(
13391 json_hname
, "rcvHostName",
13392 p
->hostname
? p
->hostname
: "n/a");
13393 json_object_string_add(
13394 json_hname
, "rcvDomainName",
13395 p
->domainname
? p
->domainname
: "n/a");
13398 json_object_object_add(json_cap
, "hostName",
13401 /* Graceful Restart */
13402 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13403 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13404 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13405 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13406 json_object_string_add(
13407 json_cap
, "gracefulRestart",
13408 "advertisedAndReceived");
13409 else if (CHECK_FLAG(p
->cap
,
13410 PEER_CAP_RESTART_ADV
))
13411 json_object_string_add(
13413 "gracefulRestartCapability",
13415 else if (CHECK_FLAG(p
->cap
,
13416 PEER_CAP_RESTART_RCV
))
13417 json_object_string_add(
13419 "gracefulRestartCapability",
13422 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13423 int restart_af_count
= 0;
13424 json_object
*json_restart
= NULL
;
13425 json_restart
= json_object_new_object();
13427 json_object_int_add(
13429 "gracefulRestartRemoteTimerMsecs",
13430 p
->v_gr_restart
* 1000);
13432 FOREACH_AFI_SAFI (afi
, safi
) {
13436 PEER_CAP_RESTART_AF_RCV
)) {
13437 json_object
*json_sub
=
13440 json_object_new_object();
13446 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13447 json_object_boolean_true_add(
13450 restart_af_count
++;
13451 json_object_object_add(
13460 if (!restart_af_count
) {
13461 json_object_string_add(
13463 "addressFamiliesByPeer",
13465 json_object_free(json_restart
);
13467 json_object_object_add(
13469 "addressFamiliesByPeer",
13473 json_object_object_add(
13474 json_neigh
, "neighborCapabilities", json_cap
);
13476 vty_out(vty
, " Neighbor capabilities:\n");
13479 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13480 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13481 vty_out(vty
, " 4 Byte AS:");
13482 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13483 vty_out(vty
, " advertised");
13484 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13485 vty_out(vty
, " %sreceived",
13490 vty_out(vty
, "\n");
13493 /* Extended Message Support */
13494 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13495 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13496 vty_out(vty
, " Extended Message:");
13497 if (CHECK_FLAG(p
->cap
,
13498 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13499 vty_out(vty
, " advertised");
13500 if (CHECK_FLAG(p
->cap
,
13501 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13502 vty_out(vty
, " %sreceived",
13505 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13508 vty_out(vty
, "\n");
13512 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13513 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13514 vty_out(vty
, " AddPath:\n");
13516 FOREACH_AFI_SAFI (afi
, safi
) {
13518 p
->af_cap
[afi
][safi
],
13519 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13521 p
->af_cap
[afi
][safi
],
13522 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13523 vty_out(vty
, " %s: TX ",
13531 PEER_CAP_ADDPATH_AF_TX_ADV
))
13538 PEER_CAP_ADDPATH_AF_TX_RCV
))
13545 PEER_CAP_ADDPATH_AF_TX_ADV
)
13549 vty_out(vty
, "\n");
13553 p
->af_cap
[afi
][safi
],
13554 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13556 p
->af_cap
[afi
][safi
],
13557 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13558 vty_out(vty
, " %s: RX ",
13566 PEER_CAP_ADDPATH_AF_RX_ADV
))
13573 PEER_CAP_ADDPATH_AF_RX_RCV
))
13580 PEER_CAP_ADDPATH_AF_RX_ADV
)
13584 vty_out(vty
, "\n");
13590 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13591 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13592 vty_out(vty
, " Dynamic:");
13593 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13594 vty_out(vty
, " advertised");
13595 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13596 vty_out(vty
, " %sreceived",
13598 PEER_CAP_DYNAMIC_ADV
)
13601 vty_out(vty
, "\n");
13605 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13606 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13607 vty_out(vty
, " Role:");
13608 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13609 vty_out(vty
, " advertised");
13610 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13611 vty_out(vty
, " %sreceived",
13616 vty_out(vty
, "\n");
13619 /* Extended nexthop */
13620 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13621 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13622 vty_out(vty
, " Extended nexthop:");
13623 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13624 vty_out(vty
, " advertised");
13625 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13626 vty_out(vty
, " %sreceived",
13631 vty_out(vty
, "\n");
13633 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13635 " Address families by peer:\n ");
13636 for (safi
= SAFI_UNICAST
;
13637 safi
< SAFI_MAX
; safi
++)
13641 PEER_CAP_ENHE_AF_RCV
))
13651 /* Long-lived Graceful Restart */
13652 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13653 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13655 " Long-lived Graceful Restart:");
13656 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13657 vty_out(vty
, " advertised");
13658 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13659 vty_out(vty
, " %sreceived",
13664 vty_out(vty
, "\n");
13666 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13668 " Address families by peer:\n");
13669 FOREACH_AFI_SAFI (afi
, safi
)
13673 PEER_CAP_LLGR_AF_RCV
))
13683 /* Route Refresh */
13684 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13685 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13686 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13687 vty_out(vty
, " Route refresh:");
13688 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13689 vty_out(vty
, " advertised");
13690 if (CHECK_FLAG(p
->cap
,
13691 PEER_CAP_REFRESH_NEW_RCV
) ||
13693 PEER_CAP_REFRESH_OLD_RCV
))
13694 vty_out(vty
, " %sreceived(%s)",
13696 PEER_CAP_REFRESH_ADV
)
13701 PEER_CAP_REFRESH_OLD_RCV
) &&
13704 PEER_CAP_REFRESH_NEW_RCV
))
13708 PEER_CAP_REFRESH_OLD_RCV
)
13712 vty_out(vty
, "\n");
13715 /* Enhanced Route Refresh */
13716 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13717 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13718 vty_out(vty
, " Enhanced Route Refresh:");
13719 if (CHECK_FLAG(p
->cap
,
13720 PEER_CAP_ENHANCED_RR_ADV
))
13721 vty_out(vty
, " advertised");
13722 if (CHECK_FLAG(p
->cap
,
13723 PEER_CAP_ENHANCED_RR_RCV
))
13724 vty_out(vty
, " %sreceived",
13726 PEER_CAP_REFRESH_ADV
)
13729 vty_out(vty
, "\n");
13732 /* Multiprotocol Extensions */
13733 FOREACH_AFI_SAFI (afi
, safi
)
13734 if (p
->afc_adv
[afi
][safi
] ||
13735 p
->afc_recv
[afi
][safi
]) {
13736 vty_out(vty
, " Address Family %s:",
13737 get_afi_safi_str(afi
, safi
,
13739 if (p
->afc_adv
[afi
][safi
])
13740 vty_out(vty
, " advertised");
13741 if (p
->afc_recv
[afi
][safi
])
13742 vty_out(vty
, " %sreceived",
13743 p
->afc_adv
[afi
][safi
]
13746 vty_out(vty
, "\n");
13749 /* Hostname capability */
13750 vty_out(vty
, " Hostname Capability:");
13752 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13754 " advertised (name: %s,domain name: %s)",
13755 bgp
->peer_self
->hostname
13756 ? bgp
->peer_self
->hostname
13758 bgp
->peer_self
->domainname
13759 ? bgp
->peer_self
->domainname
13762 vty_out(vty
, " not advertised");
13765 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13767 " received (name: %s,domain name: %s)",
13768 p
->hostname
? p
->hostname
: "n/a",
13769 p
->domainname
? p
->domainname
: "n/a");
13771 vty_out(vty
, " not received");
13774 vty_out(vty
, "\n");
13776 /* Graceful Restart */
13777 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13778 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13780 " Graceful Restart Capability:");
13781 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13782 vty_out(vty
, " advertised");
13783 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13784 vty_out(vty
, " %sreceived",
13786 PEER_CAP_RESTART_ADV
)
13789 vty_out(vty
, "\n");
13791 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13792 int restart_af_count
= 0;
13795 " Remote Restart timer is %d seconds\n",
13798 " Address families by peer:\n ");
13800 FOREACH_AFI_SAFI (afi
, safi
)
13804 PEER_CAP_RESTART_AF_RCV
)) {
13805 vty_out(vty
, "%s%s(%s)",
13817 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13819 : "not preserved");
13820 restart_af_count
++;
13822 if (!restart_af_count
)
13823 vty_out(vty
, "none");
13824 vty_out(vty
, "\n");
13826 } /* Graceful Restart */
13830 /* graceful restart information */
13831 json_object
*json_grace
= NULL
;
13832 json_object
*json_grace_send
= NULL
;
13833 json_object
*json_grace_recv
= NULL
;
13834 int eor_send_af_count
= 0;
13835 int eor_receive_af_count
= 0;
13838 json_grace
= json_object_new_object();
13839 json_grace_send
= json_object_new_object();
13840 json_grace_recv
= json_object_new_object();
13842 if ((peer_established(p
)) &&
13843 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13844 FOREACH_AFI_SAFI (afi
, safi
) {
13845 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13846 PEER_STATUS_EOR_SEND
)) {
13847 json_object_boolean_true_add(
13849 get_afi_safi_str(afi
, safi
,
13851 eor_send_af_count
++;
13854 FOREACH_AFI_SAFI (afi
, safi
) {
13855 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13856 PEER_STATUS_EOR_RECEIVED
)) {
13857 json_object_boolean_true_add(
13859 get_afi_safi_str(afi
, safi
,
13861 eor_receive_af_count
++;
13865 json_object_object_add(json_grace
, "endOfRibSend",
13867 json_object_object_add(json_grace
, "endOfRibRecv",
13871 if (p
->t_gr_restart
)
13872 json_object_int_add(
13873 json_grace
, "gracefulRestartTimerMsecs",
13874 thread_timer_remain_second(p
->t_gr_restart
) *
13878 json_object_int_add(
13879 json_grace
, "gracefulStalepathTimerMsecs",
13880 thread_timer_remain_second(p
->t_gr_stale
) *
13882 /* more gr info in new format */
13883 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13884 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13887 vty_out(vty
, " Graceful restart information:\n");
13888 if ((peer_established(p
)) &&
13889 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13891 vty_out(vty
, " End-of-RIB send: ");
13892 FOREACH_AFI_SAFI (afi
, safi
) {
13893 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13894 PEER_STATUS_EOR_SEND
)) {
13895 vty_out(vty
, "%s%s",
13896 eor_send_af_count
? ", " : "",
13897 get_afi_safi_str(afi
, safi
,
13899 eor_send_af_count
++;
13902 vty_out(vty
, "\n");
13903 vty_out(vty
, " End-of-RIB received: ");
13904 FOREACH_AFI_SAFI (afi
, safi
) {
13905 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13906 PEER_STATUS_EOR_RECEIVED
)) {
13907 vty_out(vty
, "%s%s",
13908 eor_receive_af_count
? ", "
13910 get_afi_safi_str(afi
, safi
,
13912 eor_receive_af_count
++;
13915 vty_out(vty
, "\n");
13918 if (p
->t_gr_restart
)
13920 " The remaining time of restart timer is %ld\n",
13921 thread_timer_remain_second(p
->t_gr_restart
));
13925 " The remaining time of stalepath timer is %ld\n",
13926 thread_timer_remain_second(p
->t_gr_stale
));
13928 /* more gr info in new format */
13929 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13933 json_object
*json_stat
= NULL
;
13934 json_stat
= json_object_new_object();
13935 /* Packet counts. */
13937 atomic_size_t outq_count
, inq_count
;
13938 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13939 memory_order_relaxed
);
13940 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13941 memory_order_relaxed
);
13943 json_object_int_add(json_stat
, "depthInq",
13944 (unsigned long)inq_count
);
13945 json_object_int_add(json_stat
, "depthOutq",
13946 (unsigned long)outq_count
);
13947 json_object_int_add(json_stat
, "opensSent",
13948 atomic_load_explicit(&p
->open_out
,
13949 memory_order_relaxed
));
13950 json_object_int_add(json_stat
, "opensRecv",
13951 atomic_load_explicit(&p
->open_in
,
13952 memory_order_relaxed
));
13953 json_object_int_add(json_stat
, "notificationsSent",
13954 atomic_load_explicit(&p
->notify_out
,
13955 memory_order_relaxed
));
13956 json_object_int_add(json_stat
, "notificationsRecv",
13957 atomic_load_explicit(&p
->notify_in
,
13958 memory_order_relaxed
));
13959 json_object_int_add(json_stat
, "updatesSent",
13960 atomic_load_explicit(&p
->update_out
,
13961 memory_order_relaxed
));
13962 json_object_int_add(json_stat
, "updatesRecv",
13963 atomic_load_explicit(&p
->update_in
,
13964 memory_order_relaxed
));
13965 json_object_int_add(json_stat
, "keepalivesSent",
13966 atomic_load_explicit(&p
->keepalive_out
,
13967 memory_order_relaxed
));
13968 json_object_int_add(json_stat
, "keepalivesRecv",
13969 atomic_load_explicit(&p
->keepalive_in
,
13970 memory_order_relaxed
));
13971 json_object_int_add(json_stat
, "routeRefreshSent",
13972 atomic_load_explicit(&p
->refresh_out
,
13973 memory_order_relaxed
));
13974 json_object_int_add(json_stat
, "routeRefreshRecv",
13975 atomic_load_explicit(&p
->refresh_in
,
13976 memory_order_relaxed
));
13977 json_object_int_add(json_stat
, "capabilitySent",
13978 atomic_load_explicit(&p
->dynamic_cap_out
,
13979 memory_order_relaxed
));
13980 json_object_int_add(json_stat
, "capabilityRecv",
13981 atomic_load_explicit(&p
->dynamic_cap_in
,
13982 memory_order_relaxed
));
13983 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13984 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13985 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13987 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13988 notify_out
, notify_in
, update_out
, update_in
,
13989 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13990 dynamic_cap_out
, dynamic_cap_in
;
13991 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13992 memory_order_relaxed
);
13993 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13994 memory_order_relaxed
);
13995 open_out
= atomic_load_explicit(&p
->open_out
,
13996 memory_order_relaxed
);
13998 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13999 notify_out
= atomic_load_explicit(&p
->notify_out
,
14000 memory_order_relaxed
);
14001 notify_in
= atomic_load_explicit(&p
->notify_in
,
14002 memory_order_relaxed
);
14003 update_out
= atomic_load_explicit(&p
->update_out
,
14004 memory_order_relaxed
);
14005 update_in
= atomic_load_explicit(&p
->update_in
,
14006 memory_order_relaxed
);
14007 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14008 memory_order_relaxed
);
14009 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14010 memory_order_relaxed
);
14011 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14012 memory_order_relaxed
);
14013 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14014 memory_order_relaxed
);
14015 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14016 memory_order_relaxed
);
14017 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14018 memory_order_relaxed
);
14020 /* Packet counts. */
14021 vty_out(vty
, " Message statistics:\n");
14022 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14023 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14024 vty_out(vty
, " Sent Rcvd\n");
14025 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14027 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14029 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14031 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14033 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14035 vty_out(vty
, " Capability: %10zu %10zu\n",
14036 dynamic_cap_out
, dynamic_cap_in
);
14037 vty_out(vty
, " Total: %10u %10u\n",
14038 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14042 /* advertisement-interval */
14043 json_object_int_add(json_neigh
,
14044 "minBtwnAdvertisementRunsTimerMsecs",
14045 p
->v_routeadv
* 1000);
14047 /* Update-source. */
14048 if (p
->update_if
|| p
->update_source
) {
14050 json_object_string_add(json_neigh
,
14053 else if (p
->update_source
)
14054 json_object_string_addf(json_neigh
,
14055 "updateSource", "%pSU",
14059 /* advertisement-interval */
14061 " Minimum time between advertisement runs is %d seconds\n",
14064 /* Update-source. */
14065 if (p
->update_if
|| p
->update_source
) {
14066 vty_out(vty
, " Update source is ");
14068 vty_out(vty
, "%s", p
->update_if
);
14069 else if (p
->update_source
)
14070 vty_out(vty
, "%pSU", p
->update_source
);
14071 vty_out(vty
, "\n");
14074 vty_out(vty
, "\n");
14077 /* Address Family Information */
14078 json_object
*json_hold
= NULL
;
14081 json_hold
= json_object_new_object();
14083 FOREACH_AFI_SAFI (afi
, safi
)
14084 if (p
->afc
[afi
][safi
])
14085 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14089 json_object_object_add(json_neigh
, "addressFamilyInfo",
14091 json_object_int_add(json_neigh
, "connectionsEstablished",
14093 json_object_int_add(json_neigh
, "connectionsDropped",
14096 vty_out(vty
, " Connections established %d; dropped %d\n",
14097 p
->established
, p
->dropped
);
14099 if (!p
->last_reset
) {
14101 json_object_string_add(json_neigh
, "lastReset",
14104 vty_out(vty
, " Last reset never\n");
14110 uptime
= monotime(NULL
);
14111 uptime
-= p
->resettime
;
14112 gmtime_r(&uptime
, &tm
);
14114 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14116 + (tm
.tm_min
* 60000)
14117 + (tm
.tm_hour
* 3600000));
14118 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14120 vty_out(vty
, " Last reset %s, ",
14121 peer_uptime(p
->resettime
, timebuf
,
14122 BGP_UPTIME_LEN
, 0, NULL
));
14124 bgp_show_peer_reset(vty
, p
, NULL
, false);
14125 if (p
->last_reset_cause_size
) {
14126 msg
= p
->last_reset_cause
;
14128 " Message received that caused BGP to send a NOTIFICATION:\n ");
14129 for (i
= 1; i
<= p
->last_reset_cause_size
;
14131 vty_out(vty
, "%02X", *msg
++);
14133 if (i
!= p
->last_reset_cause_size
) {
14135 vty_out(vty
, "\n ");
14136 } else if (i
% 4 == 0) {
14141 vty_out(vty
, "\n");
14146 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14148 json_object_boolean_true_add(json_neigh
,
14149 "prefixesConfigExceedMax");
14152 " Peer had exceeded the max. no. of prefixes configured.\n");
14154 if (p
->t_pmax_restart
) {
14156 json_object_boolean_true_add(
14157 json_neigh
, "reducePrefixNumFrom");
14158 json_object_int_add(json_neigh
,
14159 "restartInTimerMsec",
14160 thread_timer_remain_second(
14165 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14166 p
->host
, thread_timer_remain_second(
14167 p
->t_pmax_restart
));
14170 json_object_boolean_true_add(
14172 "reducePrefixNumAndClearIpBgp");
14175 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14180 /* EBGP Multihop and GTSM */
14181 if (p
->sort
!= BGP_PEER_IBGP
) {
14183 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14184 json_object_int_add(json_neigh
,
14185 "externalBgpNbrMaxHopsAway",
14188 json_object_int_add(json_neigh
,
14189 "externalBgpNbrMaxHopsAway",
14192 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14194 " External BGP neighbor may be up to %d hops away.\n",
14198 " External BGP neighbor may be up to %d hops away.\n",
14203 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14204 json_object_int_add(json_neigh
,
14205 "internalBgpNbrMaxHopsAway",
14208 json_object_int_add(json_neigh
,
14209 "internalBgpNbrMaxHopsAway",
14212 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14214 " Internal BGP neighbor may be up to %d hops away.\n",
14218 " Internal BGP neighbor may be up to %d hops away.\n",
14223 /* Local address. */
14226 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14228 json_object_int_add(json_neigh
, "portLocal",
14229 ntohs(p
->su_local
->sin
.sin_port
));
14231 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14232 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14235 json_object_string_add(json_neigh
, "hostLocal",
14237 json_object_int_add(json_neigh
, "portLocal", -1);
14241 /* Remote address. */
14242 if (p
->su_remote
) {
14244 json_object_string_addf(json_neigh
, "hostForeign",
14245 "%pSU", p
->su_remote
);
14246 json_object_int_add(json_neigh
, "portForeign",
14247 ntohs(p
->su_remote
->sin
.sin_port
));
14249 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14251 ntohs(p
->su_remote
->sin
.sin_port
));
14254 json_object_string_add(json_neigh
, "hostForeign",
14256 json_object_int_add(json_neigh
, "portForeign", -1);
14260 /* Nexthop display. */
14263 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14265 json_object_string_addf(json_neigh
, "nexthopGlobal",
14266 "%pI6", &p
->nexthop
.v6_global
);
14267 json_object_string_addf(json_neigh
, "nexthopLocal",
14268 "%pI6", &p
->nexthop
.v6_local
);
14269 if (p
->shared_network
)
14270 json_object_string_add(json_neigh
,
14274 json_object_string_add(json_neigh
,
14276 "nonSharedNetwork");
14278 vty_out(vty
, "Nexthop: %s\n",
14279 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14281 vty_out(vty
, "Nexthop global: %s\n",
14282 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14284 vty_out(vty
, "Nexthop local: %s\n",
14285 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14287 vty_out(vty
, "BGP connection: %s\n",
14288 p
->shared_network
? "shared network"
14289 : "non shared network");
14293 /* Timer information. */
14295 json_object_int_add(json_neigh
, "connectRetryTimer",
14297 if (peer_established(p
) && p
->rtt
)
14298 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14301 json_object_int_add(
14302 json_neigh
, "nextStartTimerDueInMsecs",
14303 thread_timer_remain_second(p
->t_start
) * 1000);
14305 json_object_int_add(
14306 json_neigh
, "nextConnectTimerDueInMsecs",
14307 thread_timer_remain_second(p
->t_connect
)
14309 if (p
->t_routeadv
) {
14310 json_object_int_add(json_neigh
, "mraiInterval",
14312 json_object_int_add(
14313 json_neigh
, "mraiTimerExpireInMsecs",
14314 thread_timer_remain_second(p
->t_routeadv
)
14318 json_object_int_add(json_neigh
, "authenticationEnabled",
14322 json_object_string_add(json_neigh
, "readThread", "on");
14324 json_object_string_add(json_neigh
, "readThread", "off");
14326 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14327 json_object_string_add(json_neigh
, "writeThread", "on");
14329 json_object_string_add(json_neigh
, "writeThread",
14332 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14334 if (peer_established(p
) && p
->rtt
)
14335 vty_out(vty
, "Estimated round trip time: %d ms\n",
14338 vty_out(vty
, "Next start timer due in %ld seconds\n",
14339 thread_timer_remain_second(p
->t_start
));
14341 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14342 thread_timer_remain_second(p
->t_connect
));
14345 "MRAI (interval %u) timer expires in %ld seconds\n",
14347 thread_timer_remain_second(p
->t_routeadv
));
14349 vty_out(vty
, "Peer Authentication Enabled\n");
14351 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14352 p
->t_read
? "on" : "off",
14353 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14358 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14359 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14360 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14363 vty_out(vty
, "\n");
14365 /* BFD information. */
14367 bgp_bfd_show_info(vty
, p
, json_neigh
);
14370 if (p
->conf_if
) /* Configured interface name. */
14371 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14372 else /* Configured IP address. */
14373 json_object_object_add(json
, p
->host
, json_neigh
);
14377 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14378 enum show_type type
,
14379 union sockunion
*su
,
14380 const char *conf_if
, afi_t afi
,
14383 struct listnode
*node
, *nnode
;
14386 safi_t safi
= SAFI_UNICAST
;
14387 json_object
*json
= NULL
;
14388 json_object
*json_neighbor
= NULL
;
14391 json
= json_object_new_object();
14392 json_neighbor
= json_object_new_object();
14395 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14397 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14400 if ((peer
->afc
[afi
][safi
]) == 0)
14403 if (type
== show_all
) {
14404 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14408 json_object_object_add(json
, peer
->host
,
14410 json_neighbor
= NULL
;
14413 } else if (type
== show_peer
) {
14416 && !strcmp(peer
->conf_if
, conf_if
))
14418 && !strcmp(peer
->hostname
, conf_if
))) {
14420 bgp_show_peer_gr_status(vty
, peer
,
14425 if (sockunion_same(&peer
->su
, su
)) {
14427 bgp_show_peer_gr_status(vty
, peer
,
14432 if (use_json
&& find
)
14433 json_object_object_add(json
, peer
->host
,
14438 json_neighbor
= NULL
;
14443 if (type
== show_peer
&& !find
) {
14445 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14447 vty_out(vty
, "%% No such neighbor\n");
14451 json_object_free(json_neighbor
);
14452 vty_json(vty
, json
);
14454 vty_out(vty
, "\n");
14457 return CMD_SUCCESS
;
14460 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14461 enum show_type type
, union sockunion
*su
,
14462 const char *conf_if
, bool use_json
,
14465 struct listnode
*node
, *nnode
;
14468 bool nbr_output
= false;
14469 afi_t afi
= AFI_MAX
;
14470 safi_t safi
= SAFI_MAX
;
14472 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14474 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14478 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14479 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14484 bgp_show_peer(vty
, peer
, use_json
, json
);
14490 && !strcmp(peer
->conf_if
, conf_if
))
14492 && !strcmp(peer
->hostname
, conf_if
))) {
14494 bgp_show_peer(vty
, peer
, use_json
,
14498 if (sockunion_same(&peer
->su
, su
)) {
14500 bgp_show_peer(vty
, peer
, use_json
,
14505 case show_ipv4_peer
:
14506 case show_ipv6_peer
:
14507 FOREACH_SAFI (safi
) {
14508 if (peer
->afc
[afi
][safi
]) {
14511 && !strcmp(peer
->conf_if
, conf_if
))
14513 && !strcmp(peer
->hostname
, conf_if
))) {
14515 bgp_show_peer(vty
, peer
, use_json
,
14520 if (sockunion_same(&peer
->su
, su
)) {
14522 bgp_show_peer(vty
, peer
, use_json
,
14530 case show_ipv4_all
:
14531 case show_ipv6_all
:
14532 FOREACH_SAFI (safi
) {
14533 if (peer
->afc
[afi
][safi
]) {
14534 bgp_show_peer(vty
, peer
, use_json
, json
);
14543 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14544 type
== show_ipv6_peer
) && !find
) {
14546 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14548 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14551 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14552 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14553 vty_out(vty
, "%% No BGP neighbors found\n");
14556 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14557 json
, JSON_C_TO_STRING_PRETTY
));
14559 vty_out(vty
, "\n");
14562 return CMD_SUCCESS
;
14565 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14566 enum show_type type
,
14567 const char *ip_str
,
14568 afi_t afi
, bool use_json
)
14573 union sockunion su
;
14575 bgp
= bgp_get_default();
14581 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14585 ret
= str2sockunion(ip_str
, &su
);
14587 bgp_show_neighbor_graceful_restart(
14588 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14590 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14591 NULL
, afi
, use_json
);
14593 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14597 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14598 enum show_type type
,
14599 const char *ip_str
,
14602 struct listnode
*node
, *nnode
;
14604 union sockunion su
;
14605 json_object
*json
= NULL
;
14606 int ret
, is_first
= 1;
14607 bool nbr_output
= false;
14610 vty_out(vty
, "{\n");
14612 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14615 if (!(json
= json_object_new_object())) {
14617 EC_BGP_JSON_MEM_ERROR
,
14618 "Unable to allocate memory for JSON object");
14620 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14624 json_object_int_add(json
, "vrfId",
14625 (bgp
->vrf_id
== VRF_UNKNOWN
)
14627 : (int64_t)bgp
->vrf_id
);
14628 json_object_string_add(
14630 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14635 vty_out(vty
, ",\n");
14639 vty_out(vty
, "\"%s\":",
14640 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14644 vty_out(vty
, "\nInstance %s:\n",
14645 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14650 if (type
== show_peer
|| type
== show_ipv4_peer
||
14651 type
== show_ipv6_peer
) {
14652 ret
= str2sockunion(ip_str
, &su
);
14654 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14657 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14660 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14663 json_object_free(json
);
14668 vty_out(vty
, "}\n");
14669 else if (!nbr_output
)
14670 vty_out(vty
, "%% BGP instance not found\n");
14673 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14674 enum show_type type
, const char *ip_str
,
14679 union sockunion su
;
14680 json_object
*json
= NULL
;
14683 if (strmatch(name
, "all")) {
14684 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14686 return CMD_SUCCESS
;
14688 bgp
= bgp_lookup_by_name(name
);
14691 json
= json_object_new_object();
14692 vty_json(vty
, json
);
14695 "%% BGP instance not found\n");
14697 return CMD_WARNING
;
14701 bgp
= bgp_get_default();
14705 json
= json_object_new_object();
14707 ret
= str2sockunion(ip_str
, &su
);
14709 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14712 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14715 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14718 json_object_free(json
);
14721 vty_out(vty
, "{}\n");
14723 vty_out(vty
, "%% BGP instance not found\n");
14726 return CMD_SUCCESS
;
14731 /* "show [ip] bgp neighbors graceful-restart" commands. */
14732 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14733 show_ip_bgp_neighbors_graceful_restart_cmd
,
14734 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14740 "Neighbor to display information about\n"
14741 "Neighbor to display information about\n"
14742 "Neighbor on BGP configured interface\n"
14746 char *sh_arg
= NULL
;
14747 enum show_type sh_type
;
14749 afi_t afi
= AFI_MAX
;
14750 bool uj
= use_json(argc
, argv
);
14752 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14757 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14758 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14759 || argv_find(argv
, argc
, "WORD", &idx
)) {
14760 sh_type
= show_peer
;
14761 sh_arg
= argv
[idx
]->arg
;
14763 sh_type
= show_all
;
14765 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14766 return CMD_SUCCESS
;
14769 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14773 /* "show [ip] bgp neighbors" commands. */
14774 DEFUN (show_ip_bgp_neighbors
,
14775 show_ip_bgp_neighbors_cmd
,
14776 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14780 BGP_INSTANCE_HELP_STR
14783 "Detailed information on TCP and BGP neighbor connections\n"
14784 "Neighbor to display information about\n"
14785 "Neighbor to display information about\n"
14786 "Neighbor on BGP configured interface\n"
14790 char *sh_arg
= NULL
;
14791 enum show_type sh_type
;
14792 afi_t afi
= AFI_MAX
;
14794 bool uj
= use_json(argc
, argv
);
14798 /* [<vrf> VIEWVRFNAME] */
14799 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14800 vrf
= argv
[idx
+ 1]->arg
;
14801 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14803 } else if (argv_find(argv
, argc
, "view", &idx
))
14804 /* [<view> VIEWVRFNAME] */
14805 vrf
= argv
[idx
+ 1]->arg
;
14809 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14810 sh_type
= show_ipv4_all
;
14812 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14813 sh_type
= show_ipv6_all
;
14816 sh_type
= show_all
;
14819 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14820 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14821 || argv_find(argv
, argc
, "WORD", &idx
)) {
14822 sh_type
= show_peer
;
14823 sh_arg
= argv
[idx
]->arg
;
14826 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14827 sh_type
= show_ipv4_peer
;
14828 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14829 sh_type
= show_ipv6_peer
;
14832 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14835 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14836 paths' and `show ip mbgp paths'. Those functions results are the
14838 DEFUN (show_ip_bgp_paths
,
14839 show_ip_bgp_paths_cmd
,
14840 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14845 "Path information\n")
14847 vty_out(vty
, "Address Refcnt Path\n");
14848 aspath_print_all_vty(vty
);
14849 return CMD_SUCCESS
;
14854 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14857 struct community
*com
;
14859 com
= (struct community
*)bucket
->data
;
14860 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14861 community_str(com
, false, false));
14864 /* Show BGP's community internal data. */
14865 DEFUN (show_ip_bgp_community_info
,
14866 show_ip_bgp_community_info_cmd
,
14867 "show [ip] bgp community-info",
14871 "List all bgp community information\n")
14873 vty_out(vty
, "Address Refcnt Community\n");
14875 hash_iterate(community_hash(),
14876 (void (*)(struct hash_bucket
*,
14877 void *))community_show_all_iterator
,
14880 return CMD_SUCCESS
;
14883 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14886 struct lcommunity
*lcom
;
14888 lcom
= (struct lcommunity
*)bucket
->data
;
14889 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14890 lcommunity_str(lcom
, false, false));
14893 /* Show BGP's community internal data. */
14894 DEFUN (show_ip_bgp_lcommunity_info
,
14895 show_ip_bgp_lcommunity_info_cmd
,
14896 "show ip bgp large-community-info",
14900 "List all bgp large-community information\n")
14902 vty_out(vty
, "Address Refcnt Large-community\n");
14904 hash_iterate(lcommunity_hash(),
14905 (void (*)(struct hash_bucket
*,
14906 void *))lcommunity_show_all_iterator
,
14909 return CMD_SUCCESS
;
14911 /* Graceful Restart */
14913 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14920 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14922 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14924 switch (bgp_global_gr_mode
) {
14926 case GLOBAL_HELPER
:
14927 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14931 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14934 case GLOBAL_DISABLE
:
14935 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14938 case GLOBAL_INVALID
:
14940 "Global BGP GR Mode Invalid\n");
14943 vty_out(vty
, "\n");
14946 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14947 enum show_type type
,
14948 const char *ip_str
,
14949 afi_t afi
, bool use_json
)
14951 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14954 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14956 bgp_show_neighbor_graceful_restart_vty(
14957 vty
, type
, ip_str
, afi
, use_json
);
14960 } else if (afi
!= AFI_MAX
) {
14961 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14964 return CMD_ERR_INCOMPLETE
;
14967 return CMD_SUCCESS
;
14969 /* Graceful Restart */
14971 DEFUN (show_ip_bgp_attr_info
,
14972 show_ip_bgp_attr_info_cmd
,
14973 "show [ip] bgp attribute-info",
14977 "List all bgp attribute information\n")
14979 attr_show_all(vty
);
14980 return CMD_SUCCESS
;
14983 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14984 afi_t afi
, safi_t safi
,
14985 bool use_json
, json_object
*json
)
14988 struct listnode
*node
;
14991 enum vpn_policy_direction dir
;
14994 json_object
*json_import_vrfs
= NULL
;
14995 json_object
*json_export_vrfs
= NULL
;
14997 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15000 vty_json(vty
, json
);
15002 return CMD_WARNING
;
15005 /* Provide context for the block */
15006 json_object_string_add(json
, "vrf", name
? name
: "default");
15007 json_object_string_add(json
, "afiSafi",
15008 get_afi_safi_str(afi
, safi
, true));
15010 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15011 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15012 json_object_string_add(json
, "importFromVrfs", "none");
15013 json_object_string_add(json
, "importRts", "none");
15015 json_import_vrfs
= json_object_new_array();
15017 for (ALL_LIST_ELEMENTS_RO(
15018 bgp
->vpn_policy
[afi
].import_vrf
,
15020 json_object_array_add(json_import_vrfs
,
15021 json_object_new_string(vname
));
15023 json_object_object_add(json
, "importFromVrfs",
15025 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15026 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15027 ecom_str
= ecommunity_ecom2str(
15028 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15029 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15030 json_object_string_add(json
, "importRts",
15032 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15034 json_object_string_add(json
, "importRts",
15038 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15039 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15040 json_object_string_add(json
, "exportToVrfs", "none");
15041 json_object_string_add(json
, "routeDistinguisher",
15043 json_object_string_add(json
, "exportRts", "none");
15045 json_export_vrfs
= json_object_new_array();
15047 for (ALL_LIST_ELEMENTS_RO(
15048 bgp
->vpn_policy
[afi
].export_vrf
,
15050 json_object_array_add(json_export_vrfs
,
15051 json_object_new_string(vname
));
15052 json_object_object_add(json
, "exportToVrfs",
15054 json_object_string_addf(json
, "routeDistinguisher",
15056 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15058 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15059 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15060 ecom_str
= ecommunity_ecom2str(
15061 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15062 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15063 json_object_string_add(json
, "exportRts",
15065 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15067 json_object_string_add(json
, "exportRts",
15072 vty_json(vty
, json
);
15075 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15078 vty_out(vty
, "%% No such BGP instance exist\n");
15079 return CMD_WARNING
;
15082 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15083 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15085 "This VRF is not importing %s routes from any other VRF\n",
15086 get_afi_safi_str(afi
, safi
, false));
15089 "This VRF is importing %s routes from the following VRFs:\n",
15090 get_afi_safi_str(afi
, safi
, false));
15092 for (ALL_LIST_ELEMENTS_RO(
15093 bgp
->vpn_policy
[afi
].import_vrf
,
15095 vty_out(vty
, " %s\n", vname
);
15097 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15099 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15100 ecom_str
= ecommunity_ecom2str(
15101 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15102 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15103 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15105 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15107 vty_out(vty
, "Import RT(s):\n");
15110 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15111 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15113 "This VRF is not exporting %s routes to any other VRF\n",
15114 get_afi_safi_str(afi
, safi
, false));
15117 "This VRF is exporting %s routes to the following VRFs:\n",
15118 get_afi_safi_str(afi
, safi
, false));
15120 for (ALL_LIST_ELEMENTS_RO(
15121 bgp
->vpn_policy
[afi
].export_vrf
,
15123 vty_out(vty
, " %s\n", vname
);
15125 vty_out(vty
, "RD: %pRD\n",
15126 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15128 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15129 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15130 ecom_str
= ecommunity_ecom2str(
15131 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15132 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15133 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15134 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15136 vty_out(vty
, "Import RT(s):\n");
15140 return CMD_SUCCESS
;
15143 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15144 safi_t safi
, bool use_json
)
15146 struct listnode
*node
, *nnode
;
15148 char *vrf_name
= NULL
;
15149 json_object
*json
= NULL
;
15150 json_object
*json_vrf
= NULL
;
15151 json_object
*json_vrfs
= NULL
;
15154 json
= json_object_new_object();
15155 json_vrfs
= json_object_new_object();
15158 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15160 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15161 vrf_name
= bgp
->name
;
15164 json_vrf
= json_object_new_object();
15166 vty_out(vty
, "\nInstance %s:\n",
15167 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15168 ? VRF_DEFAULT_NAME
: bgp
->name
);
15170 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15172 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15173 json_object_object_add(json_vrfs
,
15174 VRF_DEFAULT_NAME
, json_vrf
);
15176 json_object_object_add(json_vrfs
, vrf_name
,
15182 json_object_object_add(json
, "vrfs", json_vrfs
);
15183 vty_json(vty
, json
);
15186 return CMD_SUCCESS
;
15189 /* "show [ip] bgp route-leak" command. */
15190 DEFUN (show_ip_bgp_route_leak
,
15191 show_ip_bgp_route_leak_cmd
,
15192 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15196 BGP_INSTANCE_HELP_STR
15199 "Route leaking information\n"
15203 afi_t afi
= AFI_MAX
;
15204 safi_t safi
= SAFI_MAX
;
15206 bool uj
= use_json(argc
, argv
);
15208 json_object
*json
= NULL
;
15210 /* show [ip] bgp */
15211 if (argv_find(argv
, argc
, "ip", &idx
)) {
15213 safi
= SAFI_UNICAST
;
15215 /* [vrf VIEWVRFNAME] */
15216 if (argv_find(argv
, argc
, "view", &idx
)) {
15218 "%% This command is not applicable to BGP views\n");
15219 return CMD_WARNING
;
15222 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15223 vrf
= argv
[idx
+ 1]->arg
;
15224 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15227 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15228 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15229 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15231 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15233 "%% This command is applicable only for unicast ipv4|ipv6\n");
15234 return CMD_WARNING
;
15237 if (vrf
&& strmatch(vrf
, "all"))
15238 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15241 json
= json_object_new_object();
15243 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15246 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15249 struct listnode
*node
, *nnode
;
15252 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15253 vty_out(vty
, "\nInstance %s:\n",
15254 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15257 update_group_show(bgp
, afi
, safi
, vty
, 0);
15261 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15262 int safi
, uint64_t subgrp_id
)
15267 if (strmatch(name
, "all")) {
15268 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15269 return CMD_SUCCESS
;
15271 bgp
= bgp_lookup_by_name(name
);
15274 bgp
= bgp_get_default();
15278 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15279 return CMD_SUCCESS
;
15282 DEFUN (show_ip_bgp_updgrps
,
15283 show_ip_bgp_updgrps_cmd
,
15284 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15288 BGP_INSTANCE_HELP_STR
15290 BGP_SAFI_WITH_LABEL_HELP_STR
15291 "Detailed info about dynamic update groups\n"
15292 "Specific subgroup to display detailed info for\n")
15295 afi_t afi
= AFI_IP6
;
15296 safi_t safi
= SAFI_UNICAST
;
15297 uint64_t subgrp_id
= 0;
15301 /* show [ip] bgp */
15302 if (argv_find(argv
, argc
, "ip", &idx
))
15304 /* [<vrf> VIEWVRFNAME] */
15305 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15306 vrf
= argv
[idx
+ 1]->arg
;
15307 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15309 } else if (argv_find(argv
, argc
, "view", &idx
))
15310 /* [<view> VIEWVRFNAME] */
15311 vrf
= argv
[idx
+ 1]->arg
;
15312 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15313 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15314 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15317 /* get subgroup id, if provided */
15319 if (argv
[idx
]->type
== VARIABLE_TKN
)
15320 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15322 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15325 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15326 show_bgp_instance_all_ipv6_updgrps_cmd
,
15327 "show [ip] bgp <view|vrf> all update-groups",
15331 BGP_INSTANCE_ALL_HELP_STR
15332 "Detailed info about dynamic update groups\n")
15334 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15335 return CMD_SUCCESS
;
15338 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15339 show_bgp_l2vpn_evpn_updgrps_cmd
,
15340 "show [ip] bgp l2vpn evpn update-groups",
15344 "l2vpn address family\n"
15345 "evpn sub-address family\n"
15346 "Detailed info about dynamic update groups\n")
15349 uint64_t subgrp_id
= 0;
15351 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15352 return CMD_SUCCESS
;
15355 DEFUN (show_bgp_updgrps_stats
,
15356 show_bgp_updgrps_stats_cmd
,
15357 "show [ip] bgp update-groups statistics",
15361 "Detailed info about dynamic update groups\n"
15366 bgp
= bgp_get_default();
15368 update_group_show_stats(bgp
, vty
);
15370 return CMD_SUCCESS
;
15373 DEFUN (show_bgp_instance_updgrps_stats
,
15374 show_bgp_instance_updgrps_stats_cmd
,
15375 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15379 BGP_INSTANCE_HELP_STR
15380 "Detailed info about dynamic update groups\n"
15386 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15388 update_group_show_stats(bgp
, vty
);
15390 return CMD_SUCCESS
;
15393 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15394 afi_t afi
, safi_t safi
,
15395 const char *what
, uint64_t subgrp_id
)
15400 bgp
= bgp_lookup_by_name(name
);
15402 bgp
= bgp_get_default();
15405 if (!strcmp(what
, "advertise-queue"))
15406 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15408 else if (!strcmp(what
, "advertised-routes"))
15409 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15411 else if (!strcmp(what
, "packet-queue"))
15412 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15417 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15418 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15419 "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",
15420 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15422 "Detailed info about dynamic update groups\n"
15423 "Specific subgroup to display info for\n"
15424 "Advertisement queue\n"
15425 "Announced routes\n"
15428 uint64_t subgrp_id
= 0;
15432 subgrp_id
= strtoull(sgid
, NULL
, 10);
15437 afiz
= bgp_vty_afi_from_str(afi
);
15441 afiz
= bgp_vty_afi_from_str(afi
);
15442 if (afiz
!= AFI_IP
)
15444 "%% Cannot specify both 'ip' and 'ipv6'\n");
15445 return CMD_WARNING
;
15448 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15450 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15451 return CMD_SUCCESS
;
15454 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15457 struct listnode
*node
, *nnode
;
15458 struct prefix
*range
;
15463 const char *peer_status
;
15467 json_object
*json_peer_group
= NULL
;
15468 json_object
*json_peer_group_afc
= NULL
;
15469 json_object
*json_peer_group_members
= NULL
;
15470 json_object
*json_peer_group_dynamic
= NULL
;
15471 json_object
*json_peer_group_dynamic_af
= NULL
;
15472 json_object
*json_peer_group_ranges
= NULL
;
15474 conf
= group
->conf
;
15477 json_peer_group
= json_object_new_object();
15478 json_peer_group_afc
= json_object_new_array();
15481 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15483 json_object_int_add(json_peer_group
, "remoteAs",
15486 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15487 group
->name
, conf
->as
);
15488 } else if (conf
->as_type
== AS_INTERNAL
) {
15490 json_object_int_add(json_peer_group
, "remoteAs",
15493 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15494 group
->name
, group
->bgp
->as
);
15497 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15500 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15502 json_object_string_add(json_peer_group
, "type",
15505 vty_out(vty
, " Peer-group type is internal\n");
15508 json_object_string_add(json_peer_group
, "type",
15511 vty_out(vty
, " Peer-group type is external\n");
15514 /* Display AFs configured. */
15516 vty_out(vty
, " Configured address-families:");
15518 FOREACH_AFI_SAFI (afi
, safi
) {
15519 if (conf
->afc
[afi
][safi
]) {
15522 json_object_array_add(
15523 json_peer_group_afc
,
15524 json_object_new_string(get_afi_safi_str(
15525 afi
, safi
, false)));
15527 vty_out(vty
, " %s;",
15528 get_afi_safi_str(afi
, safi
, false));
15533 json_object_object_add(json_peer_group
,
15534 "addressFamiliesConfigured",
15535 json_peer_group_afc
);
15538 vty_out(vty
, " none\n");
15540 vty_out(vty
, "\n");
15543 /* Display listen ranges (for dynamic neighbors), if any */
15544 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15545 lr_count
= listcount(group
->listen_range
[afi
]);
15548 if (!json_peer_group_dynamic
)
15549 json_peer_group_dynamic
=
15550 json_object_new_object();
15552 json_peer_group_dynamic_af
=
15553 json_object_new_object();
15554 json_peer_group_ranges
=
15555 json_object_new_array();
15556 json_object_int_add(json_peer_group_dynamic_af
,
15557 "count", lr_count
);
15559 vty_out(vty
, " %d %s listen range(s)\n",
15560 lr_count
, afi2str(afi
));
15563 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15568 snprintfrr(buf
, sizeof(buf
), "%pFX",
15571 json_object_array_add(
15572 json_peer_group_ranges
,
15573 json_object_new_string(buf
));
15575 vty_out(vty
, " %pFX\n", range
);
15580 json_object_object_add(
15581 json_peer_group_dynamic_af
, "ranges",
15582 json_peer_group_ranges
);
15584 json_object_object_add(
15585 json_peer_group_dynamic
, afi2str(afi
),
15586 json_peer_group_dynamic_af
);
15591 if (json_peer_group_dynamic
)
15592 json_object_object_add(json_peer_group
, "dynamicRanges",
15593 json_peer_group_dynamic
);
15595 /* Display group members and their status */
15596 if (listcount(group
->peer
)) {
15598 json_peer_group_members
= json_object_new_object();
15600 vty_out(vty
, " Peer-group members:\n");
15601 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15602 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15603 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15604 peer_status
= "Idle (Admin)";
15605 else if (CHECK_FLAG(peer
->sflags
,
15606 PEER_STATUS_PREFIX_OVERFLOW
))
15607 peer_status
= "Idle (PfxCt)";
15609 peer_status
= lookup_msg(bgp_status_msg
,
15610 peer
->status
, NULL
);
15612 dynamic
= peer_dynamic_neighbor(peer
);
15615 json_object
*json_peer_group_member
=
15616 json_object_new_object();
15618 json_object_string_add(json_peer_group_member
,
15619 "status", peer_status
);
15622 json_object_boolean_true_add(
15623 json_peer_group_member
,
15626 json_object_object_add(json_peer_group_members
,
15628 json_peer_group_member
);
15630 vty_out(vty
, " %s %s %s \n", peer
->host
,
15631 dynamic
? "(dynamic)" : "",
15636 json_object_object_add(json_peer_group
, "members",
15637 json_peer_group_members
);
15641 json_object_object_add(json
, group
->name
, json_peer_group
);
15643 return CMD_SUCCESS
;
15646 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15647 const char *group_name
, bool uj
)
15650 struct listnode
*node
, *nnode
;
15651 struct peer_group
*group
;
15652 bool found
= false;
15653 json_object
*json
= NULL
;
15656 json
= json_object_new_object();
15658 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15662 vty_json(vty
, json
);
15664 vty_out(vty
, "%% BGP instance not found\n");
15666 return CMD_WARNING
;
15669 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15671 if (strmatch(group
->name
, group_name
)) {
15672 bgp_show_one_peer_group(vty
, group
, json
);
15677 bgp_show_one_peer_group(vty
, group
, json
);
15681 if (group_name
&& !found
&& !uj
)
15682 vty_out(vty
, "%% No such peer-group\n");
15685 vty_json(vty
, json
);
15687 return CMD_SUCCESS
;
15690 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15691 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15692 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15693 "Detailed information on BGP peer groups\n"
15694 "Peer group name\n" JSON_STR
)
15698 bool uj
= use_json(argc
, argv
);
15700 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15702 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15704 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15708 /* Redistribute VTY commands. */
15710 DEFUN (bgp_redistribute_ipv4
,
15711 bgp_redistribute_ipv4_cmd
,
15712 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15713 "Redistribute information from another routing protocol\n"
15714 FRR_IP_REDIST_HELP_STR_BGPD
)
15716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15717 int idx_protocol
= 1;
15720 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15722 vty_out(vty
, "%% Invalid route type\n");
15723 return CMD_WARNING_CONFIG_FAILED
;
15726 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15727 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15731 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15732 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15733 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15735 DEFUN (bgp_redistribute_ipv4_rmap
,
15736 bgp_redistribute_ipv4_rmap_cmd
,
15737 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15738 "Redistribute information from another routing protocol\n"
15739 FRR_IP_REDIST_HELP_STR_BGPD
15740 "Route map reference\n"
15741 "Pointer to route-map entries\n")
15743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15744 int idx_protocol
= 1;
15747 struct bgp_redist
*red
;
15749 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15750 vty
, argv
[idx_word
]->arg
);
15752 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15754 vty_out(vty
, "%% Invalid route type\n");
15755 return CMD_WARNING_CONFIG_FAILED
;
15758 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15760 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15761 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15765 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15766 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15767 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15768 "Route map reference\n"
15769 "Pointer to route-map entries\n")
15771 DEFUN (bgp_redistribute_ipv4_metric
,
15772 bgp_redistribute_ipv4_metric_cmd
,
15773 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15774 "Redistribute information from another routing protocol\n"
15775 FRR_IP_REDIST_HELP_STR_BGPD
15776 "Metric for redistributed routes\n"
15777 "Default metric\n")
15779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15780 int idx_protocol
= 1;
15781 int idx_number
= 3;
15784 struct bgp_redist
*red
;
15787 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15789 vty_out(vty
, "%% Invalid route type\n");
15790 return CMD_WARNING_CONFIG_FAILED
;
15792 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15794 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15795 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15796 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15800 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15801 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15802 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15803 "Metric for redistributed routes\n"
15804 "Default metric\n")
15806 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15807 bgp_redistribute_ipv4_rmap_metric_cmd
,
15808 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15809 "Redistribute information from another routing protocol\n"
15810 FRR_IP_REDIST_HELP_STR_BGPD
15811 "Route map reference\n"
15812 "Pointer to route-map entries\n"
15813 "Metric for redistributed routes\n"
15814 "Default metric\n")
15816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15817 int idx_protocol
= 1;
15819 int idx_number
= 5;
15822 struct bgp_redist
*red
;
15824 struct route_map
*route_map
=
15825 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15827 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15829 vty_out(vty
, "%% Invalid route type\n");
15830 return CMD_WARNING_CONFIG_FAILED
;
15832 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15834 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15836 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15837 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15838 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15842 bgp_redistribute_ipv4_rmap_metric
,
15843 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15844 "redistribute " FRR_IP_REDIST_STR_BGPD
15845 " route-map RMAP_NAME metric (0-4294967295)",
15846 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15847 "Route map reference\n"
15848 "Pointer to route-map entries\n"
15849 "Metric for redistributed routes\n"
15850 "Default metric\n")
15852 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15853 bgp_redistribute_ipv4_metric_rmap_cmd
,
15854 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15855 "Redistribute information from another routing protocol\n"
15856 FRR_IP_REDIST_HELP_STR_BGPD
15857 "Metric for redistributed routes\n"
15859 "Route map reference\n"
15860 "Pointer to route-map entries\n")
15862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15863 int idx_protocol
= 1;
15864 int idx_number
= 3;
15868 struct bgp_redist
*red
;
15870 struct route_map
*route_map
=
15871 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15873 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15875 vty_out(vty
, "%% Invalid route type\n");
15876 return CMD_WARNING_CONFIG_FAILED
;
15878 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15880 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15881 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15883 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15884 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15888 bgp_redistribute_ipv4_metric_rmap
,
15889 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15890 "redistribute " FRR_IP_REDIST_STR_BGPD
15891 " metric (0-4294967295) route-map RMAP_NAME",
15892 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15893 "Metric for redistributed routes\n"
15895 "Route map reference\n"
15896 "Pointer to route-map entries\n")
15898 DEFUN (bgp_redistribute_ipv4_ospf
,
15899 bgp_redistribute_ipv4_ospf_cmd
,
15900 "redistribute <ospf|table> (1-65535)",
15901 "Redistribute information from another routing protocol\n"
15902 "Open Shortest Path First (OSPFv2)\n"
15903 "Non-main Kernel Routing Table\n"
15904 "Instance ID/Table ID\n")
15906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15907 int idx_ospf_table
= 1;
15908 int idx_number
= 2;
15909 unsigned short instance
;
15910 unsigned short protocol
;
15912 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15914 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15915 protocol
= ZEBRA_ROUTE_OSPF
;
15917 protocol
= ZEBRA_ROUTE_TABLE
;
15919 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15920 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15923 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15924 "redistribute <ospf|table> (1-65535)",
15925 "Redistribute information from another routing protocol\n"
15926 "Open Shortest Path First (OSPFv2)\n"
15927 "Non-main Kernel Routing Table\n"
15928 "Instance ID/Table ID\n")
15930 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15931 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15932 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15933 "Redistribute information from another routing protocol\n"
15934 "Open Shortest Path First (OSPFv2)\n"
15935 "Non-main Kernel Routing Table\n"
15936 "Instance ID/Table ID\n"
15937 "Route map reference\n"
15938 "Pointer to route-map entries\n")
15940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15941 int idx_ospf_table
= 1;
15942 int idx_number
= 2;
15944 struct bgp_redist
*red
;
15945 unsigned short instance
;
15948 struct route_map
*route_map
=
15949 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15951 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15952 protocol
= ZEBRA_ROUTE_OSPF
;
15954 protocol
= ZEBRA_ROUTE_TABLE
;
15956 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15957 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15959 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15960 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15963 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15964 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15965 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15966 "Redistribute information from another routing protocol\n"
15967 "Open Shortest Path First (OSPFv2)\n"
15968 "Non-main Kernel Routing Table\n"
15969 "Instance ID/Table ID\n"
15970 "Route map reference\n"
15971 "Pointer to route-map entries\n")
15973 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15974 bgp_redistribute_ipv4_ospf_metric_cmd
,
15975 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15976 "Redistribute information from another routing protocol\n"
15977 "Open Shortest Path First (OSPFv2)\n"
15978 "Non-main Kernel Routing Table\n"
15979 "Instance ID/Table ID\n"
15980 "Metric for redistributed routes\n"
15981 "Default metric\n")
15983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15984 int idx_ospf_table
= 1;
15985 int idx_number
= 2;
15986 int idx_number_2
= 4;
15988 struct bgp_redist
*red
;
15989 unsigned short instance
;
15993 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15994 protocol
= ZEBRA_ROUTE_OSPF
;
15996 protocol
= ZEBRA_ROUTE_TABLE
;
15998 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15999 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16001 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16002 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16004 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16007 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16008 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16009 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16010 "Redistribute information from another routing protocol\n"
16011 "Open Shortest Path First (OSPFv2)\n"
16012 "Non-main Kernel Routing Table\n"
16013 "Instance ID/Table ID\n"
16014 "Metric for redistributed routes\n"
16015 "Default metric\n")
16017 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16018 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16019 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16020 "Redistribute information from another routing protocol\n"
16021 "Open Shortest Path First (OSPFv2)\n"
16022 "Non-main Kernel Routing Table\n"
16023 "Instance ID/Table ID\n"
16024 "Route map reference\n"
16025 "Pointer to route-map entries\n"
16026 "Metric for redistributed routes\n"
16027 "Default metric\n")
16029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16030 int idx_ospf_table
= 1;
16031 int idx_number
= 2;
16033 int idx_number_2
= 6;
16035 struct bgp_redist
*red
;
16036 unsigned short instance
;
16039 struct route_map
*route_map
=
16040 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16042 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16043 protocol
= ZEBRA_ROUTE_OSPF
;
16045 protocol
= ZEBRA_ROUTE_TABLE
;
16047 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16048 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16050 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16052 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16053 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16055 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16059 bgp_redistribute_ipv4_ospf_rmap_metric
,
16060 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16061 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16062 "Redistribute information from another routing protocol\n"
16063 "Open Shortest Path First (OSPFv2)\n"
16064 "Non-main Kernel Routing Table\n"
16065 "Instance ID/Table ID\n"
16066 "Route map reference\n"
16067 "Pointer to route-map entries\n"
16068 "Metric for redistributed routes\n"
16069 "Default metric\n")
16071 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16072 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16073 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16074 "Redistribute information from another routing protocol\n"
16075 "Open Shortest Path First (OSPFv2)\n"
16076 "Non-main Kernel Routing Table\n"
16077 "Instance ID/Table ID\n"
16078 "Metric for redistributed routes\n"
16080 "Route map reference\n"
16081 "Pointer to route-map entries\n")
16083 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16084 int idx_ospf_table
= 1;
16085 int idx_number
= 2;
16086 int idx_number_2
= 4;
16089 struct bgp_redist
*red
;
16090 unsigned short instance
;
16093 struct route_map
*route_map
=
16094 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16096 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16097 protocol
= ZEBRA_ROUTE_OSPF
;
16099 protocol
= ZEBRA_ROUTE_TABLE
;
16101 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16102 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16104 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16105 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16108 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16109 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16113 bgp_redistribute_ipv4_ospf_metric_rmap
,
16114 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16115 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16116 "Redistribute information from another routing protocol\n"
16117 "Open Shortest Path First (OSPFv2)\n"
16118 "Non-main Kernel Routing Table\n"
16119 "Instance ID/Table ID\n"
16120 "Metric for redistributed routes\n"
16122 "Route map reference\n"
16123 "Pointer to route-map entries\n")
16125 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16126 no_bgp_redistribute_ipv4_ospf_cmd
,
16127 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16129 "Redistribute information from another routing protocol\n"
16130 "Open Shortest Path First (OSPFv2)\n"
16131 "Non-main Kernel Routing Table\n"
16132 "Instance ID/Table ID\n"
16133 "Metric for redistributed routes\n"
16135 "Route map reference\n"
16136 "Pointer to route-map entries\n")
16138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16139 int idx_ospf_table
= 2;
16140 int idx_number
= 3;
16141 unsigned short instance
;
16144 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16145 protocol
= ZEBRA_ROUTE_OSPF
;
16147 protocol
= ZEBRA_ROUTE_TABLE
;
16149 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16150 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16154 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16155 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16157 "Redistribute information from another routing protocol\n"
16158 "Open Shortest Path First (OSPFv2)\n"
16159 "Non-main Kernel Routing Table\n"
16160 "Instance ID/Table ID\n"
16161 "Metric for redistributed routes\n"
16163 "Route map reference\n"
16164 "Pointer to route-map entries\n")
16166 DEFUN (no_bgp_redistribute_ipv4
,
16167 no_bgp_redistribute_ipv4_cmd
,
16168 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16170 "Redistribute information from another routing protocol\n"
16171 FRR_IP_REDIST_HELP_STR_BGPD
16172 "Metric for redistributed routes\n"
16174 "Route map reference\n"
16175 "Pointer to route-map entries\n")
16177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16178 int idx_protocol
= 2;
16181 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16183 vty_out(vty
, "%% Invalid route type\n");
16184 return CMD_WARNING_CONFIG_FAILED
;
16186 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16190 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16191 "no redistribute " FRR_IP_REDIST_STR_BGPD
16192 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16194 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16195 "Metric for redistributed routes\n"
16197 "Route map reference\n"
16198 "Pointer to route-map entries\n")
16200 DEFUN (bgp_redistribute_ipv6
,
16201 bgp_redistribute_ipv6_cmd
,
16202 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16203 "Redistribute information from another routing protocol\n"
16204 FRR_IP6_REDIST_HELP_STR_BGPD
)
16206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16207 int idx_protocol
= 1;
16210 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16212 vty_out(vty
, "%% Invalid route type\n");
16213 return CMD_WARNING_CONFIG_FAILED
;
16216 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16217 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16220 DEFUN (bgp_redistribute_ipv6_rmap
,
16221 bgp_redistribute_ipv6_rmap_cmd
,
16222 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16223 "Redistribute information from another routing protocol\n"
16224 FRR_IP6_REDIST_HELP_STR_BGPD
16225 "Route map reference\n"
16226 "Pointer to route-map entries\n")
16228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16229 int idx_protocol
= 1;
16232 struct bgp_redist
*red
;
16234 struct route_map
*route_map
=
16235 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16237 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16239 vty_out(vty
, "%% Invalid route type\n");
16240 return CMD_WARNING_CONFIG_FAILED
;
16243 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16245 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16246 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16249 DEFUN (bgp_redistribute_ipv6_metric
,
16250 bgp_redistribute_ipv6_metric_cmd
,
16251 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16252 "Redistribute information from another routing protocol\n"
16253 FRR_IP6_REDIST_HELP_STR_BGPD
16254 "Metric for redistributed routes\n"
16255 "Default metric\n")
16257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16258 int idx_protocol
= 1;
16259 int idx_number
= 3;
16262 struct bgp_redist
*red
;
16265 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16267 vty_out(vty
, "%% Invalid route type\n");
16268 return CMD_WARNING_CONFIG_FAILED
;
16270 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16272 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16273 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16274 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16277 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16278 bgp_redistribute_ipv6_rmap_metric_cmd
,
16279 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16280 "Redistribute information from another routing protocol\n"
16281 FRR_IP6_REDIST_HELP_STR_BGPD
16282 "Route map reference\n"
16283 "Pointer to route-map entries\n"
16284 "Metric for redistributed routes\n"
16285 "Default metric\n")
16287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16288 int idx_protocol
= 1;
16290 int idx_number
= 5;
16293 struct bgp_redist
*red
;
16295 struct route_map
*route_map
=
16296 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16298 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16300 vty_out(vty
, "%% Invalid route type\n");
16301 return CMD_WARNING_CONFIG_FAILED
;
16303 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16305 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16307 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16308 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16310 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16313 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16314 bgp_redistribute_ipv6_metric_rmap_cmd
,
16315 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16316 "Redistribute information from another routing protocol\n"
16317 FRR_IP6_REDIST_HELP_STR_BGPD
16318 "Metric for redistributed routes\n"
16320 "Route map reference\n"
16321 "Pointer to route-map entries\n")
16323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16324 int idx_protocol
= 1;
16325 int idx_number
= 3;
16329 struct bgp_redist
*red
;
16331 struct route_map
*route_map
=
16332 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16334 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16336 vty_out(vty
, "%% Invalid route type\n");
16337 return CMD_WARNING_CONFIG_FAILED
;
16339 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16341 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16342 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16345 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16346 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16349 DEFUN (no_bgp_redistribute_ipv6
,
16350 no_bgp_redistribute_ipv6_cmd
,
16351 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16353 "Redistribute information from another routing protocol\n"
16354 FRR_IP6_REDIST_HELP_STR_BGPD
16355 "Metric for redistributed routes\n"
16357 "Route map reference\n"
16358 "Pointer to route-map entries\n")
16360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16361 int idx_protocol
= 2;
16364 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16366 vty_out(vty
, "%% Invalid route type\n");
16367 return CMD_WARNING_CONFIG_FAILED
;
16370 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16373 /* Neighbor update tcp-mss. */
16374 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16375 const char *tcp_mss_str
)
16378 uint32_t tcp_mss_val
= 0;
16380 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16382 return CMD_WARNING_CONFIG_FAILED
;
16385 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16386 peer_tcp_mss_set(peer
, tcp_mss_val
);
16388 peer_tcp_mss_unset(peer
);
16391 return CMD_SUCCESS
;
16394 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16395 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16396 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16397 "TCP max segment size\n"
16400 int peer_index
= 1;
16404 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16405 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16406 argv
[mss_index
]->arg
);
16409 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16410 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16411 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16412 "TCP max segment size\n"
16415 int peer_index
= 2;
16418 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16419 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16422 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16423 "[no$no] bgp retain route-target all",
16425 "Retain BGP updates\n"
16426 "Retain BGP updates based on route-target values\n"
16427 "Retain all BGP updates\n")
16430 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16432 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16433 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16434 if (check
!= !no
) {
16436 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16437 [bgp_node_safi(vty
)],
16438 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16440 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16441 [bgp_node_safi(vty
)],
16442 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16443 /* trigger a flush to re-sync with ADJ-RIB-in */
16444 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16445 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16447 return CMD_SUCCESS
;
16450 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16451 afi_t afi
, safi_t safi
)
16455 /* Unicast redistribution only. */
16456 if (safi
!= SAFI_UNICAST
)
16459 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16460 /* Redistribute BGP does not make sense. */
16461 if (i
!= ZEBRA_ROUTE_BGP
) {
16462 struct list
*red_list
;
16463 struct listnode
*node
;
16464 struct bgp_redist
*red
;
16466 red_list
= bgp
->redist
[afi
][i
];
16470 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16471 /* "redistribute" configuration. */
16472 vty_out(vty
, " redistribute %s",
16473 zebra_route_string(i
));
16475 vty_out(vty
, " %d", red
->instance
);
16476 if (red
->redist_metric_flag
)
16477 vty_out(vty
, " metric %u",
16478 red
->redist_metric
);
16479 if (red
->rmap
.name
)
16480 vty_out(vty
, " route-map %s",
16482 vty_out(vty
, "\n");
16488 /* peer-group helpers for config-write */
16490 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16492 if (!peer_group_active(peer
)) {
16493 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16494 return !CHECK_FLAG(peer
->flags
, flag
);
16496 return !!CHECK_FLAG(peer
->flags
, flag
);
16499 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16502 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16505 if (!peer_group_active(peer
)) {
16506 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16507 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16509 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16512 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16515 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16516 uint8_t type
, int direct
)
16518 struct bgp_filter
*filter
;
16520 if (peer_group_active(peer
))
16521 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16524 filter
= &peer
->filter
[afi
][safi
];
16526 case PEER_FT_DISTRIBUTE_LIST
:
16527 return !!(filter
->dlist
[direct
].name
);
16528 case PEER_FT_FILTER_LIST
:
16529 return !!(filter
->aslist
[direct
].name
);
16530 case PEER_FT_PREFIX_LIST
:
16531 return !!(filter
->plist
[direct
].name
);
16532 case PEER_FT_ROUTE_MAP
:
16533 return !!(filter
->map
[direct
].name
);
16534 case PEER_FT_UNSUPPRESS_MAP
:
16535 return !!(filter
->usmap
.name
);
16536 case PEER_FT_ADVERTISE_MAP
:
16537 return !!(filter
->advmap
.aname
16538 && ((filter
->advmap
.condition
== direct
)
16539 && filter
->advmap
.cname
));
16545 /* Return true if the addpath type is set for peer and different from
16548 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16551 enum bgp_addpath_strat type
, g_type
;
16553 type
= peer
->addpath_type
[afi
][safi
];
16555 if (type
!= BGP_ADDPATH_NONE
) {
16556 if (peer_group_active(peer
)) {
16557 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16559 if (type
!= g_type
)
16571 /* This is part of the address-family block (unicast only) */
16572 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16576 uint32_t tovpn_sid_index
= 0;
16578 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16579 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16580 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16581 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16582 bgp
->vpn_policy
[afi
]
16583 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16585 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16586 bgp
->vpn_policy
[afi
]
16587 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16589 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16590 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16591 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16592 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16595 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16596 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16598 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16601 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16602 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16603 bgp
->vpn_policy
[afi
].tovpn_label
);
16607 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16608 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16609 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16610 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16611 } else if (tovpn_sid_index
!= 0) {
16612 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16616 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16617 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16618 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16620 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16621 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16623 char buf
[PREFIX_STRLEN
];
16624 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16625 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16628 vty_out(vty
, "%*snexthop vpn export %s\n",
16632 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16633 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16635 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16636 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16638 char *b
= ecommunity_ecom2str(
16639 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16640 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16641 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16642 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16644 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16645 char *b
= ecommunity_ecom2str(
16646 bgp
->vpn_policy
[afi
]
16647 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16648 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16649 ECOMMUNITY_ROUTE_TARGET
);
16650 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16651 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16653 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16654 char *b
= ecommunity_ecom2str(
16655 bgp
->vpn_policy
[afi
]
16656 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16657 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16658 ECOMMUNITY_ROUTE_TARGET
);
16659 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16660 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16664 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16665 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16666 bgp
->vpn_policy
[afi
]
16667 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16669 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16670 char *b
= ecommunity_ecom2str(
16671 bgp
->vpn_policy
[afi
]
16672 .import_redirect_rtlist
,
16673 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16674 ECOMMUNITY_ROUTE_TARGET
);
16676 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16677 != ECOMMUNITY_SIZE
)
16678 vty_out(vty
, "%*srt6 redirect import %s\n",
16681 vty_out(vty
, "%*srt redirect import %s\n",
16683 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16687 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16688 afi_t afi
, safi_t safi
)
16690 struct bgp_filter
*filter
;
16694 filter
= &peer
->filter
[afi
][safi
];
16696 /* distribute-list. */
16697 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16699 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16700 filter
->dlist
[FILTER_IN
].name
);
16702 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16704 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16705 filter
->dlist
[FILTER_OUT
].name
);
16708 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16710 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16711 filter
->plist
[FILTER_IN
].name
);
16713 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16715 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16716 filter
->plist
[FILTER_OUT
].name
);
16719 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16720 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16721 filter
->map
[RMAP_IN
].name
);
16723 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16725 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16726 filter
->map
[RMAP_OUT
].name
);
16728 /* unsuppress-map */
16729 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16730 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16731 filter
->usmap
.name
);
16733 /* advertise-map : always applied in OUT direction*/
16734 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16735 CONDITION_NON_EXIST
))
16737 " neighbor %s advertise-map %s non-exist-map %s\n",
16738 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16740 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16742 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16743 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16746 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16748 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16749 filter
->aslist
[FILTER_IN
].name
);
16751 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16753 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16754 filter
->aslist
[FILTER_OUT
].name
);
16757 /* BGP peer configuration display function. */
16758 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16761 struct peer
*g_peer
= NULL
;
16763 int if_pg_printed
= false;
16764 int if_ras_printed
= false;
16766 /* Skip dynamic neighbors. */
16767 if (peer_dynamic_neighbor(peer
))
16771 addr
= peer
->conf_if
;
16775 /************************************
16776 ****** Global to the neighbor ******
16777 ************************************/
16778 if (peer
->conf_if
) {
16779 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16780 vty_out(vty
, " neighbor %s interface v6only", addr
);
16782 vty_out(vty
, " neighbor %s interface", addr
);
16784 if (peer_group_active(peer
)) {
16785 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16786 if_pg_printed
= true;
16787 } else if (peer
->as_type
== AS_SPECIFIED
) {
16788 vty_out(vty
, " remote-as %u", peer
->as
);
16789 if_ras_printed
= true;
16790 } else if (peer
->as_type
== AS_INTERNAL
) {
16791 vty_out(vty
, " remote-as internal");
16792 if_ras_printed
= true;
16793 } else if (peer
->as_type
== AS_EXTERNAL
) {
16794 vty_out(vty
, " remote-as external");
16795 if_ras_printed
= true;
16798 vty_out(vty
, "\n");
16801 /* remote-as and peer-group */
16802 /* peer is a member of a peer-group */
16803 if (peer_group_active(peer
)) {
16804 g_peer
= peer
->group
->conf
;
16806 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16807 if (peer
->as_type
== AS_SPECIFIED
) {
16808 vty_out(vty
, " neighbor %s remote-as %u\n",
16810 } else if (peer
->as_type
== AS_INTERNAL
) {
16812 " neighbor %s remote-as internal\n",
16814 } else if (peer
->as_type
== AS_EXTERNAL
) {
16816 " neighbor %s remote-as external\n",
16821 /* For swpX peers we displayed the peer-group
16822 * via 'neighbor swpX interface peer-group PGNAME' */
16823 if (!if_pg_printed
)
16824 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16825 peer
->group
->name
);
16828 /* peer is NOT a member of a peer-group */
16830 /* peer is a peer-group, declare the peer-group */
16831 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16832 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16835 if (!if_ras_printed
) {
16836 if (peer
->as_type
== AS_SPECIFIED
) {
16837 vty_out(vty
, " neighbor %s remote-as %u\n",
16839 } else if (peer
->as_type
== AS_INTERNAL
) {
16841 " neighbor %s remote-as internal\n",
16843 } else if (peer
->as_type
== AS_EXTERNAL
) {
16845 " neighbor %s remote-as external\n",
16852 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16853 vty_out(vty
, " neighbor %s local-as %u", addr
,
16854 peer
->change_local_as
);
16855 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16856 vty_out(vty
, " no-prepend");
16857 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16858 vty_out(vty
, " replace-as");
16859 vty_out(vty
, "\n");
16864 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16868 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16869 if (peer
->tx_shutdown_message
)
16870 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16871 peer
->tx_shutdown_message
);
16873 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16876 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16877 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16878 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16881 if (peer
->bfd_config
)
16882 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16885 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16886 vty_out(vty
, " neighbor %s password %s\n", addr
,
16889 /* neighbor solo */
16890 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16891 if (!peer_group_active(peer
)) {
16892 vty_out(vty
, " neighbor %s solo\n", addr
);
16897 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16898 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16901 /* Local interface name */
16902 if (peer
->ifname
) {
16903 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16906 /* TCP max segment size */
16907 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16908 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16911 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16912 vty_out(vty
, " neighbor %s passive\n", addr
);
16914 /* ebgp-multihop */
16915 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16916 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16917 && peer
->ttl
== MAXTTL
)) {
16918 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16919 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16925 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16926 peer
->local_role
!= ROLE_UNDEFINED
)
16927 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16928 bgp_get_name_by_role(peer
->local_role
),
16929 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16933 /* ttl-security hops */
16934 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16935 if (!peer_group_active(peer
)
16936 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16937 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16938 addr
, peer
->gtsm_hops
);
16942 /* disable-connected-check */
16943 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16944 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16946 /* link-bw-encoding-ieee */
16947 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16948 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16951 /* extended-optional-parameters */
16952 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16953 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16956 /* enforce-first-as */
16957 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16958 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16960 /* update-source */
16961 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16962 if (peer
->update_source
)
16963 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16964 peer
->update_source
);
16965 else if (peer
->update_if
)
16966 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16970 /* advertisement-interval */
16971 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16972 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16976 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16977 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16978 peer
->keepalive
, peer
->holdtime
);
16980 /* timers connect */
16981 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16982 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16984 /* need special-case handling for changed default values due to
16985 * config profile / version (because there is no "timers bgp connect"
16986 * command, we need to save this per-peer :/)
16988 else if (!peer_group_active(peer
) && !peer
->connect
&&
16989 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16990 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16991 peer
->bgp
->default_connect_retry
);
16993 /* timers delayopen */
16994 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16995 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16997 /* Save config even though flag is not set if default values have been
17000 else if (!peer_group_active(peer
) && !peer
->delayopen
17001 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17002 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17003 peer
->bgp
->default_delayopen
);
17005 /* capability dynamic */
17006 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17007 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17009 /* capability extended-nexthop */
17010 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17011 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17014 " no neighbor %s capability extended-nexthop\n",
17016 else if (!peer
->conf_if
)
17018 " neighbor %s capability extended-nexthop\n",
17022 /* dont-capability-negotiation */
17023 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17024 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17026 /* override-capability */
17027 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17028 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17030 /* strict-capability-match */
17031 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17032 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17034 /* Sender side AS path loop detection. */
17035 if (peer
->as_path_loop_detection
)
17036 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17039 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17040 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17042 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17043 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17045 " neighbor %s graceful-restart-helper\n", addr
);
17046 } else if (CHECK_FLAG(
17047 peer
->peer_gr_new_status_flag
,
17048 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17050 " neighbor %s graceful-restart\n", addr
);
17052 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17053 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17055 peer
->peer_gr_new_status_flag
,
17056 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17057 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17063 /* BGP peer configuration display function. */
17064 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17065 struct peer
*peer
, afi_t afi
, safi_t safi
)
17067 struct peer
*g_peer
= NULL
;
17069 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17071 /* Skip dynamic neighbors. */
17072 if (peer_dynamic_neighbor(peer
))
17076 addr
= peer
->conf_if
;
17080 /************************************
17081 ****** Per AF to the neighbor ******
17082 ************************************/
17083 if (peer_group_active(peer
)) {
17084 g_peer
= peer
->group
->conf
;
17086 /* If the peer-group is active but peer is not, print a 'no
17088 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17089 vty_out(vty
, " no neighbor %s activate\n", addr
);
17092 /* If the peer-group is not active but peer is, print an
17094 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17095 vty_out(vty
, " neighbor %s activate\n", addr
);
17098 if (peer
->afc
[afi
][safi
]) {
17099 if (safi
== SAFI_ENCAP
)
17100 vty_out(vty
, " neighbor %s activate\n", addr
);
17101 else if (!bgp
->default_af
[afi
][safi
])
17102 vty_out(vty
, " neighbor %s activate\n", addr
);
17104 if (bgp
->default_af
[afi
][safi
])
17105 vty_out(vty
, " no neighbor %s activate\n",
17110 /* addpath TX knobs */
17111 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17112 switch (peer
->addpath_type
[afi
][safi
]) {
17113 case BGP_ADDPATH_ALL
:
17114 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17117 case BGP_ADDPATH_BEST_PER_AS
:
17119 " neighbor %s addpath-tx-bestpath-per-AS\n",
17122 case BGP_ADDPATH_MAX
:
17123 case BGP_ADDPATH_NONE
:
17128 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17129 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17131 /* ORF capability. */
17132 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17133 || peergroup_af_flag_check(peer
, afi
, safi
,
17134 PEER_FLAG_ORF_PREFIX_RM
)) {
17135 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17137 if (peergroup_af_flag_check(peer
, afi
, safi
,
17138 PEER_FLAG_ORF_PREFIX_SM
)
17139 && peergroup_af_flag_check(peer
, afi
, safi
,
17140 PEER_FLAG_ORF_PREFIX_RM
))
17141 vty_out(vty
, " both");
17142 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17143 PEER_FLAG_ORF_PREFIX_SM
))
17144 vty_out(vty
, " send");
17146 vty_out(vty
, " receive");
17147 vty_out(vty
, "\n");
17150 /* Route reflector client. */
17151 if (peergroup_af_flag_check(peer
, afi
, safi
,
17152 PEER_FLAG_REFLECTOR_CLIENT
)) {
17153 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17156 /* next-hop-self force */
17157 if (peergroup_af_flag_check(peer
, afi
, safi
,
17158 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17159 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17162 /* next-hop-self */
17163 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17164 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17167 /* remove-private-AS */
17168 if (peergroup_af_flag_check(peer
, afi
, safi
,
17169 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17170 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17174 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17175 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17176 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17180 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17181 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17182 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17185 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17186 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17187 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17191 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17192 vty_out(vty
, " neighbor %s as-override\n", addr
);
17195 /* send-community print. */
17196 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17197 PEER_FLAG_SEND_COMMUNITY
);
17198 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17199 PEER_FLAG_SEND_EXT_COMMUNITY
);
17200 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17201 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17203 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17204 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17207 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17210 " no neighbor %s send-community extended\n",
17214 vty_out(vty
, " no neighbor %s send-community large\n",
17218 /* Default information */
17219 if (peergroup_af_flag_check(peer
, afi
, safi
,
17220 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17221 vty_out(vty
, " neighbor %s default-originate", addr
);
17223 if (peer
->default_rmap
[afi
][safi
].name
)
17224 vty_out(vty
, " route-map %s",
17225 peer
->default_rmap
[afi
][safi
].name
);
17227 vty_out(vty
, "\n");
17230 /* Soft reconfiguration inbound. */
17231 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17232 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17236 /* maximum-prefix. */
17237 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17238 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17239 peer
->pmax
[afi
][safi
]);
17241 if (peer
->pmax_threshold
[afi
][safi
]
17242 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17243 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17244 if (peer_af_flag_check(peer
, afi
, safi
,
17245 PEER_FLAG_MAX_PREFIX_WARNING
))
17246 vty_out(vty
, " warning-only");
17247 if (peer
->pmax_restart
[afi
][safi
])
17248 vty_out(vty
, " restart %u",
17249 peer
->pmax_restart
[afi
][safi
]);
17250 if (peer_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_MAX_PREFIX_FORCE
))
17252 vty_out(vty
, " force");
17254 vty_out(vty
, "\n");
17257 /* maximum-prefix-out */
17258 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17259 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17260 addr
, peer
->pmax_out
[afi
][safi
]);
17262 /* Route server client. */
17263 if (peergroup_af_flag_check(peer
, afi
, safi
,
17264 PEER_FLAG_RSERVER_CLIENT
)) {
17265 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17268 /* Nexthop-local unchanged. */
17269 if (peergroup_af_flag_check(peer
, afi
, safi
,
17270 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17271 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17274 /* allowas-in <1-10> */
17275 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17276 if (peer_af_flag_check(peer
, afi
, safi
,
17277 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17278 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17279 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17280 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17282 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17283 peer
->allowas_in
[afi
][safi
]);
17288 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17289 char *soo_str
= ecommunity_ecom2str(
17290 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17292 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17293 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17297 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17298 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17299 peer
->weight
[afi
][safi
]);
17302 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17304 /* atribute-unchanged. */
17305 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17306 || (safi
!= SAFI_EVPN
17307 && peer_af_flag_check(peer
, afi
, safi
,
17308 PEER_FLAG_NEXTHOP_UNCHANGED
))
17309 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17311 if (!peer_group_active(peer
)
17312 || peergroup_af_flag_check(peer
, afi
, safi
,
17313 PEER_FLAG_AS_PATH_UNCHANGED
)
17314 || peergroup_af_flag_check(peer
, afi
, safi
,
17315 PEER_FLAG_NEXTHOP_UNCHANGED
)
17316 || peergroup_af_flag_check(peer
, afi
, safi
,
17317 PEER_FLAG_MED_UNCHANGED
)) {
17320 " neighbor %s attribute-unchanged%s%s%s\n",
17322 peer_af_flag_check(peer
, afi
, safi
,
17323 PEER_FLAG_AS_PATH_UNCHANGED
)
17326 peer_af_flag_check(peer
, afi
, safi
,
17327 PEER_FLAG_NEXTHOP_UNCHANGED
)
17330 peer_af_flag_check(peer
, afi
, safi
,
17331 PEER_FLAG_MED_UNCHANGED
)
17338 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17341 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17342 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17343 vty_out(vty
, " no bgp retain route-target all\n");
17346 /* Address family based peer configuration display. */
17347 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17351 struct peer_group
*group
;
17352 struct listnode
*node
, *nnode
;
17355 vty_frame(vty
, " !\n address-family ");
17356 if (afi
== AFI_IP
) {
17357 if (safi
== SAFI_UNICAST
)
17358 vty_frame(vty
, "ipv4 unicast");
17359 else if (safi
== SAFI_LABELED_UNICAST
)
17360 vty_frame(vty
, "ipv4 labeled-unicast");
17361 else if (safi
== SAFI_MULTICAST
)
17362 vty_frame(vty
, "ipv4 multicast");
17363 else if (safi
== SAFI_MPLS_VPN
)
17364 vty_frame(vty
, "ipv4 vpn");
17365 else if (safi
== SAFI_ENCAP
)
17366 vty_frame(vty
, "ipv4 encap");
17367 else if (safi
== SAFI_FLOWSPEC
)
17368 vty_frame(vty
, "ipv4 flowspec");
17369 } else if (afi
== AFI_IP6
) {
17370 if (safi
== SAFI_UNICAST
)
17371 vty_frame(vty
, "ipv6 unicast");
17372 else if (safi
== SAFI_LABELED_UNICAST
)
17373 vty_frame(vty
, "ipv6 labeled-unicast");
17374 else if (safi
== SAFI_MULTICAST
)
17375 vty_frame(vty
, "ipv6 multicast");
17376 else if (safi
== SAFI_MPLS_VPN
)
17377 vty_frame(vty
, "ipv6 vpn");
17378 else if (safi
== SAFI_ENCAP
)
17379 vty_frame(vty
, "ipv6 encap");
17380 else if (safi
== SAFI_FLOWSPEC
)
17381 vty_frame(vty
, "ipv6 flowspec");
17382 } else if (afi
== AFI_L2VPN
) {
17383 if (safi
== SAFI_EVPN
)
17384 vty_frame(vty
, "l2vpn evpn");
17386 vty_frame(vty
, "\n");
17388 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17390 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17392 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17394 /* BGP flag dampening. */
17395 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17396 bgp_config_write_damp(vty
, afi
, safi
);
17398 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17399 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17401 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17402 /* Do not display doppelganger peers */
17403 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17404 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17407 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17408 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17410 if (safi
== SAFI_EVPN
)
17411 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17413 if (safi
== SAFI_FLOWSPEC
)
17414 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17416 if (safi
== SAFI_MPLS_VPN
)
17417 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17419 if (safi
== SAFI_UNICAST
) {
17420 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17421 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17422 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17424 vty_out(vty
, " export vpn\n");
17426 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17427 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17429 vty_out(vty
, " import vpn\n");
17431 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17432 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17435 for (ALL_LIST_ELEMENTS_RO(
17436 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17438 vty_out(vty
, " import vrf %s\n", name
);
17442 vty_endframe(vty
, " exit-address-family\n");
17445 int bgp_config_write(struct vty
*vty
)
17448 struct peer_group
*group
;
17450 struct listnode
*node
, *nnode
;
17451 struct listnode
*mnode
, *mnnode
;
17455 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17456 vty_out(vty
, "bgp route-map delay-timer %u\n",
17457 bm
->rmap_update_timer
);
17459 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17460 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17461 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17462 vty_out(vty
, " %d", bm
->v_establish_wait
);
17463 vty_out(vty
, "\n");
17466 if (bm
->wait_for_fib
)
17467 vty_out(vty
, "bgp suppress-fib-pending\n");
17469 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17470 vty_out(vty
, "bgp graceful-shutdown\n");
17472 /* No-RIB (Zebra) option flag configuration */
17473 if (bgp_option_check(BGP_OPT_NO_FIB
))
17474 vty_out(vty
, "bgp no-rib\n");
17476 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17477 vty_out(vty
, "bgp send-extra-data zebra\n");
17479 /* BGP session DSCP value */
17480 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17481 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17483 /* BGP configuration. */
17484 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17486 /* skip all auto created vrf as they dont have user config */
17487 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17490 /* Router bgp ASN */
17491 vty_out(vty
, "router bgp %u", bgp
->as
);
17494 vty_out(vty
, " %s %s",
17495 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17496 ? "view" : "vrf", bgp
->name
);
17497 vty_out(vty
, "\n");
17499 /* BGP fast-external-failover. */
17500 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17501 vty_out(vty
, " no bgp fast-external-failover\n");
17503 /* BGP router ID. */
17504 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17505 vty_out(vty
, " bgp router-id %pI4\n",
17506 &bgp
->router_id_static
);
17508 /* Suppress fib pending */
17509 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17510 vty_out(vty
, " bgp suppress-fib-pending\n");
17512 /* BGP log-neighbor-changes. */
17513 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17514 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17515 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17516 CHECK_FLAG(bgp
->flags
,
17517 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17521 /* BGP configuration. */
17522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17523 vty_out(vty
, " bgp always-compare-med\n");
17525 /* RFC8212 default eBGP policy. */
17526 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17527 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17528 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17529 CHECK_FLAG(bgp
->flags
,
17530 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17534 /* draft-ietf-idr-deprecate-as-set-confed-set */
17535 if (bgp
->reject_as_sets
)
17536 vty_out(vty
, " bgp reject-as-sets\n");
17538 /* Suppress duplicate updates if the route actually not changed
17540 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17541 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17542 vty_out(vty
, " %sbgp suppress-duplicates\n",
17543 CHECK_FLAG(bgp
->flags
,
17544 BGP_FLAG_SUPPRESS_DUPLICATES
)
17548 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17550 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17551 SAVE_BGP_HARD_ADMIN_RESET
)
17552 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17553 CHECK_FLAG(bgp
->flags
,
17554 BGP_FLAG_HARD_ADMIN_RESET
)
17558 /* BGP default <afi>-<safi> */
17559 FOREACH_AFI_SAFI (afi
, safi
) {
17560 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17561 if (!bgp
->default_af
[afi
][safi
])
17562 vty_out(vty
, " no bgp default %s\n",
17563 get_bgp_default_af_flag(afi
,
17565 } else if (bgp
->default_af
[afi
][safi
])
17566 vty_out(vty
, " bgp default %s\n",
17567 get_bgp_default_af_flag(afi
, safi
));
17570 /* BGP default local-preference. */
17571 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17572 vty_out(vty
, " bgp default local-preference %u\n",
17573 bgp
->default_local_pref
);
17575 /* BGP default show-hostname */
17576 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17577 != SAVE_BGP_SHOW_HOSTNAME
)
17578 vty_out(vty
, " %sbgp default show-hostname\n",
17579 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17583 /* BGP default show-nexthop-hostname */
17584 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17585 != SAVE_BGP_SHOW_HOSTNAME
)
17586 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17587 CHECK_FLAG(bgp
->flags
,
17588 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17592 /* BGP default subgroup-pkt-queue-max. */
17593 if (bgp
->default_subgroup_pkt_queue_max
17594 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17595 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17596 bgp
->default_subgroup_pkt_queue_max
);
17598 /* BGP client-to-client reflection. */
17599 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17600 vty_out(vty
, " no bgp client-to-client reflection\n");
17602 /* BGP cluster ID. */
17603 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17604 vty_out(vty
, " bgp cluster-id %pI4\n",
17607 /* Disable ebgp connected nexthop check */
17608 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17610 " bgp disable-ebgp-connected-route-check\n");
17612 /* Confederation identifier*/
17613 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17614 vty_out(vty
, " bgp confederation identifier %u\n",
17617 /* Confederation peer */
17618 if (bgp
->confed_peers_cnt
> 0) {
17621 vty_out(vty
, " bgp confederation peers");
17623 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17624 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17626 vty_out(vty
, "\n");
17629 /* BGP deterministic-med. */
17630 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17631 != SAVE_BGP_DETERMINISTIC_MED
)
17632 vty_out(vty
, " %sbgp deterministic-med\n",
17633 CHECK_FLAG(bgp
->flags
,
17634 BGP_FLAG_DETERMINISTIC_MED
)
17638 /* BGP update-delay. */
17639 bgp_config_write_update_delay(vty
, bgp
);
17641 if (bgp
->v_maxmed_onstartup
17642 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17643 vty_out(vty
, " bgp max-med on-startup %u",
17644 bgp
->v_maxmed_onstartup
);
17645 if (bgp
->maxmed_onstartup_value
17646 != BGP_MAXMED_VALUE_DEFAULT
)
17647 vty_out(vty
, " %u",
17648 bgp
->maxmed_onstartup_value
);
17649 vty_out(vty
, "\n");
17651 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17652 vty_out(vty
, " bgp max-med administrative");
17653 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17654 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17655 vty_out(vty
, "\n");
17659 bgp_config_write_wpkt_quanta(vty
, bgp
);
17661 bgp_config_write_rpkt_quanta(vty
, bgp
);
17663 /* coalesce time */
17664 bgp_config_write_coalesce_time(vty
, bgp
);
17666 /* BGP per-instance graceful-shutdown */
17667 /* BGP-wide settings and per-instance settings are mutually
17670 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17671 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17672 vty_out(vty
, " bgp graceful-shutdown\n");
17674 /* Long-lived Graceful Restart */
17675 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17677 " bgp long-lived-graceful-restart stale-time %u\n",
17678 bgp
->llgr_stale_time
);
17680 /* BGP graceful-restart. */
17681 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17683 " bgp graceful-restart stalepath-time %u\n",
17684 bgp
->stalepath_time
);
17686 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17687 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17688 bgp
->restart_time
);
17690 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17691 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17692 vty_out(vty
, " %sbgp graceful-restart notification\n",
17693 CHECK_FLAG(bgp
->flags
,
17694 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17698 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17700 " bgp graceful-restart select-defer-time %u\n",
17701 bgp
->select_defer_time
);
17703 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17704 vty_out(vty
, " bgp graceful-restart\n");
17706 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17707 vty_out(vty
, " bgp graceful-restart-disable\n");
17709 /* BGP graceful-restart Preserve State F bit. */
17710 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17712 " bgp graceful-restart preserve-fw-state\n");
17714 /* Stale timer for RIB */
17715 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17717 " bgp graceful-restart rib-stale-time %u\n",
17718 bgp
->rib_stale_time
);
17720 /* BGP bestpath method. */
17721 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17722 vty_out(vty
, " bgp bestpath as-path ignore\n");
17723 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17724 vty_out(vty
, " bgp bestpath as-path confed\n");
17726 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17727 if (CHECK_FLAG(bgp
->flags
,
17728 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17730 " bgp bestpath as-path multipath-relax as-set\n");
17733 " bgp bestpath as-path multipath-relax\n");
17737 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17739 " bgp route-reflector allow-outbound-policy\n");
17741 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17742 vty_out(vty
, " bgp bestpath compare-routerid\n");
17743 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17744 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17745 vty_out(vty
, " bgp bestpath med");
17746 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17747 vty_out(vty
, " confed");
17748 if (CHECK_FLAG(bgp
->flags
,
17749 BGP_FLAG_MED_MISSING_AS_WORST
))
17750 vty_out(vty
, " missing-as-worst");
17751 vty_out(vty
, "\n");
17754 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17756 " bgp bestpath peer-type multipath-relax\n");
17758 /* Link bandwidth handling. */
17759 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17760 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17761 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17762 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17763 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17764 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17766 /* BGP network import check. */
17767 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17768 != SAVE_BGP_IMPORT_CHECK
)
17769 vty_out(vty
, " %sbgp network import-check\n",
17770 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17774 /* BGP timers configuration. */
17775 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17776 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17777 vty_out(vty
, " timers bgp %u %u\n",
17778 bgp
->default_keepalive
, bgp
->default_holdtime
);
17780 /* BGP minimum holdtime configuration. */
17781 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17782 && bgp
->default_min_holdtime
!= 0)
17783 vty_out(vty
, " bgp minimum-holdtime %u\n",
17784 bgp
->default_min_holdtime
);
17786 /* Conditional advertisement timer configuration */
17787 if (bgp
->condition_check_period
17788 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17790 " bgp conditional-advertisement timer %u\n",
17791 bgp
->condition_check_period
);
17794 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17795 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17798 /* Normal neighbor configuration. */
17799 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17800 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17801 bgp_config_write_peer_global(vty
, bgp
, peer
);
17804 /* listen range and limit for dynamic BGP neighbors */
17805 bgp_config_write_listen(vty
, bgp
);
17808 * BGP default autoshutdown neighbors
17810 * This must be placed after any peer and peer-group
17811 * configuration, to avoid setting all peers to shutdown after
17812 * a daemon restart, which is undesired behavior. (see #2286)
17814 if (bgp
->autoshutdown
)
17815 vty_out(vty
, " bgp default shutdown\n");
17817 /* BGP instance administrative shutdown */
17818 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17819 vty_out(vty
, " bgp shutdown\n");
17821 if (bgp
->allow_martian
)
17822 vty_out(vty
, " bgp allow-martian-nexthop\n");
17824 if (bgp
->fast_convergence
)
17825 vty_out(vty
, " bgp fast-convergence\n");
17827 if (bgp
->srv6_enabled
) {
17828 vty_frame(vty
, " !\n segment-routing srv6\n");
17829 if (strlen(bgp
->srv6_locator_name
))
17830 vty_out(vty
, " locator %s\n",
17831 bgp
->srv6_locator_name
);
17832 vty_endframe(vty
, " exit\n");
17836 /* IPv4 unicast configuration. */
17837 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17839 /* IPv4 multicast configuration. */
17840 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17842 /* IPv4 labeled-unicast configuration. */
17843 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17845 /* IPv4 VPN configuration. */
17846 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17848 /* ENCAPv4 configuration. */
17849 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17851 /* FLOWSPEC v4 configuration. */
17852 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17854 /* IPv6 unicast configuration. */
17855 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17857 /* IPv6 multicast configuration. */
17858 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17860 /* IPv6 labeled-unicast configuration. */
17861 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17862 SAFI_LABELED_UNICAST
);
17864 /* IPv6 VPN configuration. */
17865 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17867 /* ENCAPv6 configuration. */
17868 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17870 /* FLOWSPEC v6 configuration. */
17871 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17873 /* EVPN configuration. */
17874 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17876 hook_call(bgp_inst_config_write
, bgp
, vty
);
17878 #ifdef ENABLE_BGP_VNC
17879 bgp_rfapi_cfg_write(vty
, bgp
);
17882 vty_out(vty
, "exit\n");
17883 vty_out(vty
, "!\n");
17889 /* BGP node structure. */
17890 static struct cmd_node bgp_node
= {
17893 .parent_node
= CONFIG_NODE
,
17894 .prompt
= "%s(config-router)# ",
17895 .config_write
= bgp_config_write
,
17898 static struct cmd_node bgp_ipv4_unicast_node
= {
17899 .name
= "bgp ipv4 unicast",
17900 .node
= BGP_IPV4_NODE
,
17901 .parent_node
= BGP_NODE
,
17902 .prompt
= "%s(config-router-af)# ",
17906 static struct cmd_node bgp_ipv4_multicast_node
= {
17907 .name
= "bgp ipv4 multicast",
17908 .node
= BGP_IPV4M_NODE
,
17909 .parent_node
= BGP_NODE
,
17910 .prompt
= "%s(config-router-af)# ",
17914 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17915 .name
= "bgp ipv4 labeled unicast",
17916 .node
= BGP_IPV4L_NODE
,
17917 .parent_node
= BGP_NODE
,
17918 .prompt
= "%s(config-router-af)# ",
17922 static struct cmd_node bgp_ipv6_unicast_node
= {
17923 .name
= "bgp ipv6 unicast",
17924 .node
= BGP_IPV6_NODE
,
17925 .parent_node
= BGP_NODE
,
17926 .prompt
= "%s(config-router-af)# ",
17930 static struct cmd_node bgp_ipv6_multicast_node
= {
17931 .name
= "bgp ipv6 multicast",
17932 .node
= BGP_IPV6M_NODE
,
17933 .parent_node
= BGP_NODE
,
17934 .prompt
= "%s(config-router-af)# ",
17938 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17939 .name
= "bgp ipv6 labeled unicast",
17940 .node
= BGP_IPV6L_NODE
,
17941 .parent_node
= BGP_NODE
,
17942 .prompt
= "%s(config-router-af)# ",
17946 static struct cmd_node bgp_vpnv4_node
= {
17947 .name
= "bgp vpnv4",
17948 .node
= BGP_VPNV4_NODE
,
17949 .parent_node
= BGP_NODE
,
17950 .prompt
= "%s(config-router-af)# ",
17954 static struct cmd_node bgp_vpnv6_node
= {
17955 .name
= "bgp vpnv6",
17956 .node
= BGP_VPNV6_NODE
,
17957 .parent_node
= BGP_NODE
,
17958 .prompt
= "%s(config-router-af-vpnv6)# ",
17962 static struct cmd_node bgp_evpn_node
= {
17963 .name
= "bgp evpn",
17964 .node
= BGP_EVPN_NODE
,
17965 .parent_node
= BGP_NODE
,
17966 .prompt
= "%s(config-router-evpn)# ",
17970 static struct cmd_node bgp_evpn_vni_node
= {
17971 .name
= "bgp evpn vni",
17972 .node
= BGP_EVPN_VNI_NODE
,
17973 .parent_node
= BGP_EVPN_NODE
,
17974 .prompt
= "%s(config-router-af-vni)# ",
17977 static struct cmd_node bgp_flowspecv4_node
= {
17978 .name
= "bgp ipv4 flowspec",
17979 .node
= BGP_FLOWSPECV4_NODE
,
17980 .parent_node
= BGP_NODE
,
17981 .prompt
= "%s(config-router-af)# ",
17985 static struct cmd_node bgp_flowspecv6_node
= {
17986 .name
= "bgp ipv6 flowspec",
17987 .node
= BGP_FLOWSPECV6_NODE
,
17988 .parent_node
= BGP_NODE
,
17989 .prompt
= "%s(config-router-af-vpnv6)# ",
17993 static struct cmd_node bgp_srv6_node
= {
17994 .name
= "bgp srv6",
17995 .node
= BGP_SRV6_NODE
,
17996 .parent_node
= BGP_NODE
,
17997 .prompt
= "%s(config-router-srv6)# ",
18000 static void community_list_vty(void);
18002 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18005 struct peer_group
*group
;
18006 struct listnode
*lnbgp
, *lnpeer
;
18008 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18009 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18011 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18015 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18019 struct listnode
*lnbgp
, *lnpeer
;
18021 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18022 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18023 /* only provide suggestions on the appropriate input
18025 * they'll otherwise show up multiple times */
18026 enum cmd_token_type match_type
;
18027 char *name
= peer
->host
;
18029 if (peer
->conf_if
) {
18030 match_type
= VARIABLE_TKN
;
18031 name
= peer
->conf_if
;
18032 } else if (strchr(peer
->host
, ':'))
18033 match_type
= IPV6_TKN
;
18035 match_type
= IPV4_TKN
;
18037 if (token
->type
!= match_type
)
18040 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18045 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18047 bgp_ac_peer(comps
, token
);
18049 if (token
->type
== VARIABLE_TKN
)
18050 bgp_ac_peergroup(comps
, token
);
18053 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18054 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18055 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18056 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18057 {.completions
= NULL
}};
18059 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18060 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18061 {.completions
= NULL
} };
18063 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18065 static struct thread
*t_bgp_cfg
;
18067 bool bgp_config_inprocess(void)
18069 return thread_is_scheduled(t_bgp_cfg
);
18072 static void bgp_config_finish(struct thread
*t
)
18074 struct listnode
*node
;
18077 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18078 hook_call(bgp_config_end
, bgp
);
18081 static void bgp_config_start(void)
18083 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18084 THREAD_OFF(t_bgp_cfg
);
18085 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18086 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18089 /* When we receive a hook the configuration is read,
18090 * we start a timer to make sure we postpone sending
18091 * EoR before route-maps are processed.
18092 * This is especially valid if using `bgp route-map delay-timer`.
18094 static void bgp_config_end(void)
18096 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18097 uint32_t bgp_post_config_delay
=
18098 thread_is_scheduled(bm
->t_rmap_update
)
18099 ? thread_timer_remain_second(bm
->t_rmap_update
)
18100 : BGP_POST_CONFIG_DELAY_SECONDS
;
18102 /* If BGP config processing thread isn't running, then
18103 * we can return and rely it's properly handled.
18105 if (!bgp_config_inprocess())
18108 THREAD_OFF(t_bgp_cfg
);
18110 /* Start a new timer to make sure we don't send EoR
18111 * before route-maps are processed.
18113 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18114 bgp_post_config_delay
, &t_bgp_cfg
);
18117 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18120 struct interface
*ifp
;
18121 struct bgp_interface
*iifp
;
18123 FOR_ALL_INTERFACES (vrf
, ifp
) {
18128 if_vty_config_start(vty
, ifp
);
18130 if (CHECK_FLAG(iifp
->flags
,
18131 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18132 vty_out(vty
, " mpls bgp forwarding\n");
18136 if_vty_config_end(vty
);
18142 /* Configuration write function for bgpd. */
18143 static int config_write_interface(struct vty
*vty
)
18146 struct vrf
*vrf
= NULL
;
18148 /* Display all VRF aware OSPF interface configuration */
18149 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18150 write
+= config_write_interface_one(vty
, vrf
);
18156 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18157 "[no$no] mpls bgp forwarding",
18158 NO_STR MPLS_STR BGP_STR
18159 "Enable MPLS forwarding for eBGP directly connected peers\n")
18162 struct bgp_interface
*iifp
;
18164 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18167 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18168 return CMD_WARNING_CONFIG_FAILED
;
18170 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18171 if (check
!= !no
) {
18173 UNSET_FLAG(iifp
->flags
,
18174 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18176 SET_FLAG(iifp
->flags
,
18177 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18178 /* trigger a nht update on eBGP sessions */
18179 if (if_is_operative(ifp
))
18180 bgp_nht_ifp_up(ifp
);
18182 return CMD_SUCCESS
;
18185 /* Initialization of BGP interface. */
18186 static void bgp_vty_if_init(void)
18188 /* Install interface node. */
18189 if_cmd_init(config_write_interface
);
18191 /* "mpls bgp forwarding" commands. */
18192 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18195 void bgp_vty_init(void)
18197 cmd_variable_handler_register(bgp_var_neighbor
);
18198 cmd_variable_handler_register(bgp_var_peergroup
);
18200 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18202 /* Install bgp top node. */
18203 install_node(&bgp_node
);
18204 install_node(&bgp_ipv4_unicast_node
);
18205 install_node(&bgp_ipv4_multicast_node
);
18206 install_node(&bgp_ipv4_labeled_unicast_node
);
18207 install_node(&bgp_ipv6_unicast_node
);
18208 install_node(&bgp_ipv6_multicast_node
);
18209 install_node(&bgp_ipv6_labeled_unicast_node
);
18210 install_node(&bgp_vpnv4_node
);
18211 install_node(&bgp_vpnv6_node
);
18212 install_node(&bgp_evpn_node
);
18213 install_node(&bgp_evpn_vni_node
);
18214 install_node(&bgp_flowspecv4_node
);
18215 install_node(&bgp_flowspecv6_node
);
18216 install_node(&bgp_srv6_node
);
18218 /* Install default VTY commands to new nodes. */
18219 install_default(BGP_NODE
);
18220 install_default(BGP_IPV4_NODE
);
18221 install_default(BGP_IPV4M_NODE
);
18222 install_default(BGP_IPV4L_NODE
);
18223 install_default(BGP_IPV6_NODE
);
18224 install_default(BGP_IPV6M_NODE
);
18225 install_default(BGP_IPV6L_NODE
);
18226 install_default(BGP_VPNV4_NODE
);
18227 install_default(BGP_VPNV6_NODE
);
18228 install_default(BGP_FLOWSPECV4_NODE
);
18229 install_default(BGP_FLOWSPECV6_NODE
);
18230 install_default(BGP_EVPN_NODE
);
18231 install_default(BGP_EVPN_VNI_NODE
);
18232 install_default(BGP_SRV6_NODE
);
18234 /* "bgp local-mac" hidden commands. */
18235 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18236 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18238 /* "bgp suppress-fib-pending" global */
18239 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18241 /* bgp route-map delay-timer commands. */
18242 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18243 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18245 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18247 /* bgp fast-convergence command */
18248 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18249 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18251 /* global bgp update-delay command */
18252 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18253 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18255 /* global bgp graceful-shutdown command */
18256 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18257 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18259 /* Dummy commands (Currently not supported) */
18260 install_element(BGP_NODE
, &no_synchronization_cmd
);
18261 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18263 /* "router bgp" commands. */
18264 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18266 /* "no router bgp" commands. */
18267 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18269 /* "bgp session-dscp command */
18270 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18271 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18273 /* "bgp router-id" commands. */
18274 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18275 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18277 /* "bgp suppress-fib-pending" command */
18278 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18280 /* "bgp cluster-id" commands. */
18281 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18282 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18284 /* "bgp no-rib" commands. */
18285 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18286 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18288 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18290 /* "bgp confederation" commands. */
18291 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18292 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18294 /* "bgp confederation peers" commands. */
18295 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18296 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18298 /* bgp max-med command */
18299 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18300 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18301 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18302 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18303 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18305 /* "neighbor role" commands. */
18306 install_element(BGP_NODE
, &neighbor_role_cmd
);
18307 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18308 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18310 /* bgp disable-ebgp-connected-nh-check */
18311 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18312 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18314 /* bgp update-delay command */
18315 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18316 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18318 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18319 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18321 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18322 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18324 /* "maximum-paths" commands. */
18325 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18326 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18327 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18328 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18329 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18330 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18331 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18332 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18333 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18334 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18335 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18336 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18337 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18338 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18339 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18341 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18342 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18343 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18344 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18345 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18346 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18347 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18348 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18349 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18350 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18352 /* "timers bgp" commands. */
18353 install_element(BGP_NODE
, &bgp_timers_cmd
);
18354 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18356 /* "minimum-holdtime" commands. */
18357 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18358 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18360 /* route-map delay-timer commands - per instance for backwards compat.
18362 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18363 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18365 /* "bgp client-to-client reflection" commands */
18366 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18367 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18369 /* "bgp always-compare-med" commands */
18370 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18371 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18373 /* bgp ebgp-requires-policy */
18374 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18375 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18377 /* bgp suppress-duplicates */
18378 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18379 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18381 /* bgp reject-as-sets */
18382 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18383 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18385 /* "bgp deterministic-med" commands */
18386 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18387 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18389 /* "bgp graceful-restart" command */
18390 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18391 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18393 /* "bgp graceful-restart-disable" command */
18394 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18395 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18397 /* "neighbor a:b:c:d graceful-restart" command */
18398 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18399 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18401 /* "neighbor a:b:c:d graceful-restart-disable" command */
18402 install_element(BGP_NODE
,
18403 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18404 install_element(BGP_NODE
,
18405 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18407 /* "neighbor a:b:c:d graceful-restart-helper" command */
18408 install_element(BGP_NODE
,
18409 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18410 install_element(BGP_NODE
,
18411 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18413 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18414 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18415 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18416 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18417 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18418 install_element(BGP_NODE
,
18419 &no_bgp_graceful_restart_select_defer_time_cmd
);
18420 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18421 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18422 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18424 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18425 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18426 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18427 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18429 /* "bgp graceful-shutdown" commands */
18430 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18431 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18433 /* "bgp hard-administrative-reset" commands */
18434 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18436 /* "bgp long-lived-graceful-restart" commands */
18437 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18438 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18440 /* "bgp fast-external-failover" commands */
18441 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18442 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18444 /* "bgp bestpath compare-routerid" commands */
18445 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18446 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18448 /* "bgp bestpath as-path ignore" commands */
18449 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18450 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18452 /* "bgp bestpath as-path confed" commands */
18453 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18454 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18456 /* "bgp bestpath as-path multipath-relax" commands */
18457 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18458 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18460 /* "bgp bestpath peer-type multipath-relax" commands */
18461 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18462 install_element(BGP_NODE
,
18463 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18465 /* "bgp log-neighbor-changes" commands */
18466 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18467 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18469 /* "bgp bestpath med" commands */
18470 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18471 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18473 /* "bgp bestpath bandwidth" commands */
18474 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18475 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18477 /* "no bgp default <afi>-<safi>" commands. */
18478 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18480 /* "bgp network import-check" commands. */
18481 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18482 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18483 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18485 /* "bgp default local-preference" commands. */
18486 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18487 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18489 /* bgp default show-hostname */
18490 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18491 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18493 /* bgp default show-nexthop-hostname */
18494 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18495 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18497 /* "bgp default subgroup-pkt-queue-max" commands. */
18498 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18499 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18501 /* bgp ibgp-allow-policy-mods command */
18502 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18503 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18505 /* "bgp listen limit" commands. */
18506 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18507 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18509 /* "bgp listen range" commands. */
18510 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18511 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18513 /* "bgp default shutdown" command */
18514 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18516 /* "bgp shutdown" commands */
18517 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18518 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18519 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18520 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18522 /* "neighbor remote-as" commands. */
18523 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18524 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18525 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18526 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18527 install_element(BGP_NODE
,
18528 &neighbor_interface_v6only_config_remote_as_cmd
);
18529 install_element(BGP_NODE
, &no_neighbor_cmd
);
18530 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18532 /* "neighbor peer-group" commands. */
18533 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18534 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18535 install_element(BGP_NODE
,
18536 &no_neighbor_interface_peer_group_remote_as_cmd
);
18538 /* "neighbor local-as" commands. */
18539 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18540 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18541 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18542 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18544 /* "neighbor solo" commands. */
18545 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18546 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18548 /* "neighbor password" commands. */
18549 install_element(BGP_NODE
, &neighbor_password_cmd
);
18550 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18552 /* "neighbor activate" commands. */
18553 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18554 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18555 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18556 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18557 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18558 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18559 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18560 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18561 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18562 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18563 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18564 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18566 /* "no neighbor activate" commands. */
18567 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18568 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18569 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18570 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18571 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18572 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18573 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18574 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18575 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18576 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18577 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18578 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18580 /* "neighbor peer-group" set commands. */
18581 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18582 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18583 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18584 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18585 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18586 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18587 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18588 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18589 install_element(BGP_FLOWSPECV4_NODE
,
18590 &neighbor_set_peer_group_hidden_cmd
);
18591 install_element(BGP_FLOWSPECV6_NODE
,
18592 &neighbor_set_peer_group_hidden_cmd
);
18594 /* "no neighbor peer-group unset" commands. */
18595 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18596 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18597 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18598 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18599 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18600 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18601 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18602 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18603 install_element(BGP_FLOWSPECV4_NODE
,
18604 &no_neighbor_set_peer_group_hidden_cmd
);
18605 install_element(BGP_FLOWSPECV6_NODE
,
18606 &no_neighbor_set_peer_group_hidden_cmd
);
18608 /* "neighbor softreconfiguration inbound" commands.*/
18609 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18610 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18611 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18612 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18613 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18614 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18615 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18616 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18617 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18618 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18619 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18620 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18621 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18622 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18623 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18624 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18625 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18626 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18627 install_element(BGP_FLOWSPECV4_NODE
,
18628 &neighbor_soft_reconfiguration_cmd
);
18629 install_element(BGP_FLOWSPECV4_NODE
,
18630 &no_neighbor_soft_reconfiguration_cmd
);
18631 install_element(BGP_FLOWSPECV6_NODE
,
18632 &neighbor_soft_reconfiguration_cmd
);
18633 install_element(BGP_FLOWSPECV6_NODE
,
18634 &no_neighbor_soft_reconfiguration_cmd
);
18635 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18636 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18638 /* "neighbor attribute-unchanged" commands. */
18639 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18640 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18641 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18642 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18643 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18644 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18645 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18646 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18647 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18648 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18649 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18650 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18651 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18652 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18653 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18654 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18655 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18656 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18658 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18659 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18661 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18662 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18663 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18664 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18666 /* "nexthop-local unchanged" commands */
18667 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18668 install_element(BGP_IPV6_NODE
,
18669 &no_neighbor_nexthop_local_unchanged_cmd
);
18671 /* "neighbor next-hop-self" commands. */
18672 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18673 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18674 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18675 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18676 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18677 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18678 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18679 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18680 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18681 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18682 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18683 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18684 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18685 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18686 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18687 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18688 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18689 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18690 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18691 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18693 /* "neighbor next-hop-self force" commands. */
18694 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18695 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18696 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18697 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18698 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18699 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18700 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18701 install_element(BGP_IPV4_NODE
,
18702 &no_neighbor_nexthop_self_all_hidden_cmd
);
18703 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18704 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18705 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18706 install_element(BGP_IPV4M_NODE
,
18707 &no_neighbor_nexthop_self_all_hidden_cmd
);
18708 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18709 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18710 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18711 install_element(BGP_IPV4L_NODE
,
18712 &no_neighbor_nexthop_self_all_hidden_cmd
);
18713 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18714 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18715 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18716 install_element(BGP_IPV6_NODE
,
18717 &no_neighbor_nexthop_self_all_hidden_cmd
);
18718 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18719 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18720 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18721 install_element(BGP_IPV6M_NODE
,
18722 &no_neighbor_nexthop_self_all_hidden_cmd
);
18723 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18724 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18725 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18726 install_element(BGP_IPV6L_NODE
,
18727 &no_neighbor_nexthop_self_all_hidden_cmd
);
18728 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18729 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18730 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18731 install_element(BGP_VPNV4_NODE
,
18732 &no_neighbor_nexthop_self_all_hidden_cmd
);
18733 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18734 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18735 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18736 install_element(BGP_VPNV6_NODE
,
18737 &no_neighbor_nexthop_self_all_hidden_cmd
);
18738 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18739 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18741 /* "neighbor as-override" commands. */
18742 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18743 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18744 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18745 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18746 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18747 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18748 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18749 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18750 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18751 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18752 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18753 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18754 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18755 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18756 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18757 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18758 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18761 /* "neighbor remove-private-AS" commands. */
18762 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18763 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18764 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18765 install_element(BGP_NODE
,
18766 &no_neighbor_remove_private_as_all_hidden_cmd
);
18767 install_element(BGP_NODE
,
18768 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18769 install_element(BGP_NODE
,
18770 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18771 install_element(BGP_NODE
,
18772 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18775 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18776 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18777 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18778 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18779 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18780 install_element(BGP_IPV4_NODE
,
18781 &neighbor_remove_private_as_replace_as_cmd
);
18782 install_element(BGP_IPV4_NODE
,
18783 &no_neighbor_remove_private_as_replace_as_cmd
);
18784 install_element(BGP_IPV4_NODE
,
18785 &neighbor_remove_private_as_all_replace_as_cmd
);
18786 install_element(BGP_IPV4_NODE
,
18787 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18788 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18789 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18790 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18791 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18792 install_element(BGP_IPV4M_NODE
,
18793 &neighbor_remove_private_as_replace_as_cmd
);
18794 install_element(BGP_IPV4M_NODE
,
18795 &no_neighbor_remove_private_as_replace_as_cmd
);
18796 install_element(BGP_IPV4M_NODE
,
18797 &neighbor_remove_private_as_all_replace_as_cmd
);
18798 install_element(BGP_IPV4M_NODE
,
18799 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18800 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18801 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18802 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18803 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18804 install_element(BGP_IPV4L_NODE
,
18805 &neighbor_remove_private_as_replace_as_cmd
);
18806 install_element(BGP_IPV4L_NODE
,
18807 &no_neighbor_remove_private_as_replace_as_cmd
);
18808 install_element(BGP_IPV4L_NODE
,
18809 &neighbor_remove_private_as_all_replace_as_cmd
);
18810 install_element(BGP_IPV4L_NODE
,
18811 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18812 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18813 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18814 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18815 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18816 install_element(BGP_IPV6_NODE
,
18817 &neighbor_remove_private_as_replace_as_cmd
);
18818 install_element(BGP_IPV6_NODE
,
18819 &no_neighbor_remove_private_as_replace_as_cmd
);
18820 install_element(BGP_IPV6_NODE
,
18821 &neighbor_remove_private_as_all_replace_as_cmd
);
18822 install_element(BGP_IPV6_NODE
,
18823 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18824 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18825 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18826 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18827 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18828 install_element(BGP_IPV6M_NODE
,
18829 &neighbor_remove_private_as_replace_as_cmd
);
18830 install_element(BGP_IPV6M_NODE
,
18831 &no_neighbor_remove_private_as_replace_as_cmd
);
18832 install_element(BGP_IPV6M_NODE
,
18833 &neighbor_remove_private_as_all_replace_as_cmd
);
18834 install_element(BGP_IPV6M_NODE
,
18835 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18836 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18837 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18838 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18839 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18840 install_element(BGP_IPV6L_NODE
,
18841 &neighbor_remove_private_as_replace_as_cmd
);
18842 install_element(BGP_IPV6L_NODE
,
18843 &no_neighbor_remove_private_as_replace_as_cmd
);
18844 install_element(BGP_IPV6L_NODE
,
18845 &neighbor_remove_private_as_all_replace_as_cmd
);
18846 install_element(BGP_IPV6L_NODE
,
18847 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18848 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18849 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18850 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18851 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18852 install_element(BGP_VPNV4_NODE
,
18853 &neighbor_remove_private_as_replace_as_cmd
);
18854 install_element(BGP_VPNV4_NODE
,
18855 &no_neighbor_remove_private_as_replace_as_cmd
);
18856 install_element(BGP_VPNV4_NODE
,
18857 &neighbor_remove_private_as_all_replace_as_cmd
);
18858 install_element(BGP_VPNV4_NODE
,
18859 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18860 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18861 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18862 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18863 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18864 install_element(BGP_VPNV6_NODE
,
18865 &neighbor_remove_private_as_replace_as_cmd
);
18866 install_element(BGP_VPNV6_NODE
,
18867 &no_neighbor_remove_private_as_replace_as_cmd
);
18868 install_element(BGP_VPNV6_NODE
,
18869 &neighbor_remove_private_as_all_replace_as_cmd
);
18870 install_element(BGP_VPNV6_NODE
,
18871 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18873 /* "neighbor send-community" commands.*/
18874 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18875 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18876 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18877 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18878 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18879 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18880 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18881 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18882 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18883 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18884 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18885 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18886 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18887 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18888 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18889 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18890 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18891 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18892 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18893 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18894 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18895 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18896 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18897 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18898 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18899 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18900 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18901 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18902 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18903 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18904 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18905 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18906 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18907 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18908 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18909 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18911 /* "neighbor route-reflector" commands.*/
18912 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18913 install_element(BGP_NODE
,
18914 &no_neighbor_route_reflector_client_hidden_cmd
);
18915 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18916 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18917 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18918 install_element(BGP_IPV4M_NODE
,
18919 &no_neighbor_route_reflector_client_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18921 install_element(BGP_IPV4L_NODE
,
18922 &no_neighbor_route_reflector_client_cmd
);
18923 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18924 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18925 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18926 install_element(BGP_IPV6M_NODE
,
18927 &no_neighbor_route_reflector_client_cmd
);
18928 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18929 install_element(BGP_IPV6L_NODE
,
18930 &no_neighbor_route_reflector_client_cmd
);
18931 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18932 install_element(BGP_VPNV4_NODE
,
18933 &no_neighbor_route_reflector_client_cmd
);
18934 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18935 install_element(BGP_VPNV6_NODE
,
18936 &no_neighbor_route_reflector_client_cmd
);
18937 install_element(BGP_FLOWSPECV4_NODE
,
18938 &neighbor_route_reflector_client_cmd
);
18939 install_element(BGP_FLOWSPECV4_NODE
,
18940 &no_neighbor_route_reflector_client_cmd
);
18941 install_element(BGP_FLOWSPECV6_NODE
,
18942 &neighbor_route_reflector_client_cmd
);
18943 install_element(BGP_FLOWSPECV6_NODE
,
18944 &no_neighbor_route_reflector_client_cmd
);
18945 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18946 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18948 /* "neighbor route-server" commands.*/
18949 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18950 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18951 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18952 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18953 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18954 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18955 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18956 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18957 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18958 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18959 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18960 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18961 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18962 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18963 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18964 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18965 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18966 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18967 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18968 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18969 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18970 install_element(BGP_FLOWSPECV4_NODE
,
18971 &no_neighbor_route_server_client_cmd
);
18972 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18973 install_element(BGP_FLOWSPECV6_NODE
,
18974 &no_neighbor_route_server_client_cmd
);
18976 /* "neighbor disable-addpath-rx" commands. */
18977 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18978 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18979 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18980 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18981 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18982 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18983 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18984 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18985 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18986 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18987 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18988 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18989 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18990 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18991 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18992 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18994 /* "neighbor addpath-tx-all-paths" commands.*/
18995 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18996 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18997 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18998 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18999 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19000 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19001 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19002 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19003 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19004 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19005 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19006 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19007 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19008 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19009 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19010 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19011 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19012 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19014 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19015 install_element(BGP_NODE
,
19016 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19017 install_element(BGP_NODE
,
19018 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19019 install_element(BGP_IPV4_NODE
,
19020 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19021 install_element(BGP_IPV4_NODE
,
19022 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19023 install_element(BGP_IPV4M_NODE
,
19024 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19025 install_element(BGP_IPV4M_NODE
,
19026 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19027 install_element(BGP_IPV4L_NODE
,
19028 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19029 install_element(BGP_IPV4L_NODE
,
19030 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19031 install_element(BGP_IPV6_NODE
,
19032 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19033 install_element(BGP_IPV6_NODE
,
19034 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19035 install_element(BGP_IPV6M_NODE
,
19036 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19037 install_element(BGP_IPV6M_NODE
,
19038 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19039 install_element(BGP_IPV6L_NODE
,
19040 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19041 install_element(BGP_IPV6L_NODE
,
19042 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19043 install_element(BGP_VPNV4_NODE
,
19044 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19045 install_element(BGP_VPNV4_NODE
,
19046 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19047 install_element(BGP_VPNV6_NODE
,
19048 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19049 install_element(BGP_VPNV6_NODE
,
19050 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19052 /* "neighbor sender-as-path-loop-detection" commands. */
19053 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19054 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19056 /* "neighbor passive" commands. */
19057 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19058 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19061 /* "neighbor shutdown" commands. */
19062 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19063 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19064 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19065 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19066 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19067 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19069 /* "neighbor capability extended-nexthop" commands.*/
19070 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19071 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19073 /* "neighbor capability orf prefix-list" commands.*/
19074 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19075 install_element(BGP_NODE
,
19076 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19077 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19078 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19079 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19080 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19081 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19082 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19083 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19084 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19085 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19086 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19087 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19088 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19090 /* "neighbor capability dynamic" commands.*/
19091 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19092 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19094 /* "neighbor dont-capability-negotiate" commands. */
19095 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19096 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19098 /* "neighbor ebgp-multihop" commands. */
19099 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19100 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19101 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19103 /* "neighbor disable-connected-check" commands. */
19104 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19105 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19107 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19108 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19109 install_element(BGP_NODE
,
19110 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19112 /* "neighbor extended-optional-parameters" commands. */
19113 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19114 install_element(BGP_NODE
,
19115 &no_neighbor_extended_optional_parameters_cmd
);
19117 /* "neighbor enforce-first-as" commands. */
19118 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19119 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19121 /* "neighbor description" commands. */
19122 install_element(BGP_NODE
, &neighbor_description_cmd
);
19123 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19124 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19126 /* "neighbor update-source" commands. "*/
19127 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19128 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19130 /* "neighbor default-originate" commands. */
19131 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19132 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19133 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19134 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19135 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19136 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19137 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19138 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19139 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19140 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19141 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19142 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19143 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19144 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19145 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19146 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19147 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19148 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19149 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19150 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19151 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19153 /* "neighbor port" commands. */
19154 install_element(BGP_NODE
, &neighbor_port_cmd
);
19155 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19157 /* "neighbor weight" commands. */
19158 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19159 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19161 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19162 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19163 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19164 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19165 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19166 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19167 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19168 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19169 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19170 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19171 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19172 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19173 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19174 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19175 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19176 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19178 /* "neighbor override-capability" commands. */
19179 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19180 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19182 /* "neighbor strict-capability-match" commands. */
19183 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19184 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19186 /* "neighbor timers" commands. */
19187 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19188 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19190 /* "neighbor timers connect" commands. */
19191 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19192 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19194 /* "neighbor timers delayopen" commands. */
19195 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19196 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19198 /* "neighbor advertisement-interval" commands. */
19199 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19200 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19202 /* "neighbor interface" commands. */
19203 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19204 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19206 /* "neighbor distribute" commands. */
19207 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19208 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19209 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19210 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19211 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19212 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19213 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19214 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19215 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19216 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19217 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19218 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19219 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19220 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19221 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19222 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19223 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19224 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19226 /* "neighbor prefix-list" commands. */
19227 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19228 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19229 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19230 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19231 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19232 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19233 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19234 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19235 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19236 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19237 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19238 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19239 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19240 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19241 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19242 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19243 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19244 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19245 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19246 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19247 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19248 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19250 /* "neighbor filter-list" commands. */
19251 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19252 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19253 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19254 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19255 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19256 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19257 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19258 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19259 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19260 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19261 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19262 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19263 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19264 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19265 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19266 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19267 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19268 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19269 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19270 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19271 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19272 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19274 /* "neighbor route-map" commands. */
19275 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19276 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19277 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19278 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19279 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19280 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19281 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19282 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19283 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19284 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19285 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19286 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19287 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19288 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19289 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19290 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19291 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19292 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19293 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19294 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19295 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19296 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19297 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19298 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19300 /* "neighbor unsuppress-map" commands. */
19301 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19302 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19303 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19304 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19305 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19306 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19307 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19308 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19309 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19310 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19311 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19312 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19313 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19314 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19315 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19316 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19317 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19318 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19320 /* "neighbor advertise-map" commands. */
19321 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19322 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19323 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19324 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19325 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19326 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19327 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19328 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19329 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19330 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19332 /* neighbor maximum-prefix-out commands. */
19333 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19334 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19335 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19336 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19337 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19338 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19339 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19340 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19341 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19342 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19343 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19344 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19345 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19346 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19347 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19348 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19349 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19350 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19352 /* "neighbor maximum-prefix" commands. */
19353 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19354 install_element(BGP_NODE
,
19355 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19356 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19357 install_element(BGP_NODE
,
19358 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19359 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19360 install_element(BGP_NODE
,
19361 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19362 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19363 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19364 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19365 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19366 install_element(BGP_IPV4_NODE
,
19367 &neighbor_maximum_prefix_threshold_warning_cmd
);
19368 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19369 install_element(BGP_IPV4_NODE
,
19370 &neighbor_maximum_prefix_threshold_restart_cmd
);
19371 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19372 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19373 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19374 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19375 install_element(BGP_IPV4M_NODE
,
19376 &neighbor_maximum_prefix_threshold_warning_cmd
);
19377 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19378 install_element(BGP_IPV4M_NODE
,
19379 &neighbor_maximum_prefix_threshold_restart_cmd
);
19380 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19381 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19382 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19383 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19384 install_element(BGP_IPV4L_NODE
,
19385 &neighbor_maximum_prefix_threshold_warning_cmd
);
19386 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19387 install_element(BGP_IPV4L_NODE
,
19388 &neighbor_maximum_prefix_threshold_restart_cmd
);
19389 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19390 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19391 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19392 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19393 install_element(BGP_IPV6_NODE
,
19394 &neighbor_maximum_prefix_threshold_warning_cmd
);
19395 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19396 install_element(BGP_IPV6_NODE
,
19397 &neighbor_maximum_prefix_threshold_restart_cmd
);
19398 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19399 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19400 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19401 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19402 install_element(BGP_IPV6M_NODE
,
19403 &neighbor_maximum_prefix_threshold_warning_cmd
);
19404 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19405 install_element(BGP_IPV6M_NODE
,
19406 &neighbor_maximum_prefix_threshold_restart_cmd
);
19407 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19408 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19409 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19410 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19411 install_element(BGP_IPV6L_NODE
,
19412 &neighbor_maximum_prefix_threshold_warning_cmd
);
19413 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19414 install_element(BGP_IPV6L_NODE
,
19415 &neighbor_maximum_prefix_threshold_restart_cmd
);
19416 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19417 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19418 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19419 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19420 install_element(BGP_VPNV4_NODE
,
19421 &neighbor_maximum_prefix_threshold_warning_cmd
);
19422 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19423 install_element(BGP_VPNV4_NODE
,
19424 &neighbor_maximum_prefix_threshold_restart_cmd
);
19425 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19426 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19427 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19428 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19429 install_element(BGP_VPNV6_NODE
,
19430 &neighbor_maximum_prefix_threshold_warning_cmd
);
19431 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19432 install_element(BGP_VPNV6_NODE
,
19433 &neighbor_maximum_prefix_threshold_restart_cmd
);
19434 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19436 /* "neighbor allowas-in" */
19437 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19438 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19439 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19440 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19441 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19442 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19443 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19444 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19445 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19446 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19447 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19448 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19449 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19450 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19451 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19452 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19453 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19454 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19455 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19456 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19458 /* "neighbor soo" */
19459 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19460 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19461 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19462 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19463 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19464 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19465 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19466 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19467 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19468 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19469 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19470 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19471 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19472 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19473 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19474 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19475 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19476 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19478 /* address-family commands. */
19479 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19480 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19481 #ifdef KEEP_OLD_VPN_COMMANDS
19482 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19483 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19484 #endif /* KEEP_OLD_VPN_COMMANDS */
19486 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19488 /* "exit-address-family" command. */
19489 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19490 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19491 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19492 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19493 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19494 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19495 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19496 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19497 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19498 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19499 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19501 /* BGP retain all route-target */
19502 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19503 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19505 /* "clear ip bgp commands" */
19506 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19508 /* clear ip bgp prefix */
19509 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19510 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19511 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19513 /* "show [ip] bgp summary" commands. */
19514 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19515 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19516 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19517 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19518 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19519 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19520 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19522 /* "show [ip] bgp neighbors" commands. */
19523 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19525 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19527 /* "show [ip] bgp peer-group" commands. */
19528 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19530 /* "show [ip] bgp paths" commands. */
19531 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19533 /* "show [ip] bgp community" commands. */
19534 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19536 /* "show ip bgp large-community" commands. */
19537 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19538 /* "show [ip] bgp attribute-info" commands. */
19539 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19540 /* "show [ip] bgp route-leak" command */
19541 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19543 /* "redistribute" commands. */
19544 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19545 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19546 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19547 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19548 install_element(BGP_NODE
,
19549 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19550 install_element(BGP_NODE
,
19551 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19552 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19553 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19554 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19555 install_element(BGP_NODE
,
19556 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19557 install_element(BGP_NODE
,
19558 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19559 install_element(BGP_NODE
,
19560 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19561 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19562 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19563 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19564 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19565 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19566 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19567 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19568 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19569 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19570 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19571 install_element(BGP_IPV4_NODE
,
19572 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19573 install_element(BGP_IPV4_NODE
,
19574 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19575 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19576 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19577 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19578 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19579 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19580 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19582 /* import|export vpn [route-map RMAP_NAME] */
19583 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19584 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19586 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19587 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19589 /* ttl_security commands */
19590 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19591 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19593 /* "show [ip] bgp memory" commands. */
19594 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19596 /* "show bgp martian next-hop" */
19597 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19599 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19601 /* "show [ip] bgp views" commands. */
19602 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19604 /* "show [ip] bgp vrfs" commands. */
19605 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19607 /* Community-list. */
19608 community_list_vty();
19610 community_alias_vty();
19612 /* vpn-policy commands */
19613 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19614 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19615 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19616 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19617 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19618 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19619 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19620 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19621 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19622 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19623 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19624 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19626 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19627 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19629 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19630 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19631 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19632 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19633 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19634 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19635 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19636 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19637 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19638 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19640 /* tcp-mss command */
19641 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19642 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19644 /* srv6 commands */
19645 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19646 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19647 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19648 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19649 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19650 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19651 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19656 #include "memory.h"
19657 #include "bgp_regex.h"
19658 #include "bgp_clist.h"
19659 #include "bgp_ecommunity.h"
19661 /* VTY functions. */
19663 /* Direction value to string conversion. */
19664 static const char *community_direct_str(int direct
)
19667 case COMMUNITY_DENY
:
19669 case COMMUNITY_PERMIT
:
19676 /* Display error string. */
19677 static void community_list_perror(struct vty
*vty
, int ret
)
19680 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19681 vty_out(vty
, "%% Can't find community-list\n");
19683 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19684 vty_out(vty
, "%% Malformed community-list value\n");
19686 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19688 "%% Community name conflict, previously defined as standard community\n");
19690 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19692 "%% Community name conflict, previously defined as expanded community\n");
19697 /* "community-list" keyword help string. */
19698 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19700 /*community-list standard */
19701 DEFUN (community_list_standard
,
19702 bgp_community_list_standard_cmd
,
19703 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19706 "Community list number (standard)\n"
19707 "Add an standard community-list entry\n"
19708 "Community list name\n"
19709 "Sequence number of an entry\n"
19710 "Sequence number\n"
19711 "Specify community to reject\n"
19712 "Specify community to accept\n"
19715 char *cl_name_or_number
= NULL
;
19718 int style
= COMMUNITY_LIST_STANDARD
;
19721 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19722 seq
= argv
[idx
]->arg
;
19725 argv_find(argv
, argc
, "(1-99)", &idx
);
19726 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19727 cl_name_or_number
= argv
[idx
]->arg
;
19728 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19730 argv_find(argv
, argc
, "AA:NN", &idx
);
19731 char *str
= argv_concat(argv
, argc
, idx
);
19733 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19736 XFREE(MTYPE_TMP
, str
);
19739 /* Display error string. */
19740 community_list_perror(vty
, ret
);
19741 return CMD_WARNING_CONFIG_FAILED
;
19744 return CMD_SUCCESS
;
19747 DEFUN (no_community_list_standard_all
,
19748 no_bgp_community_list_standard_all_cmd
,
19749 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19753 "Community list number (standard)\n"
19754 "Add an standard community-list entry\n"
19755 "Community list name\n"
19756 "Sequence number of an entry\n"
19757 "Sequence number\n"
19758 "Specify community to reject\n"
19759 "Specify community to accept\n"
19762 char *cl_name_or_number
= NULL
;
19765 int style
= COMMUNITY_LIST_STANDARD
;
19769 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19770 seq
= argv
[idx
]->arg
;
19773 argv_find(argv
, argc
, "permit", &idx
);
19774 argv_find(argv
, argc
, "deny", &idx
);
19777 direct
= argv_find(argv
, argc
, "permit", &idx
)
19782 argv_find(argv
, argc
, "AA:NN", &idx
);
19783 str
= argv_concat(argv
, argc
, idx
);
19787 argv_find(argv
, argc
, "(1-99)", &idx
);
19788 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19789 cl_name_or_number
= argv
[idx
]->arg
;
19791 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19794 XFREE(MTYPE_TMP
, str
);
19797 community_list_perror(vty
, ret
);
19798 return CMD_WARNING_CONFIG_FAILED
;
19801 return CMD_SUCCESS
;
19804 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19805 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19806 NO_STR BGP_STR COMMUNITY_LIST_STR
19807 "Community list number (standard)\n"
19808 "Add an standard community-list entry\n"
19809 "Community list name\n")
19811 /*community-list expanded */
19812 DEFUN (community_list_expanded_all
,
19813 bgp_community_list_expanded_all_cmd
,
19814 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19817 "Community list number (expanded)\n"
19818 "Add an expanded community-list entry\n"
19819 "Community list name\n"
19820 "Sequence number of an entry\n"
19821 "Sequence number\n"
19822 "Specify community to reject\n"
19823 "Specify community to accept\n"
19826 char *cl_name_or_number
= NULL
;
19829 int style
= COMMUNITY_LIST_EXPANDED
;
19832 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19833 seq
= argv
[idx
]->arg
;
19837 argv_find(argv
, argc
, "(100-500)", &idx
);
19838 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19839 cl_name_or_number
= argv
[idx
]->arg
;
19840 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19842 argv_find(argv
, argc
, "AA:NN", &idx
);
19843 char *str
= argv_concat(argv
, argc
, idx
);
19845 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19848 XFREE(MTYPE_TMP
, str
);
19851 /* Display error string. */
19852 community_list_perror(vty
, ret
);
19853 return CMD_WARNING_CONFIG_FAILED
;
19856 return CMD_SUCCESS
;
19859 DEFUN (no_community_list_expanded_all
,
19860 no_bgp_community_list_expanded_all_cmd
,
19861 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19865 "Community list number (expanded)\n"
19866 "Add an expanded community-list entry\n"
19867 "Community list name\n"
19868 "Sequence number of an entry\n"
19869 "Sequence number\n"
19870 "Specify community to reject\n"
19871 "Specify community to accept\n"
19874 char *cl_name_or_number
= NULL
;
19878 int style
= COMMUNITY_LIST_EXPANDED
;
19881 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19882 seq
= argv
[idx
]->arg
;
19885 argv_find(argv
, argc
, "permit", &idx
);
19886 argv_find(argv
, argc
, "deny", &idx
);
19889 direct
= argv_find(argv
, argc
, "permit", &idx
)
19894 argv_find(argv
, argc
, "AA:NN", &idx
);
19895 str
= argv_concat(argv
, argc
, idx
);
19899 argv_find(argv
, argc
, "(100-500)", &idx
);
19900 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19901 cl_name_or_number
= argv
[idx
]->arg
;
19903 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19906 XFREE(MTYPE_TMP
, str
);
19909 community_list_perror(vty
, ret
);
19910 return CMD_WARNING_CONFIG_FAILED
;
19913 return CMD_SUCCESS
;
19916 ALIAS(no_community_list_expanded_all
,
19917 no_bgp_community_list_expanded_all_list_cmd
,
19918 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19919 NO_STR BGP_STR COMMUNITY_LIST_STR
19920 "Community list number (expanded)\n"
19921 "Add an expanded community-list entry\n"
19922 "Community list name\n")
19924 /* Return configuration string of community-list entry. */
19925 static const char *community_list_config_str(struct community_entry
*entry
)
19932 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19933 str
= community_str(entry
->u
.com
, false, false);
19934 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19935 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19937 str
= entry
->config
;
19942 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19944 struct community_entry
*entry
;
19946 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19947 if (entry
== list
->head
) {
19948 if (all_digit(list
->name
))
19949 vty_out(vty
, "Community %s list %s\n",
19950 entry
->style
== COMMUNITY_LIST_STANDARD
19952 : "(expanded) access",
19955 vty_out(vty
, "Named Community %s list %s\n",
19956 entry
->style
== COMMUNITY_LIST_STANDARD
19962 vty_out(vty
, " %s\n",
19963 community_direct_str(entry
->direct
));
19965 vty_out(vty
, " %s %s\n",
19966 community_direct_str(entry
->direct
),
19967 community_list_config_str(entry
));
19971 DEFUN (show_community_list
,
19972 show_bgp_community_list_cmd
,
19973 "show bgp community-list",
19976 "List community-list\n")
19978 struct community_list
*list
;
19979 struct community_list_master
*cm
;
19981 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19983 return CMD_SUCCESS
;
19985 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19986 community_list_show(vty
, list
);
19988 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19989 community_list_show(vty
, list
);
19991 return CMD_SUCCESS
;
19994 DEFUN (show_community_list_arg
,
19995 show_bgp_community_list_arg_cmd
,
19996 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19999 "List community-list\n"
20000 "Community-list number\n"
20001 "Community-list name\n"
20002 "Detailed information on community-list\n")
20004 int idx_comm_list
= 3;
20005 struct community_list
*list
;
20007 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20008 COMMUNITY_LIST_MASTER
);
20010 vty_out(vty
, "%% Can't find community-list\n");
20011 return CMD_WARNING
;
20014 community_list_show(vty
, list
);
20016 return CMD_SUCCESS
;
20020 * Large Community code.
20022 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20023 struct cmd_token
**argv
, int style
,
20024 int reject_all_digit_name
)
20033 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20034 seq
= argv
[idx
]->arg
;
20037 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20040 /* All digit name check. */
20042 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20043 argv_find(argv
, argc
, "(1-99)", &idx
);
20044 argv_find(argv
, argc
, "(100-500)", &idx
);
20045 cl_name
= argv
[idx
]->arg
;
20046 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20047 vty_out(vty
, "%% Community name cannot have all digits\n");
20048 return CMD_WARNING_CONFIG_FAILED
;
20052 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20053 argv_find(argv
, argc
, "LINE", &idx
);
20054 /* Concat community string argument. */
20056 str
= argv_concat(argv
, argc
, idx
);
20060 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20062 /* Free temporary community list string allocated by
20064 XFREE(MTYPE_TMP
, str
);
20067 community_list_perror(vty
, ret
);
20068 return CMD_WARNING_CONFIG_FAILED
;
20070 return CMD_SUCCESS
;
20073 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20074 struct cmd_token
**argv
, int style
)
20082 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20083 seq
= argv
[idx
]->arg
;
20086 argv_find(argv
, argc
, "permit", &idx
);
20087 argv_find(argv
, argc
, "deny", &idx
);
20090 /* Check the list direct. */
20091 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20092 direct
= COMMUNITY_PERMIT
;
20094 direct
= COMMUNITY_DENY
;
20097 argv_find(argv
, argc
, "LINE", &idx
);
20098 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20099 /* Concat community string argument. */
20100 str
= argv_concat(argv
, argc
, idx
);
20104 argv_find(argv
, argc
, "(1-99)", &idx
);
20105 argv_find(argv
, argc
, "(100-500)", &idx
);
20106 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20108 /* Unset community list. */
20109 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20112 /* Free temporary community list string allocated by
20114 XFREE(MTYPE_TMP
, str
);
20117 community_list_perror(vty
, ret
);
20118 return CMD_WARNING_CONFIG_FAILED
;
20121 return CMD_SUCCESS
;
20124 /* "large-community-list" keyword help string. */
20125 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20126 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20128 DEFUN (lcommunity_list_standard
,
20129 bgp_lcommunity_list_standard_cmd
,
20130 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20132 LCOMMUNITY_LIST_STR
20133 "Large Community list number (standard)\n"
20134 "Sequence number of an entry\n"
20135 "Sequence number\n"
20136 "Specify large community to reject\n"
20137 "Specify large community to accept\n"
20138 LCOMMUNITY_VAL_STR
)
20140 return lcommunity_list_set_vty(vty
, argc
, argv
,
20141 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20144 DEFUN (lcommunity_list_expanded
,
20145 bgp_lcommunity_list_expanded_cmd
,
20146 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20148 LCOMMUNITY_LIST_STR
20149 "Large Community list number (expanded)\n"
20150 "Sequence number of an entry\n"
20151 "Sequence number\n"
20152 "Specify large community to reject\n"
20153 "Specify large community to accept\n"
20154 "An ordered list as a regular-expression\n")
20156 return lcommunity_list_set_vty(vty
, argc
, argv
,
20157 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20160 DEFUN (lcommunity_list_name_standard
,
20161 bgp_lcommunity_list_name_standard_cmd
,
20162 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20164 LCOMMUNITY_LIST_STR
20165 "Specify standard large-community-list\n"
20166 "Large Community list name\n"
20167 "Sequence number of an entry\n"
20168 "Sequence number\n"
20169 "Specify large community to reject\n"
20170 "Specify large community to accept\n"
20171 LCOMMUNITY_VAL_STR
)
20173 return lcommunity_list_set_vty(vty
, argc
, argv
,
20174 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20177 DEFUN (lcommunity_list_name_expanded
,
20178 bgp_lcommunity_list_name_expanded_cmd
,
20179 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20181 LCOMMUNITY_LIST_STR
20182 "Specify expanded large-community-list\n"
20183 "Large Community list name\n"
20184 "Sequence number of an entry\n"
20185 "Sequence number\n"
20186 "Specify large community to reject\n"
20187 "Specify large community to accept\n"
20188 "An ordered list as a regular-expression\n")
20190 return lcommunity_list_set_vty(vty
, argc
, argv
,
20191 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20194 DEFUN (no_lcommunity_list_all
,
20195 no_bgp_lcommunity_list_all_cmd
,
20196 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20199 LCOMMUNITY_LIST_STR
20200 "Large Community list number (standard)\n"
20201 "Large Community list number (expanded)\n"
20202 "Large Community list name\n")
20204 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20205 LARGE_COMMUNITY_LIST_STANDARD
);
20208 DEFUN (no_lcommunity_list_name_standard_all
,
20209 no_bgp_lcommunity_list_name_standard_all_cmd
,
20210 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20213 LCOMMUNITY_LIST_STR
20214 "Specify standard large-community-list\n"
20215 "Large Community list name\n")
20217 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20218 LARGE_COMMUNITY_LIST_STANDARD
);
20221 DEFUN (no_lcommunity_list_name_expanded_all
,
20222 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20223 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20226 LCOMMUNITY_LIST_STR
20227 "Specify expanded large-community-list\n"
20228 "Large Community list name\n")
20230 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20231 LARGE_COMMUNITY_LIST_EXPANDED
);
20234 DEFUN (no_lcommunity_list_standard
,
20235 no_bgp_lcommunity_list_standard_cmd
,
20236 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20239 LCOMMUNITY_LIST_STR
20240 "Large Community list number (standard)\n"
20241 "Sequence number of an entry\n"
20242 "Sequence number\n"
20243 "Specify large community to reject\n"
20244 "Specify large community to accept\n"
20245 LCOMMUNITY_VAL_STR
)
20247 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20248 LARGE_COMMUNITY_LIST_STANDARD
);
20251 DEFUN (no_lcommunity_list_expanded
,
20252 no_bgp_lcommunity_list_expanded_cmd
,
20253 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20256 LCOMMUNITY_LIST_STR
20257 "Large Community list number (expanded)\n"
20258 "Sequence number of an entry\n"
20259 "Sequence number\n"
20260 "Specify large community to reject\n"
20261 "Specify large community to accept\n"
20262 "An ordered list as a regular-expression\n")
20264 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20265 LARGE_COMMUNITY_LIST_EXPANDED
);
20268 DEFUN (no_lcommunity_list_name_standard
,
20269 no_bgp_lcommunity_list_name_standard_cmd
,
20270 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20273 LCOMMUNITY_LIST_STR
20274 "Specify standard large-community-list\n"
20275 "Large Community list name\n"
20276 "Sequence number of an entry\n"
20277 "Sequence number\n"
20278 "Specify large community to reject\n"
20279 "Specify large community to accept\n"
20280 LCOMMUNITY_VAL_STR
)
20282 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20283 LARGE_COMMUNITY_LIST_STANDARD
);
20286 DEFUN (no_lcommunity_list_name_expanded
,
20287 no_bgp_lcommunity_list_name_expanded_cmd
,
20288 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20291 LCOMMUNITY_LIST_STR
20292 "Specify expanded large-community-list\n"
20293 "Large community list name\n"
20294 "Sequence number of an entry\n"
20295 "Sequence number\n"
20296 "Specify large community to reject\n"
20297 "Specify large community to accept\n"
20298 "An ordered list as a regular-expression\n")
20300 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20301 LARGE_COMMUNITY_LIST_EXPANDED
);
20304 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20306 struct community_entry
*entry
;
20308 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20309 if (entry
== list
->head
) {
20310 if (all_digit(list
->name
))
20311 vty_out(vty
, "Large community %s list %s\n",
20313 LARGE_COMMUNITY_LIST_STANDARD
20315 : "(expanded) access",
20319 "Named large community %s list %s\n",
20321 LARGE_COMMUNITY_LIST_STANDARD
20327 vty_out(vty
, " %s\n",
20328 community_direct_str(entry
->direct
));
20330 vty_out(vty
, " %s %s\n",
20331 community_direct_str(entry
->direct
),
20332 community_list_config_str(entry
));
20336 DEFUN (show_lcommunity_list
,
20337 show_bgp_lcommunity_list_cmd
,
20338 "show bgp large-community-list",
20341 "List large-community list\n")
20343 struct community_list
*list
;
20344 struct community_list_master
*cm
;
20346 cm
= community_list_master_lookup(bgp_clist
,
20347 LARGE_COMMUNITY_LIST_MASTER
);
20349 return CMD_SUCCESS
;
20351 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20352 lcommunity_list_show(vty
, list
);
20354 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20355 lcommunity_list_show(vty
, list
);
20357 return CMD_SUCCESS
;
20360 DEFUN (show_lcommunity_list_arg
,
20361 show_bgp_lcommunity_list_arg_cmd
,
20362 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20365 "List large-community list\n"
20366 "Large-community-list number\n"
20367 "Large-community-list name\n"
20368 "Detailed information on large-community-list\n")
20370 struct community_list
*list
;
20372 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20373 LARGE_COMMUNITY_LIST_MASTER
);
20375 vty_out(vty
, "%% Can't find large-community-list\n");
20376 return CMD_WARNING
;
20379 lcommunity_list_show(vty
, list
);
20381 return CMD_SUCCESS
;
20384 /* "extcommunity-list" keyword help string. */
20385 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20386 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20388 DEFUN (extcommunity_list_standard
,
20389 bgp_extcommunity_list_standard_cmd
,
20390 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20392 EXTCOMMUNITY_LIST_STR
20393 "Extended Community list number (standard)\n"
20394 "Specify standard extcommunity-list\n"
20395 "Community list name\n"
20396 "Sequence number of an entry\n"
20397 "Sequence number\n"
20398 "Specify community to reject\n"
20399 "Specify community to accept\n"
20400 EXTCOMMUNITY_VAL_STR
)
20402 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20404 char *cl_number_or_name
= NULL
;
20409 argv_find(argv
, argc
, "(1-99)", &idx
);
20410 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20411 cl_number_or_name
= argv
[idx
]->arg
;
20413 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20414 seq
= argv
[idx
]->arg
;
20416 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20418 argv_find(argv
, argc
, "AA:NN", &idx
);
20419 char *str
= argv_concat(argv
, argc
, idx
);
20421 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20424 XFREE(MTYPE_TMP
, str
);
20427 community_list_perror(vty
, ret
);
20428 return CMD_WARNING_CONFIG_FAILED
;
20431 return CMD_SUCCESS
;
20434 DEFUN (extcommunity_list_name_expanded
,
20435 bgp_extcommunity_list_name_expanded_cmd
,
20436 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20438 EXTCOMMUNITY_LIST_STR
20439 "Extended Community list number (expanded)\n"
20440 "Specify expanded extcommunity-list\n"
20441 "Extended Community list name\n"
20442 "Sequence number of an entry\n"
20443 "Sequence number\n"
20444 "Specify community to reject\n"
20445 "Specify community to accept\n"
20446 "An ordered list as a regular-expression\n")
20448 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20450 char *cl_number_or_name
= NULL
;
20454 argv_find(argv
, argc
, "(100-500)", &idx
);
20455 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20456 cl_number_or_name
= argv
[idx
]->arg
;
20458 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20459 seq
= argv
[idx
]->arg
;
20461 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20463 argv_find(argv
, argc
, "LINE", &idx
);
20464 char *str
= argv_concat(argv
, argc
, idx
);
20466 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20469 XFREE(MTYPE_TMP
, str
);
20472 community_list_perror(vty
, ret
);
20473 return CMD_WARNING_CONFIG_FAILED
;
20476 return CMD_SUCCESS
;
20479 DEFUN (no_extcommunity_list_standard_all
,
20480 no_bgp_extcommunity_list_standard_all_cmd
,
20481 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20484 EXTCOMMUNITY_LIST_STR
20485 "Extended Community list number (standard)\n"
20486 "Specify standard extcommunity-list\n"
20487 "Community list name\n"
20488 "Sequence number of an entry\n"
20489 "Sequence number\n"
20490 "Specify community to reject\n"
20491 "Specify community to accept\n"
20492 EXTCOMMUNITY_VAL_STR
)
20494 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20496 char *cl_number_or_name
= NULL
;
20501 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20502 seq
= argv
[idx
]->arg
;
20505 argv_find(argv
, argc
, "permit", &idx
);
20506 argv_find(argv
, argc
, "deny", &idx
);
20508 direct
= argv_find(argv
, argc
, "permit", &idx
)
20513 argv_find(argv
, argc
, "AA:NN", &idx
);
20514 str
= argv_concat(argv
, argc
, idx
);
20518 argv_find(argv
, argc
, "(1-99)", &idx
);
20519 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20520 cl_number_or_name
= argv
[idx
]->arg
;
20522 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20523 seq
, direct
, style
);
20525 XFREE(MTYPE_TMP
, str
);
20528 community_list_perror(vty
, ret
);
20529 return CMD_WARNING_CONFIG_FAILED
;
20532 return CMD_SUCCESS
;
20535 ALIAS(no_extcommunity_list_standard_all
,
20536 no_bgp_extcommunity_list_standard_all_list_cmd
,
20537 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20538 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20539 "Extended Community list number (standard)\n"
20540 "Specify standard extcommunity-list\n"
20541 "Community list name\n")
20543 DEFUN (no_extcommunity_list_expanded_all
,
20544 no_bgp_extcommunity_list_expanded_all_cmd
,
20545 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20548 EXTCOMMUNITY_LIST_STR
20549 "Extended Community list number (expanded)\n"
20550 "Specify expanded extcommunity-list\n"
20551 "Extended Community list name\n"
20552 "Sequence number of an entry\n"
20553 "Sequence number\n"
20554 "Specify community to reject\n"
20555 "Specify community to accept\n"
20556 "An ordered list as a regular-expression\n")
20558 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20560 char *cl_number_or_name
= NULL
;
20565 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20566 seq
= argv
[idx
]->arg
;
20569 argv_find(argv
, argc
, "permit", &idx
);
20570 argv_find(argv
, argc
, "deny", &idx
);
20573 direct
= argv_find(argv
, argc
, "permit", &idx
)
20578 argv_find(argv
, argc
, "LINE", &idx
);
20579 str
= argv_concat(argv
, argc
, idx
);
20583 argv_find(argv
, argc
, "(100-500)", &idx
);
20584 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20585 cl_number_or_name
= argv
[idx
]->arg
;
20587 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20588 seq
, direct
, style
);
20590 XFREE(MTYPE_TMP
, str
);
20593 community_list_perror(vty
, ret
);
20594 return CMD_WARNING_CONFIG_FAILED
;
20597 return CMD_SUCCESS
;
20600 ALIAS(no_extcommunity_list_expanded_all
,
20601 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20602 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20603 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20604 "Extended Community list number (expanded)\n"
20605 "Specify expanded extcommunity-list\n"
20606 "Extended Community list name\n")
20608 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20610 struct community_entry
*entry
;
20612 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20613 if (entry
== list
->head
) {
20614 if (all_digit(list
->name
))
20615 vty_out(vty
, "Extended community %s list %s\n",
20616 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20618 : "(expanded) access",
20622 "Named extended community %s list %s\n",
20623 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20629 vty_out(vty
, " %s\n",
20630 community_direct_str(entry
->direct
));
20632 vty_out(vty
, " %s %s\n",
20633 community_direct_str(entry
->direct
),
20634 community_list_config_str(entry
));
20638 DEFUN (show_extcommunity_list
,
20639 show_bgp_extcommunity_list_cmd
,
20640 "show bgp extcommunity-list",
20643 "List extended-community list\n")
20645 struct community_list
*list
;
20646 struct community_list_master
*cm
;
20648 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20650 return CMD_SUCCESS
;
20652 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20653 extcommunity_list_show(vty
, list
);
20655 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20656 extcommunity_list_show(vty
, list
);
20658 return CMD_SUCCESS
;
20661 DEFUN (show_extcommunity_list_arg
,
20662 show_bgp_extcommunity_list_arg_cmd
,
20663 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20666 "List extended-community list\n"
20667 "Extcommunity-list number\n"
20668 "Extcommunity-list name\n"
20669 "Detailed information on extcommunity-list\n")
20671 int idx_comm_list
= 3;
20672 struct community_list
*list
;
20674 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20675 EXTCOMMUNITY_LIST_MASTER
);
20677 vty_out(vty
, "%% Can't find extcommunity-list\n");
20678 return CMD_WARNING
;
20681 extcommunity_list_show(vty
, list
);
20683 return CMD_SUCCESS
;
20686 /* Display community-list and extcommunity-list configuration. */
20687 static int community_list_config_write(struct vty
*vty
)
20689 struct community_list
*list
;
20690 struct community_entry
*entry
;
20691 struct community_list_master
*cm
;
20694 /* Community-list. */
20695 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20697 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20698 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20700 "bgp community-list %s seq %" PRId64
" %s %s\n",
20701 list
->name
, entry
->seq
,
20702 community_direct_str(entry
->direct
),
20703 community_list_config_str(entry
));
20706 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20707 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20709 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20710 entry
->style
== COMMUNITY_LIST_STANDARD
20713 list
->name
, entry
->seq
,
20714 community_direct_str(entry
->direct
),
20715 community_list_config_str(entry
));
20719 /* Extcommunity-list. */
20720 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20722 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20723 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20725 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20726 list
->name
, entry
->seq
,
20727 community_direct_str(entry
->direct
),
20728 community_list_config_str(entry
));
20731 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20732 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20734 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20735 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20738 list
->name
, entry
->seq
,
20739 community_direct_str(entry
->direct
),
20740 community_list_config_str(entry
));
20745 /* lcommunity-list. */
20746 cm
= community_list_master_lookup(bgp_clist
,
20747 LARGE_COMMUNITY_LIST_MASTER
);
20749 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20750 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20752 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20753 list
->name
, entry
->seq
,
20754 community_direct_str(entry
->direct
),
20755 community_list_config_str(entry
));
20758 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20759 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20761 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20763 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20766 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20767 community_list_config_str(entry
));
20774 static int community_list_config_write(struct vty
*vty
);
20775 static struct cmd_node community_list_node
= {
20776 .name
= "community list",
20777 .node
= COMMUNITY_LIST_NODE
,
20779 .config_write
= community_list_config_write
,
20782 static void community_list_vty(void)
20784 install_node(&community_list_node
);
20786 /* Community-list. */
20787 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20788 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20789 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20790 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20791 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20792 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20793 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20794 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20796 /* Extcommunity-list. */
20797 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20798 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20799 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20800 install_element(CONFIG_NODE
,
20801 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20802 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20803 install_element(CONFIG_NODE
,
20804 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20805 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20806 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20808 /* Large Community List */
20809 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20810 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20811 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20812 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20813 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20814 install_element(CONFIG_NODE
,
20815 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20816 install_element(CONFIG_NODE
,
20817 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20818 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20819 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20820 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20821 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20822 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20823 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20825 bgp_community_list_command_completion_setup();
20828 static struct cmd_node community_alias_node
= {
20829 .name
= "community alias",
20830 .node
= COMMUNITY_ALIAS_NODE
,
20832 .config_write
= bgp_community_alias_write
,
20835 void community_alias_vty(void)
20837 install_node(&community_alias_node
);
20839 /* Community-list. */
20840 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20842 bgp_community_alias_command_completion_setup();