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_nexthop.h"
57 #include "bgpd/bgp_network.h"
58 #include "bgpd/bgp_open.h"
59 #include "bgpd/bgp_regex.h"
60 #include "bgpd/bgp_route.h"
61 #include "bgpd/bgp_mplsvpn.h"
62 #include "bgpd/bgp_zebra.h"
63 #include "bgpd/bgp_table.h"
64 #include "bgpd/bgp_vty.h"
65 #include "bgpd/bgp_mpath.h"
66 #include "bgpd/bgp_packet.h"
67 #include "bgpd/bgp_updgrp.h"
68 #include "bgpd/bgp_bfd.h"
69 #include "bgpd/bgp_io.h"
70 #include "bgpd/bgp_evpn.h"
71 #include "bgpd/bgp_evpn_vty.h"
72 #include "bgpd/bgp_evpn_mh.h"
73 #include "bgpd/bgp_addpath.h"
74 #include "bgpd/bgp_mac.h"
75 #include "bgpd/bgp_flowspec.h"
76 #include "bgpd/bgp_conditional_adv.h"
78 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
81 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
84 .match_profile
= "traditional",
85 .match_version
= "< 7.4",
89 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
90 { .val_bool
= true, .match_profile
= "datacenter", },
91 { .val_bool
= false },
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
106 { .val_ulong
= 10, .match_profile
= "datacenter", },
107 { .val_ulong
= 120 },
109 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
110 { .val_ulong
= 9, .match_profile
= "datacenter", },
111 { .val_ulong
= 180 },
113 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
114 { .val_ulong
= 3, .match_profile
= "datacenter", },
117 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
118 { .val_bool
= false, .match_profile
= "datacenter", },
119 { .val_bool
= false, .match_version
= "< 7.4", },
120 { .val_bool
= true },
122 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
123 { .val_bool
= false, .match_version
= "< 7.6", },
124 { .val_bool
= true },
126 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
127 { .val_bool
= false, .match_version
= "< 8.3", },
128 { .val_bool
= true },
130 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
131 { .val_bool
= false, .match_version
= "< 8.3", },
132 { .val_bool
= true },
135 DEFINE_HOOK(bgp_inst_config_write
,
136 (struct bgp
*bgp
, struct vty
*vty
),
138 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
139 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
141 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
142 struct prefix
*range
, int exact
);
144 /* Show BGP peer's information. */
154 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
155 struct prefix
*range
, int exact
);
157 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
162 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
165 afi_t afi
, bool use_json
);
167 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
173 return BGP_IPV4_NODE
;
175 return BGP_IPV4M_NODE
;
176 case SAFI_LABELED_UNICAST
:
177 return BGP_IPV4L_NODE
;
179 return BGP_VPNV4_NODE
;
181 return BGP_FLOWSPECV4_NODE
;
184 return BGP_IPV4_NODE
;
189 return BGP_IPV6_NODE
;
191 return BGP_IPV6M_NODE
;
192 case SAFI_LABELED_UNICAST
:
193 return BGP_IPV6L_NODE
;
195 return BGP_VPNV6_NODE
;
197 return BGP_FLOWSPECV6_NODE
;
200 return BGP_IPV4_NODE
;
203 return BGP_EVPN_NODE
;
206 // We should never be here but to clarify the switch statement..
207 return BGP_IPV4_NODE
;
210 // Impossible to happen
211 return BGP_IPV4_NODE
;
214 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
217 if (safi
== SAFI_UNICAST
)
218 return "IPv4 Unicast";
219 if (safi
== SAFI_MULTICAST
)
220 return "IPv4 Multicast";
221 if (safi
== SAFI_LABELED_UNICAST
)
222 return "IPv4 Labeled Unicast";
223 if (safi
== SAFI_MPLS_VPN
)
225 if (safi
== SAFI_ENCAP
)
227 if (safi
== SAFI_FLOWSPEC
)
228 return "IPv4 Flowspec";
229 } else if (afi
== AFI_IP6
) {
230 if (safi
== SAFI_UNICAST
)
231 return "IPv6 Unicast";
232 if (safi
== SAFI_MULTICAST
)
233 return "IPv6 Multicast";
234 if (safi
== SAFI_LABELED_UNICAST
)
235 return "IPv6 Labeled Unicast";
236 if (safi
== SAFI_MPLS_VPN
)
238 if (safi
== SAFI_ENCAP
)
240 if (safi
== SAFI_FLOWSPEC
)
241 return "IPv6 Flowspec";
242 } else if (afi
== AFI_L2VPN
) {
243 if (safi
== SAFI_EVPN
)
251 * Please note that we have intentionally camelCased
252 * the return strings here. So if you want
253 * to use this function, please ensure you
254 * are doing this within json output
256 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
259 if (safi
== SAFI_UNICAST
)
260 return "ipv4Unicast";
261 if (safi
== SAFI_MULTICAST
)
262 return "ipv4Multicast";
263 if (safi
== SAFI_LABELED_UNICAST
)
264 return "ipv4LabeledUnicast";
265 if (safi
== SAFI_MPLS_VPN
)
267 if (safi
== SAFI_ENCAP
)
269 if (safi
== SAFI_FLOWSPEC
)
270 return "ipv4Flowspec";
271 } else if (afi
== AFI_IP6
) {
272 if (safi
== SAFI_UNICAST
)
273 return "ipv6Unicast";
274 if (safi
== SAFI_MULTICAST
)
275 return "ipv6Multicast";
276 if (safi
== SAFI_LABELED_UNICAST
)
277 return "ipv6LabeledUnicast";
278 if (safi
== SAFI_MPLS_VPN
)
280 if (safi
== SAFI_ENCAP
)
282 if (safi
== SAFI_FLOWSPEC
)
283 return "ipv6Flowspec";
284 } else if (afi
== AFI_L2VPN
) {
285 if (safi
== SAFI_EVPN
)
292 /* unset srv6 locator */
293 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
296 struct listnode
*node
, *nnode
;
297 struct srv6_locator_chunk
*chunk
;
298 struct bgp_srv6_function
*func
;
300 struct in6_addr
*tovpn_sid
;
302 /* release chunk notification via ZAPI */
303 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
304 bgp
->srv6_locator_name
);
309 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
))
310 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
312 /* refresh functions */
313 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
))
314 listnode_delete(bgp
->srv6_functions
, func
);
316 /* refresh tovpn_sid */
317 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
318 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
321 /* refresh vpnv4 tovpn_sid */
322 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
;
324 XFREE(MTYPE_BGP_SRV6_SID
,
325 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
327 /* refresh vpnv6 tovpn_sid */
328 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
;
330 XFREE(MTYPE_BGP_SRV6_SID
,
331 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
334 /* update vpn bgp processes */
335 vpn_leak_postchange_all();
337 /* clear locator name */
338 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
343 /* Utility function to get address family from current node. */
344 afi_t
bgp_node_afi(struct vty
*vty
)
352 case BGP_FLOWSPECV6_NODE
:
365 /* Utility function to get subsequent address family from current
367 safi_t
bgp_node_safi(struct vty
*vty
)
373 safi
= SAFI_MPLS_VPN
;
377 safi
= SAFI_MULTICAST
;
384 safi
= SAFI_LABELED_UNICAST
;
386 case BGP_FLOWSPECV4_NODE
:
387 case BGP_FLOWSPECV6_NODE
:
388 safi
= SAFI_FLOWSPEC
;
398 * Converts an AFI in string form to afi_t
400 * @param afi string, one of
404 * @return the corresponding afi_t
406 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
408 afi_t afi
= AFI_MAX
; /* unknown */
409 if (strmatch(afi_str
, "ipv4"))
411 else if (strmatch(afi_str
, "ipv6"))
413 else if (strmatch(afi_str
, "l2vpn"))
418 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
422 if (argv_find(argv
, argc
, "ipv4", index
)) {
426 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
430 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
438 /* supports <unicast|multicast|vpn|labeled-unicast> */
439 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
441 safi_t safi
= SAFI_MAX
; /* unknown */
442 if (strmatch(safi_str
, "multicast"))
443 safi
= SAFI_MULTICAST
;
444 else if (strmatch(safi_str
, "unicast"))
446 else if (strmatch(safi_str
, "vpn"))
447 safi
= SAFI_MPLS_VPN
;
448 else if (strmatch(safi_str
, "evpn"))
450 else if (strmatch(safi_str
, "labeled-unicast"))
451 safi
= SAFI_LABELED_UNICAST
;
452 else if (strmatch(safi_str
, "flowspec"))
453 safi
= SAFI_FLOWSPEC
;
457 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
461 if (argv_find(argv
, argc
, "unicast", index
)) {
464 *safi
= SAFI_UNICAST
;
465 } else if (argv_find(argv
, argc
, "multicast", index
)) {
468 *safi
= SAFI_MULTICAST
;
469 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
472 *safi
= SAFI_LABELED_UNICAST
;
473 } else if (argv_find(argv
, argc
, "vpn", index
)) {
476 *safi
= SAFI_MPLS_VPN
;
477 } else if (argv_find(argv
, argc
, "evpn", index
)) {
481 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
484 *safi
= SAFI_FLOWSPEC
;
490 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
493 * address-family identifier
496 * subsequent address-family identifier
499 * default_af string corresponding to the supplied afi/safi pair.
500 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
503 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
509 return "ipv4-unicast";
511 return "ipv4-multicast";
516 case SAFI_LABELED_UNICAST
:
517 return "ipv4-labeled-unicast";
519 return "ipv4-flowspec";
521 return "unknown-afi/safi";
527 return "ipv6-unicast";
529 return "ipv6-multicast";
534 case SAFI_LABELED_UNICAST
:
535 return "ipv6-labeled-unicast";
537 return "ipv6-flowspec";
539 return "unknown-afi/safi";
547 return "unknown-afi/safi";
551 return "unknown-afi/safi";
553 /* all AFIs are accounted for above, so this shouldn't happen */
554 return "unknown-afi/safi";
557 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
558 enum bgp_instance_type inst_type
)
560 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
562 if (ret
== BGP_CREATED
) {
563 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
564 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
566 if (DFLT_BGP_IMPORT_CHECK
)
567 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
568 if (DFLT_BGP_SHOW_HOSTNAME
)
569 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
570 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
571 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
572 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
573 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
574 if (DFLT_BGP_DETERMINISTIC_MED
)
575 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
576 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
577 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
578 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
579 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
580 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
581 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
582 if (DFLT_BGP_HARD_ADMIN_RESET
)
583 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
591 * bgp_vty_find_and_parse_afi_safi_bgp
593 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
594 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
595 * to appropriate values for the calling function. This is to allow the
596 * calling function to make decisions appropriate for the show command
597 * that is being parsed.
599 * The show commands are generally of the form:
600 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
601 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
603 * Since we use argv_find if the show command in particular doesn't have:
605 * [<view|vrf> VIEWVRFNAME]
606 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
607 * The command parsing should still be ok.
609 * vty -> The vty for the command so we can output some useful data in
610 * the event of a parse error in the vrf.
611 * argv -> The command tokens
612 * argc -> How many command tokens we have
613 * idx -> The current place in the command, generally should be 0 for this
615 * afi -> The parsed afi if it was included in the show command, returned here
616 * safi -> The parsed safi if it was included in the show command, returned here
617 * bgp -> Pointer to the bgp data structure we need to fill in.
618 * use_json -> json is configured or not
620 * The function returns the correct location in the parse tree for the
623 * Returns 0 for failure to parse correctly, else the idx position of where
624 * it found the last token.
626 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
627 struct cmd_token
**argv
, int argc
,
628 int *idx
, afi_t
*afi
, safi_t
*safi
,
629 struct bgp
**bgp
, bool use_json
)
631 char *vrf_name
= NULL
;
637 if (argv_find(argv
, argc
, "ip", idx
))
640 if (argv_find(argv
, argc
, "view", idx
))
641 vrf_name
= argv
[*idx
+ 1]->arg
;
642 else if (argv_find(argv
, argc
, "vrf", idx
)) {
643 vrf_name
= argv
[*idx
+ 1]->arg
;
644 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
648 if (strmatch(vrf_name
, "all"))
651 *bgp
= bgp_lookup_by_name(vrf_name
);
654 json_object
*json
= NULL
;
655 json
= json_object_new_object();
656 json_object_string_add(
658 "View/Vrf is unknown");
662 vty_out(vty
, "View/Vrf %s is unknown\n",
669 *bgp
= bgp_get_default();
672 json_object
*json
= NULL
;
673 json
= json_object_new_object();
674 json_object_string_add(
676 "Default BGP instance not found");
681 "Default BGP instance not found\n");
687 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
688 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
694 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
696 struct interface
*ifp
= NULL
;
697 struct listnode
*node
;
698 struct bgp_listener
*listener
;
699 union sockunion all_su
;
701 if (su
->sa
.sa_family
== AF_INET
) {
702 (void)str2sockunion("0.0.0.0", &all_su
);
703 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
704 } else if (su
->sa
.sa_family
== AF_INET6
) {
705 (void)str2sockunion("::", &all_su
);
706 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
707 su
->sin6
.sin6_scope_id
,
712 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
713 if (sockunion_family(su
) !=
714 sockunion_family(&listener
->su
))
717 /* If 0.0.0.0/:: is a listener, then treat as self and
720 if (!sockunion_cmp(&listener
->su
, su
) ||
721 !sockunion_cmp(&listener
->su
, &all_su
))
729 /* Utility function for looking up peer from VTY. */
730 /* This is used only for configuration, so disallow if attempted on
731 * a dynamic neighbor.
733 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
735 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
744 ret
= str2sockunion(ip_str
, &su
);
746 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
748 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
751 "%% Malformed address or name: %s\n",
757 peer
= peer_lookup(bgp
, &su
);
760 "%% Specify remote-as or peer-group commands first\n");
763 if (peer_dynamic_neighbor(peer
)) {
765 "%% Operation not allowed on a dynamic neighbor\n");
772 /* Utility function for looking up peer or peer group. */
773 /* This is used only for configuration, so disallow if attempted on
774 * a dynamic neighbor.
776 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
778 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
781 struct peer
*peer
= NULL
;
782 struct peer_group
*group
= NULL
;
788 ret
= str2sockunion(peer_str
, &su
);
790 /* IP address, locate peer. */
791 peer
= peer_lookup(bgp
, &su
);
793 /* Not IP, could match either peer configured on interface or a
795 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
797 group
= peer_group_lookup(bgp
, peer_str
);
801 if (peer_dynamic_neighbor(peer
)) {
803 "%% Operation not allowed on a dynamic neighbor\n");
813 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
818 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
820 const char *str
= NULL
;
825 case BGP_GR_NO_OPERATION
:
827 case BGP_ERR_INVALID_VALUE
:
828 str
= "Invalid value";
830 case BGP_ERR_INVALID_FLAG
:
831 str
= "Invalid flag";
833 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
834 str
= "Peer-group has been shutdown. Activate the peer-group first";
836 case BGP_ERR_PEER_FLAG_CONFLICT
:
837 str
= "Can't set override-capability and strict-capability-match at the same time";
839 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
840 str
= "Specify remote-as or peer-group remote AS first";
842 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
843 str
= "Cannot change the peer-group. Deconfigure first";
845 case BGP_ERR_PEER_GROUP_MISMATCH
:
846 str
= "Peer is not a member of this peer-group";
848 case BGP_ERR_PEER_FILTER_CONFLICT
:
849 str
= "Prefix/distribute list can not co-exist";
851 case BGP_ERR_NOT_INTERNAL_PEER
:
852 str
= "Invalid command. Not an internal neighbor";
854 case BGP_ERR_REMOVE_PRIVATE_AS
:
855 str
= "remove-private-AS cannot be configured for IBGP peers";
857 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
858 str
= "Local-AS allowed only for EBGP peers";
860 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
861 str
= "Cannot have local-as same as BGP AS number";
863 case BGP_ERR_TCPSIG_FAILED
:
864 str
= "Error while applying TCP-Sig to session(s)";
866 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
867 str
= "ebgp-multihop and ttl-security cannot be configured together";
869 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
870 str
= "ttl-security only allowed for EBGP peers";
872 case BGP_ERR_AS_OVERRIDE
:
873 str
= "as-override cannot be configured for IBGP peers";
875 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
876 str
= "Invalid limit for number of dynamic neighbors";
878 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
879 str
= "Dynamic neighbor listen range already exists";
881 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
882 str
= "Operation not allowed on a dynamic neighbor";
884 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
885 str
= "Operation not allowed on a directly connected neighbor";
887 case BGP_ERR_PEER_SAFI_CONFLICT
:
888 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
890 case BGP_ERR_GR_INVALID_CMD
:
891 str
= "The Graceful Restart command used is not valid at this moment.";
893 case BGP_ERR_GR_OPERATION_FAILED
:
894 str
= "The Graceful Restart Operation failed due to an err.";
896 case BGP_ERR_PEER_GROUP_MEMBER
:
897 str
= "Peer-group member cannot override remote-as of peer-group.";
899 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
900 str
= "Peer-group members must be all internal or all external.";
902 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
903 str
= "Range specified cannot be deleted because it is not part of current config.";
905 case BGP_ERR_INSTANCE_MISMATCH
:
906 str
= "Instance specified does not match the current instance.";
908 case BGP_ERR_NO_INTERFACE_CONFIG
:
909 str
= "Interface specified is not being used for interface based peer.";
911 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
912 str
= "No configuration already specified for soft reconfiguration.";
914 case BGP_ERR_AS_MISMATCH
:
915 str
= "BGP is already running.";
917 case BGP_ERR_AF_UNCONFIGURED
:
918 str
= "AFI/SAFI specified is not currently configured.";
920 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS
:
921 str
= "AS specified for local as is the same as the remote as and this is not allowed.";
923 case BGP_ERR_INVALID_AS
:
924 str
= "Confederation AS specified is the same AS as our AS.";
928 vty_out(vty
, "%% %s\n", str
);
929 return CMD_WARNING_CONFIG_FAILED
;
934 /* BGP clear sort. */
943 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
944 safi_t safi
, int error
)
947 case BGP_ERR_AF_UNCONFIGURED
:
949 "%% BGP: Enable %s address family for the neighbor %s\n",
950 get_afi_safi_str(afi
, safi
, false), peer
->host
);
952 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
954 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
962 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
963 struct listnode
**nnode
, enum bgp_clear_type stype
)
968 /* if afi/.safi not specified, spin thru all of them */
969 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
972 enum bgp_af_index index
;
974 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
975 paf
= peer
->peer_af_array
[index
];
979 if (paf
&& paf
->subgroup
)
980 SET_FLAG(paf
->subgroup
->sflags
,
981 SUBGRP_STATUS_FORCE_UPDATES
);
984 tmp_safi
= paf
->safi
;
985 if (!peer
->afc
[tmp_afi
][tmp_safi
])
988 if (stype
== BGP_CLEAR_SOFT_NONE
)
989 ret
= peer_clear(peer
, nnode
);
991 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
994 /* if afi specified and safi not, spin thru safis on this afi */
995 } else if (safi
== SAFI_UNSPEC
) {
998 for (tmp_safi
= SAFI_UNICAST
;
999 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1000 if (!peer
->afc
[afi
][tmp_safi
])
1003 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1004 if (paf
&& paf
->subgroup
)
1005 SET_FLAG(paf
->subgroup
->sflags
,
1006 SUBGRP_STATUS_FORCE_UPDATES
);
1008 if (stype
== BGP_CLEAR_SOFT_NONE
)
1009 ret
= peer_clear(peer
, nnode
);
1011 ret
= peer_clear_soft(peer
, afi
,
1014 /* both afi/safi specified, let the caller know if not defined */
1016 if (!peer
->afc
[afi
][safi
])
1019 paf
= peer_af_find(peer
, afi
, safi
);
1020 if (paf
&& paf
->subgroup
)
1021 SET_FLAG(paf
->subgroup
->sflags
,
1022 SUBGRP_STATUS_FORCE_UPDATES
);
1024 if (stype
== BGP_CLEAR_SOFT_NONE
)
1025 ret
= peer_clear(peer
, nnode
);
1027 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1033 /* `clear ip bgp' functions. */
1034 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1035 enum clear_sort sort
, enum bgp_clear_type stype
,
1042 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1044 /* Clear all neighbors. */
1046 * Pass along pointer to next node to peer_clear() when walking all
1047 * nodes on the BGP instance as that may get freed if it is a
1050 if (sort
== clear_all
) {
1051 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1053 bgp_peer_gr_flags_update(peer
);
1055 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1056 gr_router_detected
= true;
1058 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1062 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1065 if (gr_router_detected
1066 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1067 bgp_zebra_send_capabilities(bgp
, false);
1068 } else if (!gr_router_detected
1069 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1070 bgp_zebra_send_capabilities(bgp
, true);
1073 /* This is to apply read-only mode on this clear. */
1074 if (stype
== BGP_CLEAR_SOFT_NONE
)
1075 bgp
->update_delay_over
= 0;
1080 /* Clear specified neighbor. */
1081 if (sort
== clear_peer
) {
1084 /* Make sockunion for lookup. */
1085 ret
= str2sockunion(arg
, &su
);
1087 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1089 peer
= peer_lookup_by_hostname(bgp
, arg
);
1092 "Malformed address or name: %s\n",
1098 peer
= peer_lookup(bgp
, &su
);
1101 "%% BGP: Unknown neighbor - \"%s\"\n",
1107 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1108 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1110 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1112 /* if afi/safi not defined for this peer, let caller know */
1114 ret
= BGP_ERR_AF_UNCONFIGURED
;
1117 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1122 /* Clear all neighbors belonging to a specific peer-group. */
1123 if (sort
== clear_group
) {
1124 struct peer_group
*group
;
1126 group
= peer_group_lookup(bgp
, arg
);
1128 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1132 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1133 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1136 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1143 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1144 get_afi_safi_str(afi
, safi
, false), arg
);
1149 /* Clear all external (eBGP) neighbors. */
1150 if (sort
== clear_external
) {
1151 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1152 if (peer
->sort
== BGP_PEER_IBGP
)
1155 bgp_peer_gr_flags_update(peer
);
1157 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1158 gr_router_detected
= true;
1160 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1163 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1168 if (gr_router_detected
1169 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1170 bgp_zebra_send_capabilities(bgp
, false);
1171 } else if (!gr_router_detected
1172 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1173 bgp_zebra_send_capabilities(bgp
, true);
1178 "%% BGP: No external %s peer is configured\n",
1179 get_afi_safi_str(afi
, safi
, false));
1184 /* Clear all neighbors belonging to a specific AS. */
1185 if (sort
== clear_as
) {
1186 as_t as
= strtoul(arg
, NULL
, 10);
1188 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1192 bgp_peer_gr_flags_update(peer
);
1194 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1195 gr_router_detected
= true;
1197 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1200 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1205 if (gr_router_detected
1206 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1207 bgp_zebra_send_capabilities(bgp
, false);
1208 } else if (!gr_router_detected
1209 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1210 bgp_zebra_send_capabilities(bgp
, true);
1215 "%% BGP: No %s peer is configured with AS %s\n",
1216 get_afi_safi_str(afi
, safi
, false), arg
);
1224 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1225 safi_t safi
, enum clear_sort sort
,
1226 enum bgp_clear_type stype
, const char *arg
)
1230 /* BGP structure lookup. */
1232 bgp
= bgp_lookup_by_name(name
);
1234 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1238 bgp
= bgp_get_default();
1240 vty_out(vty
, "No BGP process is configured\n");
1245 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1248 /* clear soft inbound */
1249 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1254 FOREACH_AFI_SAFI (afi
, safi
)
1255 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1256 BGP_CLEAR_SOFT_IN
, NULL
);
1259 /* clear soft outbound */
1260 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1265 FOREACH_AFI_SAFI (afi
, safi
)
1266 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1267 BGP_CLEAR_SOFT_OUT
, NULL
);
1271 #ifndef VTYSH_EXTRACT_PL
1272 #include "bgpd/bgp_vty_clippy.c"
1275 DEFUN_HIDDEN (bgp_local_mac
,
1277 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1279 "Local MAC config\n"
1280 "VxLAN Network Identifier\n"
1284 "mac-mobility sequence\n"
1294 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1295 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1296 vty_out(vty
, "%% Malformed MAC address\n");
1299 memset(&ip
, 0, sizeof(ip
));
1300 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1302 bgp
= bgp_get_default();
1304 vty_out(vty
, "Default BGP instance is not there\n");
1308 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1311 vty_out(vty
, "Internal error\n");
1318 DEFUN_HIDDEN (no_bgp_local_mac
,
1319 no_bgp_local_mac_cmd
,
1320 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1323 "Local MAC config\n"
1324 "VxLAN Network Identifier\n"
1335 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1336 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1337 vty_out(vty
, "%% Malformed MAC address\n");
1340 memset(&ip
, 0, sizeof(ip
));
1342 bgp
= bgp_get_default();
1344 vty_out(vty
, "Default BGP instance is not there\n");
1348 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1350 vty_out(vty
, "Internal error\n");
1357 DEFUN (no_synchronization
,
1358 no_synchronization_cmd
,
1359 "no synchronization",
1361 "Perform IGP synchronization\n")
1366 DEFUN (no_auto_summary
,
1367 no_auto_summary_cmd
,
1370 "Enable automatic network number summarization\n")
1375 /* "router bgp" commands. */
1376 DEFUN_NOSH (router_bgp
,
1378 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1382 BGP_INSTANCE_HELP_STR
)
1385 int idx_view_vrf
= 3;
1391 const char *name
= NULL
;
1392 enum bgp_instance_type inst_type
;
1394 // "router bgp" without an ASN
1396 // Pending: Make VRF option available for ASN less config
1397 bgp
= bgp_get_default();
1400 vty_out(vty
, "%% No BGP process is configured\n");
1401 return CMD_WARNING_CONFIG_FAILED
;
1404 if (listcount(bm
->bgp
) > 1) {
1405 vty_out(vty
, "%% Please specify ASN and VRF\n");
1406 return CMD_WARNING_CONFIG_FAILED
;
1412 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1414 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1415 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1416 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1418 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1420 name
= argv
[idx_vrf
]->arg
;
1422 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1423 if (strmatch(name
, VRF_DEFAULT_NAME
))
1426 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1427 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1428 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1431 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1432 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1434 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1436 case BGP_ERR_AS_MISMATCH
:
1437 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1438 return CMD_WARNING_CONFIG_FAILED
;
1439 case BGP_ERR_INSTANCE_MISMATCH
:
1441 "BGP instance name and AS number mismatch\n");
1443 "BGP instance is already running; AS is %u\n",
1445 return CMD_WARNING_CONFIG_FAILED
;
1449 * If we just instantiated the default instance, complete
1450 * any pending VRF-VPN leaking that was configured via
1451 * earlier "router bgp X vrf FOO" blocks.
1453 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1454 vpn_leak_postchange_all();
1456 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1457 bgp_vpn_leak_export(bgp
);
1458 /* Pending: handle when user tries to change a view to vrf n vv.
1462 /* unset the auto created flag as the user config is now present */
1463 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1464 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1469 /* "no router bgp" commands. */
1470 DEFUN (no_router_bgp
,
1472 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1477 BGP_INSTANCE_HELP_STR
)
1483 const char *name
= NULL
;
1485 // "no router bgp" without an ASN
1487 // Pending: Make VRF option available for ASN less config
1488 bgp
= bgp_get_default();
1491 vty_out(vty
, "%% No BGP process is configured\n");
1492 return CMD_WARNING_CONFIG_FAILED
;
1495 if (listcount(bm
->bgp
) > 1) {
1496 vty_out(vty
, "%% Please specify ASN and VRF\n");
1497 return CMD_WARNING_CONFIG_FAILED
;
1501 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1503 return CMD_WARNING_CONFIG_FAILED
;
1506 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1509 name
= argv
[idx_vrf
]->arg
;
1510 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1511 && strmatch(name
, VRF_DEFAULT_NAME
))
1515 /* Lookup bgp structure. */
1516 bgp
= bgp_lookup(as
, name
);
1518 vty_out(vty
, "%% Can't find BGP instance\n");
1519 return CMD_WARNING_CONFIG_FAILED
;
1523 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1525 return CMD_WARNING_CONFIG_FAILED
;
1528 /* Cannot delete default instance if vrf instances exist */
1529 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1530 struct listnode
*node
;
1531 struct bgp
*tmp_bgp
;
1533 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1534 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1536 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1537 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1538 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1539 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1540 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1541 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1542 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1543 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1544 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1545 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1546 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1547 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1548 (bgp
== bgp_get_evpn() &&
1549 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1550 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1551 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1552 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1553 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1554 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1555 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1556 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1557 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1559 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1560 return CMD_WARNING_CONFIG_FAILED
;
1571 /* bgp session-dscp */
1573 DEFPY (bgp_session_dscp
,
1574 bgp_session_dscp_cmd
,
1575 "bgp session-dscp (0-63)$dscp",
1577 "Override default (C6) bgp TCP session DSCP value\n"
1578 "Manually configured dscp parameter\n")
1580 bm
->tcp_dscp
= dscp
<< 2;
1585 DEFPY (no_bgp_session_dscp
,
1586 no_bgp_session_dscp_cmd
,
1587 "no bgp session-dscp [(0-63)]",
1590 "Override default (C6) bgp TCP session DSCP value\n"
1591 "Manually configured dscp parameter\n")
1593 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1598 /* BGP router-id. */
1600 DEFPY (bgp_router_id
,
1602 "bgp router-id A.B.C.D",
1604 "Override configured router identifier\n"
1605 "Manually configured router identifier\n")
1607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1608 bgp_router_id_static_set(bgp
, router_id
);
1612 DEFPY (no_bgp_router_id
,
1613 no_bgp_router_id_cmd
,
1614 "no bgp router-id [A.B.C.D]",
1617 "Override configured router identifier\n"
1618 "Manually configured router identifier\n")
1620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1622 if (router_id_str
) {
1623 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1624 vty_out(vty
, "%% BGP router-id doesn't match\n");
1625 return CMD_WARNING_CONFIG_FAILED
;
1629 router_id
.s_addr
= 0;
1630 bgp_router_id_static_set(bgp
, router_id
);
1635 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1636 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1638 "Add community specific parameters\n"
1639 "Create an alias for a community\n"
1640 "Community (AA:BB or AA:BB:CC)\n"
1643 struct community_alias ca1
;
1644 struct community_alias ca2
;
1645 struct community_alias
*lookup_community
;
1646 struct community_alias
*lookup_alias
;
1648 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1649 vty_out(vty
, "Invalid community format\n");
1653 memset(&ca1
, 0, sizeof(ca1
));
1654 memset(&ca2
, 0, sizeof(ca2
));
1655 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1656 strlcpy(ca1
.alias
, alias_name
, sizeof(ca1
.alias
));
1658 lookup_community
= bgp_ca_community_lookup(&ca1
);
1659 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1662 bgp_ca_alias_delete(&ca1
);
1663 bgp_ca_community_delete(&ca1
);
1666 /* Lookup if community hash table has an item
1667 * with the same alias name.
1669 strlcpy(ca2
.community
, lookup_alias
->community
,
1670 sizeof(ca2
.community
));
1671 if (bgp_ca_community_lookup(&ca2
)) {
1673 "community (%s) already has this alias (%s)\n",
1674 lookup_alias
->community
,
1675 lookup_alias
->alias
);
1678 bgp_ca_alias_delete(&ca1
);
1681 if (lookup_community
)
1682 bgp_ca_community_delete(&ca1
);
1684 bgp_ca_alias_insert(&ca1
);
1685 bgp_ca_community_insert(&ca1
);
1691 DEFPY (bgp_global_suppress_fib_pending
,
1692 bgp_global_suppress_fib_pending_cmd
,
1693 "[no] bgp suppress-fib-pending",
1696 "Advertise only routes that are programmed in kernel to peers globally\n")
1698 bm_wait_for_fib_set(!no
);
1703 DEFPY (bgp_suppress_fib_pending
,
1704 bgp_suppress_fib_pending_cmd
,
1705 "[no] bgp suppress-fib-pending",
1708 "Advertise only routes that are programmed in kernel to peers\n")
1710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1712 bgp_suppress_fib_pending_set(bgp
, !no
);
1717 /* BGP Cluster ID. */
1718 DEFUN (bgp_cluster_id
,
1720 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1722 "Configure Route-Reflector Cluster-id\n"
1723 "Route-Reflector Cluster-id in IP address format\n"
1724 "Route-Reflector Cluster-id as 32 bit quantity\n")
1726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1729 struct in_addr cluster
;
1731 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1733 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1734 return CMD_WARNING_CONFIG_FAILED
;
1737 bgp_cluster_id_set(bgp
, &cluster
);
1738 bgp_clear_star_soft_out(vty
, bgp
->name
);
1743 DEFUN (no_bgp_cluster_id
,
1744 no_bgp_cluster_id_cmd
,
1745 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1748 "Configure Route-Reflector Cluster-id\n"
1749 "Route-Reflector Cluster-id in IP address format\n"
1750 "Route-Reflector Cluster-id as 32 bit quantity\n")
1752 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1753 bgp_cluster_id_unset(bgp
);
1754 bgp_clear_star_soft_out(vty
, bgp
->name
);
1763 "Disable BGP route installation to RIB (Zebra)\n")
1765 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1767 "%% No-RIB option is already set, nothing to do here.\n");
1771 bgp_option_norib_set_runtime();
1776 DEFPY (no_bgp_norib
,
1781 "Disable BGP route installation to RIB (Zebra)\n")
1783 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1785 "%% No-RIB option is not set, nothing to do here.\n");
1789 bgp_option_norib_unset_runtime();
1794 DEFPY (no_bgp_send_extra_data
,
1795 no_bgp_send_extra_data_cmd
,
1796 "[no] bgp send-extra-data zebra",
1799 "Extra data to Zebra for display/use\n"
1803 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1805 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1810 DEFUN (bgp_confederation_identifier
,
1811 bgp_confederation_identifier_cmd
,
1812 "bgp confederation identifier (1-4294967295)",
1814 "AS confederation parameters\n"
1816 "Set routing domain confederation AS\n")
1818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1822 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1824 bgp_confederation_id_set(bgp
, as
);
1829 DEFUN (no_bgp_confederation_identifier
,
1830 no_bgp_confederation_identifier_cmd
,
1831 "no bgp confederation identifier [(1-4294967295)]",
1834 "AS confederation parameters\n"
1836 "Set routing domain confederation AS\n")
1838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1839 bgp_confederation_id_unset(bgp
);
1844 DEFUN (bgp_confederation_peers
,
1845 bgp_confederation_peers_cmd
,
1846 "bgp confederation peers (1-4294967295)...",
1848 "AS confederation parameters\n"
1849 "Peer ASs in BGP confederation\n"
1852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 for (i
= idx_asn
; i
< argc
; i
++) {
1858 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1860 if (bgp
->as
== as
) {
1862 "%% Local member-AS not allowed in confed peer list\n");
1866 bgp_confederation_peers_add(bgp
, as
);
1871 DEFUN (no_bgp_confederation_peers
,
1872 no_bgp_confederation_peers_cmd
,
1873 "no bgp confederation peers (1-4294967295)...",
1876 "AS confederation parameters\n"
1877 "Peer ASs in BGP confederation\n"
1880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1885 for (i
= idx_asn
; i
< argc
; i
++) {
1886 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1888 bgp_confederation_peers_remove(bgp
, as
);
1894 * Central routine for maximum-paths configuration.
1895 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1896 * @set: 1 for setting values, 0 for removing the max-paths config.
1898 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1899 const char *mpaths
, uint16_t options
,
1902 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1903 uint16_t maxpaths
= 0;
1908 afi
= bgp_node_afi(vty
);
1909 safi
= bgp_node_safi(vty
);
1912 maxpaths
= strtol(mpaths
, NULL
, 10);
1913 if (maxpaths
> multipath_num
) {
1915 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1916 maxpaths
, multipath_num
);
1917 return CMD_WARNING_CONFIG_FAILED
;
1919 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1922 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1926 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1927 (set
== 1) ? "" : "un",
1928 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1929 maxpaths
, afi
, safi
);
1930 return CMD_WARNING_CONFIG_FAILED
;
1933 bgp_recalculate_all_bestpaths(bgp
);
1938 DEFUN (bgp_maxmed_admin
,
1939 bgp_maxmed_admin_cmd
,
1940 "bgp max-med administrative ",
1942 "Advertise routes with max-med\n"
1943 "Administratively applied, for an indefinite period\n")
1945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1947 bgp
->v_maxmed_admin
= 1;
1948 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1950 bgp_maxmed_update(bgp
);
1955 DEFUN (bgp_maxmed_admin_medv
,
1956 bgp_maxmed_admin_medv_cmd
,
1957 "bgp max-med administrative (0-4294967295)",
1959 "Advertise routes with max-med\n"
1960 "Administratively applied, for an indefinite period\n"
1961 "Max MED value to be used\n")
1963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1966 bgp
->v_maxmed_admin
= 1;
1967 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1969 bgp_maxmed_update(bgp
);
1974 DEFUN (no_bgp_maxmed_admin
,
1975 no_bgp_maxmed_admin_cmd
,
1976 "no bgp max-med administrative [(0-4294967295)]",
1979 "Advertise routes with max-med\n"
1980 "Administratively applied, for an indefinite period\n"
1981 "Max MED value to be used\n")
1983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1985 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1986 bgp_maxmed_update(bgp
);
1991 DEFUN (bgp_maxmed_onstartup
,
1992 bgp_maxmed_onstartup_cmd
,
1993 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1995 "Advertise routes with max-med\n"
1996 "Effective on a startup\n"
1997 "Time (seconds) period for max-med\n"
1998 "Max MED value to be used\n")
2000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2003 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2004 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2005 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2006 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2008 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2010 bgp_maxmed_update(bgp
);
2015 DEFUN (no_bgp_maxmed_onstartup
,
2016 no_bgp_maxmed_onstartup_cmd
,
2017 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2020 "Advertise routes with max-med\n"
2021 "Effective on a startup\n"
2022 "Time (seconds) period for max-med\n"
2023 "Max MED value to be used\n")
2025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2027 /* Cancel max-med onstartup if its on */
2028 if (bgp
->t_maxmed_onstartup
) {
2029 thread_cancel(&bgp
->t_maxmed_onstartup
);
2030 bgp
->maxmed_onstartup_over
= 1;
2033 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2034 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2036 bgp_maxmed_update(bgp
);
2041 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2042 uint16_t update_delay
,
2043 uint16_t establish_wait
)
2045 struct listnode
*node
, *nnode
;
2047 bool vrf_cfg
= false;
2050 * See if update-delay is set per-vrf and warn user to delete it
2051 * Note that we only need to check this if this is the first time
2052 * setting the global config.
2054 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2055 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2056 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2058 "%% update-delay configuration found in vrf %s\n",
2059 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2069 "%%Failed: global update-delay config not permitted\n");
2073 if (!establish_wait
) { /* update-delay <delay> */
2074 bm
->v_update_delay
= update_delay
;
2075 bm
->v_establish_wait
= bm
->v_update_delay
;
2077 /* update-delay <delay> <establish-wait> */
2078 if (update_delay
< establish_wait
) {
2080 "%%Failed: update-delay less than the establish-wait!\n");
2081 return CMD_WARNING_CONFIG_FAILED
;
2084 bm
->v_update_delay
= update_delay
;
2085 bm
->v_establish_wait
= establish_wait
;
2088 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2089 bgp
->v_update_delay
= bm
->v_update_delay
;
2090 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2096 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2098 struct listnode
*node
, *nnode
;
2101 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2102 bm
->v_establish_wait
= bm
->v_update_delay
;
2104 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2105 bgp
->v_update_delay
= bm
->v_update_delay
;
2106 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2112 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2113 uint16_t establish_wait
)
2115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2117 /* if configured globally, per-instance config is not allowed */
2118 if (bm
->v_update_delay
) {
2120 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2121 return CMD_WARNING_CONFIG_FAILED
;
2125 if (!establish_wait
) /* update-delay <delay> */
2127 bgp
->v_update_delay
= update_delay
;
2128 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2132 /* update-delay <delay> <establish-wait> */
2133 if (update_delay
< establish_wait
) {
2135 "%%Failed: update-delay less than the establish-wait!\n");
2136 return CMD_WARNING_CONFIG_FAILED
;
2139 bgp
->v_update_delay
= update_delay
;
2140 bgp
->v_establish_wait
= establish_wait
;
2145 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2149 /* If configured globally, cannot remove from one bgp instance */
2150 if (bm
->v_update_delay
) {
2152 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2153 return CMD_WARNING_CONFIG_FAILED
;
2155 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2156 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2161 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2163 /* If configured globally, no need to display per-instance value */
2164 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2165 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2166 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2167 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2172 /* Global update-delay configuration */
2173 DEFPY (bgp_global_update_delay
,
2174 bgp_global_update_delay_cmd
,
2175 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2177 "Force initial delay for best-path and updates for all bgp instances\n"
2178 "Max delay in seconds\n"
2179 "Establish wait in seconds\n")
2181 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2184 /* Global update-delay deconfiguration */
2185 DEFPY (no_bgp_global_update_delay
,
2186 no_bgp_global_update_delay_cmd
,
2187 "no bgp update-delay [(0-3600) [(1-3600)]]",
2190 "Force initial delay for best-path and updates\n"
2191 "Max delay in seconds\n"
2192 "Establish wait in seconds\n")
2194 return bgp_global_update_delay_deconfig_vty(vty
);
2197 /* Update-delay configuration */
2199 DEFPY (bgp_update_delay
,
2200 bgp_update_delay_cmd
,
2201 "update-delay (0-3600)$delay [(1-3600)$wait]",
2202 "Force initial delay for best-path and updates\n"
2203 "Max delay in seconds\n"
2204 "Establish wait in seconds\n")
2206 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2209 /* Update-delay deconfiguration */
2210 DEFPY (no_bgp_update_delay
,
2211 no_bgp_update_delay_cmd
,
2212 "no update-delay [(0-3600) [(1-3600)]]",
2214 "Force initial delay for best-path and updates\n"
2215 "Max delay in seconds\n"
2216 "Establish wait in seconds\n")
2218 return bgp_update_delay_deconfig_vty(vty
);
2222 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2227 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2228 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2233 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2236 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2238 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2239 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2244 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2247 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2248 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2249 vty_out(vty
, " write-quanta %d\n", quanta
);
2252 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2255 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2256 if (quanta
!= BGP_READ_PACKET_MAX
)
2257 vty_out(vty
, " read-quanta %d\n", quanta
);
2260 /* Packet quanta configuration
2262 * XXX: The value set here controls the size of a stack buffer in the IO
2263 * thread. When changing these limits be careful to prevent stack overflow.
2265 * Furthermore, the maximums used here should correspond to
2266 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2268 DEFPY (bgp_wpkt_quanta
,
2269 bgp_wpkt_quanta_cmd
,
2270 "[no] write-quanta (1-64)$quanta",
2272 "How many packets to write to peer socket per run\n"
2273 "Number of packets\n")
2275 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2278 DEFPY (bgp_rpkt_quanta
,
2279 bgp_rpkt_quanta_cmd
,
2280 "[no] read-quanta (1-10)$quanta",
2282 "How many packets to read from peer socket per I/O cycle\n"
2283 "Number of packets\n")
2285 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2288 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2290 if (!bgp
->heuristic_coalesce
)
2291 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2295 DEFUN (bgp_coalesce_time
,
2296 bgp_coalesce_time_cmd
,
2297 "coalesce-time (0-4294967295)",
2298 "Subgroup coalesce timer\n"
2299 "Subgroup coalesce timer value (in ms)\n")
2301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2305 bgp
->heuristic_coalesce
= false;
2307 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2308 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2313 DEFUN (no_bgp_coalesce_time
,
2314 no_bgp_coalesce_time_cmd
,
2315 "no coalesce-time (0-4294967295)",
2317 "Subgroup coalesce timer\n"
2318 "Subgroup coalesce timer value (in ms)\n")
2320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2322 bgp
->heuristic_coalesce
= true;
2323 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2327 /* Maximum-paths configuration */
2328 DEFUN (bgp_maxpaths
,
2330 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2331 "Forward packets over multiple paths\n"
2332 "Number of paths\n")
2335 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2336 argv
[idx_number
]->arg
, 0, 1);
2339 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2340 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2341 "Forward packets over multiple paths\n"
2342 "Number of paths\n")
2344 DEFUN (bgp_maxpaths_ibgp
,
2345 bgp_maxpaths_ibgp_cmd
,
2346 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2347 "Forward packets over multiple paths\n"
2349 "Number of paths\n")
2352 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2353 argv
[idx_number
]->arg
, 0, 1);
2356 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2357 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2358 "Forward packets over multiple paths\n"
2360 "Number of paths\n")
2362 DEFUN (bgp_maxpaths_ibgp_cluster
,
2363 bgp_maxpaths_ibgp_cluster_cmd
,
2364 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2365 "Forward packets over multiple paths\n"
2368 "Match the cluster length\n")
2371 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2372 argv
[idx_number
]->arg
, true, 1);
2375 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2376 "maximum-paths ibgp " CMD_RANGE_STR(
2377 1, MULTIPATH_NUM
) " equal-cluster-length",
2378 "Forward packets over multiple paths\n"
2381 "Match the cluster length\n")
2383 DEFUN (no_bgp_maxpaths
,
2384 no_bgp_maxpaths_cmd
,
2385 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2387 "Forward packets over multiple paths\n"
2388 "Number of paths\n")
2390 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2393 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2394 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2395 "Forward packets over multiple paths\n"
2396 "Number of paths\n")
2398 DEFUN (no_bgp_maxpaths_ibgp
,
2399 no_bgp_maxpaths_ibgp_cmd
,
2400 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2402 "Forward packets over multiple paths\n"
2405 "Match the cluster length\n")
2407 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2410 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2411 "no maximum-paths ibgp [" CMD_RANGE_STR(
2412 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2414 "Forward packets over multiple paths\n"
2417 "Match the cluster length\n")
2419 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2420 afi_t afi
, safi_t safi
)
2422 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2423 vty_out(vty
, " maximum-paths %d\n",
2424 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2427 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2428 vty_out(vty
, " maximum-paths ibgp %d",
2429 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2430 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2431 vty_out(vty
, " equal-cluster-length");
2440 "timers bgp (0-65535) (0-65535)",
2441 "Adjust routing timers\n"
2443 "Keepalive interval\n"
2446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2448 int idx_number_2
= 3;
2449 unsigned long keepalive
= 0;
2450 unsigned long holdtime
= 0;
2452 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2453 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2455 /* Holdtime value check. */
2456 if (holdtime
< 3 && holdtime
!= 0) {
2458 "%% hold time value must be either 0 or greater than 3\n");
2459 return CMD_WARNING_CONFIG_FAILED
;
2462 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2463 BGP_DEFAULT_DELAYOPEN
);
2468 DEFUN (no_bgp_timers
,
2470 "no timers bgp [(0-65535) (0-65535)]",
2472 "Adjust routing timers\n"
2474 "Keepalive interval\n"
2477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2478 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2479 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2484 /* BGP minimum holdtime. */
2486 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2487 "bgp minimum-holdtime (1-65535)",
2488 "BGP specific commands\n"
2489 "BGP minimum holdtime\n"
2492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2494 unsigned long min_holdtime
;
2496 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2498 bgp
->default_min_holdtime
= min_holdtime
;
2503 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2504 "no bgp minimum-holdtime [(1-65535)]",
2506 "BGP specific commands\n"
2507 "BGP minimum holdtime\n"
2510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2512 bgp
->default_min_holdtime
= 0;
2517 DEFUN (bgp_client_to_client_reflection
,
2518 bgp_client_to_client_reflection_cmd
,
2519 "bgp client-to-client reflection",
2521 "Configure client to client route reflection\n"
2522 "reflection of routes allowed\n")
2524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2525 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2526 bgp_clear_star_soft_out(vty
, bgp
->name
);
2531 DEFUN (no_bgp_client_to_client_reflection
,
2532 no_bgp_client_to_client_reflection_cmd
,
2533 "no bgp client-to-client reflection",
2536 "Configure client to client route reflection\n"
2537 "reflection of routes allowed\n")
2539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2540 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2541 bgp_clear_star_soft_out(vty
, bgp
->name
);
2546 /* "bgp always-compare-med" configuration. */
2547 DEFUN (bgp_always_compare_med
,
2548 bgp_always_compare_med_cmd
,
2549 "bgp always-compare-med",
2551 "Allow comparing MED from different neighbors\n")
2553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2554 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2555 bgp_recalculate_all_bestpaths(bgp
);
2560 DEFUN (no_bgp_always_compare_med
,
2561 no_bgp_always_compare_med_cmd
,
2562 "no bgp always-compare-med",
2565 "Allow comparing MED from different neighbors\n")
2567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2568 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2569 bgp_recalculate_all_bestpaths(bgp
);
2575 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2576 "bgp ebgp-requires-policy",
2578 "Require in and out policy for eBGP peers (RFC8212)\n")
2580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2581 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2585 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2586 "no bgp ebgp-requires-policy",
2589 "Require in and out policy for eBGP peers (RFC8212)\n")
2591 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2592 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2596 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2597 "bgp suppress-duplicates",
2599 "Suppress duplicate updates if the route actually not changed\n")
2601 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2602 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2606 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2607 "no bgp suppress-duplicates",
2610 "Suppress duplicate updates if the route actually not changed\n")
2612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2617 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2618 "bgp reject-as-sets",
2620 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2623 struct listnode
*node
, *nnode
;
2626 bgp
->reject_as_sets
= true;
2628 /* Reset existing BGP sessions to reject routes
2629 * with aspath containing AS_SET or AS_CONFED_SET.
2631 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2632 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2633 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2634 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2635 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2642 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2643 "no bgp reject-as-sets",
2646 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2649 struct listnode
*node
, *nnode
;
2652 bgp
->reject_as_sets
= false;
2654 /* Reset existing BGP sessions to reject routes
2655 * with aspath containing AS_SET or AS_CONFED_SET.
2657 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2658 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2659 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2660 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2661 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2668 /* "bgp deterministic-med" configuration. */
2669 DEFUN (bgp_deterministic_med
,
2670 bgp_deterministic_med_cmd
,
2671 "bgp deterministic-med",
2673 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2677 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2678 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2679 bgp_recalculate_all_bestpaths(bgp
);
2685 DEFUN (no_bgp_deterministic_med
,
2686 no_bgp_deterministic_med_cmd
,
2687 "no bgp deterministic-med",
2690 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 int bestpath_per_as_used
;
2697 struct listnode
*node
, *nnode
;
2699 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2700 bestpath_per_as_used
= 0;
2702 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2703 FOREACH_AFI_SAFI (afi
, safi
)
2704 if (bgp_addpath_dmed_required(
2705 peer
->addpath_type
[afi
][safi
])) {
2706 bestpath_per_as_used
= 1;
2710 if (bestpath_per_as_used
)
2714 if (bestpath_per_as_used
) {
2716 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2717 return CMD_WARNING_CONFIG_FAILED
;
2719 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2720 bgp_recalculate_all_bestpaths(bgp
);
2727 /* "bgp graceful-restart mode" configuration. */
2728 DEFUN (bgp_graceful_restart
,
2729 bgp_graceful_restart_cmd
,
2730 "bgp graceful-restart",
2735 int ret
= BGP_GR_FAILURE
;
2737 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2738 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2742 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2744 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2747 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2748 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2750 "Graceful restart configuration changed, reset all peers to take effect\n");
2751 return bgp_vty_return(vty
, ret
);
2754 DEFUN (no_bgp_graceful_restart
,
2755 no_bgp_graceful_restart_cmd
,
2756 "no bgp graceful-restart",
2762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2764 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2765 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2767 int ret
= BGP_GR_FAILURE
;
2769 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2771 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2774 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2775 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2777 "Graceful restart configuration changed, reset all peers to take effect\n");
2779 return bgp_vty_return(vty
, ret
);
2782 DEFUN (bgp_graceful_restart_stalepath_time
,
2783 bgp_graceful_restart_stalepath_time_cmd
,
2784 "bgp graceful-restart stalepath-time (1-4095)",
2786 "Graceful restart capability parameters\n"
2787 "Set the max time to hold onto restarting peer's stale paths\n"
2788 "Delay value (seconds)\n")
2790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2794 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2795 bgp
->stalepath_time
= stalepath
;
2799 DEFUN (bgp_graceful_restart_restart_time
,
2800 bgp_graceful_restart_restart_time_cmd
,
2801 "bgp graceful-restart restart-time (0-4095)",
2803 "Graceful restart capability parameters\n"
2804 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2805 "Delay value (seconds)\n")
2807 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2811 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2812 bgp
->restart_time
= restart
;
2816 DEFUN (bgp_graceful_restart_select_defer_time
,
2817 bgp_graceful_restart_select_defer_time_cmd
,
2818 "bgp graceful-restart select-defer-time (0-3600)",
2820 "Graceful restart capability parameters\n"
2821 "Set the time to defer the BGP route selection after restart\n"
2822 "Delay value (seconds, 0 - disable)\n")
2824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2826 uint32_t defer_time
;
2828 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2829 bgp
->select_defer_time
= defer_time
;
2830 if (defer_time
== 0)
2831 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2833 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2838 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2839 no_bgp_graceful_restart_stalepath_time_cmd
,
2840 "no 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
);
2849 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2853 DEFUN (no_bgp_graceful_restart_restart_time
,
2854 no_bgp_graceful_restart_restart_time_cmd
,
2855 "no bgp graceful-restart restart-time [(0-4095)]",
2858 "Graceful restart capability parameters\n"
2859 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2860 "Delay value (seconds)\n")
2862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2864 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2868 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2869 no_bgp_graceful_restart_select_defer_time_cmd
,
2870 "no bgp graceful-restart select-defer-time [(0-3600)]",
2873 "Graceful restart capability parameters\n"
2874 "Set the time to defer the BGP route selection after restart\n"
2875 "Delay value (seconds)\n")
2877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2879 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2880 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2885 DEFUN (bgp_graceful_restart_preserve_fw
,
2886 bgp_graceful_restart_preserve_fw_cmd
,
2887 "bgp graceful-restart preserve-fw-state",
2889 "Graceful restart capability parameters\n"
2890 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2893 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2897 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2898 no_bgp_graceful_restart_preserve_fw_cmd
,
2899 "no bgp graceful-restart preserve-fw-state",
2902 "Graceful restart capability parameters\n"
2903 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2910 DEFPY (bgp_graceful_restart_notification
,
2911 bgp_graceful_restart_notification_cmd
,
2912 "[no$no] bgp graceful-restart notification",
2915 "Graceful restart capability parameters\n"
2916 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
2918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2921 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2923 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2928 DEFPY (bgp_administrative_reset
,
2929 bgp_administrative_reset_cmd
,
2930 "[no$no] bgp hard-administrative-reset",
2933 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
2935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2938 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2940 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2945 DEFUN (bgp_graceful_restart_disable
,
2946 bgp_graceful_restart_disable_cmd
,
2947 "bgp graceful-restart-disable",
2951 int ret
= BGP_GR_FAILURE
;
2953 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2955 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2959 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2961 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2964 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2966 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2968 "Graceful restart configuration changed, reset all peers to take effect\n");
2970 return bgp_vty_return(vty
, ret
);
2973 DEFUN (no_bgp_graceful_restart_disable
,
2974 no_bgp_graceful_restart_disable_cmd
,
2975 "no bgp graceful-restart-disable",
2981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2983 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2985 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2987 int ret
= BGP_GR_FAILURE
;
2989 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2991 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2994 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2996 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2998 "Graceful restart configuration changed, reset all peers to take effect\n");
3000 return bgp_vty_return(vty
, ret
);
3003 DEFUN (bgp_neighbor_graceful_restart_set
,
3004 bgp_neighbor_graceful_restart_set_cmd
,
3005 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3013 int ret
= BGP_GR_FAILURE
;
3015 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3017 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3019 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3021 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3023 return CMD_WARNING_CONFIG_FAILED
;
3025 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3027 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3028 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3030 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3032 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3034 "Graceful restart configuration changed, reset this peer to take effect\n");
3036 return bgp_vty_return(vty
, ret
);
3039 DEFUN (no_bgp_neighbor_graceful_restart
,
3040 no_bgp_neighbor_graceful_restart_set_cmd
,
3041 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3049 int ret
= BGP_GR_FAILURE
;
3052 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3054 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3056 return CMD_WARNING_CONFIG_FAILED
;
3058 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3060 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3062 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3064 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3065 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3067 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3069 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3071 "Graceful restart configuration changed, reset this peer to take effect\n");
3073 return bgp_vty_return(vty
, ret
);
3076 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3077 bgp_neighbor_graceful_restart_helper_set_cmd
,
3078 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3081 GR_NEIGHBOR_HELPER_CMD
3086 int ret
= BGP_GR_FAILURE
;
3088 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3090 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3092 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3094 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3097 return CMD_WARNING_CONFIG_FAILED
;
3100 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3102 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3103 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3105 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3107 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3109 "Graceful restart configuration changed, reset this peer to take effect\n");
3111 return bgp_vty_return(vty
, ret
);
3114 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3115 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3116 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3120 NO_GR_NEIGHBOR_HELPER_CMD
3124 int ret
= BGP_GR_FAILURE
;
3127 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3129 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3131 return CMD_WARNING_CONFIG_FAILED
;
3133 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3135 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3137 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3139 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3140 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3142 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3144 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3146 "Graceful restart configuration changed, reset this peer to take effect\n");
3148 return bgp_vty_return(vty
, ret
);
3151 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3152 bgp_neighbor_graceful_restart_disable_set_cmd
,
3153 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3156 GR_NEIGHBOR_DISABLE_CMD
3161 int ret
= BGP_GR_FAILURE
;
3163 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3165 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3167 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3169 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3171 return CMD_WARNING_CONFIG_FAILED
;
3173 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3175 if (peer
->bgp
->t_startup
)
3176 bgp_peer_gr_flags_update(peer
);
3178 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3179 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3181 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3183 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3185 "Graceful restart configuration changed, reset this peer to take effect\n");
3187 return bgp_vty_return(vty
, ret
);
3190 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3191 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3192 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3196 NO_GR_NEIGHBOR_DISABLE_CMD
3200 int ret
= BGP_GR_FAILURE
;
3203 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3205 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3207 return CMD_WARNING_CONFIG_FAILED
;
3209 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3211 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3213 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3215 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3216 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3218 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3220 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3222 "Graceful restart configuration changed, reset this peer to take effect\n");
3224 return bgp_vty_return(vty
, ret
);
3227 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3228 bgp_graceful_restart_disable_eor_cmd
,
3229 "bgp graceful-restart disable-eor",
3231 "Graceful restart configuration parameters\n"
3232 "Disable EOR Check\n")
3234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3235 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3240 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3241 no_bgp_graceful_restart_disable_eor_cmd
,
3242 "no bgp graceful-restart disable-eor",
3245 "Graceful restart configuration parameters\n"
3246 "Disable EOR Check\n")
3248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3249 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3254 DEFUN (bgp_graceful_restart_rib_stale_time
,
3255 bgp_graceful_restart_rib_stale_time_cmd
,
3256 "bgp graceful-restart rib-stale-time (1-3600)",
3258 "Graceful restart configuration parameters\n"
3259 "Specify the stale route removal timer in rib\n"
3260 "Delay value (seconds)\n")
3262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3264 uint32_t stale_time
;
3266 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3267 bgp
->rib_stale_time
= stale_time
;
3268 /* Send the stale timer update message to RIB */
3269 if (bgp_zebra_stale_timer_update(bgp
))
3275 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3276 no_bgp_graceful_restart_rib_stale_time_cmd
,
3277 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3280 "Graceful restart configuration parameters\n"
3281 "Specify the stale route removal timer in rib\n"
3282 "Delay value (seconds)\n")
3284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3286 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3287 /* Send the stale timer update message to RIB */
3288 if (bgp_zebra_stale_timer_update(bgp
))
3294 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3295 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3297 "Enable Long-lived Graceful Restart\n"
3298 "Specifies maximum time to wait before purging long-lived stale routes\n"
3299 "Stale time value (seconds)\n")
3301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3303 uint32_t llgr_stale_time
;
3305 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3306 bgp
->llgr_stale_time
= llgr_stale_time
;
3311 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3312 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3314 "Enable Long-lived Graceful Restart\n"
3315 "Specifies maximum time to wait before purging long-lived stale routes\n"
3316 "Stale time value (seconds)\n")
3318 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3320 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3325 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3328 bgp_static_redo_import_check(bgp
);
3329 bgp_redistribute_redo(bgp
);
3330 bgp_clear_star_soft_out(vty
, bgp
->name
);
3331 bgp_clear_star_soft_in(vty
, bgp
->name
);
3334 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3336 struct listnode
*node
, *nnode
;
3338 bool vrf_cfg
= false;
3340 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3343 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3344 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3345 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3347 "%% graceful-shutdown configuration found in vrf %s\n",
3348 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3349 VRF_DEFAULT_NAME
: bgp
->name
);
3356 "%%Failed: global graceful-shutdown not permitted\n");
3360 /* Set flag globally */
3361 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3363 /* Initiate processing for all BGP instances. */
3364 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3365 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3370 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3372 struct listnode
*node
, *nnode
;
3375 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3378 /* Unset flag globally */
3379 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3381 /* Initiate processing for all BGP instances. */
3382 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3383 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3388 /* "bgp graceful-shutdown" configuration */
3389 DEFUN (bgp_graceful_shutdown
,
3390 bgp_graceful_shutdown_cmd
,
3391 "bgp graceful-shutdown",
3393 "Graceful shutdown parameters\n")
3395 if (vty
->node
== CONFIG_NODE
)
3396 return bgp_global_graceful_shutdown_config_vty(vty
);
3398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3400 /* if configured globally, per-instance config is not allowed */
3401 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3403 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3404 return CMD_WARNING_CONFIG_FAILED
;
3407 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3408 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3409 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3415 DEFUN (no_bgp_graceful_shutdown
,
3416 no_bgp_graceful_shutdown_cmd
,
3417 "no bgp graceful-shutdown",
3420 "Graceful shutdown parameters\n")
3422 if (vty
->node
== CONFIG_NODE
)
3423 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3427 /* If configured globally, cannot remove from one bgp instance */
3428 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3430 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3431 return CMD_WARNING_CONFIG_FAILED
;
3434 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3435 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3436 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3442 /* "bgp fast-external-failover" configuration. */
3443 DEFUN (bgp_fast_external_failover
,
3444 bgp_fast_external_failover_cmd
,
3445 "bgp fast-external-failover",
3447 "Immediately reset session if a link to a directly connected external peer goes down\n")
3449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3450 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3454 DEFUN (no_bgp_fast_external_failover
,
3455 no_bgp_fast_external_failover_cmd
,
3456 "no bgp fast-external-failover",
3459 "Immediately reset session if a link to a directly connected external peer goes down\n")
3461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3462 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3466 /* "bgp bestpath compare-routerid" configuration. */
3467 DEFUN (bgp_bestpath_compare_router_id
,
3468 bgp_bestpath_compare_router_id_cmd
,
3469 "bgp bestpath compare-routerid",
3471 "Change the default bestpath selection\n"
3472 "Compare router-id for identical EBGP paths\n")
3474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3475 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3476 bgp_recalculate_all_bestpaths(bgp
);
3481 DEFUN (no_bgp_bestpath_compare_router_id
,
3482 no_bgp_bestpath_compare_router_id_cmd
,
3483 "no bgp bestpath compare-routerid",
3486 "Change the default bestpath selection\n"
3487 "Compare router-id for identical EBGP paths\n")
3489 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3490 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3491 bgp_recalculate_all_bestpaths(bgp
);
3496 /* "bgp bestpath as-path ignore" configuration. */
3497 DEFUN (bgp_bestpath_aspath_ignore
,
3498 bgp_bestpath_aspath_ignore_cmd
,
3499 "bgp bestpath as-path ignore",
3501 "Change the default bestpath selection\n"
3502 "AS-path attribute\n"
3503 "Ignore as-path length in selecting a route\n")
3505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3506 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3507 bgp_recalculate_all_bestpaths(bgp
);
3512 DEFUN (no_bgp_bestpath_aspath_ignore
,
3513 no_bgp_bestpath_aspath_ignore_cmd
,
3514 "no bgp bestpath as-path ignore",
3517 "Change the default bestpath selection\n"
3518 "AS-path attribute\n"
3519 "Ignore as-path length in selecting a route\n")
3521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3522 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3523 bgp_recalculate_all_bestpaths(bgp
);
3528 /* "bgp bestpath as-path confed" configuration. */
3529 DEFUN (bgp_bestpath_aspath_confed
,
3530 bgp_bestpath_aspath_confed_cmd
,
3531 "bgp bestpath as-path confed",
3533 "Change the default bestpath selection\n"
3534 "AS-path attribute\n"
3535 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3538 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3539 bgp_recalculate_all_bestpaths(bgp
);
3544 DEFUN (no_bgp_bestpath_aspath_confed
,
3545 no_bgp_bestpath_aspath_confed_cmd
,
3546 "no bgp bestpath as-path confed",
3549 "Change the default bestpath selection\n"
3550 "AS-path attribute\n"
3551 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3554 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3555 bgp_recalculate_all_bestpaths(bgp
);
3560 /* "bgp bestpath as-path multipath-relax" configuration. */
3561 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3562 bgp_bestpath_aspath_multipath_relax_cmd
,
3563 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3565 "Change the default bestpath selection\n"
3566 "AS-path attribute\n"
3567 "Allow load sharing across routes that have different AS paths (but same length)\n"
3568 "Generate an AS_SET\n"
3569 "Do not generate an AS_SET\n")
3571 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3573 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3575 /* no-as-set is now the default behavior so we can silently
3577 if (argv_find(argv
, argc
, "as-set", &idx
))
3578 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3580 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3582 bgp_recalculate_all_bestpaths(bgp
);
3587 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3588 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3589 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3592 "Change the default bestpath selection\n"
3593 "AS-path attribute\n"
3594 "Allow load sharing across routes that have different AS paths (but same length)\n"
3595 "Generate an AS_SET\n"
3596 "Do not generate an AS_SET\n")
3598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3599 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3600 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3601 bgp_recalculate_all_bestpaths(bgp
);
3606 /* "bgp bestpath peer-type multipath-relax" configuration. */
3607 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3608 bgp_bestpath_peer_type_multipath_relax_cmd
,
3609 "bgp bestpath peer-type multipath-relax",
3611 "Change the default bestpath selection\n"
3613 "Allow load sharing across routes learned from different peer types\n")
3615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3616 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3617 bgp_recalculate_all_bestpaths(bgp
);
3622 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3623 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3624 "no bgp bestpath peer-type multipath-relax",
3626 "Change the default bestpath selection\n"
3628 "Allow load sharing across routes learned from different peer types\n")
3630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3631 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3632 bgp_recalculate_all_bestpaths(bgp
);
3637 /* "bgp log-neighbor-changes" configuration. */
3638 DEFUN (bgp_log_neighbor_changes
,
3639 bgp_log_neighbor_changes_cmd
,
3640 "bgp log-neighbor-changes",
3642 "Log neighbor up/down and reset reason\n")
3644 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3645 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3649 DEFUN (no_bgp_log_neighbor_changes
,
3650 no_bgp_log_neighbor_changes_cmd
,
3651 "no bgp log-neighbor-changes",
3654 "Log neighbor up/down and reset reason\n")
3656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3657 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3661 /* "bgp bestpath med" configuration. */
3662 DEFUN (bgp_bestpath_med
,
3663 bgp_bestpath_med_cmd
,
3664 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3666 "Change the default bestpath selection\n"
3668 "Compare MED among confederation paths\n"
3669 "Treat missing MED as the least preferred one\n"
3670 "Treat missing MED as the least preferred one\n"
3671 "Compare MED among confederation paths\n")
3673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3676 if (argv_find(argv
, argc
, "confed", &idx
))
3677 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3679 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3680 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3682 bgp_recalculate_all_bestpaths(bgp
);
3687 DEFUN (no_bgp_bestpath_med
,
3688 no_bgp_bestpath_med_cmd
,
3689 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3692 "Change the default bestpath selection\n"
3694 "Compare MED among confederation paths\n"
3695 "Treat missing MED as the least preferred one\n"
3696 "Treat missing MED as the least preferred one\n"
3697 "Compare MED among confederation paths\n")
3699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3702 if (argv_find(argv
, argc
, "confed", &idx
))
3703 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3705 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3706 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3708 bgp_recalculate_all_bestpaths(bgp
);
3713 /* "bgp bestpath bandwidth" configuration. */
3714 DEFPY (bgp_bestpath_bw
,
3715 bgp_bestpath_bw_cmd
,
3716 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3718 "Change the default bestpath selection\n"
3719 "Link Bandwidth attribute\n"
3720 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3721 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3722 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3729 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3730 return CMD_ERR_INCOMPLETE
;
3732 if (!strcmp(bw_cfg
, "ignore"))
3733 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3734 else if (!strcmp(bw_cfg
, "skip-missing"))
3735 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3736 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3737 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3739 return CMD_ERR_NO_MATCH
;
3741 /* This config is used in route install, so redo that. */
3742 FOREACH_AFI_SAFI (afi
, safi
) {
3743 if (!bgp_fibupd_safi(safi
))
3745 bgp_zebra_announce_table(bgp
, afi
, safi
);
3751 DEFPY (no_bgp_bestpath_bw
,
3752 no_bgp_bestpath_bw_cmd
,
3753 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3756 "Change the default bestpath selection\n"
3757 "Link Bandwidth attribute\n"
3758 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3759 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3760 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3766 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3768 /* This config is used in route install, so redo that. */
3769 FOREACH_AFI_SAFI (afi
, safi
) {
3770 if (!bgp_fibupd_safi(safi
))
3772 bgp_zebra_announce_table(bgp
, afi
, safi
);
3777 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3778 "[no] bgp default <ipv4-unicast|"
3781 "ipv4-labeled-unicast|"
3786 "ipv6-labeled-unicast|"
3788 "l2vpn-evpn>$afi_safi",
3791 "Configure BGP defaults\n"
3792 "Activate ipv4-unicast for a peer by default\n"
3793 "Activate ipv4-multicast for a peer by default\n"
3794 "Activate ipv4-vpn for a peer by default\n"
3795 "Activate ipv4-labeled-unicast for a peer by default\n"
3796 "Activate ipv4-flowspec for a peer by default\n"
3797 "Activate ipv6-unicast for a peer by default\n"
3798 "Activate ipv6-multicast for a peer by default\n"
3799 "Activate ipv6-vpn for a peer by default\n"
3800 "Activate ipv6-labeled-unicast for a peer by default\n"
3801 "Activate ipv6-flowspec for a peer by default\n"
3802 "Activate l2vpn-evpn for a peer by default\n")
3804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3805 char afi_safi_str
[strlen(afi_safi
) + 1];
3806 char *afi_safi_str_tok
;
3808 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3809 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3810 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3811 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3814 if (strmatch(safi_str
, "labeled"))
3815 safi
= bgp_vty_safi_from_str("labeled-unicast");
3817 safi
= bgp_vty_safi_from_str(safi_str
);
3820 bgp
->default_af
[afi
][safi
] = false;
3822 if ((safi
== SAFI_LABELED_UNICAST
3823 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3824 || (safi
== SAFI_UNICAST
3825 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3826 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3828 bgp
->default_af
[afi
][safi
] = true;
3834 /* Display hostname in certain command outputs */
3835 DEFUN (bgp_default_show_hostname
,
3836 bgp_default_show_hostname_cmd
,
3837 "bgp default show-hostname",
3839 "Configure BGP defaults\n"
3840 "Show hostname in certain command outputs\n")
3842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3843 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3847 DEFUN (no_bgp_default_show_hostname
,
3848 no_bgp_default_show_hostname_cmd
,
3849 "no bgp default show-hostname",
3852 "Configure BGP defaults\n"
3853 "Show hostname in certain command outputs\n")
3855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3856 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3860 /* Display hostname in certain command outputs */
3861 DEFUN (bgp_default_show_nexthop_hostname
,
3862 bgp_default_show_nexthop_hostname_cmd
,
3863 "bgp default show-nexthop-hostname",
3865 "Configure BGP defaults\n"
3866 "Show hostname for nexthop in certain command outputs\n")
3868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3869 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3873 DEFUN (no_bgp_default_show_nexthop_hostname
,
3874 no_bgp_default_show_nexthop_hostname_cmd
,
3875 "no bgp default show-nexthop-hostname",
3878 "Configure BGP defaults\n"
3879 "Show hostname for nexthop in certain command outputs\n")
3881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3882 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3886 /* "bgp network import-check" configuration. */
3887 DEFUN (bgp_network_import_check
,
3888 bgp_network_import_check_cmd
,
3889 "bgp network import-check",
3891 "BGP network command\n"
3892 "Check BGP network route exists in IGP\n")
3894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3895 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3896 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3897 bgp_static_redo_import_check(bgp
);
3903 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3904 "bgp network import-check exact",
3906 "BGP network command\n"
3907 "Check BGP network route exists in IGP\n"
3908 "Match route precisely\n")
3910 DEFUN (no_bgp_network_import_check
,
3911 no_bgp_network_import_check_cmd
,
3912 "no bgp network import-check",
3915 "BGP network command\n"
3916 "Check BGP network route exists in IGP\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3919 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3920 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3921 bgp_static_redo_import_check(bgp
);
3927 DEFUN (bgp_default_local_preference
,
3928 bgp_default_local_preference_cmd
,
3929 "bgp default local-preference (0-4294967295)",
3931 "Configure BGP defaults\n"
3932 "local preference (higher=more preferred)\n"
3933 "Configure default local preference value\n")
3935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3937 uint32_t local_pref
;
3939 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3941 bgp_default_local_preference_set(bgp
, local_pref
);
3942 bgp_clear_star_soft_in(vty
, bgp
->name
);
3947 DEFUN (no_bgp_default_local_preference
,
3948 no_bgp_default_local_preference_cmd
,
3949 "no bgp default local-preference [(0-4294967295)]",
3952 "Configure BGP defaults\n"
3953 "local preference (higher=more preferred)\n"
3954 "Configure default local preference value\n")
3956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3957 bgp_default_local_preference_unset(bgp
);
3958 bgp_clear_star_soft_in(vty
, bgp
->name
);
3964 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3965 bgp_default_subgroup_pkt_queue_max_cmd
,
3966 "bgp default subgroup-pkt-queue-max (20-100)",
3968 "Configure BGP defaults\n"
3969 "subgroup-pkt-queue-max\n"
3970 "Configure subgroup packet queue max\n")
3972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3976 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3978 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3983 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3984 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3985 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3988 "Configure BGP defaults\n"
3989 "subgroup-pkt-queue-max\n"
3990 "Configure subgroup packet queue max\n")
3992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3993 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3998 DEFUN (bgp_rr_allow_outbound_policy
,
3999 bgp_rr_allow_outbound_policy_cmd
,
4000 "bgp route-reflector allow-outbound-policy",
4002 "Allow modifications made by out route-map\n"
4003 "on ibgp neighbors\n")
4005 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4007 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4008 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4009 update_group_announce_rrclients(bgp
);
4010 bgp_clear_star_soft_out(vty
, bgp
->name
);
4016 DEFUN (no_bgp_rr_allow_outbound_policy
,
4017 no_bgp_rr_allow_outbound_policy_cmd
,
4018 "no bgp route-reflector allow-outbound-policy",
4021 "Allow modifications made by out route-map\n"
4022 "on ibgp neighbors\n")
4024 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4026 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4027 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4028 update_group_announce_rrclients(bgp
);
4029 bgp_clear_star_soft_out(vty
, bgp
->name
);
4035 DEFUN (bgp_listen_limit
,
4036 bgp_listen_limit_cmd
,
4037 "bgp listen limit (1-65535)",
4039 "BGP Dynamic Neighbors listen commands\n"
4040 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4041 "Configure Dynamic Neighbors listen limit value\n")
4043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4047 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4049 bgp_listen_limit_set(bgp
, listen_limit
);
4054 DEFUN (no_bgp_listen_limit
,
4055 no_bgp_listen_limit_cmd
,
4056 "no bgp listen limit [(1-65535)]",
4059 "BGP Dynamic Neighbors listen commands\n"
4060 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4061 "Configure Dynamic Neighbors listen limit value\n")
4063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4064 bgp_listen_limit_unset(bgp
);
4070 * Check if this listen range is already configured. Check for exact
4071 * match or overlap based on input.
4073 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4074 struct prefix
*range
, int exact
)
4076 struct listnode
*node
, *nnode
;
4077 struct listnode
*node1
, *nnode1
;
4078 struct peer_group
*group
;
4083 afi
= family2afi(range
->family
);
4084 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4085 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4088 match
= prefix_same(range
, lr
);
4090 match
= (prefix_match(range
, lr
)
4091 || prefix_match(lr
, range
));
4100 DEFUN (bgp_listen_range
,
4101 bgp_listen_range_cmd
,
4102 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4104 "Configure BGP dynamic neighbors listen range\n"
4105 "Configure BGP dynamic neighbors listen range\n"
4107 "Member of the peer-group\n"
4108 "Peer-group name\n")
4110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4111 struct prefix range
;
4112 struct peer_group
*group
, *existing_group
;
4117 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4118 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4119 char *prefix
= argv
[idx
]->arg
;
4120 argv_find(argv
, argc
, "PGNAME", &idx
);
4121 char *peergroup
= argv
[idx
]->arg
;
4123 /* Convert IP prefix string to struct prefix. */
4124 ret
= str2prefix(prefix
, &range
);
4126 vty_out(vty
, "%% Malformed listen range\n");
4127 return CMD_WARNING_CONFIG_FAILED
;
4130 afi
= family2afi(range
.family
);
4132 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4134 "%% Malformed listen range (link-local address)\n");
4135 return CMD_WARNING_CONFIG_FAILED
;
4140 /* Check if same listen range is already configured. */
4141 existing_group
= listen_range_exists(bgp
, &range
, 1);
4142 if (existing_group
) {
4143 if (strcmp(existing_group
->name
, peergroup
) == 0)
4147 "%% Same listen range is attached to peer-group %s\n",
4148 existing_group
->name
);
4149 return CMD_WARNING_CONFIG_FAILED
;
4153 /* Check if an overlapping listen range exists. */
4154 if (listen_range_exists(bgp
, &range
, 0)) {
4156 "%% Listen range overlaps with existing listen range\n");
4157 return CMD_WARNING_CONFIG_FAILED
;
4160 group
= peer_group_lookup(bgp
, peergroup
);
4162 vty_out(vty
, "%% Configure the peer-group first\n");
4163 return CMD_WARNING_CONFIG_FAILED
;
4166 ret
= peer_group_listen_range_add(group
, &range
);
4167 return bgp_vty_return(vty
, ret
);
4170 DEFUN (no_bgp_listen_range
,
4171 no_bgp_listen_range_cmd
,
4172 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4175 "Unconfigure BGP dynamic neighbors listen range\n"
4176 "Unconfigure BGP dynamic neighbors listen range\n"
4178 "Member of the peer-group\n"
4179 "Peer-group name\n")
4181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4182 struct prefix range
;
4183 struct peer_group
*group
;
4188 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4189 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4190 char *prefix
= argv
[idx
]->arg
;
4191 argv_find(argv
, argc
, "PGNAME", &idx
);
4192 char *peergroup
= argv
[idx
]->arg
;
4194 /* Convert IP prefix string to struct prefix. */
4195 ret
= str2prefix(prefix
, &range
);
4197 vty_out(vty
, "%% Malformed listen range\n");
4198 return CMD_WARNING_CONFIG_FAILED
;
4201 afi
= family2afi(range
.family
);
4203 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4205 "%% Malformed listen range (link-local address)\n");
4206 return CMD_WARNING_CONFIG_FAILED
;
4211 group
= peer_group_lookup(bgp
, peergroup
);
4213 vty_out(vty
, "%% Peer-group does not exist\n");
4214 return CMD_WARNING_CONFIG_FAILED
;
4217 ret
= peer_group_listen_range_del(group
, &range
);
4218 return bgp_vty_return(vty
, ret
);
4221 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4223 struct peer_group
*group
;
4224 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4225 struct prefix
*range
;
4228 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4229 vty_out(vty
, " bgp listen limit %d\n",
4230 bgp
->dynamic_neighbors_limit
);
4232 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4233 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4234 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4237 " bgp listen range %pFX peer-group %s\n",
4238 range
, group
->name
);
4245 DEFUN (bgp_disable_connected_route_check
,
4246 bgp_disable_connected_route_check_cmd
,
4247 "bgp disable-ebgp-connected-route-check",
4249 "Disable checking if nexthop is connected on ebgp sessions\n")
4251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4252 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4253 bgp_clear_star_soft_in(vty
, bgp
->name
);
4258 DEFUN (no_bgp_disable_connected_route_check
,
4259 no_bgp_disable_connected_route_check_cmd
,
4260 "no bgp disable-ebgp-connected-route-check",
4263 "Disable checking if nexthop is connected on ebgp sessions\n")
4265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4266 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4267 bgp_clear_star_soft_in(vty
, bgp
->name
);
4273 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4279 int as_type
= AS_SPECIFIED
;
4282 if (as_str
[0] == 'i') {
4284 as_type
= AS_INTERNAL
;
4285 } else if (as_str
[0] == 'e') {
4287 as_type
= AS_EXTERNAL
;
4289 /* Get AS number. */
4290 as
= strtoul(as_str
, NULL
, 10);
4293 /* If peer is peer group or interface peer, call proper function. */
4294 ret
= str2sockunion(peer_str
, &su
);
4298 /* Check if existing interface peer */
4299 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4301 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4303 /* if not interface peer, check peer-group settings */
4304 if (ret
< 0 && !peer
) {
4305 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4308 "%% Create the peer-group or interface first\n");
4309 return CMD_WARNING_CONFIG_FAILED
;
4314 if (peer_address_self_check(bgp
, &su
)) {
4316 "%% Can not configure the local system as neighbor\n");
4317 return CMD_WARNING_CONFIG_FAILED
;
4319 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4322 return bgp_vty_return(vty
, ret
);
4325 DEFUN (bgp_default_shutdown
,
4326 bgp_default_shutdown_cmd
,
4327 "[no] bgp default shutdown",
4330 "Configure BGP defaults\n"
4331 "Apply administrative shutdown to newly configured peers\n")
4333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4334 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4338 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4340 "Administrative shutdown of the BGP instance\n"
4341 "Add a shutdown message (RFC 8203)\n"
4342 "Shutdown message\n")
4344 char *msgstr
= NULL
;
4346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4349 msgstr
= argv_concat(argv
, argc
, 3);
4351 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4352 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4353 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4354 return CMD_WARNING_CONFIG_FAILED
;
4357 bgp_shutdown_enable(bgp
, msgstr
);
4358 XFREE(MTYPE_TMP
, msgstr
);
4363 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4364 BGP_STR
"Administrative shutdown of the BGP instance\n")
4366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4368 bgp_shutdown_enable(bgp
, NULL
);
4373 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4374 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4376 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4378 bgp_shutdown_disable(bgp
);
4383 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4384 "no bgp shutdown message MSG...", NO_STR BGP_STR
4385 "Administrative shutdown of the BGP instance\n"
4386 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4388 DEFUN (neighbor_remote_as
,
4389 neighbor_remote_as_cmd
,
4390 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4393 "Specify a BGP neighbor\n"
4395 "Internal BGP peer\n"
4396 "External BGP peer\n")
4399 int idx_remote_as
= 3;
4400 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4401 argv
[idx_remote_as
]->arg
);
4403 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4404 * sessions do not wait for hold timer expiry to bring down the sessions
4405 * when nexthop becomes unreachable
4407 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4408 BGP_STR
"Fast convergence for bgp sessions\n")
4410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4411 bgp
->fast_convergence
= true;
4416 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4417 "no bgp fast-convergence",
4418 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4421 bgp
->fast_convergence
= false;
4426 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4428 const char *peer_group_name
,
4431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4433 int as_type
= AS_UNSPECIFIED
;
4435 struct peer_group
*group
;
4438 group
= peer_group_lookup(bgp
, conf_if
);
4441 vty_out(vty
, "%% Name conflict with peer-group \n");
4442 return CMD_WARNING_CONFIG_FAILED
;
4446 if (as_str
[0] == 'i') {
4447 as_type
= AS_INTERNAL
;
4448 } else if (as_str
[0] == 'e') {
4449 as_type
= AS_EXTERNAL
;
4451 /* Get AS number. */
4452 as
= strtoul(as_str
, NULL
, 10);
4453 as_type
= AS_SPECIFIED
;
4457 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4460 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4462 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4466 vty_out(vty
, "%% BGP failed to create peer\n");
4467 return CMD_WARNING_CONFIG_FAILED
;
4471 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4473 /* Request zebra to initiate IPv6 RAs on this interface. We do
4475 * any unnumbered peer in order to not worry about run-time
4477 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4479 * gets deleted later etc.)
4482 bgp_zebra_initiate_radv(bgp
, peer
);
4485 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4486 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4488 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4490 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4492 /* v6only flag changed. Reset bgp seesion */
4493 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4494 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4495 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4496 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4498 bgp_session_reset(peer
);
4501 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4502 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4503 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4504 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4507 if (peer_group_name
) {
4508 group
= peer_group_lookup(bgp
, peer_group_name
);
4510 vty_out(vty
, "%% Configure the peer-group first\n");
4511 return CMD_WARNING_CONFIG_FAILED
;
4514 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4517 return bgp_vty_return(vty
, ret
);
4520 DEFUN (neighbor_interface_config
,
4521 neighbor_interface_config_cmd
,
4522 "neighbor WORD interface [peer-group PGNAME]",
4524 "Interface name or neighbor tag\n"
4525 "Enable BGP on interface\n"
4526 "Member of the peer-group\n"
4527 "Peer-group name\n")
4530 int idx_peer_group_word
= 4;
4532 if (argc
> idx_peer_group_word
)
4533 return peer_conf_interface_get(
4534 vty
, argv
[idx_word
]->arg
, 0,
4535 argv
[idx_peer_group_word
]->arg
, NULL
);
4537 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4541 DEFUN (neighbor_interface_config_v6only
,
4542 neighbor_interface_config_v6only_cmd
,
4543 "neighbor WORD interface v6only [peer-group PGNAME]",
4545 "Interface name or neighbor tag\n"
4546 "Enable BGP on interface\n"
4547 "Enable BGP with v6 link-local only\n"
4548 "Member of the peer-group\n"
4549 "Peer-group name\n")
4552 int idx_peer_group_word
= 5;
4554 if (argc
> idx_peer_group_word
)
4555 return peer_conf_interface_get(
4556 vty
, argv
[idx_word
]->arg
, 1,
4557 argv
[idx_peer_group_word
]->arg
, NULL
);
4559 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4563 DEFUN (neighbor_interface_config_remote_as
,
4564 neighbor_interface_config_remote_as_cmd
,
4565 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4567 "Interface name or neighbor tag\n"
4568 "Enable BGP on interface\n"
4569 "Specify a BGP neighbor\n"
4571 "Internal BGP peer\n"
4572 "External BGP peer\n")
4575 int idx_remote_as
= 4;
4576 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4577 argv
[idx_remote_as
]->arg
);
4580 DEFUN (neighbor_interface_v6only_config_remote_as
,
4581 neighbor_interface_v6only_config_remote_as_cmd
,
4582 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4584 "Interface name or neighbor tag\n"
4585 "Enable BGP with v6 link-local only\n"
4586 "Enable BGP on interface\n"
4587 "Specify a BGP neighbor\n"
4589 "Internal BGP peer\n"
4590 "External BGP peer\n")
4593 int idx_remote_as
= 5;
4594 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4595 argv
[idx_remote_as
]->arg
);
4598 DEFUN (neighbor_peer_group
,
4599 neighbor_peer_group_cmd
,
4600 "neighbor WORD peer-group",
4602 "Interface name or neighbor tag\n"
4603 "Configure peer-group\n")
4605 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4608 struct peer_group
*group
;
4610 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4612 vty_out(vty
, "%% Name conflict with interface: \n");
4613 return CMD_WARNING_CONFIG_FAILED
;
4616 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4618 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4619 return CMD_WARNING_CONFIG_FAILED
;
4627 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4631 "Specify a BGP neighbor\n"
4633 "Internal BGP peer\n"
4634 "External BGP peer\n")
4636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4640 struct peer_group
*group
;
4644 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4646 /* look up for neighbor by interface name config. */
4647 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4649 /* Request zebra to terminate IPv6 RAs on this
4652 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4653 peer_notify_unconfig(peer
);
4658 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4660 peer_group_notify_unconfig(group
);
4661 peer_group_delete(group
);
4663 vty_out(vty
, "%% Create the peer-group first\n");
4664 return CMD_WARNING_CONFIG_FAILED
;
4667 peer
= peer_lookup(bgp
, &su
);
4669 if (peer_dynamic_neighbor(peer
)) {
4671 "%% Operation not allowed on a dynamic neighbor\n");
4672 return CMD_WARNING_CONFIG_FAILED
;
4675 other
= peer
->doppelganger
;
4677 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4678 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4680 peer_notify_unconfig(peer
);
4682 if (other
&& other
->status
!= Deleted
) {
4683 peer_notify_unconfig(other
);
4692 DEFUN (no_neighbor_interface_config
,
4693 no_neighbor_interface_config_cmd
,
4694 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4698 "Configure BGP on interface\n"
4699 "Enable BGP with v6 link-local only\n"
4700 "Member of the peer-group\n"
4702 "Specify a BGP neighbor\n"
4704 "Internal BGP peer\n"
4705 "External BGP peer\n")
4707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4711 /* look up for neighbor by interface name config. */
4712 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4714 /* Request zebra to terminate IPv6 RAs on this interface. */
4716 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4717 peer_notify_unconfig(peer
);
4720 vty_out(vty
, "%% Create the bgp interface first\n");
4721 return CMD_WARNING_CONFIG_FAILED
;
4726 DEFUN (no_neighbor_peer_group
,
4727 no_neighbor_peer_group_cmd
,
4728 "no neighbor WORD peer-group",
4732 "Configure peer-group\n")
4734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4736 struct peer_group
*group
;
4738 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4740 peer_group_notify_unconfig(group
);
4741 peer_group_delete(group
);
4743 vty_out(vty
, "%% Create the peer-group first\n");
4744 return CMD_WARNING_CONFIG_FAILED
;
4749 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4750 no_neighbor_interface_peer_group_remote_as_cmd
,
4751 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4754 "Interface name or neighbor tag\n"
4755 "Specify a BGP neighbor\n"
4757 "Internal BGP peer\n"
4758 "External BGP peer\n")
4760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4762 struct peer_group
*group
;
4765 /* look up for neighbor by interface name config. */
4766 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4768 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4772 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4774 peer_group_remote_as_delete(group
);
4776 vty_out(vty
, "%% Create the peer-group or interface first\n");
4777 return CMD_WARNING_CONFIG_FAILED
;
4782 DEFUN (neighbor_local_as
,
4783 neighbor_local_as_cmd
,
4784 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4787 "Specify a local-as number\n"
4788 "AS number used as local AS\n")
4796 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4798 return CMD_WARNING_CONFIG_FAILED
;
4800 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4801 ret
= peer_local_as_set(peer
, as
, 0, 0);
4802 return bgp_vty_return(vty
, ret
);
4805 DEFUN (neighbor_local_as_no_prepend
,
4806 neighbor_local_as_no_prepend_cmd
,
4807 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4810 "Specify a local-as number\n"
4811 "AS number used as local AS\n"
4812 "Do not prepend local-as to updates from ebgp peers\n")
4820 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4822 return CMD_WARNING_CONFIG_FAILED
;
4824 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4825 ret
= peer_local_as_set(peer
, as
, 1, 0);
4826 return bgp_vty_return(vty
, ret
);
4829 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4830 neighbor_local_as_no_prepend_replace_as_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4834 "Specify a local-as number\n"
4835 "AS number used as local AS\n"
4836 "Do not prepend local-as to updates from ebgp peers\n"
4837 "Do not prepend local-as to updates from ibgp peers\n")
4845 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4847 return CMD_WARNING_CONFIG_FAILED
;
4849 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4850 ret
= peer_local_as_set(peer
, as
, 1, 1);
4851 return bgp_vty_return(vty
, ret
);
4854 DEFUN (no_neighbor_local_as
,
4855 no_neighbor_local_as_cmd
,
4856 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4860 "Specify a local-as number\n"
4861 "AS number used as local AS\n"
4862 "Do not prepend local-as to updates from ebgp peers\n"
4863 "Do not prepend local-as to updates from ibgp peers\n")
4869 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4871 return CMD_WARNING_CONFIG_FAILED
;
4873 ret
= peer_local_as_unset(peer
);
4874 return bgp_vty_return(vty
, ret
);
4878 DEFUN (neighbor_solo
,
4880 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4883 "Solo peer - part of its own update group\n")
4889 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4891 return CMD_WARNING_CONFIG_FAILED
;
4893 ret
= update_group_adjust_soloness(peer
, 1);
4894 return bgp_vty_return(vty
, ret
);
4897 DEFUN (no_neighbor_solo
,
4898 no_neighbor_solo_cmd
,
4899 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4903 "Solo peer - part of its own update group\n")
4909 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4911 return CMD_WARNING_CONFIG_FAILED
;
4913 ret
= update_group_adjust_soloness(peer
, 0);
4914 return bgp_vty_return(vty
, ret
);
4917 DEFUN (neighbor_password
,
4918 neighbor_password_cmd
,
4919 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4930 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4932 return CMD_WARNING_CONFIG_FAILED
;
4934 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4935 return bgp_vty_return(vty
, ret
);
4938 DEFUN (no_neighbor_password
,
4939 no_neighbor_password_cmd
,
4940 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4951 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4953 return CMD_WARNING_CONFIG_FAILED
;
4955 ret
= peer_password_unset(peer
);
4956 return bgp_vty_return(vty
, ret
);
4959 DEFUN (neighbor_activate
,
4960 neighbor_activate_cmd
,
4961 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4964 "Enable the Address Family for this Neighbor\n")
4970 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4972 return CMD_WARNING_CONFIG_FAILED
;
4974 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4975 return bgp_vty_return(vty
, ret
);
4978 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4979 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4980 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4981 "Enable the Address Family for this Neighbor\n")
4983 DEFUN (no_neighbor_activate
,
4984 no_neighbor_activate_cmd
,
4985 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4989 "Enable the Address Family for this Neighbor\n")
4996 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4998 return CMD_WARNING_CONFIG_FAILED
;
5000 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5001 return bgp_vty_return(vty
, ret
);
5004 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5005 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5006 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5007 "Enable the Address Family for this Neighbor\n")
5009 DEFUN (neighbor_set_peer_group
,
5010 neighbor_set_peer_group_cmd
,
5011 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5014 "Member of the peer-group\n"
5015 "Peer-group name\n")
5017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5024 struct peer_group
*group
;
5026 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5028 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5030 vty_out(vty
, "%% Malformed address or name: %s\n",
5031 argv
[idx_peer
]->arg
);
5032 return CMD_WARNING_CONFIG_FAILED
;
5035 if (peer_address_self_check(bgp
, &su
)) {
5037 "%% Can not configure the local system as neighbor\n");
5038 return CMD_WARNING_CONFIG_FAILED
;
5041 /* Disallow for dynamic neighbor. */
5042 peer
= peer_lookup(bgp
, &su
);
5043 if (peer
&& peer_dynamic_neighbor(peer
)) {
5045 "%% Operation not allowed on a dynamic neighbor\n");
5046 return CMD_WARNING_CONFIG_FAILED
;
5050 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5052 vty_out(vty
, "%% Configure the peer-group first\n");
5053 return CMD_WARNING_CONFIG_FAILED
;
5056 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5058 return bgp_vty_return(vty
, ret
);
5061 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5062 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5063 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5064 "Member of the peer-group\n"
5065 "Peer-group name\n")
5067 DEFUN (no_neighbor_set_peer_group
,
5068 no_neighbor_set_peer_group_cmd
,
5069 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5073 "Member of the peer-group\n"
5074 "Peer-group name\n")
5076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5081 struct peer_group
*group
;
5083 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5085 return CMD_WARNING_CONFIG_FAILED
;
5087 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5089 vty_out(vty
, "%% Configure the peer-group first\n");
5090 return CMD_WARNING_CONFIG_FAILED
;
5093 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5094 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5096 peer_notify_unconfig(peer
);
5097 ret
= peer_delete(peer
);
5099 return bgp_vty_return(vty
, ret
);
5102 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5103 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5104 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5105 "Member of the peer-group\n"
5106 "Peer-group name\n")
5108 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5109 uint32_t flag
, int set
)
5114 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5116 return CMD_WARNING_CONFIG_FAILED
;
5119 * If 'neighbor <interface>', then this is for directly connected peers,
5120 * we should not accept disable-connected-check.
5122 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5124 "%s is directly connected peer, cannot accept disable-connected-check\n",
5126 return CMD_WARNING_CONFIG_FAILED
;
5129 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5130 peer_tx_shutdown_message_unset(peer
);
5133 ret
= peer_flag_set(peer
, flag
);
5135 ret
= peer_flag_unset(peer
, flag
);
5137 return bgp_vty_return(vty
, ret
);
5140 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5142 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5145 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5148 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5151 /* neighbor passive. */
5152 DEFUN (neighbor_passive
,
5153 neighbor_passive_cmd
,
5154 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5157 "Don't send open messages to this neighbor\n")
5160 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5163 DEFUN (no_neighbor_passive
,
5164 no_neighbor_passive_cmd
,
5165 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5169 "Don't send open messages to this neighbor\n")
5172 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5175 /* neighbor shutdown. */
5176 DEFUN (neighbor_shutdown_msg
,
5177 neighbor_shutdown_msg_cmd
,
5178 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5181 "Administratively shut down this neighbor\n"
5182 "Add a shutdown message (RFC 8203)\n"
5183 "Shutdown message\n")
5189 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5193 return CMD_WARNING_CONFIG_FAILED
;
5194 message
= argv_concat(argv
, argc
, 4);
5195 peer_tx_shutdown_message_set(peer
, message
);
5196 XFREE(MTYPE_TMP
, message
);
5199 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5202 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5203 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5204 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5205 "Administratively shut down this neighbor\n")
5207 DEFUN (no_neighbor_shutdown_msg
,
5208 no_neighbor_shutdown_msg_cmd
,
5209 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5213 "Administratively shut down this neighbor\n"
5214 "Remove a shutdown message (RFC 8203)\n"
5215 "Shutdown message\n")
5219 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5220 PEER_FLAG_SHUTDOWN
);
5223 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5224 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5225 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5226 "Administratively shut down this neighbor\n")
5228 DEFUN(neighbor_shutdown_rtt
,
5229 neighbor_shutdown_rtt_cmd
,
5230 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5233 "Administratively shut down this neighbor\n"
5234 "Shutdown if round-trip-time is higher than expected\n"
5235 "Round-trip-time in milliseconds\n"
5236 "Specify the number of keepalives before shutdown\n"
5237 "The number of keepalives with higher RTT to shutdown\n")
5244 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5247 return CMD_WARNING_CONFIG_FAILED
;
5249 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5251 if (argv_find(argv
, argc
, "count", &idx_count
))
5252 peer
->rtt_keepalive_conf
=
5253 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5255 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5256 PEER_FLAG_RTT_SHUTDOWN
);
5259 DEFUN(no_neighbor_shutdown_rtt
,
5260 no_neighbor_shutdown_rtt_cmd
,
5261 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5265 "Administratively shut down this neighbor\n"
5266 "Shutdown if round-trip-time is higher than expected\n"
5267 "Round-trip-time in milliseconds\n"
5268 "Specify the number of keepalives before shutdown\n"
5269 "The number of keepalives with higher RTT to shutdown\n")
5274 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5277 return CMD_WARNING_CONFIG_FAILED
;
5279 peer
->rtt_expected
= 0;
5280 peer
->rtt_keepalive_conf
= 1;
5282 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5283 PEER_FLAG_RTT_SHUTDOWN
);
5286 /* neighbor capability dynamic. */
5287 DEFUN (neighbor_capability_dynamic
,
5288 neighbor_capability_dynamic_cmd
,
5289 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5292 "Advertise capability to the peer\n"
5293 "Advertise dynamic capability to this neighbor\n")
5296 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5297 PEER_FLAG_DYNAMIC_CAPABILITY
);
5300 DEFUN (no_neighbor_capability_dynamic
,
5301 no_neighbor_capability_dynamic_cmd
,
5302 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5306 "Advertise capability to the peer\n"
5307 "Advertise dynamic capability to this neighbor\n")
5310 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5311 PEER_FLAG_DYNAMIC_CAPABILITY
);
5314 /* neighbor dont-capability-negotiate */
5315 DEFUN (neighbor_dont_capability_negotiate
,
5316 neighbor_dont_capability_negotiate_cmd
,
5317 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5320 "Do not perform capability negotiation\n")
5323 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5324 PEER_FLAG_DONT_CAPABILITY
);
5327 DEFUN (no_neighbor_dont_capability_negotiate
,
5328 no_neighbor_dont_capability_negotiate_cmd
,
5329 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5333 "Do not perform capability negotiation\n")
5336 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5337 PEER_FLAG_DONT_CAPABILITY
);
5340 /* neighbor capability extended next hop encoding */
5341 DEFUN (neighbor_capability_enhe
,
5342 neighbor_capability_enhe_cmd
,
5343 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5346 "Advertise capability to the peer\n"
5347 "Advertise extended next-hop capability to the peer\n")
5352 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5353 if (peer
&& peer
->conf_if
)
5356 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5357 PEER_FLAG_CAPABILITY_ENHE
);
5360 DEFUN (no_neighbor_capability_enhe
,
5361 no_neighbor_capability_enhe_cmd
,
5362 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5366 "Advertise capability to the peer\n"
5367 "Advertise extended next-hop capability to the peer\n")
5372 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5373 if (peer
&& peer
->conf_if
) {
5375 "Peer %s cannot have capability extended-nexthop turned off\n",
5376 argv
[idx_peer
]->arg
);
5377 return CMD_WARNING_CONFIG_FAILED
;
5380 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5381 PEER_FLAG_CAPABILITY_ENHE
);
5384 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5385 afi_t afi
, safi_t safi
, uint32_t flag
,
5391 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5393 return CMD_WARNING_CONFIG_FAILED
;
5396 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5398 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5400 return bgp_vty_return(vty
, ret
);
5403 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5404 afi_t afi
, safi_t safi
, uint32_t flag
)
5406 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5409 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5410 afi_t afi
, safi_t safi
, uint32_t flag
)
5412 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5415 /* neighbor capability orf prefix-list. */
5416 DEFUN (neighbor_capability_orf_prefix
,
5417 neighbor_capability_orf_prefix_cmd
,
5418 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5421 "Advertise capability to the peer\n"
5422 "Advertise ORF capability to the peer\n"
5423 "Advertise prefixlist ORF capability to this neighbor\n"
5424 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5425 "Capability to RECEIVE the ORF from this neighbor\n"
5426 "Capability to SEND the ORF to this neighbor\n")
5428 int idx_send_recv
= 5;
5429 char *peer_str
= argv
[1]->arg
;
5431 afi_t afi
= bgp_node_afi(vty
);
5432 safi_t safi
= bgp_node_safi(vty
);
5434 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5436 return CMD_WARNING_CONFIG_FAILED
;
5438 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5439 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5440 PEER_FLAG_ORF_PREFIX_SM
);
5442 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5443 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5444 PEER_FLAG_ORF_PREFIX_RM
);
5446 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5447 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5448 PEER_FLAG_ORF_PREFIX_SM
)
5449 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5450 PEER_FLAG_ORF_PREFIX_RM
);
5452 return CMD_WARNING_CONFIG_FAILED
;
5456 neighbor_capability_orf_prefix
,
5457 neighbor_capability_orf_prefix_hidden_cmd
,
5458 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5459 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5460 "Advertise capability to the peer\n"
5461 "Advertise ORF capability to the peer\n"
5462 "Advertise prefixlist ORF capability to this neighbor\n"
5463 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5464 "Capability to RECEIVE the ORF from this neighbor\n"
5465 "Capability to SEND the ORF to this neighbor\n")
5467 DEFUN (no_neighbor_capability_orf_prefix
,
5468 no_neighbor_capability_orf_prefix_cmd
,
5469 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5473 "Advertise capability to the peer\n"
5474 "Advertise ORF capability to the peer\n"
5475 "Advertise prefixlist ORF capability to this neighbor\n"
5476 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5477 "Capability to RECEIVE the ORF from this neighbor\n"
5478 "Capability to SEND the ORF to this neighbor\n")
5480 int idx_send_recv
= 6;
5481 char *peer_str
= argv
[2]->arg
;
5483 afi_t afi
= bgp_node_afi(vty
);
5484 safi_t safi
= bgp_node_safi(vty
);
5486 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5488 return CMD_WARNING_CONFIG_FAILED
;
5490 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5491 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5492 PEER_FLAG_ORF_PREFIX_SM
);
5494 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5495 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5496 PEER_FLAG_ORF_PREFIX_RM
);
5498 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5499 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5500 PEER_FLAG_ORF_PREFIX_SM
)
5501 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5502 PEER_FLAG_ORF_PREFIX_RM
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5508 no_neighbor_capability_orf_prefix
,
5509 no_neighbor_capability_orf_prefix_hidden_cmd
,
5510 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5511 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5512 "Advertise capability to the peer\n"
5513 "Advertise ORF capability to the peer\n"
5514 "Advertise prefixlist ORF capability to this neighbor\n"
5515 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5516 "Capability to RECEIVE the ORF from this neighbor\n"
5517 "Capability to SEND the ORF to this neighbor\n")
5519 /* neighbor next-hop-self. */
5520 DEFUN (neighbor_nexthop_self
,
5521 neighbor_nexthop_self_cmd
,
5522 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5525 "Disable the next hop calculation for this neighbor\n")
5528 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5529 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5532 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5533 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5534 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5535 "Disable the next hop calculation for this neighbor\n")
5537 /* neighbor next-hop-self. */
5538 DEFUN (neighbor_nexthop_self_force
,
5539 neighbor_nexthop_self_force_cmd
,
5540 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5543 "Disable the next hop calculation for this neighbor\n"
5544 "Set the next hop to self for reflected routes\n")
5547 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5549 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5552 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5553 neighbor_nexthop_self_force_hidden_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5555 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5556 "Disable the next hop calculation for this neighbor\n"
5557 "Set the next hop to self for reflected routes\n")
5559 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5560 neighbor_nexthop_self_all_hidden_cmd
,
5561 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5562 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5563 "Disable the next hop calculation for this neighbor\n"
5564 "Set the next hop to self for reflected routes\n")
5566 DEFUN (no_neighbor_nexthop_self
,
5567 no_neighbor_nexthop_self_cmd
,
5568 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5572 "Disable the next hop calculation for this neighbor\n")
5575 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5576 bgp_node_afi(vty
), bgp_node_safi(vty
),
5577 PEER_FLAG_NEXTHOP_SELF
);
5580 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5581 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5582 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5583 "Disable the next hop calculation for this neighbor\n")
5585 DEFUN (no_neighbor_nexthop_self_force
,
5586 no_neighbor_nexthop_self_force_cmd
,
5587 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5591 "Disable the next hop calculation for this neighbor\n"
5592 "Set the next hop to self for reflected routes\n")
5595 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5596 bgp_node_afi(vty
), bgp_node_safi(vty
),
5597 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5600 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5601 no_neighbor_nexthop_self_force_hidden_cmd
,
5602 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5603 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5604 "Disable the next hop calculation for this neighbor\n"
5605 "Set the next hop to self for reflected routes\n")
5607 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5608 no_neighbor_nexthop_self_all_hidden_cmd
,
5609 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5610 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5611 "Disable the next hop calculation for this neighbor\n"
5612 "Set the next hop to self for reflected routes\n")
5614 /* neighbor as-override */
5615 DEFUN (neighbor_as_override
,
5616 neighbor_as_override_cmd
,
5617 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5620 "Override ASNs in outbound updates if aspath equals remote-as\n")
5623 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5624 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5627 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5628 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5629 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5630 "Override ASNs in outbound updates if aspath equals remote-as\n")
5632 DEFUN (no_neighbor_as_override
,
5633 no_neighbor_as_override_cmd
,
5634 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5638 "Override ASNs in outbound updates if aspath equals remote-as\n")
5641 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5642 bgp_node_afi(vty
), bgp_node_safi(vty
),
5643 PEER_FLAG_AS_OVERRIDE
);
5646 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5647 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5648 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5649 "Override ASNs in outbound updates if aspath equals remote-as\n")
5651 /* neighbor remove-private-AS. */
5652 DEFUN (neighbor_remove_private_as
,
5653 neighbor_remove_private_as_cmd
,
5654 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5657 "Remove private ASNs in outbound updates\n")
5660 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5662 PEER_FLAG_REMOVE_PRIVATE_AS
);
5665 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5666 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5667 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5668 "Remove private ASNs in outbound updates\n")
5670 DEFUN (neighbor_remove_private_as_all
,
5671 neighbor_remove_private_as_all_cmd
,
5672 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5675 "Remove private ASNs in outbound updates\n"
5676 "Apply to all AS numbers\n")
5679 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5681 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5684 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5685 neighbor_remove_private_as_all_hidden_cmd
,
5686 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5687 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5688 "Remove private ASNs in outbound updates\n"
5689 "Apply to all AS numbers")
5691 DEFUN (neighbor_remove_private_as_replace_as
,
5692 neighbor_remove_private_as_replace_as_cmd
,
5693 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5696 "Remove private ASNs in outbound updates\n"
5697 "Replace private ASNs with our ASN in outbound updates\n")
5700 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5702 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5705 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5706 neighbor_remove_private_as_replace_as_hidden_cmd
,
5707 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5708 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5709 "Remove private ASNs in outbound updates\n"
5710 "Replace private ASNs with our ASN in outbound updates\n")
5712 DEFUN (neighbor_remove_private_as_all_replace_as
,
5713 neighbor_remove_private_as_all_replace_as_cmd
,
5714 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5717 "Remove private ASNs in outbound updates\n"
5718 "Apply to all AS numbers\n"
5719 "Replace private ASNs with our ASN in outbound updates\n")
5722 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5724 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5728 neighbor_remove_private_as_all_replace_as
,
5729 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5730 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5731 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5732 "Remove private ASNs in outbound updates\n"
5733 "Apply to all AS numbers\n"
5734 "Replace private ASNs with our ASN in outbound updates\n")
5736 DEFUN (no_neighbor_remove_private_as
,
5737 no_neighbor_remove_private_as_cmd
,
5738 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5742 "Remove private ASNs in outbound updates\n")
5745 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5746 bgp_node_afi(vty
), bgp_node_safi(vty
),
5747 PEER_FLAG_REMOVE_PRIVATE_AS
);
5750 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5751 no_neighbor_remove_private_as_hidden_cmd
,
5752 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5753 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5754 "Remove private ASNs in outbound updates\n")
5756 DEFUN (no_neighbor_remove_private_as_all
,
5757 no_neighbor_remove_private_as_all_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5762 "Remove private ASNs in outbound updates\n"
5763 "Apply to all AS numbers\n")
5766 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5767 bgp_node_afi(vty
), bgp_node_safi(vty
),
5768 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5771 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5772 no_neighbor_remove_private_as_all_hidden_cmd
,
5773 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5774 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5775 "Remove private ASNs in outbound updates\n"
5776 "Apply to all AS numbers\n")
5778 DEFUN (no_neighbor_remove_private_as_replace_as
,
5779 no_neighbor_remove_private_as_replace_as_cmd
,
5780 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5784 "Remove private ASNs in outbound updates\n"
5785 "Replace private ASNs with our ASN in outbound updates\n")
5788 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5789 bgp_node_afi(vty
), bgp_node_safi(vty
),
5790 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5793 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5794 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5795 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5796 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5797 "Remove private ASNs in outbound updates\n"
5798 "Replace private ASNs with our ASN in outbound updates\n")
5800 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5801 no_neighbor_remove_private_as_all_replace_as_cmd
,
5802 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5806 "Remove private ASNs in outbound updates\n"
5807 "Apply to all AS numbers\n"
5808 "Replace private ASNs with our ASN in outbound updates\n")
5811 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5812 bgp_node_afi(vty
), bgp_node_safi(vty
),
5813 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5817 no_neighbor_remove_private_as_all_replace_as
,
5818 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5819 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5820 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5821 "Remove private ASNs in outbound updates\n"
5822 "Apply to all AS numbers\n"
5823 "Replace private ASNs with our ASN in outbound updates\n")
5826 /* neighbor send-community. */
5827 DEFUN (neighbor_send_community
,
5828 neighbor_send_community_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5832 "Send Community attribute to this neighbor\n")
5836 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5838 PEER_FLAG_SEND_COMMUNITY
);
5841 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5842 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5843 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5844 "Send Community attribute to this neighbor\n")
5846 DEFUN (no_neighbor_send_community
,
5847 no_neighbor_send_community_cmd
,
5848 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5852 "Send Community attribute to this neighbor\n")
5856 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5857 bgp_node_afi(vty
), bgp_node_safi(vty
),
5858 PEER_FLAG_SEND_COMMUNITY
);
5861 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5862 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5863 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5864 "Send Community attribute to this neighbor\n")
5866 /* neighbor send-community extended. */
5867 DEFUN (neighbor_send_community_type
,
5868 neighbor_send_community_type_cmd
,
5869 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5872 "Send Community attribute to this neighbor\n"
5873 "Send Standard and Extended Community attributes\n"
5874 "Send Standard, Large and Extended Community attributes\n"
5875 "Send Extended Community attributes\n"
5876 "Send Standard Community attributes\n"
5877 "Send Large Community attributes\n")
5879 const char *type
= argv
[argc
- 1]->text
;
5880 char *peer_str
= argv
[1]->arg
;
5882 afi_t afi
= bgp_node_afi(vty
);
5883 safi_t safi
= bgp_node_safi(vty
);
5885 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5887 return CMD_WARNING_CONFIG_FAILED
;
5889 if (strmatch(type
, "standard"))
5890 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5891 PEER_FLAG_SEND_COMMUNITY
);
5893 if (strmatch(type
, "extended"))
5894 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5895 PEER_FLAG_SEND_EXT_COMMUNITY
);
5897 if (strmatch(type
, "large"))
5898 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5899 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5901 if (strmatch(type
, "both")) {
5902 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5903 PEER_FLAG_SEND_COMMUNITY
)
5904 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5905 PEER_FLAG_SEND_EXT_COMMUNITY
);
5907 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5908 PEER_FLAG_SEND_COMMUNITY
)
5909 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5910 PEER_FLAG_SEND_EXT_COMMUNITY
)
5911 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5912 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5916 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5917 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5918 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5919 "Send Community attribute to this neighbor\n"
5920 "Send Standard and Extended Community attributes\n"
5921 "Send Standard, Large and Extended Community attributes\n"
5922 "Send Extended Community attributes\n"
5923 "Send Standard Community attributes\n"
5924 "Send Large Community attributes\n")
5926 DEFUN (no_neighbor_send_community_type
,
5927 no_neighbor_send_community_type_cmd
,
5928 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5932 "Send Community attribute to this neighbor\n"
5933 "Send Standard and Extended Community attributes\n"
5934 "Send Standard, Large and Extended Community attributes\n"
5935 "Send Extended Community attributes\n"
5936 "Send Standard Community attributes\n"
5937 "Send Large Community attributes\n")
5939 const char *type
= argv
[argc
- 1]->text
;
5940 char *peer_str
= argv
[2]->arg
;
5942 afi_t afi
= bgp_node_afi(vty
);
5943 safi_t safi
= bgp_node_safi(vty
);
5945 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5947 return CMD_WARNING_CONFIG_FAILED
;
5949 if (strmatch(type
, "standard"))
5950 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5951 PEER_FLAG_SEND_COMMUNITY
);
5953 if (strmatch(type
, "extended"))
5954 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5955 PEER_FLAG_SEND_EXT_COMMUNITY
);
5957 if (strmatch(type
, "large"))
5958 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5959 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5961 if (strmatch(type
, "both")) {
5963 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5964 PEER_FLAG_SEND_COMMUNITY
)
5965 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5966 PEER_FLAG_SEND_EXT_COMMUNITY
);
5969 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5970 PEER_FLAG_SEND_COMMUNITY
)
5971 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5972 PEER_FLAG_SEND_EXT_COMMUNITY
)
5973 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5974 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5978 no_neighbor_send_community_type
,
5979 no_neighbor_send_community_type_hidden_cmd
,
5980 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5982 "Send Community attribute to this neighbor\n"
5983 "Send Standard and Extended Community attributes\n"
5984 "Send Standard, Large and Extended Community attributes\n"
5985 "Send Extended Community attributes\n"
5986 "Send Standard Community attributes\n"
5987 "Send Large Community attributes\n")
5989 /* neighbor soft-reconfig. */
5990 DEFUN (neighbor_soft_reconfiguration
,
5991 neighbor_soft_reconfiguration_cmd
,
5992 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5995 "Per neighbor soft reconfiguration\n"
5996 "Allow inbound soft reconfiguration for this neighbor\n")
5999 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6001 PEER_FLAG_SOFT_RECONFIG
);
6004 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6005 neighbor_soft_reconfiguration_hidden_cmd
,
6006 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6007 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6008 "Per neighbor soft reconfiguration\n"
6009 "Allow inbound soft reconfiguration for this neighbor\n")
6011 DEFUN (no_neighbor_soft_reconfiguration
,
6012 no_neighbor_soft_reconfiguration_cmd
,
6013 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6017 "Per neighbor soft reconfiguration\n"
6018 "Allow inbound soft reconfiguration for this neighbor\n")
6021 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6022 bgp_node_afi(vty
), bgp_node_safi(vty
),
6023 PEER_FLAG_SOFT_RECONFIG
);
6026 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6027 no_neighbor_soft_reconfiguration_hidden_cmd
,
6028 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6029 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6030 "Per neighbor soft reconfiguration\n"
6031 "Allow inbound soft reconfiguration for this neighbor\n")
6033 DEFUN (neighbor_route_reflector_client
,
6034 neighbor_route_reflector_client_cmd
,
6035 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6038 "Configure a neighbor as Route Reflector client\n")
6044 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6046 return CMD_WARNING_CONFIG_FAILED
;
6048 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6050 PEER_FLAG_REFLECTOR_CLIENT
);
6053 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6054 neighbor_route_reflector_client_hidden_cmd
,
6055 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6056 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6057 "Configure a neighbor as Route Reflector client\n")
6059 DEFUN (no_neighbor_route_reflector_client
,
6060 no_neighbor_route_reflector_client_cmd
,
6061 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6065 "Configure a neighbor as Route Reflector client\n")
6068 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6069 bgp_node_afi(vty
), bgp_node_safi(vty
),
6070 PEER_FLAG_REFLECTOR_CLIENT
);
6073 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6074 no_neighbor_route_reflector_client_hidden_cmd
,
6075 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6076 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6077 "Configure a neighbor as Route Reflector client\n")
6079 /* neighbor route-server-client. */
6080 DEFUN (neighbor_route_server_client
,
6081 neighbor_route_server_client_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6085 "Configure a neighbor as Route Server client\n")
6090 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6092 return CMD_WARNING_CONFIG_FAILED
;
6093 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6095 PEER_FLAG_RSERVER_CLIENT
);
6098 ALIAS_HIDDEN(neighbor_route_server_client
,
6099 neighbor_route_server_client_hidden_cmd
,
6100 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6101 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6102 "Configure a neighbor as Route Server client\n")
6104 DEFUN (no_neighbor_route_server_client
,
6105 no_neighbor_route_server_client_cmd
,
6106 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6110 "Configure a neighbor as Route Server client\n")
6113 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6114 bgp_node_afi(vty
), bgp_node_safi(vty
),
6115 PEER_FLAG_RSERVER_CLIENT
);
6118 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6119 no_neighbor_route_server_client_hidden_cmd
,
6120 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6121 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6122 "Configure a neighbor as Route Server client\n")
6124 DEFUN (neighbor_nexthop_local_unchanged
,
6125 neighbor_nexthop_local_unchanged_cmd
,
6126 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6129 "Configure treatment of outgoing link-local nexthop attribute\n"
6130 "Leave link-local nexthop unchanged for this peer\n")
6133 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6135 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6138 DEFUN (no_neighbor_nexthop_local_unchanged
,
6139 no_neighbor_nexthop_local_unchanged_cmd
,
6140 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6144 "Configure treatment of outgoing link-local-nexthop attribute\n"
6145 "Leave link-local nexthop unchanged for this peer\n")
6148 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6149 bgp_node_afi(vty
), bgp_node_safi(vty
),
6150 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6153 DEFUN (neighbor_attr_unchanged
,
6154 neighbor_attr_unchanged_cmd
,
6155 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6158 "BGP attribute is propagated unchanged to this neighbor\n"
6159 "As-path attribute\n"
6160 "Nexthop attribute\n"
6164 char *peer_str
= argv
[1]->arg
;
6166 bool aspath
= false;
6167 bool nexthop
= false;
6169 afi_t afi
= bgp_node_afi(vty
);
6170 safi_t safi
= bgp_node_safi(vty
);
6173 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6175 return CMD_WARNING_CONFIG_FAILED
;
6177 if (argv_find(argv
, argc
, "as-path", &idx
))
6181 if (argv_find(argv
, argc
, "next-hop", &idx
))
6185 if (argv_find(argv
, argc
, "med", &idx
))
6188 /* no flags means all of them! */
6189 if (!aspath
&& !nexthop
&& !med
) {
6190 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6191 PEER_FLAG_AS_PATH_UNCHANGED
);
6192 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6193 PEER_FLAG_NEXTHOP_UNCHANGED
);
6194 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6195 PEER_FLAG_MED_UNCHANGED
);
6198 if (peer_af_flag_check(peer
, afi
, safi
,
6199 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6200 ret
|= peer_af_flag_unset_vty(
6201 vty
, peer_str
, afi
, safi
,
6202 PEER_FLAG_AS_PATH_UNCHANGED
);
6205 ret
|= peer_af_flag_set_vty(
6206 vty
, peer_str
, afi
, safi
,
6207 PEER_FLAG_AS_PATH_UNCHANGED
);
6210 if (peer_af_flag_check(peer
, afi
, safi
,
6211 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6212 ret
|= peer_af_flag_unset_vty(
6213 vty
, peer_str
, afi
, safi
,
6214 PEER_FLAG_NEXTHOP_UNCHANGED
);
6217 ret
|= peer_af_flag_set_vty(
6218 vty
, peer_str
, afi
, safi
,
6219 PEER_FLAG_NEXTHOP_UNCHANGED
);
6222 if (peer_af_flag_check(peer
, afi
, safi
,
6223 PEER_FLAG_MED_UNCHANGED
)) {
6224 ret
|= peer_af_flag_unset_vty(
6225 vty
, peer_str
, afi
, safi
,
6226 PEER_FLAG_MED_UNCHANGED
);
6229 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6230 PEER_FLAG_MED_UNCHANGED
);
6237 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6238 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6239 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6240 "BGP attribute is propagated unchanged to this neighbor\n"
6241 "As-path attribute\n"
6242 "Nexthop attribute\n"
6245 DEFUN (no_neighbor_attr_unchanged
,
6246 no_neighbor_attr_unchanged_cmd
,
6247 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6251 "BGP attribute is propagated unchanged to this neighbor\n"
6252 "As-path attribute\n"
6253 "Nexthop attribute\n"
6257 char *peer_str
= argv
[2]->arg
;
6259 bool aspath
= false;
6260 bool nexthop
= false;
6262 afi_t afi
= bgp_node_afi(vty
);
6263 safi_t safi
= bgp_node_safi(vty
);
6266 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6268 return CMD_WARNING_CONFIG_FAILED
;
6270 if (argv_find(argv
, argc
, "as-path", &idx
))
6274 if (argv_find(argv
, argc
, "next-hop", &idx
))
6278 if (argv_find(argv
, argc
, "med", &idx
))
6281 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6282 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6283 PEER_FLAG_AS_PATH_UNCHANGED
)
6284 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6285 PEER_FLAG_NEXTHOP_UNCHANGED
)
6286 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6287 PEER_FLAG_MED_UNCHANGED
);
6290 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6291 PEER_FLAG_AS_PATH_UNCHANGED
);
6294 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6295 PEER_FLAG_NEXTHOP_UNCHANGED
);
6298 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6299 PEER_FLAG_MED_UNCHANGED
);
6305 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6306 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "BGP attribute is propagated unchanged to this neighbor\n"
6309 "As-path attribute\n"
6310 "Nexthop attribute\n"
6313 /* EBGP multihop configuration. */
6314 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6315 const char *ttl_str
)
6320 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6322 return CMD_WARNING_CONFIG_FAILED
;
6325 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6330 ttl
= strtoul(ttl_str
, NULL
, 10);
6332 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6335 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6339 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6341 return CMD_WARNING_CONFIG_FAILED
;
6343 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6346 /* neighbor ebgp-multihop. */
6347 DEFUN (neighbor_ebgp_multihop
,
6348 neighbor_ebgp_multihop_cmd
,
6349 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6352 "Allow EBGP neighbors not on directly connected networks\n")
6355 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6358 DEFUN (neighbor_ebgp_multihop_ttl
,
6359 neighbor_ebgp_multihop_ttl_cmd
,
6360 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6363 "Allow EBGP neighbors not on directly connected networks\n"
6364 "maximum hop count\n")
6368 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6369 argv
[idx_number
]->arg
);
6372 DEFUN (no_neighbor_ebgp_multihop
,
6373 no_neighbor_ebgp_multihop_cmd
,
6374 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6378 "Allow EBGP neighbors not on directly connected networks\n"
6379 "maximum hop count\n")
6382 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6386 /* disable-connected-check */
6387 DEFUN (neighbor_disable_connected_check
,
6388 neighbor_disable_connected_check_cmd
,
6389 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6392 "one-hop away EBGP peer using loopback address\n"
6393 "Enforce EBGP neighbors perform multihop\n")
6396 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6397 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6400 DEFUN (no_neighbor_disable_connected_check
,
6401 no_neighbor_disable_connected_check_cmd
,
6402 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6406 "one-hop away EBGP peer using loopback address\n"
6407 "Enforce EBGP neighbors perform multihop\n")
6410 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6411 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6414 /* disable-link-bw-encoding-ieee */
6415 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6416 neighbor_disable_link_bw_encoding_ieee_cmd
,
6417 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6418 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6419 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6423 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6424 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6427 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6428 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6429 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6430 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6431 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6435 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6436 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6439 /* extended-optional-parameters */
6440 DEFUN(neighbor_extended_optional_parameters
,
6441 neighbor_extended_optional_parameters_cmd
,
6442 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6443 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6444 "Force the extended optional parameters format for OPEN messages\n")
6448 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6449 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6452 DEFUN(no_neighbor_extended_optional_parameters
,
6453 no_neighbor_extended_optional_parameters_cmd
,
6454 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6455 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6456 "Force the extended optional parameters format for OPEN messages\n")
6460 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6461 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6464 /* enforce-first-as */
6465 DEFUN (neighbor_enforce_first_as
,
6466 neighbor_enforce_first_as_cmd
,
6467 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6470 "Enforce the first AS for EBGP routes\n")
6474 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6475 PEER_FLAG_ENFORCE_FIRST_AS
);
6478 DEFUN (no_neighbor_enforce_first_as
,
6479 no_neighbor_enforce_first_as_cmd
,
6480 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6484 "Enforce the first AS for EBGP routes\n")
6488 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6489 PEER_FLAG_ENFORCE_FIRST_AS
);
6493 DEFUN (neighbor_description
,
6494 neighbor_description_cmd
,
6495 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6498 "Neighbor specific description\n"
6499 "Up to 80 characters describing this neighbor\n")
6506 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6508 return CMD_WARNING_CONFIG_FAILED
;
6510 str
= argv_concat(argv
, argc
, idx_line
);
6512 peer_description_set(peer
, str
);
6514 XFREE(MTYPE_TMP
, str
);
6519 DEFUN (no_neighbor_description
,
6520 no_neighbor_description_cmd
,
6521 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6525 "Neighbor specific description\n")
6530 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6532 return CMD_WARNING_CONFIG_FAILED
;
6534 peer_description_unset(peer
);
6539 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6540 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6541 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6542 "Neighbor specific description\n"
6543 "Up to 80 characters describing this neighbor\n")
6545 /* Neighbor update-source. */
6546 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6547 const char *source_str
)
6553 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6555 return CMD_WARNING_CONFIG_FAILED
;
6561 if (str2sockunion(source_str
, &su
) == 0)
6562 peer_update_source_addr_set(peer
, &su
);
6564 if (str2prefix(source_str
, &p
)) {
6566 "%% Invalid update-source, remove prefix length \n");
6567 return CMD_WARNING_CONFIG_FAILED
;
6569 peer_update_source_if_set(peer
, source_str
);
6572 peer_update_source_unset(peer
);
6577 #define BGP_UPDATE_SOURCE_HELP_STR \
6580 "Interface name (requires zebra to be running)\n"
6582 DEFUN (neighbor_update_source
,
6583 neighbor_update_source_cmd
,
6584 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6587 "Source of routing updates\n"
6588 BGP_UPDATE_SOURCE_HELP_STR
)
6592 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6593 argv
[idx_peer_2
]->arg
);
6596 DEFUN (no_neighbor_update_source
,
6597 no_neighbor_update_source_cmd
,
6598 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6602 "Source of routing updates\n"
6603 BGP_UPDATE_SOURCE_HELP_STR
)
6606 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6609 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6610 afi_t afi
, safi_t safi
,
6611 const char *rmap
, int set
)
6615 struct route_map
*route_map
= NULL
;
6617 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6619 return CMD_WARNING_CONFIG_FAILED
;
6623 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6624 ret
= peer_default_originate_set(peer
, afi
, safi
,
6627 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6629 return bgp_vty_return(vty
, ret
);
6632 /* neighbor default-originate. */
6633 DEFUN (neighbor_default_originate
,
6634 neighbor_default_originate_cmd
,
6635 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6638 "Originate default route to this neighbor\n")
6641 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6643 bgp_node_safi(vty
), NULL
, 1);
6646 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6647 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6648 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6649 "Originate default route to this neighbor\n")
6651 DEFUN (neighbor_default_originate_rmap
,
6652 neighbor_default_originate_rmap_cmd
,
6653 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6656 "Originate default route to this neighbor\n"
6657 "Route-map to specify criteria to originate default\n"
6662 return peer_default_originate_set_vty(
6663 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6664 argv
[idx_word
]->arg
, 1);
6668 neighbor_default_originate_rmap
,
6669 neighbor_default_originate_rmap_hidden_cmd
,
6670 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6671 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6672 "Originate default route to this neighbor\n"
6673 "Route-map to specify criteria to originate default\n"
6676 DEFUN (no_neighbor_default_originate
,
6677 no_neighbor_default_originate_cmd
,
6678 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6682 "Originate default route to this neighbor\n"
6683 "Route-map to specify criteria to originate default\n"
6687 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6689 bgp_node_safi(vty
), NULL
, 0);
6693 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6694 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6695 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6696 "Originate default route to this neighbor\n"
6697 "Route-map to specify criteria to originate default\n"
6701 /* Set neighbor's BGP port. */
6702 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6703 const char *port_str
)
6709 peer
= peer_lookup_vty(vty
, ip_str
);
6711 return CMD_WARNING_CONFIG_FAILED
;
6714 sp
= getservbyname("bgp", "tcp");
6715 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6717 port
= strtoul(port_str
, NULL
, 10);
6720 peer_port_set(peer
, port
);
6725 /* Set specified peer's BGP port. */
6726 DEFUN (neighbor_port
,
6728 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6731 "Neighbor's BGP port\n"
6732 "TCP port number\n")
6736 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6737 argv
[idx_number
]->arg
);
6740 DEFUN (no_neighbor_port
,
6741 no_neighbor_port_cmd
,
6742 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6746 "Neighbor's BGP port\n"
6747 "TCP port number\n")
6750 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6754 /* neighbor weight. */
6755 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6756 safi_t safi
, const char *weight_str
)
6760 unsigned long weight
;
6762 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6764 return CMD_WARNING_CONFIG_FAILED
;
6766 weight
= strtoul(weight_str
, NULL
, 10);
6768 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6769 return bgp_vty_return(vty
, ret
);
6772 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6778 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6780 return CMD_WARNING_CONFIG_FAILED
;
6782 ret
= peer_weight_unset(peer
, afi
, safi
);
6783 return bgp_vty_return(vty
, ret
);
6786 DEFUN (neighbor_weight
,
6787 neighbor_weight_cmd
,
6788 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6791 "Set default weight for routes from this neighbor\n"
6796 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6797 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6800 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6801 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6803 "Set default weight for routes from this neighbor\n"
6806 DEFUN (no_neighbor_weight
,
6807 no_neighbor_weight_cmd
,
6808 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6812 "Set default weight for routes from this neighbor\n"
6816 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6817 bgp_node_afi(vty
), bgp_node_safi(vty
));
6820 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6821 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6822 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6823 "Set default weight for routes from this neighbor\n"
6827 /* Override capability negotiation. */
6828 DEFUN (neighbor_override_capability
,
6829 neighbor_override_capability_cmd
,
6830 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6833 "Override capability negotiation result\n")
6836 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6837 PEER_FLAG_OVERRIDE_CAPABILITY
);
6840 DEFUN (no_neighbor_override_capability
,
6841 no_neighbor_override_capability_cmd
,
6842 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6846 "Override capability negotiation result\n")
6849 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6850 PEER_FLAG_OVERRIDE_CAPABILITY
);
6853 DEFUN (neighbor_strict_capability
,
6854 neighbor_strict_capability_cmd
,
6855 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6858 "Strict capability negotiation match\n")
6862 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6863 PEER_FLAG_STRICT_CAP_MATCH
);
6866 DEFUN (no_neighbor_strict_capability
,
6867 no_neighbor_strict_capability_cmd
,
6868 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6872 "Strict capability negotiation match\n")
6876 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6877 PEER_FLAG_STRICT_CAP_MATCH
);
6880 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6881 const char *keep_str
, const char *hold_str
)
6888 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6890 return CMD_WARNING_CONFIG_FAILED
;
6892 keepalive
= strtoul(keep_str
, NULL
, 10);
6893 holdtime
= strtoul(hold_str
, NULL
, 10);
6895 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6897 return bgp_vty_return(vty
, ret
);
6900 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6905 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6907 return CMD_WARNING_CONFIG_FAILED
;
6909 ret
= peer_timers_unset(peer
);
6911 return bgp_vty_return(vty
, ret
);
6914 DEFUN (neighbor_timers
,
6915 neighbor_timers_cmd
,
6916 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6919 "BGP per neighbor timers\n"
6920 "Keepalive interval\n"
6925 int idx_number_2
= 4;
6926 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6927 argv
[idx_number
]->arg
,
6928 argv
[idx_number_2
]->arg
);
6931 DEFUN (no_neighbor_timers
,
6932 no_neighbor_timers_cmd
,
6933 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6937 "BGP per neighbor timers\n"
6938 "Keepalive interval\n"
6942 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6946 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6947 const char *time_str
)
6953 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6955 return CMD_WARNING_CONFIG_FAILED
;
6957 connect
= strtoul(time_str
, NULL
, 10);
6959 ret
= peer_timers_connect_set(peer
, connect
);
6961 return bgp_vty_return(vty
, ret
);
6964 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6969 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6971 return CMD_WARNING_CONFIG_FAILED
;
6973 ret
= peer_timers_connect_unset(peer
);
6975 return bgp_vty_return(vty
, ret
);
6978 DEFUN (neighbor_timers_connect
,
6979 neighbor_timers_connect_cmd
,
6980 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6983 "BGP per neighbor timers\n"
6984 "BGP connect timer\n"
6989 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6990 argv
[idx_number
]->arg
);
6993 DEFUN (no_neighbor_timers_connect
,
6994 no_neighbor_timers_connect_cmd
,
6995 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6999 "BGP per neighbor timers\n"
7000 "BGP connect timer\n"
7004 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7007 DEFPY (neighbor_timers_delayopen
,
7008 neighbor_timers_delayopen_cmd
,
7009 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7012 "BGP per neighbor timers\n"
7013 "RFC 4271 DelayOpenTimer\n"
7014 "DelayOpenTime timer interval\n")
7018 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7020 return CMD_WARNING_CONFIG_FAILED
;
7023 if (peer_timers_delayopen_unset(peer
))
7024 return CMD_WARNING_CONFIG_FAILED
;
7026 if (peer_timers_delayopen_set(peer
, interval
))
7027 return CMD_WARNING_CONFIG_FAILED
;
7033 DEFPY (no_neighbor_timers_delayopen
,
7034 no_neighbor_timers_delayopen_cmd
,
7035 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7039 "BGP per neighbor timers\n"
7040 "RFC 4271 DelayOpenTimer\n"
7041 "DelayOpenTime timer interval\n")
7045 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7047 return CMD_WARNING_CONFIG_FAILED
;
7049 if (peer_timers_delayopen_unset(peer
))
7050 return CMD_WARNING_CONFIG_FAILED
;
7055 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7056 const char *time_str
, int set
)
7060 uint32_t routeadv
= 0;
7062 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7064 return CMD_WARNING_CONFIG_FAILED
;
7067 routeadv
= strtoul(time_str
, NULL
, 10);
7070 ret
= peer_advertise_interval_set(peer
, routeadv
);
7072 ret
= peer_advertise_interval_unset(peer
);
7074 return bgp_vty_return(vty
, ret
);
7077 DEFUN (neighbor_advertise_interval
,
7078 neighbor_advertise_interval_cmd
,
7079 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7082 "Minimum interval between sending BGP routing updates\n"
7083 "time in seconds\n")
7087 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7088 argv
[idx_number
]->arg
, 1);
7091 DEFUN (no_neighbor_advertise_interval
,
7092 no_neighbor_advertise_interval_cmd
,
7093 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7097 "Minimum interval between sending BGP routing updates\n"
7098 "time in seconds\n")
7101 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7105 /* Time to wait before processing route-map updates */
7106 DEFUN (bgp_set_route_map_delay_timer
,
7107 bgp_set_route_map_delay_timer_cmd
,
7108 "bgp route-map delay-timer (0-600)",
7110 "BGP route-map delay timer\n"
7111 "Time in secs to wait before processing route-map changes\n"
7112 "0 disables the timer, no route updates happen when route-maps change\n")
7115 uint32_t rmap_delay_timer
;
7117 if (argv
[idx_number
]->arg
) {
7118 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7119 bm
->rmap_update_timer
= rmap_delay_timer
;
7121 /* if the dynamic update handling is being disabled, and a timer
7123 * running, stop the timer and act as if the timer has already
7126 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7127 BGP_TIMER_OFF(bm
->t_rmap_update
);
7128 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7133 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7134 return CMD_WARNING_CONFIG_FAILED
;
7138 DEFUN (no_bgp_set_route_map_delay_timer
,
7139 no_bgp_set_route_map_delay_timer_cmd
,
7140 "no bgp route-map delay-timer [(0-600)]",
7143 "Default BGP route-map delay timer\n"
7144 "Reset to default time to wait for processing route-map changes\n"
7145 "0 disables the timer, no route updates happen when route-maps change\n")
7148 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7153 /* neighbor interface */
7154 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7159 peer
= peer_lookup_vty(vty
, ip_str
);
7160 if (!peer
|| peer
->conf_if
) {
7161 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7162 return CMD_WARNING_CONFIG_FAILED
;
7166 peer_interface_set(peer
, str
);
7168 peer_interface_unset(peer
);
7173 DEFUN (neighbor_interface
,
7174 neighbor_interface_cmd
,
7175 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7184 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7187 DEFUN (no_neighbor_interface
,
7188 no_neighbor_interface_cmd
,
7189 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7198 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7201 DEFUN (neighbor_distribute_list
,
7202 neighbor_distribute_list_cmd
,
7203 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7206 "Filter updates to/from this neighbor\n"
7207 "IP Access-list name\n"
7208 "Filter incoming updates\n"
7209 "Filter outgoing updates\n")
7216 const char *pstr
= argv
[idx_peer
]->arg
;
7217 const char *acl
= argv
[idx_acl
]->arg
;
7218 const char *inout
= argv
[argc
- 1]->text
;
7220 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7222 return CMD_WARNING_CONFIG_FAILED
;
7224 /* Check filter direction. */
7225 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7226 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7229 return bgp_vty_return(vty
, ret
);
7233 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7234 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7235 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7236 "Filter updates to/from this neighbor\n"
7237 "IP Access-list name\n"
7238 "Filter incoming updates\n"
7239 "Filter outgoing updates\n")
7241 DEFUN (no_neighbor_distribute_list
,
7242 no_neighbor_distribute_list_cmd
,
7243 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7247 "Filter updates to/from this neighbor\n"
7248 "IP Access-list name\n"
7249 "Filter incoming updates\n"
7250 "Filter outgoing updates\n")
7256 const char *pstr
= argv
[idx_peer
]->arg
;
7257 const char *inout
= argv
[argc
- 1]->text
;
7259 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7261 return CMD_WARNING_CONFIG_FAILED
;
7263 /* Check filter direction. */
7264 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7265 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7268 return bgp_vty_return(vty
, ret
);
7272 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7273 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7274 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7275 "Filter updates to/from this neighbor\n"
7276 "IP Access-list name\n"
7277 "Filter incoming updates\n"
7278 "Filter outgoing updates\n")
7280 /* Set prefix list to the peer. */
7281 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7282 afi_t afi
, safi_t safi
,
7283 const char *name_str
,
7284 const char *direct_str
)
7287 int direct
= FILTER_IN
;
7290 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7292 return CMD_WARNING_CONFIG_FAILED
;
7294 /* Check filter direction. */
7295 if (strncmp(direct_str
, "i", 1) == 0)
7297 else if (strncmp(direct_str
, "o", 1) == 0)
7298 direct
= FILTER_OUT
;
7300 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7302 return bgp_vty_return(vty
, ret
);
7305 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7306 afi_t afi
, safi_t safi
,
7307 const char *direct_str
)
7311 int direct
= FILTER_IN
;
7313 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7315 return CMD_WARNING_CONFIG_FAILED
;
7317 /* Check filter direction. */
7318 if (strncmp(direct_str
, "i", 1) == 0)
7320 else if (strncmp(direct_str
, "o", 1) == 0)
7321 direct
= FILTER_OUT
;
7323 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7325 return bgp_vty_return(vty
, ret
);
7328 DEFUN (neighbor_prefix_list
,
7329 neighbor_prefix_list_cmd
,
7330 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7333 "Filter updates to/from this neighbor\n"
7334 "Name of a prefix list\n"
7335 "Filter incoming updates\n"
7336 "Filter outgoing updates\n")
7341 return peer_prefix_list_set_vty(
7342 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7343 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7346 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7347 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7348 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7349 "Filter updates to/from this neighbor\n"
7350 "Name of a prefix list\n"
7351 "Filter incoming updates\n"
7352 "Filter outgoing updates\n")
7354 DEFUN (no_neighbor_prefix_list
,
7355 no_neighbor_prefix_list_cmd
,
7356 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7360 "Filter updates to/from this neighbor\n"
7361 "Name of a prefix list\n"
7362 "Filter incoming updates\n"
7363 "Filter outgoing updates\n")
7367 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7368 bgp_node_afi(vty
), bgp_node_safi(vty
),
7369 argv
[idx_in_out
]->arg
);
7372 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7373 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7374 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7375 "Filter updates to/from this neighbor\n"
7376 "Name of a prefix list\n"
7377 "Filter incoming updates\n"
7378 "Filter outgoing updates\n")
7380 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7381 safi_t safi
, const char *name_str
,
7382 const char *direct_str
)
7386 int direct
= FILTER_IN
;
7388 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7390 return CMD_WARNING_CONFIG_FAILED
;
7392 /* Check filter direction. */
7393 if (strncmp(direct_str
, "i", 1) == 0)
7395 else if (strncmp(direct_str
, "o", 1) == 0)
7396 direct
= FILTER_OUT
;
7398 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7400 return bgp_vty_return(vty
, ret
);
7403 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7404 safi_t safi
, const char *direct_str
)
7408 int direct
= FILTER_IN
;
7410 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7412 return CMD_WARNING_CONFIG_FAILED
;
7414 /* Check filter direction. */
7415 if (strncmp(direct_str
, "i", 1) == 0)
7417 else if (strncmp(direct_str
, "o", 1) == 0)
7418 direct
= FILTER_OUT
;
7420 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7422 return bgp_vty_return(vty
, ret
);
7425 DEFUN (neighbor_filter_list
,
7426 neighbor_filter_list_cmd
,
7427 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7430 "Establish BGP filters\n"
7431 "AS path access-list name\n"
7432 "Filter incoming routes\n"
7433 "Filter outgoing routes\n")
7438 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7439 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7440 argv
[idx_in_out
]->arg
);
7443 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7444 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7445 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7446 "Establish BGP filters\n"
7447 "AS path access-list name\n"
7448 "Filter incoming routes\n"
7449 "Filter outgoing routes\n")
7451 DEFUN (no_neighbor_filter_list
,
7452 no_neighbor_filter_list_cmd
,
7453 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7457 "Establish BGP filters\n"
7458 "AS path access-list name\n"
7459 "Filter incoming routes\n"
7460 "Filter outgoing routes\n")
7464 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7465 bgp_node_afi(vty
), bgp_node_safi(vty
),
7466 argv
[idx_in_out
]->arg
);
7469 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7470 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7471 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7472 "Establish BGP filters\n"
7473 "AS path access-list name\n"
7474 "Filter incoming routes\n"
7475 "Filter outgoing routes\n")
7477 /* Set advertise-map to the peer. */
7478 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7479 afi_t afi
, safi_t safi
,
7480 const char *advertise_str
,
7481 const char *condition_str
, bool condition
,
7484 int ret
= CMD_WARNING_CONFIG_FAILED
;
7486 struct route_map
*advertise_map
;
7487 struct route_map
*condition_map
;
7489 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7493 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7494 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7497 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7498 advertise_map
, condition_str
,
7499 condition_map
, condition
);
7501 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7502 advertise_map
, condition_str
,
7503 condition_map
, condition
);
7505 return bgp_vty_return(vty
, ret
);
7508 DEFPY (bgp_condadv_period
,
7509 bgp_condadv_period_cmd
,
7510 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7513 "Conditional advertisement settings\n"
7514 "Set period to rescan BGP table to check if condition is met\n"
7515 "Period between BGP table scans, in seconds; default 60\n")
7517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7519 bgp
->condition_check_period
=
7520 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7525 DEFPY (neighbor_advertise_map
,
7526 neighbor_advertise_map_cmd
,
7527 "[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",
7531 "Route-map to conditionally advertise routes\n"
7532 "Name of advertise map\n"
7533 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7534 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7535 "Name of the exist or non exist map\n")
7537 bool condition
= CONDITION_EXIST
;
7539 if (!strcmp(exist
, "non-exist-map"))
7540 condition
= CONDITION_NON_EXIST
;
7542 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7543 bgp_node_safi(vty
), advertise_str
,
7544 condition_str
, condition
, !no
);
7547 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7548 "[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",
7549 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7550 "Route-map to conditionally advertise routes\n"
7551 "Name of advertise map\n"
7552 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7553 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7554 "Name of the exist or non exist map\n")
7556 /* Set route-map to the peer. */
7557 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7558 afi_t afi
, safi_t safi
, const char *name_str
,
7559 const char *direct_str
)
7563 int direct
= RMAP_IN
;
7564 struct route_map
*route_map
;
7566 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7568 return CMD_WARNING_CONFIG_FAILED
;
7570 /* Check filter direction. */
7571 if (strncmp(direct_str
, "in", 2) == 0)
7573 else if (strncmp(direct_str
, "o", 1) == 0)
7576 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7577 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7579 return bgp_vty_return(vty
, ret
);
7582 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7583 afi_t afi
, safi_t safi
,
7584 const char *direct_str
)
7588 int direct
= RMAP_IN
;
7590 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7592 return CMD_WARNING_CONFIG_FAILED
;
7594 /* Check filter direction. */
7595 if (strncmp(direct_str
, "in", 2) == 0)
7597 else if (strncmp(direct_str
, "o", 1) == 0)
7600 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7602 return bgp_vty_return(vty
, ret
);
7605 DEFUN (neighbor_route_map
,
7606 neighbor_route_map_cmd
,
7607 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7610 "Apply route map to neighbor\n"
7611 "Name of route map\n"
7612 "Apply map to incoming routes\n"
7613 "Apply map to outbound routes\n")
7618 return peer_route_map_set_vty(
7619 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7620 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7623 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7624 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7625 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7626 "Apply route map to neighbor\n"
7627 "Name of route map\n"
7628 "Apply map to incoming routes\n"
7629 "Apply map to outbound routes\n")
7631 DEFUN (no_neighbor_route_map
,
7632 no_neighbor_route_map_cmd
,
7633 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7637 "Apply route map to neighbor\n"
7638 "Name of route map\n"
7639 "Apply map to incoming routes\n"
7640 "Apply map to outbound routes\n")
7644 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7645 bgp_node_afi(vty
), bgp_node_safi(vty
),
7646 argv
[idx_in_out
]->arg
);
7649 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7650 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7651 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7652 "Apply route map to neighbor\n"
7653 "Name of route map\n"
7654 "Apply map to incoming routes\n"
7655 "Apply map to outbound routes\n")
7657 /* Set unsuppress-map to the peer. */
7658 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7659 afi_t afi
, safi_t safi
,
7660 const char *name_str
)
7664 struct route_map
*route_map
;
7666 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7668 return CMD_WARNING_CONFIG_FAILED
;
7670 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7671 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7673 return bgp_vty_return(vty
, ret
);
7676 /* Unset route-map from the peer. */
7677 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7678 afi_t afi
, safi_t safi
)
7683 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7685 return CMD_WARNING_CONFIG_FAILED
;
7687 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7689 return bgp_vty_return(vty
, ret
);
7692 DEFUN (neighbor_unsuppress_map
,
7693 neighbor_unsuppress_map_cmd
,
7694 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7697 "Route-map to selectively unsuppress suppressed routes\n"
7698 "Name of route map\n")
7702 return peer_unsuppress_map_set_vty(
7703 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7704 argv
[idx_word
]->arg
);
7707 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7708 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7709 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7710 "Route-map to selectively unsuppress suppressed routes\n"
7711 "Name of route map\n")
7713 DEFUN (no_neighbor_unsuppress_map
,
7714 no_neighbor_unsuppress_map_cmd
,
7715 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7719 "Route-map to selectively unsuppress suppressed routes\n"
7720 "Name of route map\n")
7723 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7725 bgp_node_safi(vty
));
7728 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7729 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7730 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7731 "Route-map to selectively unsuppress suppressed routes\n"
7732 "Name of route map\n")
7734 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7735 afi_t afi
, safi_t safi
,
7736 const char *num_str
,
7737 const char *threshold_str
, int warning
,
7738 const char *restart_str
,
7739 const char *force_str
)
7747 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7749 return CMD_WARNING_CONFIG_FAILED
;
7751 max
= strtoul(num_str
, NULL
, 10);
7753 threshold
= atoi(threshold_str
);
7755 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7758 restart
= atoi(restart_str
);
7762 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7763 restart
, force_str
? true : false);
7765 return bgp_vty_return(vty
, ret
);
7768 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7769 afi_t afi
, safi_t safi
)
7774 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7776 return CMD_WARNING_CONFIG_FAILED
;
7778 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7780 return bgp_vty_return(vty
, ret
);
7783 /* Maximum number of prefix to be sent to the neighbor. */
7784 DEFUN(neighbor_maximum_prefix_out
,
7785 neighbor_maximum_prefix_out_cmd
,
7786 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7789 "Maximum number of prefixes to be sent to this peer\n"
7790 "Maximum no. of prefix limit\n")
7797 afi_t afi
= bgp_node_afi(vty
);
7798 safi_t safi
= bgp_node_safi(vty
);
7800 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7802 return CMD_WARNING_CONFIG_FAILED
;
7804 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7806 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7808 return bgp_vty_return(vty
, ret
);
7811 DEFUN(no_neighbor_maximum_prefix_out
,
7812 no_neighbor_maximum_prefix_out_cmd
,
7813 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7817 "Maximum number of prefixes to be sent to this peer\n"
7818 "Maximum no. of prefix limit\n")
7823 afi_t afi
= bgp_node_afi(vty
);
7824 safi_t safi
= bgp_node_safi(vty
);
7826 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7828 return CMD_WARNING_CONFIG_FAILED
;
7830 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
7832 return bgp_vty_return(vty
, ret
);
7835 /* Maximum number of prefix configuration. Prefix count is different
7836 for each peer configuration. So this configuration can be set for
7837 each peer configuration. */
7838 DEFUN (neighbor_maximum_prefix
,
7839 neighbor_maximum_prefix_cmd
,
7840 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7843 "Maximum number of prefix accept from this peer\n"
7844 "maximum no. of prefix limit\n"
7845 "Force checking all received routes not only accepted\n")
7852 if (argv_find(argv
, argc
, "force", &idx_force
))
7853 force
= argv
[idx_force
]->arg
;
7855 return peer_maximum_prefix_set_vty(
7856 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7857 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7860 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7861 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7862 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7863 "Maximum number of prefix accept from this peer\n"
7864 "maximum no. of prefix limit\n"
7865 "Force checking all received routes not only accepted\n")
7867 DEFUN (neighbor_maximum_prefix_threshold
,
7868 neighbor_maximum_prefix_threshold_cmd
,
7869 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7872 "Maximum number of prefix accept from this peer\n"
7873 "maximum no. of prefix limit\n"
7874 "Threshold value (%) at which to generate a warning msg\n"
7875 "Force checking all received routes not only accepted\n")
7879 int idx_number_2
= 4;
7883 if (argv_find(argv
, argc
, "force", &idx_force
))
7884 force
= argv
[idx_force
]->arg
;
7886 return peer_maximum_prefix_set_vty(
7887 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7888 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
7892 neighbor_maximum_prefix_threshold
,
7893 neighbor_maximum_prefix_threshold_hidden_cmd
,
7894 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7895 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7896 "Maximum number of prefix accept from this peer\n"
7897 "maximum no. of prefix limit\n"
7898 "Threshold value (%) at which to generate a warning msg\n"
7899 "Force checking all received routes not only accepted\n")
7901 DEFUN (neighbor_maximum_prefix_warning
,
7902 neighbor_maximum_prefix_warning_cmd
,
7903 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7906 "Maximum number of prefix accept from this peer\n"
7907 "maximum no. of prefix limit\n"
7908 "Only give warning message when limit is exceeded\n"
7909 "Force checking all received routes not only accepted\n")
7916 if (argv_find(argv
, argc
, "force", &idx_force
))
7917 force
= argv
[idx_force
]->arg
;
7919 return peer_maximum_prefix_set_vty(
7920 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7921 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
7925 neighbor_maximum_prefix_warning
,
7926 neighbor_maximum_prefix_warning_hidden_cmd
,
7927 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7928 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7929 "Maximum number of prefix accept from this peer\n"
7930 "maximum no. of prefix limit\n"
7931 "Only give warning message when limit is exceeded\n"
7932 "Force checking all received routes not only accepted\n")
7934 DEFUN (neighbor_maximum_prefix_threshold_warning
,
7935 neighbor_maximum_prefix_threshold_warning_cmd
,
7936 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7939 "Maximum number of prefix accept from this peer\n"
7940 "maximum no. of prefix limit\n"
7941 "Threshold value (%) at which to generate a warning msg\n"
7942 "Only give warning message when limit is exceeded\n"
7943 "Force checking all received routes not only accepted\n")
7947 int idx_number_2
= 4;
7951 if (argv_find(argv
, argc
, "force", &idx_force
))
7952 force
= argv
[idx_force
]->arg
;
7954 return peer_maximum_prefix_set_vty(
7955 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7956 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
7960 neighbor_maximum_prefix_threshold_warning
,
7961 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
7962 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7963 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7964 "Maximum number of prefix accept from this peer\n"
7965 "maximum no. of prefix limit\n"
7966 "Threshold value (%) at which to generate a warning msg\n"
7967 "Only give warning message when limit is exceeded\n"
7968 "Force checking all received routes not only accepted\n")
7970 DEFUN (neighbor_maximum_prefix_restart
,
7971 neighbor_maximum_prefix_restart_cmd
,
7972 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7975 "Maximum number of prefix accept from this peer\n"
7976 "maximum no. of prefix limit\n"
7977 "Restart bgp connection after limit is exceeded\n"
7978 "Restart interval in minutes\n"
7979 "Force checking all received routes not only accepted\n")
7983 int idx_number_2
= 5;
7987 if (argv_find(argv
, argc
, "force", &idx_force
))
7988 force
= argv
[idx_force
]->arg
;
7990 return peer_maximum_prefix_set_vty(
7991 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7992 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7996 neighbor_maximum_prefix_restart
,
7997 neighbor_maximum_prefix_restart_hidden_cmd
,
7998 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7999 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8000 "Maximum number of prefix accept from this peer\n"
8001 "maximum no. of prefix limit\n"
8002 "Restart bgp connection after limit is exceeded\n"
8003 "Restart interval in minutes\n"
8004 "Force checking all received routes not only accepted\n")
8006 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8007 neighbor_maximum_prefix_threshold_restart_cmd
,
8008 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8011 "Maximum number of prefixes to accept from this peer\n"
8012 "maximum no. of prefix limit\n"
8013 "Threshold value (%) at which to generate a warning msg\n"
8014 "Restart bgp connection after limit is exceeded\n"
8015 "Restart interval in minutes\n"
8016 "Force checking all received routes not only accepted\n")
8020 int idx_number_2
= 4;
8021 int idx_number_3
= 6;
8025 if (argv_find(argv
, argc
, "force", &idx_force
))
8026 force
= argv
[idx_force
]->arg
;
8028 return peer_maximum_prefix_set_vty(
8029 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8030 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8031 argv
[idx_number_3
]->arg
, force
);
8035 neighbor_maximum_prefix_threshold_restart
,
8036 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8037 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8038 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8039 "Maximum number of prefixes to accept from this peer\n"
8040 "maximum no. of prefix limit\n"
8041 "Threshold value (%) at which to generate a warning msg\n"
8042 "Restart bgp connection after limit is exceeded\n"
8043 "Restart interval in minutes\n"
8044 "Force checking all received routes not only accepted\n")
8046 DEFUN (no_neighbor_maximum_prefix
,
8047 no_neighbor_maximum_prefix_cmd
,
8048 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8052 "Maximum number of prefixes to accept from this peer\n"
8053 "maximum no. of prefix limit\n"
8054 "Threshold value (%) at which to generate a warning msg\n"
8055 "Restart bgp connection after limit is exceeded\n"
8056 "Restart interval in minutes\n"
8057 "Only give warning message when limit is exceeded\n"
8058 "Force checking all received routes not only accepted\n")
8061 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8063 bgp_node_safi(vty
));
8067 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8068 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8069 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8070 "Maximum number of prefixes to accept from this peer\n"
8071 "maximum no. of prefix limit\n"
8072 "Threshold value (%) at which to generate a warning msg\n"
8073 "Restart bgp connection after limit is exceeded\n"
8074 "Restart interval in minutes\n"
8075 "Only give warning message when limit is exceeded\n"
8076 "Force checking all received routes not only accepted\n")
8079 /* "neighbor allowas-in" */
8080 DEFUN (neighbor_allowas_in
,
8081 neighbor_allowas_in_cmd
,
8082 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8085 "Accept as-path with my AS present in it\n"
8086 "Number of occurrences of AS number\n"
8087 "Only accept my AS in the as-path if the route was originated in my AS\n")
8090 int idx_number_origin
= 3;
8096 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8098 return CMD_WARNING_CONFIG_FAILED
;
8100 if (argc
<= idx_number_origin
)
8103 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8106 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8109 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8112 return bgp_vty_return(vty
, ret
);
8116 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8117 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8118 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8119 "Accept as-path with my AS present in it\n"
8120 "Number of occurrences of AS number\n"
8121 "Only accept my AS in the as-path if the route was originated in my AS\n")
8123 DEFUN (no_neighbor_allowas_in
,
8124 no_neighbor_allowas_in_cmd
,
8125 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8129 "allow local ASN appears in aspath attribute\n"
8130 "Number of occurrences of AS number\n"
8131 "Only accept my AS in the as-path if the route was originated in my AS\n")
8137 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8139 return CMD_WARNING_CONFIG_FAILED
;
8141 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8142 bgp_node_safi(vty
));
8144 return bgp_vty_return(vty
, ret
);
8148 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8149 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8150 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8151 "allow local ASN appears in aspath attribute\n"
8152 "Number of occurrences of AS number\n"
8153 "Only accept my AS in the as-path if the route was originated in my AS\n")
8155 DEFUN (neighbor_ttl_security
,
8156 neighbor_ttl_security_cmd
,
8157 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8160 "BGP ttl-security parameters\n"
8161 "Specify the maximum number of hops to the BGP peer\n"
8162 "Number of hops to BGP peer\n")
8169 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8171 return CMD_WARNING_CONFIG_FAILED
;
8173 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8176 * If 'neighbor swpX', then this is for directly connected peers,
8177 * we should not accept a ttl-security hops value greater than 1.
8179 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8181 "%s is directly connected peer, hops cannot exceed 1\n",
8182 argv
[idx_peer
]->arg
);
8183 return CMD_WARNING_CONFIG_FAILED
;
8186 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8189 DEFUN (no_neighbor_ttl_security
,
8190 no_neighbor_ttl_security_cmd
,
8191 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8195 "BGP ttl-security parameters\n"
8196 "Specify the maximum number of hops to the BGP peer\n"
8197 "Number of hops to BGP peer\n")
8202 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8204 return CMD_WARNING_CONFIG_FAILED
;
8206 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8209 /* disable-addpath-rx */
8210 DEFUN(neighbor_disable_addpath_rx
,
8211 neighbor_disable_addpath_rx_cmd
,
8212 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8215 "Do not accept additional paths\n")
8217 char *peer_str
= argv
[1]->arg
;
8219 afi_t afi
= bgp_node_afi(vty
);
8220 safi_t safi
= bgp_node_safi(vty
);
8222 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8224 return CMD_WARNING_CONFIG_FAILED
;
8226 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8227 PEER_FLAG_DISABLE_ADDPATH_RX
);
8230 DEFUN(no_neighbor_disable_addpath_rx
,
8231 no_neighbor_disable_addpath_rx_cmd
,
8232 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8236 "Do not accept additional paths\n")
8238 char *peer_str
= argv
[2]->arg
;
8240 afi_t afi
= bgp_node_afi(vty
);
8241 safi_t safi
= bgp_node_safi(vty
);
8243 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8245 return CMD_WARNING_CONFIG_FAILED
;
8247 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8248 PEER_FLAG_DISABLE_ADDPATH_RX
);
8251 DEFUN (neighbor_addpath_tx_all_paths
,
8252 neighbor_addpath_tx_all_paths_cmd
,
8253 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8256 "Use addpath to advertise all paths to a neighbor\n")
8261 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8263 return CMD_WARNING_CONFIG_FAILED
;
8265 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8270 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8271 neighbor_addpath_tx_all_paths_hidden_cmd
,
8272 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8273 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8274 "Use addpath to advertise all paths to a neighbor\n")
8276 DEFUN (no_neighbor_addpath_tx_all_paths
,
8277 no_neighbor_addpath_tx_all_paths_cmd
,
8278 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8282 "Use addpath to advertise all paths to a neighbor\n")
8287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8289 return CMD_WARNING_CONFIG_FAILED
;
8291 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8292 != BGP_ADDPATH_ALL
) {
8294 "%% Peer not currently configured to transmit all paths.");
8295 return CMD_WARNING_CONFIG_FAILED
;
8298 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8304 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8305 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8306 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8308 "Use addpath to advertise all paths to a neighbor\n")
8310 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8311 neighbor_addpath_tx_bestpath_per_as_cmd
,
8312 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8315 "Use addpath to advertise the bestpath per each neighboring AS\n")
8320 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8322 return CMD_WARNING_CONFIG_FAILED
;
8324 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8325 BGP_ADDPATH_BEST_PER_AS
);
8330 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8331 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8332 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8333 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8334 "Use addpath to advertise the bestpath per each neighboring AS\n")
8336 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8337 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8338 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8342 "Use addpath to advertise the bestpath per each neighboring AS\n")
8347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8349 return CMD_WARNING_CONFIG_FAILED
;
8351 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8352 != BGP_ADDPATH_BEST_PER_AS
) {
8354 "%% Peer not currently configured to transmit all best path per as.");
8355 return CMD_WARNING_CONFIG_FAILED
;
8358 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8364 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8365 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8366 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8367 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8368 "Use addpath to advertise the bestpath per each neighboring AS\n")
8371 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8372 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8375 "Detect AS loops before sending to neighbor\n")
8379 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8381 return CMD_WARNING_CONFIG_FAILED
;
8383 peer
->as_path_loop_detection
= true;
8389 no_neighbor_aspath_loop_detection
,
8390 no_neighbor_aspath_loop_detection_cmd
,
8391 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8395 "Detect AS loops before sending to neighbor\n")
8399 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8401 return CMD_WARNING_CONFIG_FAILED
;
8403 peer
->as_path_loop_detection
= false;
8408 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8409 struct ecommunity
**list
, bool is_rt6
)
8411 struct ecommunity
*ecom
= NULL
;
8412 struct ecommunity
*ecomadd
;
8414 for (; argc
; --argc
, ++argv
) {
8416 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8417 ECOMMUNITY_ROUTE_TARGET
,
8420 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8421 ECOMMUNITY_ROUTE_TARGET
,
8424 vty_out(vty
, "Malformed community-list value\n");
8426 ecommunity_free(&ecom
);
8427 return CMD_WARNING_CONFIG_FAILED
;
8431 ecommunity_merge(ecom
, ecomadd
);
8432 ecommunity_free(&ecomadd
);
8439 ecommunity_free(&*list
);
8447 * v2vimport is true if we are handling a `import vrf ...` command
8449 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8453 switch (vty
->node
) {
8462 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8467 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8468 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8469 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8470 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8472 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8476 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8477 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8478 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8479 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8481 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8488 DEFPY (af_rd_vpn_export
,
8489 af_rd_vpn_export_cmd
,
8490 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8492 "Specify route distinguisher\n"
8493 "Between current address-family and vpn\n"
8494 "For routes leaked from current address-family to vpn\n"
8495 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8498 struct prefix_rd prd
;
8504 if (argv_find(argv
, argc
, "no", &idx
))
8508 ret
= str2prefix_rd(rd_str
, &prd
);
8510 vty_out(vty
, "%% Malformed rd\n");
8511 return CMD_WARNING_CONFIG_FAILED
;
8515 afi
= vpn_policy_getafi(vty
, bgp
, false);
8517 return CMD_WARNING_CONFIG_FAILED
;
8520 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8522 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8523 bgp_get_default(), bgp
);
8526 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8527 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8528 BGP_VPN_POLICY_TOVPN_RD_SET
);
8530 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8531 BGP_VPN_POLICY_TOVPN_RD_SET
);
8534 /* post-change: re-export vpn routes */
8535 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8536 bgp_get_default(), bgp
);
8541 ALIAS (af_rd_vpn_export
,
8542 af_no_rd_vpn_export_cmd
,
8545 "Specify route distinguisher\n"
8546 "Between current address-family and vpn\n"
8547 "For routes leaked from current address-family to vpn\n")
8549 DEFPY (af_label_vpn_export
,
8550 af_label_vpn_export_cmd
,
8551 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8553 "label value for VRF\n"
8554 "Between current address-family and vpn\n"
8555 "For routes leaked from current address-family to vpn\n"
8556 "Label Value <0-1048575>\n"
8557 "Automatically assign a label\n")
8559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8560 mpls_label_t label
= MPLS_LABEL_NONE
;
8565 if (argv_find(argv
, argc
, "no", &idx
))
8568 /* If "no ...", squash trailing parameter */
8574 label
= label_val
; /* parser should force unsigned */
8577 afi
= vpn_policy_getafi(vty
, bgp
, false);
8579 return CMD_WARNING_CONFIG_FAILED
;
8582 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8583 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8588 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8590 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8591 bgp_get_default(), bgp
);
8593 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8594 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8596 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8599 * label has previously been automatically
8600 * assigned by labelpool: release it
8602 * NB if tovpn_label == MPLS_LABEL_NONE it
8603 * means the automatic assignment is in flight
8604 * and therefore the labelpool callback must
8605 * detect that the auto label is not needed.
8608 bgp_lp_release(LP_TYPE_VRF
,
8609 &bgp
->vpn_policy
[afi
],
8610 bgp
->vpn_policy
[afi
].tovpn_label
);
8612 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8613 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8616 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8618 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8619 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8620 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8621 vpn_leak_label_callback
);
8624 /* post-change: re-export vpn routes */
8625 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8626 bgp_get_default(), bgp
);
8628 hook_call(bgp_snmp_update_last_changed
, bgp
);
8632 DEFPY (af_sid_vpn_export
,
8633 af_sid_vpn_export_cmd
,
8634 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8636 "sid value for VRF\n"
8637 "Between current address-family and vpn\n"
8638 "For routes leaked from current address-family to vpn\n"
8639 "Sid allocation index\n"
8640 "Automatically assign a label\n")
8642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8648 if (argv_find(argv
, argc
, "no", &idx
))
8650 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8651 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8653 afi
= vpn_policy_getafi(vty
, bgp
, false);
8655 return CMD_WARNING_CONFIG_FAILED
;
8659 vty_out(vty
, "It's not implemented\n");
8660 return CMD_WARNING_CONFIG_FAILED
;
8663 /* skip when it's already configured */
8664 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8665 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8666 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8670 * mode change between sid_idx and sid_auto isn't supported.
8671 * user must negate sid vpn export when they want to change the mode
8673 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8674 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8675 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8676 vty_out(vty
, "it's already configured as %s.\n",
8677 sid_auto
? "auto-mode" : "idx-mode");
8678 return CMD_WARNING_CONFIG_FAILED
;
8682 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8683 bgp_get_default(), bgp
);
8686 /* SID allocation auto-mode */
8688 zlog_debug("%s: auto sid alloc.", __func__
);
8689 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8690 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8692 /* SID allocation index-mode */
8694 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8695 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8699 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8700 bgp_get_default(), bgp
);
8704 ALIAS (af_label_vpn_export
,
8705 af_no_label_vpn_export_cmd
,
8706 "no label vpn export",
8708 "label value for VRF\n"
8709 "Between current address-family and vpn\n"
8710 "For routes leaked from current address-family to vpn\n")
8712 DEFPY (af_nexthop_vpn_export
,
8713 af_nexthop_vpn_export_cmd
,
8714 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8716 "Specify next hop to use for VRF advertised prefixes\n"
8717 "Between current address-family and vpn\n"
8718 "For routes leaked from current address-family to vpn\n"
8722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8728 vty_out(vty
, "%% Nexthop required\n");
8729 return CMD_WARNING_CONFIG_FAILED
;
8731 if (!sockunion2hostprefix(nexthop_su
, &p
))
8732 return CMD_WARNING_CONFIG_FAILED
;
8735 afi
= vpn_policy_getafi(vty
, bgp
, false);
8737 return CMD_WARNING_CONFIG_FAILED
;
8740 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8742 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8743 bgp_get_default(), bgp
);
8746 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8747 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8748 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8750 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8751 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8754 /* post-change: re-export vpn routes */
8755 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8756 bgp_get_default(), bgp
);
8761 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8763 if (!strcmp(dstr
, "import")) {
8764 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8765 } else if (!strcmp(dstr
, "export")) {
8766 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8767 } else if (!strcmp(dstr
, "both")) {
8768 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8769 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8771 vty_out(vty
, "%% direction parse error\n");
8772 return CMD_WARNING_CONFIG_FAILED
;
8777 DEFPY (af_rt_vpn_imexport
,
8778 af_rt_vpn_imexport_cmd
,
8779 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8781 "Specify route target list\n"
8782 "Specify route target list\n"
8783 "Between current address-family and vpn\n"
8784 "For routes leaked from vpn to current address-family: match any\n"
8785 "For routes leaked from current address-family to vpn: set\n"
8786 "both import: match any and export: set\n"
8787 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8791 struct ecommunity
*ecom
= NULL
;
8792 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8793 enum vpn_policy_direction dir
;
8798 if (argv_find(argv
, argc
, "no", &idx
))
8801 afi
= vpn_policy_getafi(vty
, bgp
, false);
8803 return CMD_WARNING_CONFIG_FAILED
;
8805 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8806 if (ret
!= CMD_SUCCESS
)
8810 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8811 vty_out(vty
, "%% Missing RTLIST\n");
8812 return CMD_WARNING_CONFIG_FAILED
;
8814 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8815 if (ret
!= CMD_SUCCESS
) {
8820 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8824 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8827 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8829 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8830 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8831 ecommunity_dup(ecom
);
8833 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8835 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8836 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8839 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8843 ecommunity_free(&ecom
);
8848 ALIAS (af_rt_vpn_imexport
,
8849 af_no_rt_vpn_imexport_cmd
,
8850 "no <rt|route-target> vpn <import|export|both>$direction_str",
8852 "Specify route target list\n"
8853 "Specify route target list\n"
8854 "Between current address-family and vpn\n"
8855 "For routes leaked from vpn to current address-family\n"
8856 "For routes leaked from current address-family to vpn\n"
8857 "both import and export\n")
8859 DEFPY (af_route_map_vpn_imexport
,
8860 af_route_map_vpn_imexport_cmd
,
8861 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8862 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8864 "Specify route map\n"
8865 "Between current address-family and vpn\n"
8866 "For routes leaked from vpn to current address-family\n"
8867 "For routes leaked from current address-family to vpn\n"
8868 "name of route-map\n")
8870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8872 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8873 enum vpn_policy_direction dir
;
8878 if (argv_find(argv
, argc
, "no", &idx
))
8881 afi
= vpn_policy_getafi(vty
, bgp
, false);
8883 return CMD_WARNING_CONFIG_FAILED
;
8885 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8886 if (ret
!= CMD_SUCCESS
)
8889 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8893 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8896 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8897 XFREE(MTYPE_ROUTE_MAP_NAME
,
8898 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8899 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
8900 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8901 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8902 route_map_lookup_warn_noexist(vty
, rmap_str
);
8903 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8906 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8907 XFREE(MTYPE_ROUTE_MAP_NAME
,
8908 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8909 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8910 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8913 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8919 ALIAS (af_route_map_vpn_imexport
,
8920 af_no_route_map_vpn_imexport_cmd
,
8921 "no route-map vpn <import|export>$direction_str",
8923 "Specify route map\n"
8924 "Between current address-family and vpn\n"
8925 "For routes leaked from vpn to current address-family\n"
8926 "For routes leaked from current address-family to vpn\n")
8928 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
8929 "import vrf route-map RMAP$rmap_str",
8930 "Import routes from another VRF\n"
8931 "Vrf routes being filtered\n"
8932 "Specify route map\n"
8933 "name of route-map\n")
8935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8936 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8938 struct bgp
*bgp_default
;
8940 afi
= vpn_policy_getafi(vty
, bgp
, true);
8942 return CMD_WARNING_CONFIG_FAILED
;
8944 bgp_default
= bgp_get_default();
8949 /* Auto-create assuming the same AS */
8950 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8951 BGP_INSTANCE_TYPE_DEFAULT
);
8955 "VRF default is not configured as a bgp instance\n");
8960 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8962 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8963 XFREE(MTYPE_ROUTE_MAP_NAME
,
8964 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8965 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
8966 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8967 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8968 route_map_lookup_warn_noexist(vty
, rmap_str
);
8969 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8972 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8973 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8975 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8980 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
8981 "no import vrf route-map [RMAP$rmap_str]",
8983 "Import routes from another VRF\n"
8984 "Vrf routes being filtered\n"
8985 "Specify route map\n"
8986 "name of route-map\n")
8988 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8989 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8992 afi
= vpn_policy_getafi(vty
, bgp
, true);
8994 return CMD_WARNING_CONFIG_FAILED
;
8996 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8998 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8999 XFREE(MTYPE_ROUTE_MAP_NAME
,
9000 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9001 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9002 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9004 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9005 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9006 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9008 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9013 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9014 "[no] import vrf VIEWVRFNAME$import_name",
9016 "Import routes from another VRF\n"
9017 "VRF to import from\n"
9018 "The name of the VRF\n")
9020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9021 struct listnode
*node
;
9022 struct bgp
*vrf_bgp
, *bgp_default
;
9025 bool remove
= false;
9028 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9032 if (import_name
== NULL
) {
9033 vty_out(vty
, "%% Missing import name\n");
9037 if (strcmp(import_name
, "route-map") == 0) {
9038 vty_out(vty
, "%% Must include route-map name\n");
9042 if (argv_find(argv
, argc
, "no", &idx
))
9045 afi
= vpn_policy_getafi(vty
, bgp
, true);
9047 return CMD_WARNING_CONFIG_FAILED
;
9049 safi
= bgp_node_safi(vty
);
9051 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9052 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9053 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9054 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9055 remove
? "unimport" : "import", import_name
);
9059 bgp_default
= bgp_get_default();
9061 /* Auto-create assuming the same AS */
9062 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9063 BGP_INSTANCE_TYPE_DEFAULT
);
9067 "VRF default is not configured as a bgp instance\n");
9072 vrf_bgp
= bgp_lookup_by_name(import_name
);
9074 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9075 vrf_bgp
= bgp_default
;
9077 /* Auto-create assuming the same AS */
9078 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9082 "VRF %s is not configured as a bgp instance\n",
9089 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9091 /* Already importing from "import_vrf"? */
9092 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9094 if (strcmp(vname
, import_name
) == 0)
9098 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9104 /* This command is valid only in a bgp vrf instance or the default instance */
9105 DEFPY (bgp_imexport_vpn
,
9106 bgp_imexport_vpn_cmd
,
9107 "[no] <import|export>$direction_str vpn",
9109 "Import routes to this address-family\n"
9110 "Export routes from this address-family\n"
9111 "to/from default instance VPN RIB\n")
9113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9120 enum vpn_policy_direction dir
;
9122 if (argv_find(argv
, argc
, "no", &idx
))
9125 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9126 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9128 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9129 return CMD_WARNING_CONFIG_FAILED
;
9132 afi
= bgp_node_afi(vty
);
9133 safi
= bgp_node_safi(vty
);
9134 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9135 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9136 return CMD_WARNING_CONFIG_FAILED
;
9139 if (!strcmp(direction_str
, "import")) {
9140 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9141 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9142 } else if (!strcmp(direction_str
, "export")) {
9143 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9144 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9146 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9147 return CMD_WARNING_CONFIG_FAILED
;
9150 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9153 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9154 if (!previous_state
) {
9155 /* trigger export current vrf */
9156 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9159 if (previous_state
) {
9160 /* trigger un-export current vrf */
9161 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9163 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9166 hook_call(bgp_snmp_init_stats
, bgp
);
9171 DEFPY (af_routetarget_import
,
9172 af_routetarget_import_cmd
,
9173 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9175 "Specify route target list\n"
9176 "Specify route target list\n"
9177 "Specify route target list\n"
9178 "Specify route target list\n"
9179 "Flow-spec redirect type route target\n"
9180 "Import routes to this address-family\n"
9181 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9185 struct ecommunity
*ecom
= NULL
;
9187 int idx
= 0, idx_unused
= 0;
9191 if (argv_find(argv
, argc
, "no", &idx
))
9194 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9195 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9198 afi
= vpn_policy_getafi(vty
, bgp
, false);
9200 return CMD_WARNING_CONFIG_FAILED
;
9202 if (rt6
&& afi
!= AFI_IP6
)
9203 return CMD_WARNING_CONFIG_FAILED
;
9206 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9207 vty_out(vty
, "%% Missing RTLIST\n");
9208 return CMD_WARNING_CONFIG_FAILED
;
9210 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9211 if (ret
!= CMD_SUCCESS
)
9216 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9217 ecommunity_free(&bgp
->vpn_policy
[afi
]
9218 .import_redirect_rtlist
);
9219 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9220 ecommunity_dup(ecom
);
9222 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9223 ecommunity_free(&bgp
->vpn_policy
[afi
]
9224 .import_redirect_rtlist
);
9225 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9229 ecommunity_free(&ecom
);
9234 DEFUN_NOSH (address_family_ipv4_safi
,
9235 address_family_ipv4_safi_cmd
,
9236 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9237 "Enter Address Family command mode\n"
9239 BGP_SAFI_WITH_LABEL_HELP_STR
)
9243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9244 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9245 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9246 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9247 && safi
!= SAFI_EVPN
) {
9249 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9250 return CMD_WARNING_CONFIG_FAILED
;
9252 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9254 vty
->node
= BGP_IPV4_NODE
;
9259 DEFUN_NOSH (address_family_ipv6_safi
,
9260 address_family_ipv6_safi_cmd
,
9261 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9262 "Enter Address Family command mode\n"
9264 BGP_SAFI_WITH_LABEL_HELP_STR
)
9267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9268 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9269 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9270 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9271 && safi
!= SAFI_EVPN
) {
9273 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9274 return CMD_WARNING_CONFIG_FAILED
;
9276 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9278 vty
->node
= BGP_IPV6_NODE
;
9283 #ifdef KEEP_OLD_VPN_COMMANDS
9284 DEFUN_NOSH (address_family_vpnv4
,
9285 address_family_vpnv4_cmd
,
9286 "address-family vpnv4 [unicast]",
9287 "Enter Address Family command mode\n"
9289 "Address Family modifier\n")
9291 vty
->node
= BGP_VPNV4_NODE
;
9295 DEFUN_NOSH (address_family_vpnv6
,
9296 address_family_vpnv6_cmd
,
9297 "address-family vpnv6 [unicast]",
9298 "Enter Address Family command mode\n"
9300 "Address Family modifier\n")
9302 vty
->node
= BGP_VPNV6_NODE
;
9305 #endif /* KEEP_OLD_VPN_COMMANDS */
9307 DEFUN_NOSH (address_family_evpn
,
9308 address_family_evpn_cmd
,
9309 "address-family l2vpn evpn",
9310 "Enter Address Family command mode\n"
9312 "Address Family modifier\n")
9314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9315 vty
->node
= BGP_EVPN_NODE
;
9319 DEFUN_NOSH (bgp_segment_routing_srv6
,
9320 bgp_segment_routing_srv6_cmd
,
9321 "segment-routing srv6",
9322 "Segment-Routing configuration\n"
9323 "Segment-Routing SRv6 configuration\n")
9325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9326 bgp
->srv6_enabled
= true;
9327 vty
->node
= BGP_SRV6_NODE
;
9331 DEFUN (no_bgp_segment_routing_srv6
,
9332 no_bgp_segment_routing_srv6_cmd
,
9333 "no segment-routing srv6",
9335 "Segment-Routing configuration\n"
9336 "Segment-Routing SRv6 configuration\n")
9338 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9340 if (strlen(bgp
->srv6_locator_name
) > 0)
9341 if (bgp_srv6_locator_unset(bgp
) < 0)
9342 return CMD_WARNING_CONFIG_FAILED
;
9344 bgp
->srv6_enabled
= false;
9348 DEFPY (bgp_srv6_locator
,
9349 bgp_srv6_locator_cmd
,
9350 "locator NAME$name",
9351 "Specify SRv6 locator\n"
9352 "Specify SRv6 locator\n")
9354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9357 if (strlen(bgp
->srv6_locator_name
) > 0
9358 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9359 vty_out(vty
, "srv6 locator is already configured\n");
9360 return CMD_WARNING_CONFIG_FAILED
;
9363 snprintf(bgp
->srv6_locator_name
,
9364 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9366 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9368 return CMD_WARNING_CONFIG_FAILED
;
9373 DEFPY (no_bgp_srv6_locator
,
9374 no_bgp_srv6_locator_cmd
,
9375 "no locator NAME$name",
9377 "Specify SRv6 locator\n"
9378 "Specify SRv6 locator\n")
9380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9382 /* when locator isn't configured, do nothing */
9383 if (strlen(bgp
->srv6_locator_name
) < 1)
9386 /* name validation */
9387 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9388 vty_out(vty
, "%% No srv6 locator is configured\n");
9389 return CMD_WARNING_CONFIG_FAILED
;
9393 if (bgp_srv6_locator_unset(bgp
) < 0)
9394 return CMD_WARNING_CONFIG_FAILED
;
9399 DEFPY (show_bgp_srv6
,
9401 "show bgp segment-routing srv6",
9404 "BGP Segment Routing\n"
9405 "BGP Segment Routing SRv6\n")
9408 struct listnode
*node
;
9409 struct srv6_locator_chunk
*chunk
;
9410 struct bgp_srv6_function
*func
;
9411 struct in6_addr
*tovpn4_sid
;
9412 struct in6_addr
*tovpn6_sid
;
9414 char buf_tovpn4_sid
[256];
9415 char buf_tovpn6_sid
[256];
9417 bgp
= bgp_get_default();
9421 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9422 vty_out(vty
, "locator_chunks:\n");
9423 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9424 prefix2str(&chunk
->prefix
, buf
, sizeof(buf
));
9425 vty_out(vty
, "- %s\n", buf
);
9428 vty_out(vty
, "functions:\n");
9429 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9430 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9431 vty_out(vty
, "- sid: %s\n", buf
);
9432 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9435 vty_out(vty
, "bgps:\n");
9436 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9437 vty_out(vty
, "- name: %s\n",
9438 bgp
->name
? bgp
->name
: "default");
9440 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9441 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9443 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9444 sizeof(buf_tovpn4_sid
));
9446 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9447 sizeof(buf_tovpn6_sid
));
9449 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9450 tovpn4_sid
? buf_tovpn4_sid
: "none");
9451 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9452 tovpn6_sid
? buf_tovpn6_sid
: "none");
9458 DEFUN_NOSH (exit_address_family
,
9459 exit_address_family_cmd
,
9460 "exit-address-family",
9461 "Exit from Address Family configuration mode\n")
9463 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9464 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9465 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9466 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9467 || vty
->node
== BGP_EVPN_NODE
9468 || vty
->node
== BGP_FLOWSPECV4_NODE
9469 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9470 vty
->node
= BGP_NODE
;
9474 /* Recalculate bestpath and re-advertise a prefix */
9475 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9476 const char *ip_str
, afi_t afi
, safi_t safi
,
9477 struct prefix_rd
*prd
)
9480 struct prefix match
;
9481 struct bgp_dest
*dest
;
9482 struct bgp_dest
*rm
;
9484 struct bgp_table
*table
;
9485 struct bgp_table
*rib
;
9487 /* BGP structure lookup. */
9489 bgp
= bgp_lookup_by_name(view_name
);
9491 vty_out(vty
, "%% Can't find BGP instance %s\n",
9496 bgp
= bgp_get_default();
9498 vty_out(vty
, "%% No BGP process is configured\n");
9503 /* Check IP address argument. */
9504 ret
= str2prefix(ip_str
, &match
);
9506 vty_out(vty
, "%% address is malformed\n");
9510 match
.family
= afi2family(afi
);
9511 rib
= bgp
->rib
[afi
][safi
];
9513 if (safi
== SAFI_MPLS_VPN
) {
9514 for (dest
= bgp_table_top(rib
); dest
;
9515 dest
= bgp_route_next(dest
)) {
9516 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9518 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9521 table
= bgp_dest_get_bgp_table_info(dest
);
9525 rm
= bgp_node_match(table
, &match
);
9527 const struct prefix
*rm_p
=
9528 bgp_dest_get_prefix(rm
);
9530 if (rm_p
->prefixlen
== match
.prefixlen
) {
9532 BGP_NODE_USER_CLEAR
);
9533 bgp_process(bgp
, rm
, afi
, safi
);
9535 bgp_dest_unlock_node(rm
);
9539 dest
= bgp_node_match(rib
, &match
);
9541 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9543 if (dest_p
->prefixlen
== match
.prefixlen
) {
9544 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9545 bgp_process(bgp
, dest
, afi
, safi
);
9547 bgp_dest_unlock_node(dest
);
9554 /* one clear bgp command to rule them all */
9555 DEFUN (clear_ip_bgp_all
,
9556 clear_ip_bgp_all_cmd
,
9557 "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>]",
9561 BGP_INSTANCE_HELP_STR
9564 BGP_SAFI_WITH_LABEL_HELP_STR
9565 "Address Family modifier\n"
9567 "BGP IPv4 neighbor to clear\n"
9568 "BGP IPv6 neighbor to clear\n"
9569 "BGP neighbor on interface to clear\n"
9570 "Clear peers with the AS number\n"
9571 "Clear all external peers\n"
9572 "Clear all members of peer-group\n"
9573 "BGP peer-group name\n"
9578 "Push out prefix-list ORF and do inbound soft reconfig\n"
9580 "Reset message statistics\n")
9584 afi_t afi
= AFI_UNSPEC
;
9585 safi_t safi
= SAFI_UNSPEC
;
9586 enum clear_sort clr_sort
= clear_peer
;
9587 enum bgp_clear_type clr_type
;
9588 char *clr_arg
= NULL
;
9592 /* clear [ip] bgp */
9593 if (argv_find(argv
, argc
, "ip", &idx
))
9596 /* [<vrf> VIEWVRFNAME] */
9597 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9598 vrf
= argv
[idx
+ 1]->arg
;
9600 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9602 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9603 /* [<view> VIEWVRFNAME] */
9604 vrf
= argv
[idx
+ 1]->arg
;
9607 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9608 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9609 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9611 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9612 if (argv_find(argv
, argc
, "*", &idx
)) {
9613 clr_sort
= clear_all
;
9614 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9615 clr_sort
= clear_peer
;
9616 clr_arg
= argv
[idx
]->arg
;
9617 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9618 clr_sort
= clear_peer
;
9619 clr_arg
= argv
[idx
]->arg
;
9620 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9621 clr_sort
= clear_group
;
9623 clr_arg
= argv
[idx
]->arg
;
9624 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9625 clr_sort
= clear_peer
;
9626 clr_arg
= argv
[idx
]->arg
;
9627 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9628 clr_sort
= clear_peer
;
9629 clr_arg
= argv
[idx
]->arg
;
9630 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9631 clr_sort
= clear_as
;
9632 clr_arg
= argv
[idx
]->arg
;
9633 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9634 clr_sort
= clear_external
;
9637 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9638 if (argv_find(argv
, argc
, "soft", &idx
)) {
9639 if (argv_find(argv
, argc
, "in", &idx
)
9640 || argv_find(argv
, argc
, "out", &idx
))
9641 clr_type
= strmatch(argv
[idx
]->text
, "in")
9643 : BGP_CLEAR_SOFT_OUT
;
9645 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9646 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9647 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9648 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9649 : BGP_CLEAR_SOFT_IN
;
9650 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9651 clr_type
= BGP_CLEAR_SOFT_OUT
;
9652 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9653 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9655 clr_type
= BGP_CLEAR_SOFT_NONE
;
9657 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9660 DEFUN (clear_ip_bgp_prefix
,
9661 clear_ip_bgp_prefix_cmd
,
9662 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9666 BGP_INSTANCE_HELP_STR
9667 "Clear bestpath and re-advertise\n"
9671 char *prefix
= NULL
;
9675 /* [<view|vrf> VIEWVRFNAME] */
9676 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9677 vrf
= argv
[idx
+ 1]->arg
;
9679 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9681 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9682 /* [<view> VIEWVRFNAME] */
9683 vrf
= argv
[idx
+ 1]->arg
;
9687 prefix
= argv
[argc
- 1]->arg
;
9689 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9692 DEFUN (clear_bgp_ipv6_safi_prefix
,
9693 clear_bgp_ipv6_safi_prefix_cmd
,
9694 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9700 "Clear bestpath and re-advertise\n"
9704 int idx_ipv6_prefix
= 0;
9705 safi_t safi
= SAFI_UNICAST
;
9706 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9707 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9709 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9710 return bgp_clear_prefix(
9711 vty
, NULL
, prefix
, AFI_IP6
,
9715 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9716 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9717 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9721 BGP_INSTANCE_HELP_STR
9724 "Clear bestpath and re-advertise\n"
9728 int idx_vrfview
= 0;
9729 int idx_ipv6_prefix
= 0;
9730 safi_t safi
= SAFI_UNICAST
;
9731 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9732 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9733 char *vrfview
= NULL
;
9735 /* [<view|vrf> VIEWVRFNAME] */
9736 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9737 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9738 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9740 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9741 /* [<view> VIEWVRFNAME] */
9742 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9744 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9746 return bgp_clear_prefix(
9747 vty
, vrfview
, prefix
,
9748 AFI_IP6
, safi
, NULL
);
9751 DEFUN (show_bgp_views
,
9753 "show [ip] bgp views",
9757 "Show the defined BGP views\n")
9759 struct list
*inst
= bm
->bgp
;
9760 struct listnode
*node
;
9763 vty_out(vty
, "Defined BGP views:\n");
9764 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9766 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9768 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9775 DEFUN (show_bgp_vrfs
,
9777 "show [ip] bgp vrfs [json]",
9784 char buf
[ETHER_ADDR_STRLEN
];
9785 struct list
*inst
= bm
->bgp
;
9786 struct listnode
*node
;
9788 bool uj
= use_json(argc
, argv
);
9789 json_object
*json
= NULL
;
9790 json_object
*json_vrfs
= NULL
;
9794 json
= json_object_new_object();
9795 json_vrfs
= json_object_new_object();
9798 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9799 const char *name
, *type
;
9801 struct listnode
*node2
, *nnode2
;
9802 int peers_cfg
, peers_estb
;
9803 json_object
*json_vrf
= NULL
;
9806 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9810 if (!uj
&& count
== 1) {
9812 "%4s %-5s %-16s %9s %10s %-37s\n",
9813 "Type", "Id", "routerId", "#PeersCfg",
9814 "#PeersEstb", "Name");
9815 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9816 "L3-VNI", "RouterMAC", "Interface");
9819 peers_cfg
= peers_estb
= 0;
9821 json_vrf
= json_object_new_object();
9824 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9825 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9828 if (peer_established(peer
))
9832 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9833 name
= VRF_DEFAULT_NAME
;
9842 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9844 : (int64_t)bgp
->vrf_id
;
9845 char buf
[BUFSIZ
] = {0};
9847 json_object_string_add(json_vrf
, "type", type
);
9848 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9849 json_object_string_addf(json_vrf
, "routerId", "%pI4",
9851 json_object_int_add(json_vrf
, "numConfiguredPeers",
9853 json_object_int_add(json_vrf
, "numEstablishedPeers",
9856 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9857 json_object_string_add(
9859 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9860 json_object_string_add(json_vrf
, "interface",
9861 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9863 json_object_object_add(json_vrfs
, name
, json_vrf
);
9865 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
9867 bgp
->vrf_id
== VRF_UNKNOWN
? -1
9869 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
9870 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
9872 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
9873 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9879 json_object_object_add(json
, "vrfs", json_vrfs
);
9881 json_object_int_add(json
, "totalVrfs", count
);
9883 vty_json(vty
, json
);
9887 "\nTotal number of VRFs (including default): %d\n",
9894 DEFUN (show_bgp_mac_hash
,
9895 show_bgp_mac_hash_cmd
,
9896 "show bgp mac hash",
9900 "Mac Address database\n")
9902 bgp_mac_dump_table(vty
);
9907 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
9909 struct vty
*vty
= (struct vty
*)args
;
9910 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
9912 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
9915 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
9917 vty_out(vty
, "self nexthop database:\n");
9918 bgp_nexthop_show_address_hash(vty
, bgp
);
9920 vty_out(vty
, "Tunnel-ip database:\n");
9921 hash_iterate(bgp
->tip_hash
,
9922 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
9926 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
9927 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
9928 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
9929 "martian next-hops\n"
9930 "martian next-hop database\n")
9932 struct bgp
*bgp
= NULL
;
9936 /* [<vrf> VIEWVRFNAME] */
9937 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9938 name
= argv
[idx
+ 1]->arg
;
9939 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
9941 } else if (argv_find(argv
, argc
, "view", &idx
))
9942 /* [<view> VIEWVRFNAME] */
9943 name
= argv
[idx
+ 1]->arg
;
9945 bgp
= bgp_lookup_by_name(name
);
9947 bgp
= bgp_get_default();
9950 vty_out(vty
, "%% No BGP process is configured\n");
9953 bgp_show_martian_nexthops(vty
, bgp
);
9958 DEFUN (show_bgp_memory
,
9959 show_bgp_memory_cmd
,
9960 "show [ip] bgp memory",
9964 "Global BGP memory statistics\n")
9966 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9967 unsigned long count
;
9969 /* RIB related usage stats */
9970 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
9971 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
9972 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9973 count
* sizeof(struct bgp_dest
)));
9975 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
9976 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
9977 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9978 count
* sizeof(struct bgp_path_info
)));
9979 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
9980 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
9983 memstrbuf
, sizeof(memstrbuf
),
9984 count
* sizeof(struct bgp_path_info_extra
)));
9986 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
9987 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
9988 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9989 count
* sizeof(struct bgp_static
)));
9991 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
9992 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
9993 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9994 count
* sizeof(struct bpacket
)));
9997 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
9998 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
9999 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10000 count
* sizeof(struct bgp_adj_in
)));
10001 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10002 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10003 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10004 count
* sizeof(struct bgp_adj_out
)));
10006 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10007 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10009 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10010 count
* sizeof(struct bgp_nexthop_cache
)));
10012 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10013 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10015 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10016 count
* sizeof(struct bgp_damp_info
)));
10019 count
= attr_count();
10020 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10021 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10022 count
* sizeof(struct attr
)));
10024 if ((count
= attr_unknown_count()))
10025 vty_out(vty
, "%ld unknown attributes\n", count
);
10027 /* AS_PATH attributes */
10028 count
= aspath_count();
10029 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10030 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10031 count
* sizeof(struct aspath
)));
10033 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10034 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10035 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10036 count
* sizeof(struct assegment
)));
10038 /* Other attributes */
10039 if ((count
= community_count()))
10040 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10041 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10042 count
* sizeof(struct community
)));
10043 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10044 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10045 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10046 count
* sizeof(struct ecommunity
)));
10047 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10049 "%ld BGP large-community entries, using %s of memory\n",
10050 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10051 count
* sizeof(struct lcommunity
)));
10053 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10054 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10055 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10056 count
* sizeof(struct cluster_list
)));
10058 /* Peer related usage */
10059 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10060 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10061 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10062 count
* sizeof(struct peer
)));
10064 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10065 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10066 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10067 count
* sizeof(struct peer_group
)));
10070 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10071 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10072 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10073 count
* sizeof(regex_t
)));
10074 return CMD_SUCCESS
;
10077 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10079 json_object
*bestpath
= json_object_new_object();
10081 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10082 json_object_string_add(bestpath
, "asPath", "ignore");
10084 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10085 json_object_string_add(bestpath
, "asPath", "confed");
10087 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10088 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10089 json_object_string_add(bestpath
, "multiPathRelax",
10092 json_object_string_add(bestpath
, "multiPathRelax",
10095 json_object_string_add(bestpath
, "multiPathRelax", "false");
10097 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10098 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10100 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10101 json_object_string_add(bestpath
, "compareRouterId", "true");
10102 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10103 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10104 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10105 json_object_string_add(bestpath
, "med", "confed");
10106 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10107 json_object_string_add(bestpath
, "med",
10108 "missing-as-worst");
10110 json_object_string_add(bestpath
, "med", "true");
10113 json_object_object_add(json
, "bestPath", bestpath
);
10116 /* Print the error code/subcode for why the peer is down */
10117 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10118 json_object
*json_peer
, bool use_json
)
10120 const char *code_str
;
10121 const char *subcode_str
;
10124 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10125 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10126 char errorcodesubcode_hexstr
[5];
10127 char errorcodesubcode_str
[256];
10129 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10130 subcode_str
= bgp_notify_subcode_str(
10132 peer
->notify
.subcode
);
10134 snprintf(errorcodesubcode_hexstr
,
10135 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10136 peer
->notify
.code
, peer
->notify
.subcode
);
10137 json_object_string_add(json_peer
,
10138 "lastErrorCodeSubcode",
10139 errorcodesubcode_hexstr
);
10140 snprintf(errorcodesubcode_str
, 255, "%s%s",
10141 code_str
, subcode_str
);
10142 json_object_string_add(json_peer
,
10143 "lastNotificationReason",
10144 errorcodesubcode_str
);
10145 json_object_boolean_add(json_peer
,
10146 "lastNotificationHardReset",
10147 peer
->notify
.hard_reset
);
10148 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10149 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10150 && (peer
->notify
.subcode
10151 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10152 || peer
->notify
.subcode
10153 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10154 && peer
->notify
.length
) {
10156 const char *msg_str
;
10158 msg_str
= bgp_notify_admin_message(
10159 msgbuf
, sizeof(msgbuf
),
10160 (uint8_t *)peer
->notify
.data
,
10161 peer
->notify
.length
);
10163 json_object_string_add(
10165 "lastShutdownDescription",
10170 json_object_string_add(json_peer
, "lastResetDueTo",
10171 peer_down_str
[(int)peer
->last_reset
]);
10172 json_object_int_add(json_peer
, "lastResetCode",
10175 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10176 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10177 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10179 bgp_notify_subcode_str(peer
->notify
.code
,
10180 peer
->notify
.subcode
);
10181 vty_out(vty
, " Notification %s (%s%s%s)\n",
10182 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10185 code_str
, subcode_str
,
10186 peer
->notify
.hard_reset
10187 ? bgp_notify_subcode_str(
10189 BGP_NOTIFY_CEASE_HARD_RESET
)
10192 vty_out(vty
, " %s\n",
10193 peer_down_str
[(int)peer
->last_reset
]);
10198 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10201 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10204 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10205 struct peer
*peer
, json_object
*json_peer
,
10206 int max_neighbor_width
, bool use_json
)
10208 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10212 if (peer_dynamic_neighbor(peer
))
10213 json_object_boolean_true_add(json_peer
,
10215 if (peer
->hostname
)
10216 json_object_string_add(json_peer
, "hostname",
10219 if (peer
->domainname
)
10220 json_object_string_add(json_peer
, "domainname",
10222 json_object_int_add(json_peer
, "connectionsEstablished",
10223 peer
->established
);
10224 json_object_int_add(json_peer
, "connectionsDropped",
10226 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10227 use_json
, json_peer
);
10228 if (peer_established(peer
))
10229 json_object_string_add(json_peer
, "lastResetDueTo",
10230 "AFI/SAFI Not Negotiated");
10232 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10235 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10237 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10238 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10239 peer
->hostname
, peer
->host
);
10241 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10243 /* pad the neighbor column with spaces */
10244 if (len
< max_neighbor_width
)
10245 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10247 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10249 peer_uptime(peer
->uptime
, timebuf
,
10250 BGP_UPTIME_LEN
, 0, NULL
));
10251 if (peer_established(peer
))
10252 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10254 bgp_show_peer_reset(vty
, peer
, NULL
,
10259 /* Strip peer's description to the given size. */
10260 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10262 static char stripped
[BUFSIZ
];
10263 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10265 strlcpy(stripped
, desc
, len
+ 1);
10270 /* Determine whether var peer should be filtered out of the summary. */
10271 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10272 struct peer
*fpeer
, int as_type
,
10276 /* filter neighbor XXXX */
10277 if (fpeer
&& fpeer
!= peer
)
10280 /* filter remote-as (internal|external) */
10281 if (as_type
!= AS_UNSPECIFIED
) {
10282 if (peer
->as_type
== AS_SPECIFIED
) {
10283 if (as_type
== AS_INTERNAL
) {
10284 if (peer
->as
!= peer
->local_as
)
10286 } else if (peer
->as
== peer
->local_as
)
10288 } else if (as_type
!= peer
->as_type
)
10290 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10296 /* Show BGP peer's summary information.
10298 * Peer's description is stripped according to if `wide` option is given
10301 * When adding new columns to `show bgp summary` output, please make
10302 * sure `Desc` is the lastest column to show because it can contain
10303 * whitespaces and the whole output will be tricky.
10305 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10306 struct peer
*fpeer
, int as_type
, as_t as
,
10307 uint16_t show_flags
)
10310 struct listnode
*node
, *nnode
;
10311 unsigned int count
= 0, dn_count
= 0;
10312 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10313 char neighbor_buf
[VTY_BUFSIZ
];
10314 int neighbor_col_default_width
= 16;
10315 int len
, failed_count
= 0;
10316 unsigned int filtered_count
= 0;
10317 int max_neighbor_width
= 0;
10319 json_object
*json
= NULL
;
10320 json_object
*json_peer
= NULL
;
10321 json_object
*json_peers
= NULL
;
10322 struct peer_af
*paf
;
10323 struct bgp_filter
*filter
;
10324 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10325 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10326 bool show_established
=
10327 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10328 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10329 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10331 /* labeled-unicast routes are installed in the unicast table so in order
10333 * display the correct PfxRcd value we must look at SAFI_UNICAST
10336 if (safi
== SAFI_LABELED_UNICAST
)
10337 pfx_rcd_safi
= SAFI_UNICAST
;
10339 pfx_rcd_safi
= safi
;
10342 json
= json_object_new_object();
10343 json_peers
= json_object_new_object();
10344 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10345 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10352 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10355 if (peer
->afc
[afi
][safi
]) {
10356 /* See if we have at least a single failed peer */
10357 if (bgp_has_peer_failed(peer
, afi
, safi
))
10361 if (peer_dynamic_neighbor(peer
))
10366 /* Loop over all neighbors that will be displayed to determine
10368 * characters are needed for the Neighbor column
10370 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10371 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10378 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10381 if (peer
->afc
[afi
][safi
]) {
10382 memset(dn_flag
, '\0', sizeof(dn_flag
));
10383 if (peer_dynamic_neighbor(peer
))
10387 && CHECK_FLAG(bgp
->flags
,
10388 BGP_FLAG_SHOW_HOSTNAME
))
10389 snprintf(neighbor_buf
,
10390 sizeof(neighbor_buf
),
10391 "%s%s(%s) ", dn_flag
,
10392 peer
->hostname
, peer
->host
);
10394 snprintf(neighbor_buf
,
10395 sizeof(neighbor_buf
), "%s%s ",
10396 dn_flag
, peer
->host
);
10398 len
= strlen(neighbor_buf
);
10400 if (len
> max_neighbor_width
)
10401 max_neighbor_width
= len
;
10403 /* See if we have at least a single failed peer */
10404 if (bgp_has_peer_failed(peer
, afi
, safi
))
10410 /* Originally we displayed the Neighbor column as 16
10411 * characters wide so make that the default
10413 if (max_neighbor_width
< neighbor_col_default_width
)
10414 max_neighbor_width
= neighbor_col_default_width
;
10417 if (show_failed
&& !failed_count
) {
10419 json_object_int_add(json
, "failedPeersCount", 0);
10420 json_object_int_add(json
, "dynamicPeers", dn_count
);
10421 json_object_int_add(json
, "totalPeers", count
);
10423 vty_json(vty
, json
);
10425 vty_out(vty
, "%% No failed BGP neighbors found\n");
10427 return CMD_SUCCESS
;
10430 count
= 0; /* Reset the value as its used again */
10431 filtered_count
= 0;
10433 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10434 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10437 if (!peer
->afc
[afi
][safi
])
10441 unsigned long ents
;
10442 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10445 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10447 : (int64_t)bgp
->vrf_id
;
10449 /* Usage summary and header */
10451 json_object_string_addf(json
, "routerId",
10454 json_object_int_add(json
, "as", bgp
->as
);
10455 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10456 json_object_string_add(
10459 == BGP_INSTANCE_TYPE_DEFAULT
)
10464 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10465 &bgp
->router_id
, bgp
->as
,
10466 bgp
->vrf_id
== VRF_UNKNOWN
10468 : (int)bgp
->vrf_id
);
10469 vty_out(vty
, "\n");
10472 if (bgp_update_delay_configured(bgp
)) {
10474 json_object_int_add(
10475 json
, "updateDelayLimit",
10476 bgp
->v_update_delay
);
10478 if (bgp
->v_update_delay
10479 != bgp
->v_establish_wait
)
10480 json_object_int_add(
10482 "updateDelayEstablishWait",
10483 bgp
->v_establish_wait
);
10485 if (bgp_update_delay_active(bgp
)) {
10486 json_object_string_add(
10488 "updateDelayFirstNeighbor",
10489 bgp
->update_delay_begin_time
);
10490 json_object_boolean_true_add(
10492 "updateDelayInProgress");
10494 if (bgp
->update_delay_over
) {
10495 json_object_string_add(
10497 "updateDelayFirstNeighbor",
10498 bgp
->update_delay_begin_time
);
10499 json_object_string_add(
10501 "updateDelayBestpathResumed",
10502 bgp
->update_delay_end_time
);
10503 json_object_string_add(
10505 "updateDelayZebraUpdateResume",
10506 bgp
->update_delay_zebra_resume_time
);
10507 json_object_string_add(
10509 "updateDelayPeerUpdateResume",
10510 bgp
->update_delay_peers_resume_time
);
10515 "Read-only mode update-delay limit: %d seconds\n",
10516 bgp
->v_update_delay
);
10517 if (bgp
->v_update_delay
10518 != bgp
->v_establish_wait
)
10520 " Establish wait: %d seconds\n",
10521 bgp
->v_establish_wait
);
10523 if (bgp_update_delay_active(bgp
)) {
10525 " First neighbor established: %s\n",
10526 bgp
->update_delay_begin_time
);
10528 " Delay in progress\n");
10530 if (bgp
->update_delay_over
) {
10532 " First neighbor established: %s\n",
10533 bgp
->update_delay_begin_time
);
10535 " Best-paths resumed: %s\n",
10536 bgp
->update_delay_end_time
);
10538 " zebra update resumed: %s\n",
10539 bgp
->update_delay_zebra_resume_time
);
10541 " peers update resumed: %s\n",
10542 bgp
->update_delay_peers_resume_time
);
10549 if (bgp_maxmed_onstartup_configured(bgp
)
10550 && bgp
->maxmed_active
)
10551 json_object_boolean_true_add(
10552 json
, "maxMedOnStartup");
10553 if (bgp
->v_maxmed_admin
)
10554 json_object_boolean_true_add(
10555 json
, "maxMedAdministrative");
10557 json_object_int_add(
10558 json
, "tableVersion",
10559 bgp_table_version(bgp
->rib
[afi
][safi
]));
10561 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10562 json_object_int_add(json
, "ribCount", ents
);
10563 json_object_int_add(
10565 ents
* sizeof(struct bgp_dest
));
10567 ents
= bgp
->af_peer_count
[afi
][safi
];
10568 json_object_int_add(json
, "peerCount", ents
);
10569 json_object_int_add(json
, "peerMemory",
10570 ents
* sizeof(struct peer
));
10572 if ((ents
= listcount(bgp
->group
))) {
10573 json_object_int_add(
10574 json
, "peerGroupCount", ents
);
10575 json_object_int_add(
10576 json
, "peerGroupMemory",
10577 ents
* sizeof(struct
10581 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10582 BGP_CONFIG_DAMPENING
))
10583 json_object_boolean_true_add(
10584 json
, "dampeningEnabled");
10587 if (bgp_maxmed_onstartup_configured(bgp
)
10588 && bgp
->maxmed_active
)
10590 "Max-med on-startup active\n");
10591 if (bgp
->v_maxmed_admin
)
10593 "Max-med administrative active\n");
10596 "BGP table version %" PRIu64
10599 bgp
->rib
[afi
][safi
]));
10601 ents
= bgp_table_count(
10602 bgp
->rib
[afi
][safi
]);
10604 "RIB entries %ld, using %s of memory\n",
10614 /* Peer related usage */
10615 ents
= bgp
->af_peer_count
[afi
][safi
];
10617 "Peers %ld, using %s of memory\n",
10627 if ((ents
= listcount(bgp
->group
)))
10629 "Peer groups %ld, using %s of memory\n",
10639 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10640 BGP_CONFIG_DAMPENING
))
10642 "Dampening enabled.\n");
10645 vty_out(vty
, "\n");
10647 /* Subtract 8 here because 'Neighbor' is
10649 vty_out(vty
, "Neighbor");
10650 vty_out(vty
, "%*s",
10651 max_neighbor_width
- 8, " ");
10653 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10658 paf
= peer_af_find(peer
, afi
, safi
);
10659 filter
= &peer
->filter
[afi
][safi
];
10662 /* Works for both failed & successful cases */
10663 if (peer_dynamic_neighbor(peer
))
10668 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10674 bgp_has_peer_failed(peer
, afi
, safi
)) {
10675 json_peer
= json_object_new_object();
10676 bgp_show_failed_summary(vty
, bgp
, peer
,
10677 json_peer
, 0, use_json
);
10678 } else if (!show_failed
) {
10679 if (show_established
10680 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10685 json_peer
= json_object_new_object();
10686 if (peer_dynamic_neighbor(peer
)) {
10687 json_object_boolean_true_add(json_peer
,
10691 if (peer
->hostname
)
10692 json_object_string_add(json_peer
, "hostname",
10695 if (peer
->domainname
)
10696 json_object_string_add(json_peer
, "domainname",
10699 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10700 json_object_int_add(
10701 json_peer
, "localAs",
10702 peer
->change_local_as
10703 ? peer
->change_local_as
10705 json_object_int_add(json_peer
, "version", 4);
10706 json_object_int_add(json_peer
, "msgRcvd",
10707 PEER_TOTAL_RX(peer
));
10708 json_object_int_add(json_peer
, "msgSent",
10709 PEER_TOTAL_TX(peer
));
10711 atomic_size_t outq_count
, inq_count
;
10712 outq_count
= atomic_load_explicit(
10713 &peer
->obuf
->count
,
10714 memory_order_relaxed
);
10715 inq_count
= atomic_load_explicit(
10716 &peer
->ibuf
->count
,
10717 memory_order_relaxed
);
10719 json_object_int_add(json_peer
, "tableVersion",
10720 peer
->version
[afi
][safi
]);
10721 json_object_int_add(json_peer
, "outq",
10723 json_object_int_add(json_peer
, "inq",
10725 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10726 use_json
, json_peer
);
10728 json_object_int_add(json_peer
, "pfxRcd",
10729 peer
->pcount
[afi
][pfx_rcd_safi
]);
10731 if (paf
&& PAF_SUBGRP(paf
))
10732 json_object_int_add(
10733 json_peer
, "pfxSnt",
10734 (PAF_SUBGRP(paf
))->scount
);
10736 json_object_int_add(json_peer
, "pfxSnt",
10739 /* BGP FSM state */
10740 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10741 || CHECK_FLAG(peer
->bgp
->flags
,
10742 BGP_FLAG_SHUTDOWN
))
10743 json_object_string_add(json_peer
,
10746 else if (peer
->afc_recv
[afi
][safi
])
10747 json_object_string_add(
10748 json_peer
, "state",
10749 lookup_msg(bgp_status_msg
,
10750 peer
->status
, NULL
));
10751 else if (CHECK_FLAG(
10753 PEER_STATUS_PREFIX_OVERFLOW
))
10754 json_object_string_add(json_peer
,
10758 json_object_string_add(
10759 json_peer
, "state",
10760 lookup_msg(bgp_status_msg
,
10761 peer
->status
, NULL
));
10763 /* BGP peer state */
10764 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10765 || CHECK_FLAG(peer
->bgp
->flags
,
10766 BGP_FLAG_SHUTDOWN
))
10767 json_object_string_add(json_peer
,
10770 else if (CHECK_FLAG(
10772 PEER_STATUS_PREFIX_OVERFLOW
))
10773 json_object_string_add(json_peer
,
10776 else if (CHECK_FLAG(peer
->flags
,
10777 PEER_FLAG_PASSIVE
))
10778 json_object_string_add(json_peer
,
10781 else if (CHECK_FLAG(peer
->sflags
,
10782 PEER_STATUS_NSF_WAIT
))
10783 json_object_string_add(json_peer
,
10786 else if (CHECK_FLAG(
10788 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10789 && (!bgp_inbound_policy_exists(peer
,
10791 || !bgp_outbound_policy_exists(
10793 json_object_string_add(json_peer
,
10797 json_object_string_add(
10798 json_peer
, "peerState", "OK");
10800 json_object_int_add(json_peer
, "connectionsEstablished",
10801 peer
->established
);
10802 json_object_int_add(json_peer
, "connectionsDropped",
10805 json_object_string_add(
10806 json_peer
, "desc", peer
->desc
);
10808 /* Avoid creating empty peer dicts in JSON */
10809 if (json_peer
== NULL
)
10813 json_object_string_add(json_peer
, "idType",
10815 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10816 json_object_string_add(json_peer
, "idType",
10818 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10819 json_object_string_add(json_peer
, "idType",
10821 json_object_object_add(json_peers
, peer
->host
,
10824 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10830 bgp_has_peer_failed(peer
, afi
, safi
)) {
10831 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10832 max_neighbor_width
,
10834 } else if (!show_failed
) {
10835 if (show_established
10836 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10841 if ((count
- filtered_count
) == 1) {
10842 /* display headline before the first
10844 vty_out(vty
, "\n");
10846 /* Subtract 8 here because 'Neighbor' is
10848 vty_out(vty
, "Neighbor");
10849 vty_out(vty
, "%*s",
10850 max_neighbor_width
- 8, " ");
10853 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10854 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10857 memset(dn_flag
, '\0', sizeof(dn_flag
));
10858 if (peer_dynamic_neighbor(peer
)) {
10863 && CHECK_FLAG(bgp
->flags
,
10864 BGP_FLAG_SHOW_HOSTNAME
))
10865 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10869 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10871 /* pad the neighbor column with spaces */
10872 if (len
< max_neighbor_width
)
10873 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10876 atomic_size_t outq_count
, inq_count
;
10877 outq_count
= atomic_load_explicit(
10878 &peer
->obuf
->count
,
10879 memory_order_relaxed
);
10880 inq_count
= atomic_load_explicit(
10881 &peer
->ibuf
->count
,
10882 memory_order_relaxed
);
10886 "4 %10u %10u %9u %9u %8" PRIu64
10889 peer
->change_local_as
10890 ? peer
->change_local_as
10892 PEER_TOTAL_RX(peer
),
10893 PEER_TOTAL_TX(peer
),
10894 peer
->version
[afi
][safi
],
10895 inq_count
, outq_count
,
10896 peer_uptime(peer
->uptime
,
10901 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
10903 peer
->as
, PEER_TOTAL_RX(peer
),
10904 PEER_TOTAL_TX(peer
),
10905 peer
->version
[afi
][safi
],
10906 inq_count
, outq_count
,
10907 peer_uptime(peer
->uptime
,
10912 if (peer_established(peer
)) {
10913 if (peer
->afc_recv
[afi
][safi
]) {
10916 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10917 && !bgp_inbound_policy_exists(
10919 vty_out(vty
, " %12s",
10928 vty_out(vty
, " NoNeg");
10931 if (paf
&& PAF_SUBGRP(paf
)) {
10934 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10935 && !bgp_outbound_policy_exists(
10937 vty_out(vty
, " %8s",
10946 vty_out(vty
, " NoNeg");
10949 if (CHECK_FLAG(peer
->flags
,
10950 PEER_FLAG_SHUTDOWN
)
10951 || CHECK_FLAG(peer
->bgp
->flags
,
10952 BGP_FLAG_SHUTDOWN
))
10953 vty_out(vty
, " Idle (Admin)");
10954 else if (CHECK_FLAG(
10956 PEER_STATUS_PREFIX_OVERFLOW
))
10957 vty_out(vty
, " Idle (PfxCt)");
10959 vty_out(vty
, " %12s",
10960 lookup_msg(bgp_status_msg
,
10961 peer
->status
, NULL
));
10963 vty_out(vty
, " %8u", 0);
10965 /* Make sure `Desc` column is the lastest in
10969 vty_out(vty
, " %s",
10970 bgp_peer_description_stripped(
10972 show_wide
? 64 : 20));
10974 vty_out(vty
, " N/A");
10975 vty_out(vty
, "\n");
10982 json_object_object_add(json
, "peers", json_peers
);
10983 json_object_int_add(json
, "failedPeers", failed_count
);
10984 json_object_int_add(json
, "displayedPeers",
10985 count
- filtered_count
);
10986 json_object_int_add(json
, "totalPeers", count
);
10987 json_object_int_add(json
, "dynamicPeers", dn_count
);
10990 bgp_show_bestpath_json(bgp
, json
);
10992 vty_json(vty
, json
);
10995 if (filtered_count
== count
)
10996 vty_out(vty
, "\n%% No matching neighbor\n");
10999 vty_out(vty
, "\nDisplayed neighbors %d",
11001 else if (as_type
!= AS_UNSPECIFIED
|| as
11002 || fpeer
|| show_established
)
11003 vty_out(vty
, "\nDisplayed neighbors %d",
11004 count
- filtered_count
);
11006 vty_out(vty
, "\nTotal number of neighbors %d\n",
11010 vty_out(vty
, "No %s neighbor is configured\n",
11011 get_afi_safi_str(afi
, safi
, false));
11015 vty_out(vty
, "* - dynamic neighbor\n");
11016 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11017 dn_count
, bgp
->dynamic_neighbors_limit
);
11021 return CMD_SUCCESS
;
11024 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11025 int safi
, struct peer
*fpeer
, int as_type
,
11026 as_t as
, uint16_t show_flags
)
11029 int afi_wildcard
= (afi
== AFI_MAX
);
11030 int safi_wildcard
= (safi
== SAFI_MAX
);
11031 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11032 bool nbr_output
= false;
11033 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11035 if (use_json
&& is_wildcard
)
11036 vty_out(vty
, "{\n");
11038 afi
= 1; /* AFI_IP */
11039 while (afi
< AFI_MAX
) {
11041 safi
= 1; /* SAFI_UNICAST */
11042 while (safi
< SAFI_MAX
) {
11043 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11048 * So limit output to those afi/safi
11050 * actualy have something interesting in
11055 vty_out(vty
, ",\n");
11059 vty_out(vty
, "\"%s\":",
11060 get_afi_safi_str(afi
,
11065 "\n%s Summary (%s):\n",
11066 get_afi_safi_str(afi
,
11072 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11073 as_type
, as
, show_flags
);
11076 if (!safi_wildcard
)
11084 if (use_json
&& is_wildcard
)
11085 vty_out(vty
, "}\n");
11086 else if (!nbr_output
) {
11088 vty_out(vty
, "{}\n");
11090 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11095 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11097 const char *neighbor
,
11098 int as_type
, as_t as
,
11099 uint16_t show_flags
)
11101 struct listnode
*node
, *nnode
;
11103 struct peer
*fpeer
= NULL
;
11105 bool nbr_output
= false;
11106 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11109 vty_out(vty
, "{\n");
11111 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11115 vty_out(vty
, ",\n");
11119 vty_out(vty
, "\"%s\":",
11120 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11125 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11130 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11135 vty_out(vty
, "}\n");
11136 else if (!nbr_output
)
11137 vty_out(vty
, "%% BGP instance not found\n");
11140 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11141 safi_t safi
, const char *neighbor
, int as_type
,
11142 as_t as
, uint16_t show_flags
)
11145 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11146 struct peer
*fpeer
= NULL
;
11149 if (strmatch(name
, "all")) {
11150 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11153 return CMD_SUCCESS
;
11155 bgp
= bgp_lookup_by_name(name
);
11159 vty_out(vty
, "{}\n");
11162 "%% BGP instance not found\n");
11163 return CMD_WARNING
;
11167 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11170 return CMD_WARNING
;
11172 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11173 as_type
, as
, show_flags
);
11174 return CMD_SUCCESS
;
11178 bgp
= bgp_get_default();
11182 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11185 return CMD_WARNING
;
11187 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11191 vty_out(vty
, "{}\n");
11193 vty_out(vty
, "%% BGP instance not found\n");
11194 return CMD_WARNING
;
11197 return CMD_SUCCESS
;
11200 /* `show [ip] bgp summary' commands. */
11201 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11202 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11203 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11204 "]] [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]",
11205 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11206 BGP_SAFI_WITH_LABEL_HELP_STR
11207 "Display the entries for all address families\n"
11208 "Summary of BGP neighbor status\n"
11209 "Show only sessions in Established state\n"
11210 "Show only sessions not in Established state\n"
11211 "Show only the specified neighbor session\n"
11212 "Neighbor to display information about\n"
11213 "Neighbor to display information about\n"
11214 "Neighbor on BGP configured interface\n"
11215 "Show only the specified remote AS sessions\n"
11217 "Internal (iBGP) AS sessions\n"
11218 "External (eBGP) AS sessions\n"
11219 "Shorten the information on BGP instances\n"
11220 "Increase table width for longer output\n" JSON_STR
)
11223 afi_t afi
= AFI_MAX
;
11224 safi_t safi
= SAFI_MAX
;
11225 as_t as
= 0; /* 0 means AS filter not set */
11226 int as_type
= AS_UNSPECIFIED
;
11227 uint16_t show_flags
= 0;
11231 /* show [ip] bgp */
11232 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11234 /* [<vrf> VIEWVRFNAME] */
11235 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11236 vrf
= argv
[idx
+ 1]->arg
;
11237 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11239 } else if (argv_find(argv
, argc
, "view", &idx
))
11240 /* [<view> VIEWVRFNAME] */
11241 vrf
= argv
[idx
+ 1]->arg
;
11242 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11243 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11244 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11247 if (argv_find(argv
, argc
, "failed", &idx
))
11248 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11250 if (argv_find(argv
, argc
, "established", &idx
))
11251 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11253 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11254 if (argv
[idx
+ 1]->arg
[0] == 'i')
11255 as_type
= AS_INTERNAL
;
11256 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11257 as_type
= AS_EXTERNAL
;
11259 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11262 if (argv_find(argv
, argc
, "terse", &idx
))
11263 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11265 if (argv_find(argv
, argc
, "wide", &idx
))
11266 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11268 if (argv_find(argv
, argc
, "json", &idx
))
11269 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11271 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11275 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11278 return get_afi_safi_json_str(afi
, safi
);
11280 return get_afi_safi_vty_str(afi
, safi
);
11284 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11285 afi_t afi
, safi_t safi
,
11286 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11287 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11288 bool use_json
, json_object
*json_pref
)
11291 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11292 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11294 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11295 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11296 json_object_string_add(json_pref
, "sendMode",
11297 "advertisedAndReceived");
11298 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11299 json_object_string_add(json_pref
, "sendMode",
11301 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11302 json_object_string_add(json_pref
, "sendMode",
11305 vty_out(vty
, " Send-mode: ");
11306 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11307 vty_out(vty
, "advertised");
11308 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11309 vty_out(vty
, "%sreceived",
11310 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11314 vty_out(vty
, "\n");
11319 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11320 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11322 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11323 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11324 json_object_string_add(json_pref
, "recvMode",
11325 "advertisedAndReceived");
11326 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11327 json_object_string_add(json_pref
, "recvMode",
11329 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11330 json_object_string_add(json_pref
, "recvMode",
11333 vty_out(vty
, " Receive-mode: ");
11334 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11335 vty_out(vty
, "advertised");
11336 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11337 vty_out(vty
, "%sreceived",
11338 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11342 vty_out(vty
, "\n");
11347 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11355 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11356 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11357 && (peer_established(p
))) {
11358 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11359 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11363 json_object_boolean_add(json
, "rBit", rbit
);
11364 json_object_boolean_add(json
, "nBit", nbit
);
11366 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11367 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11371 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11376 const char *mode
= "NotApplicable";
11379 vty_out(vty
, "\n Remote GR Mode: ");
11381 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11382 && (peer_established(peer
))) {
11384 if ((peer
->nsf_af_count
== 0)
11385 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11389 } else if (peer
->nsf_af_count
== 0
11390 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11394 } else if (peer
->nsf_af_count
!= 0
11395 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11402 json_object_string_add(json
, "remoteGrMode", mode
);
11404 vty_out(vty
, mode
, "\n");
11407 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11412 const char *mode
= "Invalid";
11415 vty_out(vty
, " Local GR Mode: ");
11417 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11419 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11421 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11423 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11424 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11426 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11428 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11435 json_object_string_add(json
, "localGrMode", mode
);
11437 vty_out(vty
, mode
, "\n");
11441 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11442 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11446 json_object
*json_afi_safi
= NULL
;
11447 json_object
*json_timer
= NULL
;
11448 json_object
*json_endofrib_status
= NULL
;
11449 bool eor_flag
= false;
11451 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11452 if (!peer
->afc
[afi
][safi
])
11455 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11456 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11460 json_afi_safi
= json_object_new_object();
11461 json_endofrib_status
= json_object_new_object();
11462 json_timer
= json_object_new_object();
11465 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11471 vty_out(vty
, " %s:\n",
11472 get_afi_safi_str(afi
, safi
, false));
11474 vty_out(vty
, " F bit: ");
11477 if (peer
->nsf
[afi
][safi
] &&
11478 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11479 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11482 json_object_boolean_true_add(json_afi_safi
,
11485 vty_out(vty
, "True\n");
11488 json_object_boolean_false_add(json_afi_safi
,
11491 vty_out(vty
, "False\n");
11495 vty_out(vty
, " End-of-RIB sent: ");
11497 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11498 PEER_STATUS_EOR_SEND
)) {
11500 json_object_boolean_true_add(
11501 json_endofrib_status
, "endOfRibSend");
11503 PRINT_EOR_JSON(eor_flag
);
11505 vty_out(vty
, "Yes\n");
11507 " End-of-RIB sent after update: ");
11509 PRINT_EOR(eor_flag
);
11513 json_object_boolean_false_add(
11514 json_endofrib_status
, "endOfRibSend");
11515 json_object_boolean_false_add(
11516 json_endofrib_status
,
11517 "endOfRibSentAfterUpdate");
11519 vty_out(vty
, "No\n");
11521 " End-of-RIB sent after update: ");
11522 vty_out(vty
, "No\n");
11527 vty_out(vty
, " End-of-RIB received: ");
11529 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11530 PEER_STATUS_EOR_RECEIVED
)) {
11532 json_object_boolean_true_add(
11533 json_endofrib_status
, "endOfRibRecv");
11535 vty_out(vty
, "Yes\n");
11538 json_object_boolean_false_add(
11539 json_endofrib_status
, "endOfRibRecv");
11541 vty_out(vty
, "No\n");
11545 json_object_int_add(json_timer
, "stalePathTimer",
11546 peer
->bgp
->stalepath_time
);
11548 if (peer
->t_gr_stale
!= NULL
) {
11549 json_object_int_add(json_timer
,
11550 "stalePathTimerRemaining",
11551 thread_timer_remain_second(
11552 peer
->t_gr_stale
));
11555 /* Display Configured Selection
11556 * Deferral only when when
11557 * Gr mode is enabled.
11559 if (CHECK_FLAG(peer
->flags
,
11560 PEER_FLAG_GRACEFUL_RESTART
)) {
11561 json_object_int_add(json_timer
,
11562 "selectionDeferralTimer",
11563 peer
->bgp
->stalepath_time
);
11566 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11569 json_object_int_add(
11571 "selectionDeferralTimerRemaining",
11572 thread_timer_remain_second(
11573 peer
->bgp
->gr_info
[afi
][safi
]
11574 .t_select_deferral
));
11577 vty_out(vty
, " Timers:\n");
11579 " Configured Stale Path Time(sec): %u\n",
11580 peer
->bgp
->stalepath_time
);
11582 if (peer
->t_gr_stale
!= NULL
)
11584 " Stale Path Remaining(sec): %ld\n",
11585 thread_timer_remain_second(
11586 peer
->t_gr_stale
));
11587 /* Display Configured Selection
11588 * Deferral only when when
11589 * Gr mode is enabled.
11591 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11593 " Configured Selection Deferral Time(sec): %u\n",
11594 peer
->bgp
->select_defer_time
);
11596 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11599 " Selection Deferral Time Remaining(sec): %ld\n",
11600 thread_timer_remain_second(
11601 peer
->bgp
->gr_info
[afi
][safi
]
11602 .t_select_deferral
));
11605 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11606 json_endofrib_status
);
11607 json_object_object_add(json_afi_safi
, "timers",
11609 json_object_object_add(
11610 json
, get_afi_safi_str(afi
, safi
, true),
11616 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11622 json_object
*json_timer
= NULL
;
11624 json_timer
= json_object_new_object();
11626 json_object_int_add(json_timer
, "configuredRestartTimer",
11627 p
->bgp
->restart_time
);
11629 json_object_int_add(json_timer
, "receivedRestartTimer",
11632 if (p
->t_gr_restart
!= NULL
)
11633 json_object_int_add(
11634 json_timer
, "restartTimerRemaining",
11635 thread_timer_remain_second(p
->t_gr_restart
));
11637 json_object_object_add(json
, "timers", json_timer
);
11640 vty_out(vty
, " Timers:\n");
11641 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11642 p
->bgp
->restart_time
);
11644 vty_out(vty
, " Received Restart Time(sec): %u\n",
11646 if (p
->t_gr_restart
!= NULL
)
11647 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11648 thread_timer_remain_second(p
->t_gr_restart
));
11649 if (p
->t_gr_restart
!= NULL
) {
11650 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11651 thread_timer_remain_second(p
->t_gr_restart
));
11656 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11657 bool use_json
, json_object
*json
)
11659 char buf
[SU_ADDRSTRLEN
] = {0};
11660 char dn_flag
[2] = {0};
11661 /* '*' + v6 address of neighbor */
11662 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11664 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11669 json_object_string_add(
11670 json
, "neighborAddr",
11671 BGP_PEER_SU_UNSPEC(p
)
11673 : sockunion2str(&p
->su
, buf
,
11676 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11677 BGP_PEER_SU_UNSPEC(p
)
11679 : sockunion2str(&p
->su
, buf
,
11682 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11686 json_object_string_add(json
, "neighborAddr",
11689 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11692 /* more gr info in new format */
11693 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11696 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11697 safi_t safi
, bool use_json
,
11698 json_object
*json_neigh
)
11700 struct bgp_filter
*filter
;
11701 struct peer_af
*paf
;
11702 char orf_pfx_name
[BUFSIZ
];
11704 json_object
*json_af
= NULL
;
11705 json_object
*json_prefA
= NULL
;
11706 json_object
*json_prefB
= NULL
;
11707 json_object
*json_addr
= NULL
;
11708 json_object
*json_advmap
= NULL
;
11711 json_addr
= json_object_new_object();
11712 json_af
= json_object_new_object();
11713 filter
= &p
->filter
[afi
][safi
];
11715 if (peer_group_active(p
))
11716 json_object_string_add(json_addr
, "peerGroupMember",
11719 paf
= peer_af_find(p
, afi
, safi
);
11720 if (paf
&& PAF_SUBGRP(paf
)) {
11721 json_object_int_add(json_addr
, "updateGroupId",
11722 PAF_UPDGRP(paf
)->id
);
11723 json_object_int_add(json_addr
, "subGroupId",
11724 PAF_SUBGRP(paf
)->id
);
11725 json_object_int_add(json_addr
, "packetQueueLength",
11726 bpacket_queue_virtual_length(paf
));
11729 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11730 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11731 PEER_CAP_ORF_PREFIX_SM_RCV
)
11732 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11733 PEER_CAP_ORF_PREFIX_RM_ADV
)
11734 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11735 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11736 json_object_int_add(json_af
, "orfType",
11738 json_prefA
= json_object_new_object();
11739 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11740 PEER_CAP_ORF_PREFIX_SM_ADV
,
11741 PEER_CAP_ORF_PREFIX_RM_ADV
,
11742 PEER_CAP_ORF_PREFIX_SM_RCV
,
11743 PEER_CAP_ORF_PREFIX_RM_RCV
,
11744 use_json
, json_prefA
);
11745 json_object_object_add(json_af
, "orfPrefixList",
11749 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11750 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11751 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11752 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11753 PEER_CAP_ORF_PREFIX_RM_ADV
)
11754 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11755 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11756 json_object_int_add(json_af
, "orfOldType",
11757 ORF_TYPE_PREFIX_OLD
);
11758 json_prefB
= json_object_new_object();
11759 bgp_show_peer_afi_orf_cap(
11760 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11761 PEER_CAP_ORF_PREFIX_RM_ADV
,
11762 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11763 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11765 json_object_object_add(json_af
, "orfOldPrefixList",
11769 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11770 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11771 PEER_CAP_ORF_PREFIX_SM_RCV
)
11772 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11773 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11774 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11775 PEER_CAP_ORF_PREFIX_RM_ADV
)
11776 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11777 PEER_CAP_ORF_PREFIX_RM_RCV
)
11778 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11779 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11780 json_object_object_add(json_addr
, "afDependentCap",
11783 json_object_free(json_af
);
11785 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11786 p
->host
, afi
, safi
);
11787 orf_pfx_count
= prefix_bgp_show_prefix_list(
11788 NULL
, afi
, orf_pfx_name
, use_json
);
11790 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11791 PEER_STATUS_ORF_PREFIX_SEND
)
11792 || orf_pfx_count
) {
11793 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11794 PEER_STATUS_ORF_PREFIX_SEND
))
11795 json_object_boolean_true_add(json_neigh
,
11798 json_object_int_add(json_addr
, "orfRecvCounter",
11801 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11802 PEER_STATUS_ORF_WAIT_REFRESH
))
11803 json_object_string_add(
11804 json_addr
, "orfFirstUpdate",
11805 "deferredUntilORFOrRouteRefreshRecvd");
11807 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11808 PEER_FLAG_REFLECTOR_CLIENT
))
11809 json_object_boolean_true_add(json_addr
,
11810 "routeReflectorClient");
11811 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11812 PEER_FLAG_RSERVER_CLIENT
))
11813 json_object_boolean_true_add(json_addr
,
11814 "routeServerClient");
11815 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11816 json_object_boolean_true_add(json_addr
,
11817 "inboundSoftConfigPermit");
11819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11820 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11821 json_object_boolean_true_add(
11823 "privateAsNumsAllReplacedInUpdatesToNbr");
11824 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11825 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11826 json_object_boolean_true_add(
11828 "privateAsNumsReplacedInUpdatesToNbr");
11829 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11830 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11831 json_object_boolean_true_add(
11833 "privateAsNumsAllRemovedInUpdatesToNbr");
11834 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11835 PEER_FLAG_REMOVE_PRIVATE_AS
))
11836 json_object_boolean_true_add(
11838 "privateAsNumsRemovedInUpdatesToNbr");
11840 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11841 json_object_boolean_true_add(
11843 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11846 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11847 json_object_string_add(json_addr
,
11848 "overrideASNsInOutboundUpdates",
11849 "ifAspathEqualRemoteAs");
11851 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11852 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11853 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11854 json_object_boolean_true_add(json_addr
,
11855 "routerAlwaysNextHop");
11856 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11857 PEER_FLAG_AS_PATH_UNCHANGED
))
11858 json_object_boolean_true_add(
11859 json_addr
, "unchangedAsPathPropogatedToNbr");
11860 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11861 PEER_FLAG_NEXTHOP_UNCHANGED
))
11862 json_object_boolean_true_add(
11863 json_addr
, "unchangedNextHopPropogatedToNbr");
11864 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11865 json_object_boolean_true_add(
11866 json_addr
, "unchangedMedPropogatedToNbr");
11867 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11868 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11869 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11870 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11871 PEER_FLAG_SEND_COMMUNITY
)
11872 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11873 PEER_FLAG_SEND_EXT_COMMUNITY
))
11874 json_object_string_add(json_addr
,
11875 "commAttriSentToNbr",
11876 "extendedAndStandard");
11877 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11878 PEER_FLAG_SEND_EXT_COMMUNITY
))
11879 json_object_string_add(json_addr
,
11880 "commAttriSentToNbr",
11883 json_object_string_add(json_addr
,
11884 "commAttriSentToNbr",
11887 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11888 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11889 if (p
->default_rmap
[afi
][safi
].name
)
11890 json_object_string_add(
11891 json_addr
, "defaultRouteMap",
11892 p
->default_rmap
[afi
][safi
].name
);
11894 if (paf
&& PAF_SUBGRP(paf
)
11895 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11896 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11897 json_object_boolean_true_add(json_addr
,
11900 json_object_boolean_true_add(json_addr
,
11904 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11905 if (is_evpn_enabled())
11906 json_object_boolean_true_add(
11907 json_addr
, "advertiseAllVnis");
11910 if (filter
->plist
[FILTER_IN
].name
11911 || filter
->dlist
[FILTER_IN
].name
11912 || filter
->aslist
[FILTER_IN
].name
11913 || filter
->map
[RMAP_IN
].name
)
11914 json_object_boolean_true_add(json_addr
,
11915 "inboundPathPolicyConfig");
11916 if (filter
->plist
[FILTER_OUT
].name
11917 || filter
->dlist
[FILTER_OUT
].name
11918 || filter
->aslist
[FILTER_OUT
].name
11919 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11920 json_object_boolean_true_add(
11921 json_addr
, "outboundPathPolicyConfig");
11924 if (filter
->plist
[FILTER_IN
].name
)
11925 json_object_string_add(json_addr
,
11926 "incomingUpdatePrefixFilterList",
11927 filter
->plist
[FILTER_IN
].name
);
11928 if (filter
->plist
[FILTER_OUT
].name
)
11929 json_object_string_add(json_addr
,
11930 "outgoingUpdatePrefixFilterList",
11931 filter
->plist
[FILTER_OUT
].name
);
11933 /* distribute-list */
11934 if (filter
->dlist
[FILTER_IN
].name
)
11935 json_object_string_add(
11936 json_addr
, "incomingUpdateNetworkFilterList",
11937 filter
->dlist
[FILTER_IN
].name
);
11938 if (filter
->dlist
[FILTER_OUT
].name
)
11939 json_object_string_add(
11940 json_addr
, "outgoingUpdateNetworkFilterList",
11941 filter
->dlist
[FILTER_OUT
].name
);
11944 if (filter
->aslist
[FILTER_IN
].name
)
11945 json_object_string_add(json_addr
,
11946 "incomingUpdateAsPathFilterList",
11947 filter
->aslist
[FILTER_IN
].name
);
11948 if (filter
->aslist
[FILTER_OUT
].name
)
11949 json_object_string_add(json_addr
,
11950 "outgoingUpdateAsPathFilterList",
11951 filter
->aslist
[FILTER_OUT
].name
);
11954 if (filter
->map
[RMAP_IN
].name
)
11955 json_object_string_add(
11956 json_addr
, "routeMapForIncomingAdvertisements",
11957 filter
->map
[RMAP_IN
].name
);
11958 if (filter
->map
[RMAP_OUT
].name
)
11959 json_object_string_add(
11960 json_addr
, "routeMapForOutgoingAdvertisements",
11961 filter
->map
[RMAP_OUT
].name
);
11963 /* ebgp-requires-policy (inbound) */
11964 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11965 && !bgp_inbound_policy_exists(p
, filter
))
11966 json_object_string_add(
11967 json_addr
, "inboundEbgpRequiresPolicy",
11968 "Inbound updates discarded due to missing policy");
11970 /* ebgp-requires-policy (outbound) */
11971 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11972 && (!bgp_outbound_policy_exists(p
, filter
)))
11973 json_object_string_add(
11974 json_addr
, "outboundEbgpRequiresPolicy",
11975 "Outbound updates discarded due to missing policy");
11977 /* unsuppress-map */
11978 if (filter
->usmap
.name
)
11979 json_object_string_add(json_addr
,
11980 "selectiveUnsuppressRouteMap",
11981 filter
->usmap
.name
);
11983 /* advertise-map */
11984 if (filter
->advmap
.aname
) {
11985 json_advmap
= json_object_new_object();
11986 json_object_string_add(json_advmap
, "condition",
11987 filter
->advmap
.condition
11990 json_object_string_add(json_advmap
, "conditionMap",
11991 filter
->advmap
.cname
);
11992 json_object_string_add(json_advmap
, "advertiseMap",
11993 filter
->advmap
.aname
);
11994 json_object_string_add(json_advmap
, "advertiseStatus",
11995 filter
->advmap
.update_type
11999 json_object_object_add(json_addr
, "advertiseMap",
12003 /* Receive prefix count */
12004 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12005 p
->pcount
[afi
][safi
]);
12006 if (paf
&& PAF_SUBGRP(paf
))
12007 json_object_int_add(json_addr
, "sentPrefixCounter",
12008 (PAF_SUBGRP(paf
))->scount
);
12010 /* Maximum prefix */
12011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12012 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12013 p
->pmax_out
[afi
][safi
]);
12015 /* Maximum prefix */
12016 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12017 json_object_int_add(json_addr
, "prefixAllowedMax",
12018 p
->pmax
[afi
][safi
]);
12019 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12020 PEER_FLAG_MAX_PREFIX_WARNING
))
12021 json_object_boolean_true_add(
12022 json_addr
, "prefixAllowedMaxWarning");
12023 json_object_int_add(json_addr
,
12024 "prefixAllowedWarningThresh",
12025 p
->pmax_threshold
[afi
][safi
]);
12026 if (p
->pmax_restart
[afi
][safi
])
12027 json_object_int_add(
12029 "prefixAllowedRestartIntervalMsecs",
12030 p
->pmax_restart
[afi
][safi
] * 60000);
12032 json_object_object_add(json_neigh
,
12033 get_afi_safi_str(afi
, safi
, true),
12037 filter
= &p
->filter
[afi
][safi
];
12039 vty_out(vty
, " For address family: %s\n",
12040 get_afi_safi_str(afi
, safi
, false));
12042 if (peer_group_active(p
))
12043 vty_out(vty
, " %s peer-group member\n",
12046 paf
= peer_af_find(p
, afi
, safi
);
12047 if (paf
&& PAF_SUBGRP(paf
)) {
12048 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12049 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12050 vty_out(vty
, " Packet Queue length %d\n",
12051 bpacket_queue_virtual_length(paf
));
12053 vty_out(vty
, " Not part of any update group\n");
12055 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12056 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12057 PEER_CAP_ORF_PREFIX_SM_RCV
)
12058 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12059 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12060 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12061 PEER_CAP_ORF_PREFIX_RM_ADV
)
12062 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12063 PEER_CAP_ORF_PREFIX_RM_RCV
)
12064 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12065 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12066 vty_out(vty
, " AF-dependant capabilities:\n");
12068 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12069 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12070 PEER_CAP_ORF_PREFIX_SM_RCV
)
12071 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12072 PEER_CAP_ORF_PREFIX_RM_ADV
)
12073 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12074 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12076 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12078 bgp_show_peer_afi_orf_cap(
12079 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12080 PEER_CAP_ORF_PREFIX_RM_ADV
,
12081 PEER_CAP_ORF_PREFIX_SM_RCV
,
12082 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12084 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12085 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12086 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12087 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12088 PEER_CAP_ORF_PREFIX_RM_ADV
)
12089 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12090 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12092 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12093 ORF_TYPE_PREFIX_OLD
);
12094 bgp_show_peer_afi_orf_cap(
12095 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12096 PEER_CAP_ORF_PREFIX_RM_ADV
,
12097 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12098 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12101 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12102 p
->host
, afi
, safi
);
12103 orf_pfx_count
= prefix_bgp_show_prefix_list(
12104 NULL
, afi
, orf_pfx_name
, use_json
);
12106 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12107 PEER_STATUS_ORF_PREFIX_SEND
)
12108 || orf_pfx_count
) {
12109 vty_out(vty
, " Outbound Route Filter (ORF):");
12110 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12111 PEER_STATUS_ORF_PREFIX_SEND
))
12112 vty_out(vty
, " sent;");
12114 vty_out(vty
, " received (%d entries)",
12116 vty_out(vty
, "\n");
12118 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12119 PEER_STATUS_ORF_WAIT_REFRESH
))
12121 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12123 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12124 PEER_FLAG_REFLECTOR_CLIENT
))
12125 vty_out(vty
, " Route-Reflector Client\n");
12126 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12127 PEER_FLAG_RSERVER_CLIENT
))
12128 vty_out(vty
, " Route-Server Client\n");
12129 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12131 " Inbound soft reconfiguration allowed\n");
12133 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12134 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12136 " Private AS numbers (all) replaced in updates to this neighbor\n");
12137 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12138 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12140 " Private AS numbers replaced in updates to this neighbor\n");
12141 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12142 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12144 " Private AS numbers (all) removed in updates to this neighbor\n");
12145 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12146 PEER_FLAG_REMOVE_PRIVATE_AS
))
12148 " Private AS numbers removed in updates to this neighbor\n");
12150 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12151 vty_out(vty
, " %s\n",
12152 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12153 ->human_description
);
12155 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12157 " Override ASNs in outbound updates if aspath equals remote-as\n");
12159 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12160 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12161 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12162 vty_out(vty
, " NEXT_HOP is always this router\n");
12163 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12164 PEER_FLAG_AS_PATH_UNCHANGED
))
12166 " AS_PATH is propagated unchanged to this neighbor\n");
12167 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12168 PEER_FLAG_NEXTHOP_UNCHANGED
))
12170 " NEXT_HOP is propagated unchanged to this neighbor\n");
12171 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12173 " MED is propagated unchanged to this neighbor\n");
12174 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12175 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12176 PEER_FLAG_SEND_EXT_COMMUNITY
)
12177 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12178 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12180 " Community attribute sent to this neighbor");
12181 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12182 PEER_FLAG_SEND_COMMUNITY
)
12183 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12184 PEER_FLAG_SEND_EXT_COMMUNITY
)
12185 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12186 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12187 vty_out(vty
, "(all)\n");
12188 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12189 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12190 vty_out(vty
, "(large)\n");
12191 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12192 PEER_FLAG_SEND_EXT_COMMUNITY
))
12193 vty_out(vty
, "(extended)\n");
12195 vty_out(vty
, "(standard)\n");
12197 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12198 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12199 vty_out(vty
, " Default information originate,");
12201 if (p
->default_rmap
[afi
][safi
].name
)
12202 vty_out(vty
, " default route-map %s%s,",
12203 p
->default_rmap
[afi
][safi
].map
? "*"
12205 p
->default_rmap
[afi
][safi
].name
);
12206 if (paf
&& PAF_SUBGRP(paf
)
12207 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12208 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12209 vty_out(vty
, " default sent\n");
12211 vty_out(vty
, " default not sent\n");
12214 /* advertise-vni-all */
12215 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12216 if (is_evpn_enabled())
12217 vty_out(vty
, " advertise-all-vni\n");
12220 if (filter
->plist
[FILTER_IN
].name
12221 || filter
->dlist
[FILTER_IN
].name
12222 || filter
->aslist
[FILTER_IN
].name
12223 || filter
->map
[RMAP_IN
].name
)
12224 vty_out(vty
, " Inbound path policy configured\n");
12225 if (filter
->plist
[FILTER_OUT
].name
12226 || filter
->dlist
[FILTER_OUT
].name
12227 || filter
->aslist
[FILTER_OUT
].name
12228 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12229 vty_out(vty
, " Outbound path policy configured\n");
12232 if (filter
->plist
[FILTER_IN
].name
)
12234 " Incoming update prefix filter list is %s%s\n",
12235 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12236 filter
->plist
[FILTER_IN
].name
);
12237 if (filter
->plist
[FILTER_OUT
].name
)
12239 " Outgoing update prefix filter list is %s%s\n",
12240 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12241 filter
->plist
[FILTER_OUT
].name
);
12243 /* distribute-list */
12244 if (filter
->dlist
[FILTER_IN
].name
)
12246 " Incoming update network filter list is %s%s\n",
12247 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12248 filter
->dlist
[FILTER_IN
].name
);
12249 if (filter
->dlist
[FILTER_OUT
].name
)
12251 " Outgoing update network filter list is %s%s\n",
12252 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12253 filter
->dlist
[FILTER_OUT
].name
);
12256 if (filter
->aslist
[FILTER_IN
].name
)
12258 " Incoming update AS path filter list is %s%s\n",
12259 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12260 filter
->aslist
[FILTER_IN
].name
);
12261 if (filter
->aslist
[FILTER_OUT
].name
)
12263 " Outgoing update AS path filter list is %s%s\n",
12264 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12265 filter
->aslist
[FILTER_OUT
].name
);
12268 if (filter
->map
[RMAP_IN
].name
)
12270 " Route map for incoming advertisements is %s%s\n",
12271 filter
->map
[RMAP_IN
].map
? "*" : "",
12272 filter
->map
[RMAP_IN
].name
);
12273 if (filter
->map
[RMAP_OUT
].name
)
12275 " Route map for outgoing advertisements is %s%s\n",
12276 filter
->map
[RMAP_OUT
].map
? "*" : "",
12277 filter
->map
[RMAP_OUT
].name
);
12279 /* ebgp-requires-policy (inbound) */
12280 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12281 && !bgp_inbound_policy_exists(p
, filter
))
12283 " Inbound updates discarded due to missing policy\n");
12285 /* ebgp-requires-policy (outbound) */
12286 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12287 && !bgp_outbound_policy_exists(p
, filter
))
12289 " Outbound updates discarded due to missing policy\n");
12291 /* unsuppress-map */
12292 if (filter
->usmap
.name
)
12294 " Route map for selective unsuppress is %s%s\n",
12295 filter
->usmap
.map
? "*" : "",
12296 filter
->usmap
.name
);
12298 /* advertise-map */
12299 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12301 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12302 filter
->advmap
.condition
? "EXIST"
12304 filter
->advmap
.cmap
? "*" : "",
12305 filter
->advmap
.cname
,
12306 filter
->advmap
.amap
? "*" : "",
12307 filter
->advmap
.aname
,
12308 filter
->advmap
.update_type
== ADVERTISE
12312 /* Receive prefix count */
12313 vty_out(vty
, " %u accepted prefixes\n",
12314 p
->pcount
[afi
][safi
]);
12316 /* maximum-prefix-out */
12317 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12318 PEER_FLAG_MAX_PREFIX_OUT
))
12320 " Maximum allowed prefixes sent %u\n",
12321 p
->pmax_out
[afi
][safi
]);
12323 /* Maximum prefix */
12324 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12326 " Maximum prefixes allowed %u%s\n",
12327 p
->pmax
[afi
][safi
],
12328 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12329 PEER_FLAG_MAX_PREFIX_WARNING
)
12330 ? " (warning-only)"
12332 vty_out(vty
, " Threshold for warning message %d%%",
12333 p
->pmax_threshold
[afi
][safi
]);
12334 if (p
->pmax_restart
[afi
][safi
])
12335 vty_out(vty
, ", restart interval %d min",
12336 p
->pmax_restart
[afi
][safi
]);
12337 vty_out(vty
, "\n");
12340 vty_out(vty
, "\n");
12344 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12348 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12349 char timebuf
[BGP_UPTIME_LEN
];
12355 json_object
*json_neigh
= NULL
;
12357 uint32_t sync_tcp_mss
;
12362 json_neigh
= json_object_new_object();
12364 memset(dn_flag
, '\0', sizeof(dn_flag
));
12365 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12369 if (p
->conf_if
) /* Configured interface name. */
12370 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12371 BGP_PEER_SU_UNSPEC(p
)
12373 : sockunion2str(&p
->su
, buf
,
12375 else /* Configured IP address. */
12376 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12381 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12382 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12384 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12385 json_object_string_add(
12386 json_neigh
, "bgpNeighborAddr",
12387 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12389 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12391 if (p
->change_local_as
)
12392 json_object_int_add(json_neigh
, "localAs",
12393 p
->change_local_as
);
12395 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12397 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12398 json_object_boolean_true_add(json_neigh
,
12399 "localAsNoPrepend");
12401 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12402 json_object_boolean_true_add(json_neigh
,
12403 "localAsReplaceAs");
12405 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12406 || (p
->as_type
== AS_INTERNAL
))
12407 vty_out(vty
, "remote AS %u, ", p
->as
);
12409 vty_out(vty
, "remote AS Unspecified, ");
12410 vty_out(vty
, "local AS %u%s%s, ",
12411 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12412 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12415 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12419 /* peer type internal or confed-internal */
12420 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12422 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12423 json_object_boolean_true_add(
12424 json_neigh
, "nbrConfedInternalLink");
12426 json_object_boolean_true_add(json_neigh
,
12427 "nbrInternalLink");
12429 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12430 vty_out(vty
, "confed-internal link\n");
12432 vty_out(vty
, "internal link\n");
12434 /* peer type external or confed-external */
12435 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12437 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12438 json_object_boolean_true_add(
12439 json_neigh
, "nbrConfedExternalLink");
12441 json_object_boolean_true_add(json_neigh
,
12442 "nbrExternalLink");
12444 if (bgp_confederation_peers_check(bgp
, p
->as
))
12445 vty_out(vty
, "confed-external link\n");
12447 vty_out(vty
, "external link\n");
12451 json_object_boolean_true_add(json_neigh
,
12452 "nbrUnspecifiedLink");
12454 vty_out(vty
, "unspecified link\n");
12460 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12462 vty_out(vty
, " Description: %s\n", p
->desc
);
12468 json_object_string_add(json_neigh
, "hostname",
12472 json_object_string_add(json_neigh
, "domainname",
12475 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12476 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12479 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12486 json_object_string_add(json_neigh
, "peerGroup",
12490 struct prefix prefix
, *range
= NULL
;
12492 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12493 range
= peer_group_lookup_dynamic_neighbor_range(
12494 p
->group
, &prefix
);
12497 json_object_string_addf(
12499 "peerSubnetRangeGroup", "%pFX",
12505 " Member of peer-group %s for session parameters\n",
12509 struct prefix prefix
, *range
= NULL
;
12511 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12512 range
= peer_group_lookup_dynamic_neighbor_range(
12513 p
->group
, &prefix
);
12517 " Belongs to the subnet range group: %pFX\n",
12525 /* Administrative shutdown. */
12526 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12527 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12528 json_object_boolean_true_add(json_neigh
,
12532 json_object_int_add(json_neigh
, "bgpVersion", 4);
12533 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12535 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12538 /* Confederation */
12539 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12540 && bgp_confederation_peers_check(bgp
, p
->as
))
12541 json_object_boolean_true_add(json_neigh
,
12545 json_object_string_add(
12546 json_neigh
, "bgpState",
12547 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12549 if (peer_established(p
)) {
12552 uptime
= bgp_clock();
12553 uptime
-= p
->uptime
;
12554 epoch_tbuf
= time(NULL
) - uptime
;
12556 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12558 json_object_string_add(json_neigh
, "bgpTimerUpString",
12559 peer_uptime(p
->uptime
, timebuf
,
12562 json_object_int_add(json_neigh
,
12563 "bgpTimerUpEstablishedEpoch",
12567 else if (p
->status
== Active
) {
12568 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12569 json_object_string_add(json_neigh
, "bgpStateIs",
12571 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12572 json_object_string_add(json_neigh
, "bgpStateIs",
12580 uptime
= bgp_clock();
12581 uptime
-= p
->readtime
;
12582 gmtime_r(&uptime
, &tm
);
12584 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12585 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12586 + (tm
.tm_hour
* 3600000));
12588 uptime
= bgp_clock();
12589 uptime
-= p
->last_write
;
12590 gmtime_r(&uptime
, &tm
);
12592 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12593 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12594 + (tm
.tm_hour
* 3600000));
12596 uptime
= bgp_clock();
12597 uptime
-= p
->update_time
;
12598 gmtime_r(&uptime
, &tm
);
12600 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12601 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12602 + (tm
.tm_hour
* 3600000));
12604 /* Configured timer values. */
12605 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12606 p
->v_holdtime
* 1000);
12607 json_object_int_add(json_neigh
,
12608 "bgpTimerKeepAliveIntervalMsecs",
12609 p
->v_keepalive
* 1000);
12610 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12611 json_object_int_add(json_neigh
,
12612 "bgpTimerDelayOpenTimeMsecs",
12613 p
->v_delayopen
* 1000);
12616 /* Configured and Synced tcp-mss value for peer */
12617 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12618 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12619 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12621 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12625 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12626 json_object_int_add(json_neigh
,
12627 "bgpTimerConfiguredHoldTimeMsecs",
12628 p
->holdtime
* 1000);
12629 json_object_int_add(
12631 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12632 p
->keepalive
* 1000);
12633 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12634 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12635 json_object_int_add(json_neigh
,
12636 "bgpTimerConfiguredHoldTimeMsecs",
12637 bgp
->default_holdtime
);
12638 json_object_int_add(
12640 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12641 bgp
->default_keepalive
);
12644 /* Extended Optional Parameters Length for BGP OPEN Message */
12645 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12646 json_object_boolean_true_add(
12647 json_neigh
, "extendedOptionalParametersLength");
12649 json_object_boolean_false_add(
12650 json_neigh
, "extendedOptionalParametersLength");
12652 /* Conditional advertisements */
12653 json_object_int_add(
12655 "bgpTimerConfiguredConditionalAdvertisementsSec",
12656 bgp
->condition_check_period
);
12657 if (thread_is_scheduled(bgp
->t_condition_check
))
12658 json_object_int_add(
12660 "bgpTimerUntilConditionalAdvertisementsSec",
12661 thread_timer_remain_second(
12662 bgp
->t_condition_check
));
12664 /* Administrative shutdown. */
12665 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12666 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12667 vty_out(vty
, " Administratively shut down\n");
12670 vty_out(vty
, " BGP version 4");
12671 vty_out(vty
, ", remote router ID %s",
12672 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12673 vty_out(vty
, ", local router ID %s\n",
12674 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12677 /* Confederation */
12678 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12679 && bgp_confederation_peers_check(bgp
, p
->as
))
12681 " Neighbor under common administration\n");
12684 vty_out(vty
, " BGP state = %s",
12685 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12687 if (peer_established(p
))
12688 vty_out(vty
, ", up for %8s",
12689 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12692 else if (p
->status
== Active
) {
12693 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12694 vty_out(vty
, " (passive)");
12695 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12696 vty_out(vty
, " (NSF passive)");
12698 vty_out(vty
, "\n");
12701 vty_out(vty
, " Last read %s",
12702 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12704 vty_out(vty
, ", Last write %s\n",
12705 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12708 /* Configured timer values. */
12710 " Hold time is %d, keepalive interval is %d seconds\n",
12711 p
->v_holdtime
, p
->v_keepalive
);
12712 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12713 vty_out(vty
, " Configured hold time is %d",
12715 vty_out(vty
, ", keepalive interval is %d seconds\n",
12717 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12718 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12719 vty_out(vty
, " Configured hold time is %d",
12720 bgp
->default_holdtime
);
12721 vty_out(vty
, ", keepalive interval is %d seconds\n",
12722 bgp
->default_keepalive
);
12724 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12726 " Configured DelayOpenTime is %d seconds\n",
12729 /* Configured and synced tcp-mss value for peer */
12730 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12731 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12732 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12733 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12736 /* Extended Optional Parameters Length for BGP OPEN Message */
12737 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12739 " Extended Optional Parameters Length is enabled\n");
12741 /* Conditional advertisements */
12743 " Configured conditional advertisements interval is %d seconds\n",
12744 bgp
->condition_check_period
);
12745 if (thread_is_scheduled(bgp
->t_condition_check
))
12747 " Time until conditional advertisements begin is %lu seconds\n",
12748 thread_timer_remain_second(
12749 bgp
->t_condition_check
));
12752 if (peer_established(p
) &&
12753 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12755 json_object
*json_cap
= NULL
;
12757 json_cap
= json_object_new_object();
12760 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12761 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12762 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12763 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12764 json_object_string_add(
12765 json_cap
, "4byteAs",
12766 "advertisedAndReceived");
12767 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12768 json_object_string_add(json_cap
,
12771 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12772 json_object_string_add(json_cap
,
12777 /* Extended Message Support */
12778 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12779 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12780 json_object_string_add(json_cap
,
12782 "advertisedAndReceived");
12783 else if (CHECK_FLAG(p
->cap
,
12784 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12785 json_object_string_add(json_cap
,
12788 else if (CHECK_FLAG(p
->cap
,
12789 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12790 json_object_string_add(json_cap
,
12795 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12796 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12797 json_object
*json_add
= NULL
;
12798 const char *print_store
;
12800 json_add
= json_object_new_object();
12802 FOREACH_AFI_SAFI (afi
, safi
) {
12803 json_object
*json_sub
= NULL
;
12804 json_sub
= json_object_new_object();
12805 print_store
= get_afi_safi_str(
12809 p
->af_cap
[afi
][safi
],
12810 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12812 p
->af_cap
[afi
][safi
],
12813 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12817 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12821 PEER_CAP_ADDPATH_AF_TX_RCV
))
12822 json_object_boolean_true_add(
12824 "txAdvertisedAndReceived");
12829 PEER_CAP_ADDPATH_AF_TX_ADV
))
12830 json_object_boolean_true_add(
12837 PEER_CAP_ADDPATH_AF_TX_RCV
))
12838 json_object_boolean_true_add(
12844 p
->af_cap
[afi
][safi
],
12845 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12847 p
->af_cap
[afi
][safi
],
12848 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12852 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12856 PEER_CAP_ADDPATH_AF_RX_RCV
))
12857 json_object_boolean_true_add(
12859 "rxAdvertisedAndReceived");
12864 PEER_CAP_ADDPATH_AF_RX_ADV
))
12865 json_object_boolean_true_add(
12872 PEER_CAP_ADDPATH_AF_RX_RCV
))
12873 json_object_boolean_true_add(
12879 p
->af_cap
[afi
][safi
],
12880 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12882 p
->af_cap
[afi
][safi
],
12883 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
12885 p
->af_cap
[afi
][safi
],
12886 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12888 p
->af_cap
[afi
][safi
],
12889 PEER_CAP_ADDPATH_AF_RX_RCV
))
12890 json_object_object_add(
12891 json_add
, print_store
,
12894 json_object_free(json_sub
);
12897 json_object_object_add(json_cap
, "addPath",
12902 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
12903 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
12904 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
12905 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
12906 json_object_string_add(
12907 json_cap
, "dynamic",
12908 "advertisedAndReceived");
12909 else if (CHECK_FLAG(p
->cap
,
12910 PEER_CAP_DYNAMIC_ADV
))
12911 json_object_string_add(json_cap
,
12914 else if (CHECK_FLAG(p
->cap
,
12915 PEER_CAP_DYNAMIC_RCV
))
12916 json_object_string_add(json_cap
,
12921 /* Extended nexthop */
12922 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
12923 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12924 json_object
*json_nxt
= NULL
;
12925 const char *print_store
;
12928 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
12929 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12930 json_object_string_add(
12931 json_cap
, "extendedNexthop",
12932 "advertisedAndReceived");
12933 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
12934 json_object_string_add(
12935 json_cap
, "extendedNexthop",
12937 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12938 json_object_string_add(
12939 json_cap
, "extendedNexthop",
12942 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
12943 json_nxt
= json_object_new_object();
12945 for (safi
= SAFI_UNICAST
;
12946 safi
< SAFI_MAX
; safi
++) {
12950 PEER_CAP_ENHE_AF_RCV
)) {
12956 json_object_string_add(
12959 "recieved"); /* misspelled for compatibility */
12962 json_object_object_add(
12964 "extendedNexthopFamililesByPeer",
12969 /* Long-lived Graceful Restart */
12970 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
12971 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
12972 json_object
*json_llgr
= NULL
;
12973 const char *afi_safi_str
;
12975 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
12976 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12977 json_object_string_add(
12979 "longLivedGracefulRestart",
12980 "advertisedAndReceived");
12981 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
12982 json_object_string_add(
12984 "longLivedGracefulRestart",
12986 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12987 json_object_string_add(
12989 "longLivedGracefulRestart",
12992 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
12993 json_llgr
= json_object_new_object();
12995 FOREACH_AFI_SAFI (afi
, safi
) {
12999 PEER_CAP_ENHE_AF_RCV
)) {
13005 json_object_string_add(
13011 json_object_object_add(
13013 "longLivedGracefulRestartByPeer",
13018 /* Route Refresh */
13019 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13020 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13021 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13022 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13023 (CHECK_FLAG(p
->cap
,
13024 PEER_CAP_REFRESH_NEW_RCV
) ||
13026 PEER_CAP_REFRESH_OLD_RCV
))) {
13029 PEER_CAP_REFRESH_OLD_RCV
) &&
13032 PEER_CAP_REFRESH_NEW_RCV
))
13033 json_object_string_add(
13036 "advertisedAndReceivedOldNew");
13040 PEER_CAP_REFRESH_OLD_RCV
))
13041 json_object_string_add(
13044 "advertisedAndReceivedOld");
13046 json_object_string_add(
13049 "advertisedAndReceivedNew");
13051 } else if (CHECK_FLAG(p
->cap
,
13052 PEER_CAP_REFRESH_ADV
))
13053 json_object_string_add(json_cap
,
13056 else if (CHECK_FLAG(p
->cap
,
13057 PEER_CAP_REFRESH_NEW_RCV
) ||
13059 PEER_CAP_REFRESH_OLD_RCV
))
13060 json_object_string_add(json_cap
,
13065 /* Enhanced Route Refresh */
13066 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13067 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13068 if (CHECK_FLAG(p
->cap
,
13069 PEER_CAP_ENHANCED_RR_ADV
) &&
13071 PEER_CAP_ENHANCED_RR_RCV
))
13072 json_object_string_add(
13074 "enhancedRouteRefresh",
13075 "advertisedAndReceived");
13076 else if (CHECK_FLAG(p
->cap
,
13077 PEER_CAP_ENHANCED_RR_ADV
))
13078 json_object_string_add(
13080 "enhancedRouteRefresh",
13082 else if (CHECK_FLAG(p
->cap
,
13083 PEER_CAP_ENHANCED_RR_RCV
))
13084 json_object_string_add(
13086 "enhancedRouteRefresh",
13090 /* Multiprotocol Extensions */
13091 json_object
*json_multi
= NULL
;
13093 json_multi
= json_object_new_object();
13095 FOREACH_AFI_SAFI (afi
, safi
) {
13096 if (p
->afc_adv
[afi
][safi
] ||
13097 p
->afc_recv
[afi
][safi
]) {
13098 json_object
*json_exten
= NULL
;
13099 json_exten
= json_object_new_object();
13101 if (p
->afc_adv
[afi
][safi
] &&
13102 p
->afc_recv
[afi
][safi
])
13103 json_object_boolean_true_add(
13105 "advertisedAndReceived");
13106 else if (p
->afc_adv
[afi
][safi
])
13107 json_object_boolean_true_add(
13110 else if (p
->afc_recv
[afi
][safi
])
13111 json_object_boolean_true_add(
13112 json_exten
, "received");
13114 json_object_object_add(
13116 get_afi_safi_str(afi
, safi
,
13121 json_object_object_add(json_cap
,
13122 "multiprotocolExtensions",
13125 /* Hostname capabilities */
13126 json_object
*json_hname
= NULL
;
13128 json_hname
= json_object_new_object();
13130 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13131 json_object_string_add(
13132 json_hname
, "advHostName",
13133 bgp
->peer_self
->hostname
13134 ? bgp
->peer_self
->hostname
13136 json_object_string_add(
13137 json_hname
, "advDomainName",
13138 bgp
->peer_self
->domainname
13139 ? bgp
->peer_self
->domainname
13144 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13145 json_object_string_add(
13146 json_hname
, "rcvHostName",
13147 p
->hostname
? p
->hostname
: "n/a");
13148 json_object_string_add(
13149 json_hname
, "rcvDomainName",
13150 p
->domainname
? p
->domainname
: "n/a");
13153 json_object_object_add(json_cap
, "hostName",
13156 /* Graceful Restart */
13157 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13158 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13159 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13160 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13161 json_object_string_add(
13162 json_cap
, "gracefulRestart",
13163 "advertisedAndReceived");
13164 else if (CHECK_FLAG(p
->cap
,
13165 PEER_CAP_RESTART_ADV
))
13166 json_object_string_add(
13168 "gracefulRestartCapability",
13170 else if (CHECK_FLAG(p
->cap
,
13171 PEER_CAP_RESTART_RCV
))
13172 json_object_string_add(
13174 "gracefulRestartCapability",
13177 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13178 int restart_af_count
= 0;
13179 json_object
*json_restart
= NULL
;
13180 json_restart
= json_object_new_object();
13182 json_object_int_add(
13184 "gracefulRestartRemoteTimerMsecs",
13185 p
->v_gr_restart
* 1000);
13187 FOREACH_AFI_SAFI (afi
, safi
) {
13191 PEER_CAP_RESTART_AF_RCV
)) {
13192 json_object
*json_sub
=
13195 json_object_new_object();
13201 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13202 json_object_boolean_true_add(
13205 restart_af_count
++;
13206 json_object_object_add(
13215 if (!restart_af_count
) {
13216 json_object_string_add(
13218 "addressFamiliesByPeer",
13220 json_object_free(json_restart
);
13222 json_object_object_add(
13224 "addressFamiliesByPeer",
13228 json_object_object_add(
13229 json_neigh
, "neighborCapabilities", json_cap
);
13231 vty_out(vty
, " Neighbor capabilities:\n");
13234 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13235 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13236 vty_out(vty
, " 4 Byte AS:");
13237 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13238 vty_out(vty
, " advertised");
13239 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13240 vty_out(vty
, " %sreceived",
13245 vty_out(vty
, "\n");
13248 /* Extended Message Support */
13249 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13250 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13251 vty_out(vty
, " Extended Message:");
13252 if (CHECK_FLAG(p
->cap
,
13253 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13254 vty_out(vty
, " advertised");
13255 if (CHECK_FLAG(p
->cap
,
13256 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13257 vty_out(vty
, " %sreceived",
13260 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13263 vty_out(vty
, "\n");
13267 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13268 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13269 vty_out(vty
, " AddPath:\n");
13271 FOREACH_AFI_SAFI (afi
, safi
) {
13273 p
->af_cap
[afi
][safi
],
13274 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13276 p
->af_cap
[afi
][safi
],
13277 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13278 vty_out(vty
, " %s: TX ",
13286 PEER_CAP_ADDPATH_AF_TX_ADV
))
13293 PEER_CAP_ADDPATH_AF_TX_RCV
))
13300 PEER_CAP_ADDPATH_AF_TX_ADV
)
13304 vty_out(vty
, "\n");
13308 p
->af_cap
[afi
][safi
],
13309 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13311 p
->af_cap
[afi
][safi
],
13312 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13313 vty_out(vty
, " %s: RX ",
13321 PEER_CAP_ADDPATH_AF_RX_ADV
))
13328 PEER_CAP_ADDPATH_AF_RX_RCV
))
13335 PEER_CAP_ADDPATH_AF_RX_ADV
)
13339 vty_out(vty
, "\n");
13345 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13346 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13347 vty_out(vty
, " Dynamic:");
13348 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13349 vty_out(vty
, " advertised");
13350 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13351 vty_out(vty
, " %sreceived",
13353 PEER_CAP_DYNAMIC_ADV
)
13356 vty_out(vty
, "\n");
13359 /* Extended nexthop */
13360 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13361 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13362 vty_out(vty
, " Extended nexthop:");
13363 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13364 vty_out(vty
, " advertised");
13365 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13366 vty_out(vty
, " %sreceived",
13371 vty_out(vty
, "\n");
13373 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13375 " Address families by peer:\n ");
13376 for (safi
= SAFI_UNICAST
;
13377 safi
< SAFI_MAX
; safi
++)
13381 PEER_CAP_ENHE_AF_RCV
))
13391 /* Long-lived Graceful Restart */
13392 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13393 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13395 " Long-lived Graceful Restart:");
13396 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13397 vty_out(vty
, " advertised");
13398 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13399 vty_out(vty
, " %sreceived",
13404 vty_out(vty
, "\n");
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13408 " Address families by peer:\n");
13409 FOREACH_AFI_SAFI (afi
, safi
)
13413 PEER_CAP_LLGR_AF_RCV
))
13423 /* Route Refresh */
13424 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13425 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13426 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13427 vty_out(vty
, " Route refresh:");
13428 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13429 vty_out(vty
, " advertised");
13430 if (CHECK_FLAG(p
->cap
,
13431 PEER_CAP_REFRESH_NEW_RCV
) ||
13433 PEER_CAP_REFRESH_OLD_RCV
))
13434 vty_out(vty
, " %sreceived(%s)",
13436 PEER_CAP_REFRESH_ADV
)
13441 PEER_CAP_REFRESH_OLD_RCV
) &&
13444 PEER_CAP_REFRESH_NEW_RCV
))
13448 PEER_CAP_REFRESH_OLD_RCV
)
13452 vty_out(vty
, "\n");
13455 /* Enhanced Route Refresh */
13456 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13457 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13458 vty_out(vty
, " Enhanced Route Refresh:");
13459 if (CHECK_FLAG(p
->cap
,
13460 PEER_CAP_ENHANCED_RR_ADV
))
13461 vty_out(vty
, " advertised");
13462 if (CHECK_FLAG(p
->cap
,
13463 PEER_CAP_ENHANCED_RR_RCV
))
13464 vty_out(vty
, " %sreceived",
13466 PEER_CAP_REFRESH_ADV
)
13469 vty_out(vty
, "\n");
13472 /* Multiprotocol Extensions */
13473 FOREACH_AFI_SAFI (afi
, safi
)
13474 if (p
->afc_adv
[afi
][safi
] ||
13475 p
->afc_recv
[afi
][safi
]) {
13476 vty_out(vty
, " Address Family %s:",
13477 get_afi_safi_str(afi
, safi
,
13479 if (p
->afc_adv
[afi
][safi
])
13480 vty_out(vty
, " advertised");
13481 if (p
->afc_recv
[afi
][safi
])
13482 vty_out(vty
, " %sreceived",
13483 p
->afc_adv
[afi
][safi
]
13486 vty_out(vty
, "\n");
13489 /* Hostname capability */
13490 vty_out(vty
, " Hostname Capability:");
13492 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13494 " advertised (name: %s,domain name: %s)",
13495 bgp
->peer_self
->hostname
13496 ? bgp
->peer_self
->hostname
13498 bgp
->peer_self
->domainname
13499 ? bgp
->peer_self
->domainname
13502 vty_out(vty
, " not advertised");
13505 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13507 " received (name: %s,domain name: %s)",
13508 p
->hostname
? p
->hostname
: "n/a",
13509 p
->domainname
? p
->domainname
: "n/a");
13511 vty_out(vty
, " not received");
13514 vty_out(vty
, "\n");
13516 /* Graceful Restart */
13517 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13518 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13520 " Graceful Restart Capability:");
13521 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13522 vty_out(vty
, " advertised");
13523 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13524 vty_out(vty
, " %sreceived",
13526 PEER_CAP_RESTART_ADV
)
13529 vty_out(vty
, "\n");
13531 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13532 int restart_af_count
= 0;
13535 " Remote Restart timer is %d seconds\n",
13538 " Address families by peer:\n ");
13540 FOREACH_AFI_SAFI (afi
, safi
)
13544 PEER_CAP_RESTART_AF_RCV
)) {
13545 vty_out(vty
, "%s%s(%s)",
13557 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13559 : "not preserved");
13560 restart_af_count
++;
13562 if (!restart_af_count
)
13563 vty_out(vty
, "none");
13564 vty_out(vty
, "\n");
13566 } /* Graceful Restart */
13570 /* graceful restart information */
13571 json_object
*json_grace
= NULL
;
13572 json_object
*json_grace_send
= NULL
;
13573 json_object
*json_grace_recv
= NULL
;
13574 int eor_send_af_count
= 0;
13575 int eor_receive_af_count
= 0;
13578 json_grace
= json_object_new_object();
13579 json_grace_send
= json_object_new_object();
13580 json_grace_recv
= json_object_new_object();
13582 if ((peer_established(p
)) &&
13583 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13584 FOREACH_AFI_SAFI (afi
, safi
) {
13585 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13586 PEER_STATUS_EOR_SEND
)) {
13587 json_object_boolean_true_add(
13589 get_afi_safi_str(afi
, safi
,
13591 eor_send_af_count
++;
13594 FOREACH_AFI_SAFI (afi
, safi
) {
13595 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13596 PEER_STATUS_EOR_RECEIVED
)) {
13597 json_object_boolean_true_add(
13599 get_afi_safi_str(afi
, safi
,
13601 eor_receive_af_count
++;
13605 json_object_object_add(json_grace
, "endOfRibSend",
13607 json_object_object_add(json_grace
, "endOfRibRecv",
13611 if (p
->t_gr_restart
)
13612 json_object_int_add(
13613 json_grace
, "gracefulRestartTimerMsecs",
13614 thread_timer_remain_second(p
->t_gr_restart
) *
13618 json_object_int_add(
13619 json_grace
, "gracefulStalepathTimerMsecs",
13620 thread_timer_remain_second(p
->t_gr_stale
) *
13622 /* more gr info in new format */
13623 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13624 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13627 vty_out(vty
, " Graceful restart information:\n");
13628 if ((peer_established(p
)) &&
13629 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13631 vty_out(vty
, " End-of-RIB send: ");
13632 FOREACH_AFI_SAFI (afi
, safi
) {
13633 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13634 PEER_STATUS_EOR_SEND
)) {
13635 vty_out(vty
, "%s%s",
13636 eor_send_af_count
? ", " : "",
13637 get_afi_safi_str(afi
, safi
,
13639 eor_send_af_count
++;
13642 vty_out(vty
, "\n");
13643 vty_out(vty
, " End-of-RIB received: ");
13644 FOREACH_AFI_SAFI (afi
, safi
) {
13645 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13646 PEER_STATUS_EOR_RECEIVED
)) {
13647 vty_out(vty
, "%s%s",
13648 eor_receive_af_count
? ", "
13650 get_afi_safi_str(afi
, safi
,
13652 eor_receive_af_count
++;
13655 vty_out(vty
, "\n");
13658 if (p
->t_gr_restart
)
13660 " The remaining time of restart timer is %ld\n",
13661 thread_timer_remain_second(p
->t_gr_restart
));
13665 " The remaining time of stalepath timer is %ld\n",
13666 thread_timer_remain_second(p
->t_gr_stale
));
13668 /* more gr info in new format */
13669 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13673 json_object
*json_stat
= NULL
;
13674 json_stat
= json_object_new_object();
13675 /* Packet counts. */
13677 atomic_size_t outq_count
, inq_count
;
13678 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13679 memory_order_relaxed
);
13680 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13681 memory_order_relaxed
);
13683 json_object_int_add(json_stat
, "depthInq",
13684 (unsigned long)inq_count
);
13685 json_object_int_add(json_stat
, "depthOutq",
13686 (unsigned long)outq_count
);
13687 json_object_int_add(json_stat
, "opensSent",
13688 atomic_load_explicit(&p
->open_out
,
13689 memory_order_relaxed
));
13690 json_object_int_add(json_stat
, "opensRecv",
13691 atomic_load_explicit(&p
->open_in
,
13692 memory_order_relaxed
));
13693 json_object_int_add(json_stat
, "notificationsSent",
13694 atomic_load_explicit(&p
->notify_out
,
13695 memory_order_relaxed
));
13696 json_object_int_add(json_stat
, "notificationsRecv",
13697 atomic_load_explicit(&p
->notify_in
,
13698 memory_order_relaxed
));
13699 json_object_int_add(json_stat
, "updatesSent",
13700 atomic_load_explicit(&p
->update_out
,
13701 memory_order_relaxed
));
13702 json_object_int_add(json_stat
, "updatesRecv",
13703 atomic_load_explicit(&p
->update_in
,
13704 memory_order_relaxed
));
13705 json_object_int_add(json_stat
, "keepalivesSent",
13706 atomic_load_explicit(&p
->keepalive_out
,
13707 memory_order_relaxed
));
13708 json_object_int_add(json_stat
, "keepalivesRecv",
13709 atomic_load_explicit(&p
->keepalive_in
,
13710 memory_order_relaxed
));
13711 json_object_int_add(json_stat
, "routeRefreshSent",
13712 atomic_load_explicit(&p
->refresh_out
,
13713 memory_order_relaxed
));
13714 json_object_int_add(json_stat
, "routeRefreshRecv",
13715 atomic_load_explicit(&p
->refresh_in
,
13716 memory_order_relaxed
));
13717 json_object_int_add(json_stat
, "capabilitySent",
13718 atomic_load_explicit(&p
->dynamic_cap_out
,
13719 memory_order_relaxed
));
13720 json_object_int_add(json_stat
, "capabilityRecv",
13721 atomic_load_explicit(&p
->dynamic_cap_in
,
13722 memory_order_relaxed
));
13723 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13724 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13725 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13727 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13728 notify_out
, notify_in
, update_out
, update_in
,
13729 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13730 dynamic_cap_out
, dynamic_cap_in
;
13731 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13732 memory_order_relaxed
);
13733 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13734 memory_order_relaxed
);
13735 open_out
= atomic_load_explicit(&p
->open_out
,
13736 memory_order_relaxed
);
13738 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13739 notify_out
= atomic_load_explicit(&p
->notify_out
,
13740 memory_order_relaxed
);
13741 notify_in
= atomic_load_explicit(&p
->notify_in
,
13742 memory_order_relaxed
);
13743 update_out
= atomic_load_explicit(&p
->update_out
,
13744 memory_order_relaxed
);
13745 update_in
= atomic_load_explicit(&p
->update_in
,
13746 memory_order_relaxed
);
13747 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13748 memory_order_relaxed
);
13749 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13750 memory_order_relaxed
);
13751 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13752 memory_order_relaxed
);
13753 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13754 memory_order_relaxed
);
13755 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13756 memory_order_relaxed
);
13757 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13758 memory_order_relaxed
);
13760 /* Packet counts. */
13761 vty_out(vty
, " Message statistics:\n");
13762 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13763 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13764 vty_out(vty
, " Sent Rcvd\n");
13765 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13767 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13769 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13771 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13773 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13775 vty_out(vty
, " Capability: %10zu %10zu\n",
13776 dynamic_cap_out
, dynamic_cap_in
);
13777 vty_out(vty
, " Total: %10u %10u\n",
13778 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13782 /* advertisement-interval */
13783 json_object_int_add(json_neigh
,
13784 "minBtwnAdvertisementRunsTimerMsecs",
13785 p
->v_routeadv
* 1000);
13787 /* Update-source. */
13788 if (p
->update_if
|| p
->update_source
) {
13790 json_object_string_add(json_neigh
,
13793 else if (p
->update_source
)
13794 json_object_string_add(
13795 json_neigh
, "updateSource",
13796 sockunion2str(p
->update_source
, buf1
,
13800 /* advertisement-interval */
13802 " Minimum time between advertisement runs is %d seconds\n",
13805 /* Update-source. */
13806 if (p
->update_if
|| p
->update_source
) {
13807 vty_out(vty
, " Update source is ");
13809 vty_out(vty
, "%s", p
->update_if
);
13810 else if (p
->update_source
)
13812 sockunion2str(p
->update_source
, buf1
,
13814 vty_out(vty
, "\n");
13817 vty_out(vty
, "\n");
13820 /* Address Family Information */
13821 json_object
*json_hold
= NULL
;
13824 json_hold
= json_object_new_object();
13826 FOREACH_AFI_SAFI (afi
, safi
)
13827 if (p
->afc
[afi
][safi
])
13828 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13832 json_object_object_add(json_neigh
, "addressFamilyInfo",
13834 json_object_int_add(json_neigh
, "connectionsEstablished",
13836 json_object_int_add(json_neigh
, "connectionsDropped",
13839 vty_out(vty
, " Connections established %d; dropped %d\n",
13840 p
->established
, p
->dropped
);
13842 if (!p
->last_reset
) {
13844 json_object_string_add(json_neigh
, "lastReset",
13847 vty_out(vty
, " Last reset never\n");
13853 uptime
= bgp_clock();
13854 uptime
-= p
->resettime
;
13855 gmtime_r(&uptime
, &tm
);
13857 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13859 + (tm
.tm_min
* 60000)
13860 + (tm
.tm_hour
* 3600000));
13861 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13863 vty_out(vty
, " Last reset %s, ",
13864 peer_uptime(p
->resettime
, timebuf
,
13865 BGP_UPTIME_LEN
, 0, NULL
));
13867 bgp_show_peer_reset(vty
, p
, NULL
, false);
13868 if (p
->last_reset_cause_size
) {
13869 msg
= p
->last_reset_cause
;
13871 " Message received that caused BGP to send a NOTIFICATION:\n ");
13872 for (i
= 1; i
<= p
->last_reset_cause_size
;
13874 vty_out(vty
, "%02X", *msg
++);
13876 if (i
!= p
->last_reset_cause_size
) {
13878 vty_out(vty
, "\n ");
13879 } else if (i
% 4 == 0) {
13884 vty_out(vty
, "\n");
13889 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13891 json_object_boolean_true_add(json_neigh
,
13892 "prefixesConfigExceedMax");
13895 " Peer had exceeded the max. no. of prefixes configured.\n");
13897 if (p
->t_pmax_restart
) {
13899 json_object_boolean_true_add(
13900 json_neigh
, "reducePrefixNumFrom");
13901 json_object_int_add(json_neigh
,
13902 "restartInTimerMsec",
13903 thread_timer_remain_second(
13908 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13909 p
->host
, thread_timer_remain_second(
13910 p
->t_pmax_restart
));
13913 json_object_boolean_true_add(
13915 "reducePrefixNumAndClearIpBgp");
13918 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13923 /* EBGP Multihop and GTSM */
13924 if (p
->sort
!= BGP_PEER_IBGP
) {
13926 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13927 json_object_int_add(json_neigh
,
13928 "externalBgpNbrMaxHopsAway",
13930 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13931 json_object_int_add(json_neigh
,
13932 "externalBgpNbrMaxHopsAway",
13935 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13937 " External BGP neighbor may be up to %d hops away.\n",
13939 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13941 " External BGP neighbor may be up to %d hops away.\n",
13945 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13947 json_object_int_add(json_neigh
,
13948 "internalBgpNbrMaxHopsAway",
13952 " Internal BGP neighbor may be up to %d hops away.\n",
13957 /* Local address. */
13960 json_object_string_add(json_neigh
, "hostLocal",
13961 sockunion2str(p
->su_local
, buf1
,
13963 json_object_int_add(json_neigh
, "portLocal",
13964 ntohs(p
->su_local
->sin
.sin_port
));
13966 vty_out(vty
, "Local host: %s, Local port: %d\n",
13967 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13968 ntohs(p
->su_local
->sin
.sin_port
));
13971 /* Remote address. */
13972 if (p
->su_remote
) {
13974 json_object_string_add(json_neigh
, "hostForeign",
13975 sockunion2str(p
->su_remote
, buf1
,
13977 json_object_int_add(json_neigh
, "portForeign",
13978 ntohs(p
->su_remote
->sin
.sin_port
));
13980 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13981 sockunion2str(p
->su_remote
, buf1
,
13983 ntohs(p
->su_remote
->sin
.sin_port
));
13986 /* Nexthop display. */
13989 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
13991 json_object_string_addf(json_neigh
, "nexthopGlobal",
13992 "%pI6", &p
->nexthop
.v6_global
);
13993 json_object_string_addf(json_neigh
, "nexthopLocal",
13994 "%pI6", &p
->nexthop
.v6_local
);
13995 if (p
->shared_network
)
13996 json_object_string_add(json_neigh
,
14000 json_object_string_add(json_neigh
,
14002 "nonSharedNetwork");
14004 vty_out(vty
, "Nexthop: %s\n",
14005 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14007 vty_out(vty
, "Nexthop global: %s\n",
14008 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14010 vty_out(vty
, "Nexthop local: %s\n",
14011 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14013 vty_out(vty
, "BGP connection: %s\n",
14014 p
->shared_network
? "shared network"
14015 : "non shared network");
14019 /* Timer information. */
14021 json_object_int_add(json_neigh
, "connectRetryTimer",
14023 if (peer_established(p
) && p
->rtt
)
14024 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14027 json_object_int_add(
14028 json_neigh
, "nextStartTimerDueInMsecs",
14029 thread_timer_remain_second(p
->t_start
) * 1000);
14031 json_object_int_add(
14032 json_neigh
, "nextConnectTimerDueInMsecs",
14033 thread_timer_remain_second(p
->t_connect
)
14035 if (p
->t_routeadv
) {
14036 json_object_int_add(json_neigh
, "mraiInterval",
14038 json_object_int_add(
14039 json_neigh
, "mraiTimerExpireInMsecs",
14040 thread_timer_remain_second(p
->t_routeadv
)
14044 json_object_int_add(json_neigh
, "authenticationEnabled",
14048 json_object_string_add(json_neigh
, "readThread", "on");
14050 json_object_string_add(json_neigh
, "readThread", "off");
14052 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14053 json_object_string_add(json_neigh
, "writeThread", "on");
14055 json_object_string_add(json_neigh
, "writeThread",
14058 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14060 if (peer_established(p
) && p
->rtt
)
14061 vty_out(vty
, "Estimated round trip time: %d ms\n",
14064 vty_out(vty
, "Next start timer due in %ld seconds\n",
14065 thread_timer_remain_second(p
->t_start
));
14067 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14068 thread_timer_remain_second(p
->t_connect
));
14071 "MRAI (interval %u) timer expires in %ld seconds\n",
14073 thread_timer_remain_second(p
->t_routeadv
));
14075 vty_out(vty
, "Peer Authentication Enabled\n");
14077 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14078 p
->t_read
? "on" : "off",
14079 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14084 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14085 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14086 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14089 vty_out(vty
, "\n");
14091 /* BFD information. */
14093 bgp_bfd_show_info(vty
, p
, json_neigh
);
14096 if (p
->conf_if
) /* Configured interface name. */
14097 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14098 else /* Configured IP address. */
14099 json_object_object_add(json
, p
->host
, json_neigh
);
14103 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14104 enum show_type type
,
14105 union sockunion
*su
,
14106 const char *conf_if
, afi_t afi
,
14109 struct listnode
*node
, *nnode
;
14112 safi_t safi
= SAFI_UNICAST
;
14113 json_object
*json
= NULL
;
14114 json_object
*json_neighbor
= NULL
;
14117 json
= json_object_new_object();
14118 json_neighbor
= json_object_new_object();
14121 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14123 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14126 if ((peer
->afc
[afi
][safi
]) == 0)
14129 if (type
== show_all
) {
14130 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14134 json_object_object_add(json
, peer
->host
,
14136 json_neighbor
= NULL
;
14139 } else if (type
== show_peer
) {
14142 && !strcmp(peer
->conf_if
, conf_if
))
14144 && !strcmp(peer
->hostname
, conf_if
))) {
14146 bgp_show_peer_gr_status(vty
, peer
,
14151 if (sockunion_same(&peer
->su
, su
)) {
14153 bgp_show_peer_gr_status(vty
, peer
,
14158 if (use_json
&& find
)
14159 json_object_object_add(json
, peer
->host
,
14164 json_neighbor
= NULL
;
14169 if (type
== show_peer
&& !find
) {
14171 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14173 vty_out(vty
, "%% No such neighbor\n");
14177 json_object_free(json_neighbor
);
14178 vty_json(vty
, json
);
14180 vty_out(vty
, "\n");
14183 return CMD_SUCCESS
;
14186 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14187 enum show_type type
, union sockunion
*su
,
14188 const char *conf_if
, bool use_json
,
14191 struct listnode
*node
, *nnode
;
14194 bool nbr_output
= false;
14195 afi_t afi
= AFI_MAX
;
14196 safi_t safi
= SAFI_MAX
;
14198 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14200 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14204 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14205 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14210 bgp_show_peer(vty
, peer
, use_json
, json
);
14216 && !strcmp(peer
->conf_if
, conf_if
))
14218 && !strcmp(peer
->hostname
, conf_if
))) {
14220 bgp_show_peer(vty
, peer
, use_json
,
14224 if (sockunion_same(&peer
->su
, su
)) {
14226 bgp_show_peer(vty
, peer
, use_json
,
14231 case show_ipv4_peer
:
14232 case show_ipv6_peer
:
14233 FOREACH_SAFI (safi
) {
14234 if (peer
->afc
[afi
][safi
]) {
14237 && !strcmp(peer
->conf_if
, conf_if
))
14239 && !strcmp(peer
->hostname
, conf_if
))) {
14241 bgp_show_peer(vty
, peer
, use_json
,
14246 if (sockunion_same(&peer
->su
, su
)) {
14248 bgp_show_peer(vty
, peer
, use_json
,
14256 case show_ipv4_all
:
14257 case show_ipv6_all
:
14258 FOREACH_SAFI (safi
) {
14259 if (peer
->afc
[afi
][safi
]) {
14260 bgp_show_peer(vty
, peer
, use_json
, json
);
14269 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14270 type
== show_ipv6_peer
) && !find
) {
14272 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14274 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14277 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14278 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14279 vty_out(vty
, "%% No BGP neighbors found\n");
14282 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14283 json
, JSON_C_TO_STRING_PRETTY
));
14285 vty_out(vty
, "\n");
14288 return CMD_SUCCESS
;
14291 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14292 enum show_type type
,
14293 const char *ip_str
,
14294 afi_t afi
, bool use_json
)
14299 union sockunion su
;
14301 bgp
= bgp_get_default();
14307 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14311 ret
= str2sockunion(ip_str
, &su
);
14313 bgp_show_neighbor_graceful_restart(
14314 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14316 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14317 NULL
, afi
, use_json
);
14319 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14323 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14324 enum show_type type
,
14325 const char *ip_str
,
14328 struct listnode
*node
, *nnode
;
14330 union sockunion su
;
14331 json_object
*json
= NULL
;
14332 int ret
, is_first
= 1;
14333 bool nbr_output
= false;
14336 vty_out(vty
, "{\n");
14338 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14341 if (!(json
= json_object_new_object())) {
14343 EC_BGP_JSON_MEM_ERROR
,
14344 "Unable to allocate memory for JSON object");
14346 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14350 json_object_int_add(json
, "vrfId",
14351 (bgp
->vrf_id
== VRF_UNKNOWN
)
14353 : (int64_t)bgp
->vrf_id
);
14354 json_object_string_add(
14356 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14361 vty_out(vty
, ",\n");
14365 vty_out(vty
, "\"%s\":",
14366 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14370 vty_out(vty
, "\nInstance %s:\n",
14371 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14376 if (type
== show_peer
|| type
== show_ipv4_peer
||
14377 type
== show_ipv6_peer
) {
14378 ret
= str2sockunion(ip_str
, &su
);
14380 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14383 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14386 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14389 json_object_free(json
);
14394 vty_out(vty
, "}\n");
14395 else if (!nbr_output
)
14396 vty_out(vty
, "%% BGP instance not found\n");
14399 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14400 enum show_type type
, const char *ip_str
,
14405 union sockunion su
;
14406 json_object
*json
= NULL
;
14409 if (strmatch(name
, "all")) {
14410 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14412 return CMD_SUCCESS
;
14414 bgp
= bgp_lookup_by_name(name
);
14417 json
= json_object_new_object();
14418 vty_json(vty
, json
);
14421 "%% BGP instance not found\n");
14423 return CMD_WARNING
;
14427 bgp
= bgp_get_default();
14431 json
= json_object_new_object();
14433 ret
= str2sockunion(ip_str
, &su
);
14435 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14438 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14441 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14444 json_object_free(json
);
14447 vty_out(vty
, "{}\n");
14449 vty_out(vty
, "%% BGP instance not found\n");
14452 return CMD_SUCCESS
;
14457 /* "show [ip] bgp neighbors graceful-restart" commands. */
14458 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14459 show_ip_bgp_neighbors_graceful_restart_cmd
,
14460 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14466 "Neighbor to display information about\n"
14467 "Neighbor to display information about\n"
14468 "Neighbor on BGP configured interface\n"
14472 char *sh_arg
= NULL
;
14473 enum show_type sh_type
;
14475 afi_t afi
= AFI_MAX
;
14476 bool uj
= use_json(argc
, argv
);
14478 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14483 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14484 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14485 || argv_find(argv
, argc
, "WORD", &idx
)) {
14486 sh_type
= show_peer
;
14487 sh_arg
= argv
[idx
]->arg
;
14489 sh_type
= show_all
;
14491 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14492 return CMD_SUCCESS
;
14495 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14499 /* "show [ip] bgp neighbors" commands. */
14500 DEFUN (show_ip_bgp_neighbors
,
14501 show_ip_bgp_neighbors_cmd
,
14502 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14506 BGP_INSTANCE_HELP_STR
14509 "Detailed information on TCP and BGP neighbor connections\n"
14510 "Neighbor to display information about\n"
14511 "Neighbor to display information about\n"
14512 "Neighbor on BGP configured interface\n"
14516 char *sh_arg
= NULL
;
14517 enum show_type sh_type
;
14518 afi_t afi
= AFI_MAX
;
14520 bool uj
= use_json(argc
, argv
);
14524 /* [<vrf> VIEWVRFNAME] */
14525 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14526 vrf
= argv
[idx
+ 1]->arg
;
14527 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14529 } else if (argv_find(argv
, argc
, "view", &idx
))
14530 /* [<view> VIEWVRFNAME] */
14531 vrf
= argv
[idx
+ 1]->arg
;
14535 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14536 sh_type
= show_ipv4_all
;
14538 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14539 sh_type
= show_ipv6_all
;
14542 sh_type
= show_all
;
14545 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14546 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14547 || argv_find(argv
, argc
, "WORD", &idx
)) {
14548 sh_type
= show_peer
;
14549 sh_arg
= argv
[idx
]->arg
;
14552 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14553 sh_type
= show_ipv4_peer
;
14554 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14555 sh_type
= show_ipv6_peer
;
14558 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14561 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14562 paths' and `show ip mbgp paths'. Those functions results are the
14564 DEFUN (show_ip_bgp_paths
,
14565 show_ip_bgp_paths_cmd
,
14566 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14571 "Path information\n")
14573 vty_out(vty
, "Address Refcnt Path\n");
14574 aspath_print_all_vty(vty
);
14575 return CMD_SUCCESS
;
14580 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14583 struct community
*com
;
14585 com
= (struct community
*)bucket
->data
;
14586 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14587 community_str(com
, false, false));
14590 /* Show BGP's community internal data. */
14591 DEFUN (show_ip_bgp_community_info
,
14592 show_ip_bgp_community_info_cmd
,
14593 "show [ip] bgp community-info",
14597 "List all bgp community information\n")
14599 vty_out(vty
, "Address Refcnt Community\n");
14601 hash_iterate(community_hash(),
14602 (void (*)(struct hash_bucket
*,
14603 void *))community_show_all_iterator
,
14606 return CMD_SUCCESS
;
14609 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14612 struct lcommunity
*lcom
;
14614 lcom
= (struct lcommunity
*)bucket
->data
;
14615 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14616 lcommunity_str(lcom
, false, false));
14619 /* Show BGP's community internal data. */
14620 DEFUN (show_ip_bgp_lcommunity_info
,
14621 show_ip_bgp_lcommunity_info_cmd
,
14622 "show ip bgp large-community-info",
14626 "List all bgp large-community information\n")
14628 vty_out(vty
, "Address Refcnt Large-community\n");
14630 hash_iterate(lcommunity_hash(),
14631 (void (*)(struct hash_bucket
*,
14632 void *))lcommunity_show_all_iterator
,
14635 return CMD_SUCCESS
;
14637 /* Graceful Restart */
14639 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14646 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14648 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14650 switch (bgp_global_gr_mode
) {
14652 case GLOBAL_HELPER
:
14653 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14657 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14660 case GLOBAL_DISABLE
:
14661 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14664 case GLOBAL_INVALID
:
14666 "Global BGP GR Mode Invalid\n");
14669 vty_out(vty
, "\n");
14672 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14673 enum show_type type
,
14674 const char *ip_str
,
14675 afi_t afi
, bool use_json
)
14677 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14680 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14682 bgp_show_neighbor_graceful_restart_vty(
14683 vty
, type
, ip_str
, afi
, use_json
);
14686 } else if (afi
!= AFI_MAX
) {
14687 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14690 return CMD_ERR_INCOMPLETE
;
14693 return CMD_SUCCESS
;
14695 /* Graceful Restart */
14697 DEFUN (show_ip_bgp_attr_info
,
14698 show_ip_bgp_attr_info_cmd
,
14699 "show [ip] bgp attribute-info",
14703 "List all bgp attribute information\n")
14705 attr_show_all(vty
);
14706 return CMD_SUCCESS
;
14709 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14710 afi_t afi
, safi_t safi
,
14711 bool use_json
, json_object
*json
)
14714 struct listnode
*node
;
14716 char buf1
[INET6_ADDRSTRLEN
];
14718 enum vpn_policy_direction dir
;
14721 json_object
*json_import_vrfs
= NULL
;
14722 json_object
*json_export_vrfs
= NULL
;
14724 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14727 vty_json(vty
, json
);
14729 return CMD_WARNING
;
14732 /* Provide context for the block */
14733 json_object_string_add(json
, "vrf", name
? name
: "default");
14734 json_object_string_add(json
, "afiSafi",
14735 get_afi_safi_str(afi
, safi
, true));
14737 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14738 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14739 json_object_string_add(json
, "importFromVrfs", "none");
14740 json_object_string_add(json
, "importRts", "none");
14742 json_import_vrfs
= json_object_new_array();
14744 for (ALL_LIST_ELEMENTS_RO(
14745 bgp
->vpn_policy
[afi
].import_vrf
,
14747 json_object_array_add(json_import_vrfs
,
14748 json_object_new_string(vname
));
14750 json_object_object_add(json
, "importFromVrfs",
14752 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14753 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14754 ecom_str
= ecommunity_ecom2str(
14755 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14756 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14757 json_object_string_add(json
, "importRts",
14759 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14761 json_object_string_add(json
, "importRts",
14765 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14766 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14767 json_object_string_add(json
, "exportToVrfs", "none");
14768 json_object_string_add(json
, "routeDistinguisher",
14770 json_object_string_add(json
, "exportRts", "none");
14772 json_export_vrfs
= json_object_new_array();
14774 for (ALL_LIST_ELEMENTS_RO(
14775 bgp
->vpn_policy
[afi
].export_vrf
,
14777 json_object_array_add(json_export_vrfs
,
14778 json_object_new_string(vname
));
14779 json_object_object_add(json
, "exportToVrfs",
14781 json_object_string_add(json
, "routeDistinguisher",
14782 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14783 buf1
, RD_ADDRSTRLEN
));
14785 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14786 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14787 ecom_str
= ecommunity_ecom2str(
14788 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14789 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14790 json_object_string_add(json
, "exportRts",
14792 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14794 json_object_string_add(json
, "exportRts",
14799 vty_json(vty
, json
);
14802 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14805 vty_out(vty
, "%% No such BGP instance exist\n");
14806 return CMD_WARNING
;
14809 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14810 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14812 "This VRF is not importing %s routes from any other VRF\n",
14813 get_afi_safi_str(afi
, safi
, false));
14816 "This VRF is importing %s routes from the following VRFs:\n",
14817 get_afi_safi_str(afi
, safi
, false));
14819 for (ALL_LIST_ELEMENTS_RO(
14820 bgp
->vpn_policy
[afi
].import_vrf
,
14822 vty_out(vty
, " %s\n", vname
);
14824 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14826 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14827 ecom_str
= ecommunity_ecom2str(
14828 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14829 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14830 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14832 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14834 vty_out(vty
, "Import RT(s):\n");
14837 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14838 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14840 "This VRF is not exporting %s routes to any other VRF\n",
14841 get_afi_safi_str(afi
, safi
, false));
14844 "This VRF is exporting %s routes to the following VRFs:\n",
14845 get_afi_safi_str(afi
, safi
, false));
14847 for (ALL_LIST_ELEMENTS_RO(
14848 bgp
->vpn_policy
[afi
].export_vrf
,
14850 vty_out(vty
, " %s\n", vname
);
14852 vty_out(vty
, "RD: %s\n",
14853 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14854 buf1
, RD_ADDRSTRLEN
));
14856 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14857 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14858 ecom_str
= ecommunity_ecom2str(
14859 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14860 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14861 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14862 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14864 vty_out(vty
, "Import RT(s):\n");
14868 return CMD_SUCCESS
;
14871 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14872 safi_t safi
, bool use_json
)
14874 struct listnode
*node
, *nnode
;
14876 char *vrf_name
= NULL
;
14877 json_object
*json
= NULL
;
14878 json_object
*json_vrf
= NULL
;
14879 json_object
*json_vrfs
= NULL
;
14882 json
= json_object_new_object();
14883 json_vrfs
= json_object_new_object();
14886 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14888 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14889 vrf_name
= bgp
->name
;
14892 json_vrf
= json_object_new_object();
14894 vty_out(vty
, "\nInstance %s:\n",
14895 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14896 ? VRF_DEFAULT_NAME
: bgp
->name
);
14898 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14900 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14901 json_object_object_add(json_vrfs
,
14902 VRF_DEFAULT_NAME
, json_vrf
);
14904 json_object_object_add(json_vrfs
, vrf_name
,
14910 json_object_object_add(json
, "vrfs", json_vrfs
);
14911 vty_json(vty
, json
);
14914 return CMD_SUCCESS
;
14917 /* "show [ip] bgp route-leak" command. */
14918 DEFUN (show_ip_bgp_route_leak
,
14919 show_ip_bgp_route_leak_cmd
,
14920 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14924 BGP_INSTANCE_HELP_STR
14927 "Route leaking information\n"
14931 afi_t afi
= AFI_MAX
;
14932 safi_t safi
= SAFI_MAX
;
14934 bool uj
= use_json(argc
, argv
);
14936 json_object
*json
= NULL
;
14938 /* show [ip] bgp */
14939 if (argv_find(argv
, argc
, "ip", &idx
)) {
14941 safi
= SAFI_UNICAST
;
14943 /* [vrf VIEWVRFNAME] */
14944 if (argv_find(argv
, argc
, "view", &idx
)) {
14946 "%% This command is not applicable to BGP views\n");
14947 return CMD_WARNING
;
14950 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14951 vrf
= argv
[idx
+ 1]->arg
;
14952 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14955 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14956 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14957 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14959 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14961 "%% This command is applicable only for unicast ipv4|ipv6\n");
14962 return CMD_WARNING
;
14965 if (vrf
&& strmatch(vrf
, "all"))
14966 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14969 json
= json_object_new_object();
14971 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14974 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14977 struct listnode
*node
, *nnode
;
14980 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14981 vty_out(vty
, "\nInstance %s:\n",
14982 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14985 update_group_show(bgp
, afi
, safi
, vty
, 0);
14989 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14990 int safi
, uint64_t subgrp_id
)
14995 if (strmatch(name
, "all")) {
14996 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14997 return CMD_SUCCESS
;
14999 bgp
= bgp_lookup_by_name(name
);
15002 bgp
= bgp_get_default();
15006 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15007 return CMD_SUCCESS
;
15010 DEFUN (show_ip_bgp_updgrps
,
15011 show_ip_bgp_updgrps_cmd
,
15012 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15016 BGP_INSTANCE_HELP_STR
15018 BGP_SAFI_WITH_LABEL_HELP_STR
15019 "Detailed info about dynamic update groups\n"
15020 "Specific subgroup to display detailed info for\n")
15023 afi_t afi
= AFI_IP6
;
15024 safi_t safi
= SAFI_UNICAST
;
15025 uint64_t subgrp_id
= 0;
15029 /* show [ip] bgp */
15030 if (argv_find(argv
, argc
, "ip", &idx
))
15032 /* [<vrf> VIEWVRFNAME] */
15033 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15034 vrf
= argv
[idx
+ 1]->arg
;
15035 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15037 } else if (argv_find(argv
, argc
, "view", &idx
))
15038 /* [<view> VIEWVRFNAME] */
15039 vrf
= argv
[idx
+ 1]->arg
;
15040 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15041 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15042 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15045 /* get subgroup id, if provided */
15047 if (argv
[idx
]->type
== VARIABLE_TKN
)
15048 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15050 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15053 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15054 show_bgp_instance_all_ipv6_updgrps_cmd
,
15055 "show [ip] bgp <view|vrf> all update-groups",
15059 BGP_INSTANCE_ALL_HELP_STR
15060 "Detailed info about dynamic update groups\n")
15062 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15063 return CMD_SUCCESS
;
15066 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15067 show_bgp_l2vpn_evpn_updgrps_cmd
,
15068 "show [ip] bgp l2vpn evpn update-groups",
15072 "l2vpn address family\n"
15073 "evpn sub-address family\n"
15074 "Detailed info about dynamic update groups\n")
15077 uint64_t subgrp_id
= 0;
15079 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15080 return CMD_SUCCESS
;
15083 DEFUN (show_bgp_updgrps_stats
,
15084 show_bgp_updgrps_stats_cmd
,
15085 "show [ip] bgp update-groups statistics",
15089 "Detailed info about dynamic update groups\n"
15094 bgp
= bgp_get_default();
15096 update_group_show_stats(bgp
, vty
);
15098 return CMD_SUCCESS
;
15101 DEFUN (show_bgp_instance_updgrps_stats
,
15102 show_bgp_instance_updgrps_stats_cmd
,
15103 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15107 BGP_INSTANCE_HELP_STR
15108 "Detailed info about dynamic update groups\n"
15114 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15116 update_group_show_stats(bgp
, vty
);
15118 return CMD_SUCCESS
;
15121 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15122 afi_t afi
, safi_t safi
,
15123 const char *what
, uint64_t subgrp_id
)
15128 bgp
= bgp_lookup_by_name(name
);
15130 bgp
= bgp_get_default();
15133 if (!strcmp(what
, "advertise-queue"))
15134 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15136 else if (!strcmp(what
, "advertised-routes"))
15137 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15139 else if (!strcmp(what
, "packet-queue"))
15140 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15145 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15146 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15147 "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",
15148 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15150 "Detailed info about dynamic update groups\n"
15151 "Specific subgroup to display info for\n"
15152 "Advertisement queue\n"
15153 "Announced routes\n"
15156 uint64_t subgrp_id
= 0;
15160 subgrp_id
= strtoull(sgid
, NULL
, 10);
15165 afiz
= bgp_vty_afi_from_str(afi
);
15169 afiz
= bgp_vty_afi_from_str(afi
);
15170 if (afiz
!= AFI_IP
)
15172 "%% Cannot specify both 'ip' and 'ipv6'\n");
15173 return CMD_WARNING
;
15176 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15178 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15179 return CMD_SUCCESS
;
15182 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15185 struct listnode
*node
, *nnode
;
15186 struct prefix
*range
;
15191 const char *peer_status
;
15195 json_object
*json_peer_group
= NULL
;
15196 json_object
*json_peer_group_afc
= NULL
;
15197 json_object
*json_peer_group_members
= NULL
;
15198 json_object
*json_peer_group_dynamic
= NULL
;
15199 json_object
*json_peer_group_dynamic_af
= NULL
;
15200 json_object
*json_peer_group_ranges
= NULL
;
15202 conf
= group
->conf
;
15205 json_peer_group
= json_object_new_object();
15206 json_peer_group_afc
= json_object_new_array();
15209 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15211 json_object_int_add(json_peer_group
, "remoteAs",
15214 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15215 group
->name
, conf
->as
);
15216 } else if (conf
->as_type
== AS_INTERNAL
) {
15218 json_object_int_add(json_peer_group
, "remoteAs",
15221 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15222 group
->name
, group
->bgp
->as
);
15225 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15228 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15230 json_object_string_add(json_peer_group
, "type",
15233 vty_out(vty
, " Peer-group type is internal\n");
15236 json_object_string_add(json_peer_group
, "type",
15239 vty_out(vty
, " Peer-group type is external\n");
15242 /* Display AFs configured. */
15244 vty_out(vty
, " Configured address-families:");
15246 FOREACH_AFI_SAFI (afi
, safi
) {
15247 if (conf
->afc
[afi
][safi
]) {
15250 json_object_array_add(
15251 json_peer_group_afc
,
15252 json_object_new_string(get_afi_safi_str(
15253 afi
, safi
, false)));
15255 vty_out(vty
, " %s;",
15256 get_afi_safi_str(afi
, safi
, false));
15261 json_object_object_add(json_peer_group
,
15262 "addressFamiliesConfigured",
15263 json_peer_group_afc
);
15266 vty_out(vty
, " none\n");
15268 vty_out(vty
, "\n");
15271 /* Display listen ranges (for dynamic neighbors), if any */
15272 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15273 lr_count
= listcount(group
->listen_range
[afi
]);
15276 if (!json_peer_group_dynamic
)
15277 json_peer_group_dynamic
=
15278 json_object_new_object();
15280 json_peer_group_dynamic_af
=
15281 json_object_new_object();
15282 json_peer_group_ranges
=
15283 json_object_new_array();
15284 json_object_int_add(json_peer_group_dynamic_af
,
15285 "count", lr_count
);
15287 vty_out(vty
, " %d %s listen range(s)\n",
15288 lr_count
, afi2str(afi
));
15291 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15296 snprintfrr(buf
, sizeof(buf
), "%pFX",
15299 json_object_array_add(
15300 json_peer_group_ranges
,
15301 json_object_new_string(buf
));
15303 vty_out(vty
, " %pFX\n", range
);
15308 json_object_object_add(
15309 json_peer_group_dynamic_af
, "ranges",
15310 json_peer_group_ranges
);
15312 json_object_object_add(
15313 json_peer_group_dynamic
, afi2str(afi
),
15314 json_peer_group_dynamic_af
);
15319 if (json_peer_group_dynamic
)
15320 json_object_object_add(json_peer_group
, "dynamicRanges",
15321 json_peer_group_dynamic
);
15323 /* Display group members and their status */
15324 if (listcount(group
->peer
)) {
15326 json_peer_group_members
= json_object_new_object();
15328 vty_out(vty
, " Peer-group members:\n");
15329 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15330 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15331 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15332 peer_status
= "Idle (Admin)";
15333 else if (CHECK_FLAG(peer
->sflags
,
15334 PEER_STATUS_PREFIX_OVERFLOW
))
15335 peer_status
= "Idle (PfxCt)";
15337 peer_status
= lookup_msg(bgp_status_msg
,
15338 peer
->status
, NULL
);
15340 dynamic
= peer_dynamic_neighbor(peer
);
15343 json_object
*json_peer_group_member
=
15344 json_object_new_object();
15346 json_object_string_add(json_peer_group_member
,
15347 "status", peer_status
);
15350 json_object_boolean_true_add(
15351 json_peer_group_member
,
15354 json_object_object_add(json_peer_group_members
,
15356 json_peer_group_member
);
15358 vty_out(vty
, " %s %s %s \n", peer
->host
,
15359 dynamic
? "(dynamic)" : "",
15364 json_object_object_add(json_peer_group
, "members",
15365 json_peer_group_members
);
15369 json_object_object_add(json
, group
->name
, json_peer_group
);
15371 return CMD_SUCCESS
;
15374 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15375 const char *group_name
, bool uj
)
15378 struct listnode
*node
, *nnode
;
15379 struct peer_group
*group
;
15380 bool found
= false;
15381 json_object
*json
= NULL
;
15384 json
= json_object_new_object();
15386 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15390 vty_json(vty
, json
);
15392 vty_out(vty
, "%% BGP instance not found\n");
15394 return CMD_WARNING
;
15397 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15399 if (strmatch(group
->name
, group_name
)) {
15400 bgp_show_one_peer_group(vty
, group
, json
);
15405 bgp_show_one_peer_group(vty
, group
, json
);
15409 if (group_name
&& !found
&& !uj
)
15410 vty_out(vty
, "%% No such peer-group\n");
15413 vty_json(vty
, json
);
15415 return CMD_SUCCESS
;
15418 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15419 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15420 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15421 "Detailed information on BGP peer groups\n"
15422 "Peer group name\n" JSON_STR
)
15426 bool uj
= use_json(argc
, argv
);
15428 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15430 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15432 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15436 /* Redistribute VTY commands. */
15438 DEFUN (bgp_redistribute_ipv4
,
15439 bgp_redistribute_ipv4_cmd
,
15440 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15441 "Redistribute information from another routing protocol\n"
15442 FRR_IP_REDIST_HELP_STR_BGPD
)
15444 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15445 int idx_protocol
= 1;
15448 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15450 vty_out(vty
, "%% Invalid route type\n");
15451 return CMD_WARNING_CONFIG_FAILED
;
15454 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15455 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15459 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15460 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15461 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15463 DEFUN (bgp_redistribute_ipv4_rmap
,
15464 bgp_redistribute_ipv4_rmap_cmd
,
15465 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15466 "Redistribute information from another routing protocol\n"
15467 FRR_IP_REDIST_HELP_STR_BGPD
15468 "Route map reference\n"
15469 "Pointer to route-map entries\n")
15471 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15472 int idx_protocol
= 1;
15475 struct bgp_redist
*red
;
15477 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15478 vty
, argv
[idx_word
]->arg
);
15480 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15482 vty_out(vty
, "%% Invalid route type\n");
15483 return CMD_WARNING_CONFIG_FAILED
;
15486 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15488 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15489 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15493 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15494 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15495 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15496 "Route map reference\n"
15497 "Pointer to route-map entries\n")
15499 DEFUN (bgp_redistribute_ipv4_metric
,
15500 bgp_redistribute_ipv4_metric_cmd
,
15501 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15502 "Redistribute information from another routing protocol\n"
15503 FRR_IP_REDIST_HELP_STR_BGPD
15504 "Metric for redistributed routes\n"
15505 "Default metric\n")
15507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15508 int idx_protocol
= 1;
15509 int idx_number
= 3;
15512 struct bgp_redist
*red
;
15515 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15517 vty_out(vty
, "%% Invalid route type\n");
15518 return CMD_WARNING_CONFIG_FAILED
;
15520 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15522 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15523 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15524 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15528 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15529 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15530 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15531 "Metric for redistributed routes\n"
15532 "Default metric\n")
15534 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15535 bgp_redistribute_ipv4_rmap_metric_cmd
,
15536 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15537 "Redistribute information from another routing protocol\n"
15538 FRR_IP_REDIST_HELP_STR_BGPD
15539 "Route map reference\n"
15540 "Pointer to route-map entries\n"
15541 "Metric for redistributed routes\n"
15542 "Default metric\n")
15544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15545 int idx_protocol
= 1;
15547 int idx_number
= 5;
15550 struct bgp_redist
*red
;
15552 struct route_map
*route_map
=
15553 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15555 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15557 vty_out(vty
, "%% Invalid route type\n");
15558 return CMD_WARNING_CONFIG_FAILED
;
15560 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15562 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15564 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15565 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15566 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15570 bgp_redistribute_ipv4_rmap_metric
,
15571 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15572 "redistribute " FRR_IP_REDIST_STR_BGPD
15573 " route-map WORD metric (0-4294967295)",
15574 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15575 "Route map reference\n"
15576 "Pointer to route-map entries\n"
15577 "Metric for redistributed routes\n"
15578 "Default metric\n")
15580 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15581 bgp_redistribute_ipv4_metric_rmap_cmd
,
15582 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15583 "Redistribute information from another routing protocol\n"
15584 FRR_IP_REDIST_HELP_STR_BGPD
15585 "Metric for redistributed routes\n"
15587 "Route map reference\n"
15588 "Pointer to route-map entries\n")
15590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15591 int idx_protocol
= 1;
15592 int idx_number
= 3;
15596 struct bgp_redist
*red
;
15598 struct route_map
*route_map
=
15599 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15601 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15603 vty_out(vty
, "%% Invalid route type\n");
15604 return CMD_WARNING_CONFIG_FAILED
;
15606 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15608 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15609 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15611 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15612 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15616 bgp_redistribute_ipv4_metric_rmap
,
15617 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15618 "redistribute " FRR_IP_REDIST_STR_BGPD
15619 " metric (0-4294967295) route-map WORD",
15620 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15621 "Metric for redistributed routes\n"
15623 "Route map reference\n"
15624 "Pointer to route-map entries\n")
15626 DEFUN (bgp_redistribute_ipv4_ospf
,
15627 bgp_redistribute_ipv4_ospf_cmd
,
15628 "redistribute <ospf|table> (1-65535)",
15629 "Redistribute information from another routing protocol\n"
15630 "Open Shortest Path First (OSPFv2)\n"
15631 "Non-main Kernel Routing Table\n"
15632 "Instance ID/Table ID\n")
15634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15635 int idx_ospf_table
= 1;
15636 int idx_number
= 2;
15637 unsigned short instance
;
15638 unsigned short protocol
;
15640 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15642 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15643 protocol
= ZEBRA_ROUTE_OSPF
;
15645 protocol
= ZEBRA_ROUTE_TABLE
;
15647 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15648 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15651 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15652 "redistribute <ospf|table> (1-65535)",
15653 "Redistribute information from another routing protocol\n"
15654 "Open Shortest Path First (OSPFv2)\n"
15655 "Non-main Kernel Routing Table\n"
15656 "Instance ID/Table ID\n")
15658 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15659 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15660 "redistribute <ospf|table> (1-65535) route-map WORD",
15661 "Redistribute information from another routing protocol\n"
15662 "Open Shortest Path First (OSPFv2)\n"
15663 "Non-main Kernel Routing Table\n"
15664 "Instance ID/Table ID\n"
15665 "Route map reference\n"
15666 "Pointer to route-map entries\n")
15668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15669 int idx_ospf_table
= 1;
15670 int idx_number
= 2;
15672 struct bgp_redist
*red
;
15673 unsigned short instance
;
15676 struct route_map
*route_map
=
15677 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15679 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15680 protocol
= ZEBRA_ROUTE_OSPF
;
15682 protocol
= ZEBRA_ROUTE_TABLE
;
15684 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15685 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15687 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15688 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15691 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15692 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15693 "redistribute <ospf|table> (1-65535) route-map WORD",
15694 "Redistribute information from another routing protocol\n"
15695 "Open Shortest Path First (OSPFv2)\n"
15696 "Non-main Kernel Routing Table\n"
15697 "Instance ID/Table ID\n"
15698 "Route map reference\n"
15699 "Pointer to route-map entries\n")
15701 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15702 bgp_redistribute_ipv4_ospf_metric_cmd
,
15703 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15704 "Redistribute information from another routing protocol\n"
15705 "Open Shortest Path First (OSPFv2)\n"
15706 "Non-main Kernel Routing Table\n"
15707 "Instance ID/Table ID\n"
15708 "Metric for redistributed routes\n"
15709 "Default metric\n")
15711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15712 int idx_ospf_table
= 1;
15713 int idx_number
= 2;
15714 int idx_number_2
= 4;
15716 struct bgp_redist
*red
;
15717 unsigned short instance
;
15721 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15722 protocol
= ZEBRA_ROUTE_OSPF
;
15724 protocol
= ZEBRA_ROUTE_TABLE
;
15726 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15727 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15729 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15730 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15732 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15735 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15736 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15737 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15738 "Redistribute information from another routing protocol\n"
15739 "Open Shortest Path First (OSPFv2)\n"
15740 "Non-main Kernel Routing Table\n"
15741 "Instance ID/Table ID\n"
15742 "Metric for redistributed routes\n"
15743 "Default metric\n")
15745 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15746 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15747 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15748 "Redistribute information from another routing protocol\n"
15749 "Open Shortest Path First (OSPFv2)\n"
15750 "Non-main Kernel Routing Table\n"
15751 "Instance ID/Table ID\n"
15752 "Route map reference\n"
15753 "Pointer to route-map entries\n"
15754 "Metric for redistributed routes\n"
15755 "Default metric\n")
15757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15758 int idx_ospf_table
= 1;
15759 int idx_number
= 2;
15761 int idx_number_2
= 6;
15763 struct bgp_redist
*red
;
15764 unsigned short instance
;
15767 struct route_map
*route_map
=
15768 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15770 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15771 protocol
= ZEBRA_ROUTE_OSPF
;
15773 protocol
= ZEBRA_ROUTE_TABLE
;
15775 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15776 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15778 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15780 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15781 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15783 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15787 bgp_redistribute_ipv4_ospf_rmap_metric
,
15788 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15789 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15790 "Redistribute information from another routing protocol\n"
15791 "Open Shortest Path First (OSPFv2)\n"
15792 "Non-main Kernel Routing Table\n"
15793 "Instance ID/Table ID\n"
15794 "Route map reference\n"
15795 "Pointer to route-map entries\n"
15796 "Metric for redistributed routes\n"
15797 "Default metric\n")
15799 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15800 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15801 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15802 "Redistribute information from another routing protocol\n"
15803 "Open Shortest Path First (OSPFv2)\n"
15804 "Non-main Kernel Routing Table\n"
15805 "Instance ID/Table ID\n"
15806 "Metric for redistributed routes\n"
15808 "Route map reference\n"
15809 "Pointer to route-map entries\n")
15811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15812 int idx_ospf_table
= 1;
15813 int idx_number
= 2;
15814 int idx_number_2
= 4;
15817 struct bgp_redist
*red
;
15818 unsigned short instance
;
15821 struct route_map
*route_map
=
15822 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15824 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15825 protocol
= ZEBRA_ROUTE_OSPF
;
15827 protocol
= ZEBRA_ROUTE_TABLE
;
15829 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15830 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15832 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15833 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15836 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15837 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15841 bgp_redistribute_ipv4_ospf_metric_rmap
,
15842 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15843 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15844 "Redistribute information from another routing protocol\n"
15845 "Open Shortest Path First (OSPFv2)\n"
15846 "Non-main Kernel Routing Table\n"
15847 "Instance ID/Table ID\n"
15848 "Metric for redistributed routes\n"
15850 "Route map reference\n"
15851 "Pointer to route-map entries\n")
15853 DEFUN (no_bgp_redistribute_ipv4_ospf
,
15854 no_bgp_redistribute_ipv4_ospf_cmd
,
15855 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15857 "Redistribute information from another routing protocol\n"
15858 "Open Shortest Path First (OSPFv2)\n"
15859 "Non-main Kernel Routing Table\n"
15860 "Instance ID/Table ID\n"
15861 "Metric for redistributed routes\n"
15863 "Route map reference\n"
15864 "Pointer to route-map entries\n")
15866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15867 int idx_ospf_table
= 2;
15868 int idx_number
= 3;
15869 unsigned short instance
;
15872 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15873 protocol
= ZEBRA_ROUTE_OSPF
;
15875 protocol
= ZEBRA_ROUTE_TABLE
;
15877 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15878 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
15882 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15883 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15885 "Redistribute information from another routing protocol\n"
15886 "Open Shortest Path First (OSPFv2)\n"
15887 "Non-main Kernel Routing Table\n"
15888 "Instance ID/Table ID\n"
15889 "Metric for redistributed routes\n"
15891 "Route map reference\n"
15892 "Pointer to route-map entries\n")
15894 DEFUN (no_bgp_redistribute_ipv4
,
15895 no_bgp_redistribute_ipv4_cmd
,
15896 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15898 "Redistribute information from another routing protocol\n"
15899 FRR_IP_REDIST_HELP_STR_BGPD
15900 "Metric for redistributed routes\n"
15902 "Route map reference\n"
15903 "Pointer to route-map entries\n")
15905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15906 int idx_protocol
= 2;
15909 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15911 vty_out(vty
, "%% Invalid route type\n");
15912 return CMD_WARNING_CONFIG_FAILED
;
15914 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
15918 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15919 "no redistribute " FRR_IP_REDIST_STR_BGPD
15920 " [{metric (0-4294967295)|route-map WORD}]",
15922 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15923 "Metric for redistributed routes\n"
15925 "Route map reference\n"
15926 "Pointer to route-map entries\n")
15928 DEFUN (bgp_redistribute_ipv6
,
15929 bgp_redistribute_ipv6_cmd
,
15930 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15931 "Redistribute information from another routing protocol\n"
15932 FRR_IP6_REDIST_HELP_STR_BGPD
)
15934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15935 int idx_protocol
= 1;
15938 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15940 vty_out(vty
, "%% Invalid route type\n");
15941 return CMD_WARNING_CONFIG_FAILED
;
15944 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15945 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
15948 DEFUN (bgp_redistribute_ipv6_rmap
,
15949 bgp_redistribute_ipv6_rmap_cmd
,
15950 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15951 "Redistribute information from another routing protocol\n"
15952 FRR_IP6_REDIST_HELP_STR_BGPD
15953 "Route map reference\n"
15954 "Pointer to route-map entries\n")
15956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15957 int idx_protocol
= 1;
15960 struct bgp_redist
*red
;
15962 struct route_map
*route_map
=
15963 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15965 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15967 vty_out(vty
, "%% Invalid route type\n");
15968 return CMD_WARNING_CONFIG_FAILED
;
15971 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15973 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15974 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15977 DEFUN (bgp_redistribute_ipv6_metric
,
15978 bgp_redistribute_ipv6_metric_cmd
,
15979 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15980 "Redistribute information from another routing protocol\n"
15981 FRR_IP6_REDIST_HELP_STR_BGPD
15982 "Metric for redistributed routes\n"
15983 "Default metric\n")
15985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15986 int idx_protocol
= 1;
15987 int idx_number
= 3;
15990 struct bgp_redist
*red
;
15993 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15995 vty_out(vty
, "%% Invalid route type\n");
15996 return CMD_WARNING_CONFIG_FAILED
;
15998 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16000 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16001 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16002 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16005 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16006 bgp_redistribute_ipv6_rmap_metric_cmd
,
16007 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
16008 "Redistribute information from another routing protocol\n"
16009 FRR_IP6_REDIST_HELP_STR_BGPD
16010 "Route map reference\n"
16011 "Pointer to route-map entries\n"
16012 "Metric for redistributed routes\n"
16013 "Default metric\n")
16015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16016 int idx_protocol
= 1;
16018 int idx_number
= 5;
16021 struct bgp_redist
*red
;
16023 struct route_map
*route_map
=
16024 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16026 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16028 vty_out(vty
, "%% Invalid route type\n");
16029 return CMD_WARNING_CONFIG_FAILED
;
16031 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16033 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16035 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16036 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16038 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16041 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16042 bgp_redistribute_ipv6_metric_rmap_cmd
,
16043 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
16044 "Redistribute information from another routing protocol\n"
16045 FRR_IP6_REDIST_HELP_STR_BGPD
16046 "Metric for redistributed routes\n"
16048 "Route map reference\n"
16049 "Pointer to route-map entries\n")
16051 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16052 int idx_protocol
= 1;
16053 int idx_number
= 3;
16057 struct bgp_redist
*red
;
16059 struct route_map
*route_map
=
16060 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16062 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16064 vty_out(vty
, "%% Invalid route type\n");
16065 return CMD_WARNING_CONFIG_FAILED
;
16067 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16069 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16070 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16073 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16074 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16077 DEFUN (no_bgp_redistribute_ipv6
,
16078 no_bgp_redistribute_ipv6_cmd
,
16079 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16081 "Redistribute information from another routing protocol\n"
16082 FRR_IP6_REDIST_HELP_STR_BGPD
16083 "Metric for redistributed routes\n"
16085 "Route map reference\n"
16086 "Pointer to route-map entries\n")
16088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16089 int idx_protocol
= 2;
16092 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16094 vty_out(vty
, "%% Invalid route type\n");
16095 return CMD_WARNING_CONFIG_FAILED
;
16098 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16101 /* Neighbor update tcp-mss. */
16102 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16103 const char *tcp_mss_str
)
16106 uint32_t tcp_mss_val
= 0;
16108 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16110 return CMD_WARNING_CONFIG_FAILED
;
16113 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16114 peer_tcp_mss_set(peer
, tcp_mss_val
);
16116 peer_tcp_mss_unset(peer
);
16119 return CMD_SUCCESS
;
16122 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16123 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16124 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16125 "TCP max segment size\n"
16128 int peer_index
= 1;
16132 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16133 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16134 argv
[mss_index
]->arg
);
16137 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16138 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16139 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16140 "TCP max segment size\n"
16143 int peer_index
= 2;
16146 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16147 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16150 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16151 afi_t afi
, safi_t safi
)
16155 /* Unicast redistribution only. */
16156 if (safi
!= SAFI_UNICAST
)
16159 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16160 /* Redistribute BGP does not make sense. */
16161 if (i
!= ZEBRA_ROUTE_BGP
) {
16162 struct list
*red_list
;
16163 struct listnode
*node
;
16164 struct bgp_redist
*red
;
16166 red_list
= bgp
->redist
[afi
][i
];
16170 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16171 /* "redistribute" configuration. */
16172 vty_out(vty
, " redistribute %s",
16173 zebra_route_string(i
));
16175 vty_out(vty
, " %d", red
->instance
);
16176 if (red
->redist_metric_flag
)
16177 vty_out(vty
, " metric %u",
16178 red
->redist_metric
);
16179 if (red
->rmap
.name
)
16180 vty_out(vty
, " route-map %s",
16182 vty_out(vty
, "\n");
16188 /* peer-group helpers for config-write */
16190 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16192 if (!peer_group_active(peer
)) {
16193 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16194 return !CHECK_FLAG(peer
->flags
, flag
);
16196 return !!CHECK_FLAG(peer
->flags
, flag
);
16199 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16202 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16205 if (!peer_group_active(peer
)) {
16206 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16207 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16209 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16212 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16215 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16216 uint8_t type
, int direct
)
16218 struct bgp_filter
*filter
;
16220 if (peer_group_active(peer
))
16221 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16224 filter
= &peer
->filter
[afi
][safi
];
16226 case PEER_FT_DISTRIBUTE_LIST
:
16227 return !!(filter
->dlist
[direct
].name
);
16228 case PEER_FT_FILTER_LIST
:
16229 return !!(filter
->aslist
[direct
].name
);
16230 case PEER_FT_PREFIX_LIST
:
16231 return !!(filter
->plist
[direct
].name
);
16232 case PEER_FT_ROUTE_MAP
:
16233 return !!(filter
->map
[direct
].name
);
16234 case PEER_FT_UNSUPPRESS_MAP
:
16235 return !!(filter
->usmap
.name
);
16236 case PEER_FT_ADVERTISE_MAP
:
16237 return !!(filter
->advmap
.aname
16238 && ((filter
->advmap
.condition
== direct
)
16239 && filter
->advmap
.cname
));
16245 /* Return true if the addpath type is set for peer and different from
16248 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16251 enum bgp_addpath_strat type
, g_type
;
16253 type
= peer
->addpath_type
[afi
][safi
];
16255 if (type
!= BGP_ADDPATH_NONE
) {
16256 if (peer_group_active(peer
)) {
16257 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16259 if (type
!= g_type
)
16271 /* This is part of the address-family block (unicast only) */
16272 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16276 uint32_t tovpn_sid_index
= 0;
16278 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16279 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16280 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16281 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16282 bgp
->vpn_policy
[afi
]
16283 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16285 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16286 bgp
->vpn_policy
[afi
]
16287 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16289 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16290 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16291 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16292 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16295 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16296 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16298 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16301 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16302 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16303 bgp
->vpn_policy
[afi
].tovpn_label
);
16307 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16308 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16309 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16310 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16311 } else if (tovpn_sid_index
!= 0) {
16312 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16316 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16317 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16318 char buf
[RD_ADDRSTRLEN
];
16319 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16320 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16323 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16324 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16326 char buf
[PREFIX_STRLEN
];
16327 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16328 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16331 vty_out(vty
, "%*snexthop vpn export %s\n",
16335 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16336 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16338 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16339 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16341 char *b
= ecommunity_ecom2str(
16342 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16343 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16344 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16345 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16347 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16348 char *b
= ecommunity_ecom2str(
16349 bgp
->vpn_policy
[afi
]
16350 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16351 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16352 ECOMMUNITY_ROUTE_TARGET
);
16353 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16354 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16356 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16357 char *b
= ecommunity_ecom2str(
16358 bgp
->vpn_policy
[afi
]
16359 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16360 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16361 ECOMMUNITY_ROUTE_TARGET
);
16362 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16363 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16367 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16368 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16369 bgp
->vpn_policy
[afi
]
16370 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16372 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16373 char *b
= ecommunity_ecom2str(
16374 bgp
->vpn_policy
[afi
]
16375 .import_redirect_rtlist
,
16376 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16377 ECOMMUNITY_ROUTE_TARGET
);
16379 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16380 != ECOMMUNITY_SIZE
)
16381 vty_out(vty
, "%*srt6 redirect import %s\n",
16384 vty_out(vty
, "%*srt redirect import %s\n",
16386 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16390 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16391 afi_t afi
, safi_t safi
)
16393 struct bgp_filter
*filter
;
16397 filter
= &peer
->filter
[afi
][safi
];
16399 /* distribute-list. */
16400 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16402 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16403 filter
->dlist
[FILTER_IN
].name
);
16405 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16407 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16408 filter
->dlist
[FILTER_OUT
].name
);
16411 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16413 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16414 filter
->plist
[FILTER_IN
].name
);
16416 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16418 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16419 filter
->plist
[FILTER_OUT
].name
);
16422 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16423 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16424 filter
->map
[RMAP_IN
].name
);
16426 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16428 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16429 filter
->map
[RMAP_OUT
].name
);
16431 /* unsuppress-map */
16432 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16433 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16434 filter
->usmap
.name
);
16436 /* advertise-map : always applied in OUT direction*/
16437 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16438 CONDITION_NON_EXIST
))
16440 " neighbor %s advertise-map %s non-exist-map %s\n",
16441 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16443 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16445 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16446 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16449 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16451 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16452 filter
->aslist
[FILTER_IN
].name
);
16454 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16456 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16457 filter
->aslist
[FILTER_OUT
].name
);
16460 /* BGP peer configuration display function. */
16461 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16464 struct peer
*g_peer
= NULL
;
16465 char buf
[SU_ADDRSTRLEN
];
16467 int if_pg_printed
= false;
16468 int if_ras_printed
= false;
16470 /* Skip dynamic neighbors. */
16471 if (peer_dynamic_neighbor(peer
))
16475 addr
= peer
->conf_if
;
16479 /************************************
16480 ****** Global to the neighbor ******
16481 ************************************/
16482 if (peer
->conf_if
) {
16483 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16484 vty_out(vty
, " neighbor %s interface v6only", addr
);
16486 vty_out(vty
, " neighbor %s interface", addr
);
16488 if (peer_group_active(peer
)) {
16489 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16490 if_pg_printed
= true;
16491 } else if (peer
->as_type
== AS_SPECIFIED
) {
16492 vty_out(vty
, " remote-as %u", peer
->as
);
16493 if_ras_printed
= true;
16494 } else if (peer
->as_type
== AS_INTERNAL
) {
16495 vty_out(vty
, " remote-as internal");
16496 if_ras_printed
= true;
16497 } else if (peer
->as_type
== AS_EXTERNAL
) {
16498 vty_out(vty
, " remote-as external");
16499 if_ras_printed
= true;
16502 vty_out(vty
, "\n");
16505 /* remote-as and peer-group */
16506 /* peer is a member of a peer-group */
16507 if (peer_group_active(peer
)) {
16508 g_peer
= peer
->group
->conf
;
16510 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16511 if (peer
->as_type
== AS_SPECIFIED
) {
16512 vty_out(vty
, " neighbor %s remote-as %u\n",
16514 } else if (peer
->as_type
== AS_INTERNAL
) {
16516 " neighbor %s remote-as internal\n",
16518 } else if (peer
->as_type
== AS_EXTERNAL
) {
16520 " neighbor %s remote-as external\n",
16525 /* For swpX peers we displayed the peer-group
16526 * via 'neighbor swpX interface peer-group PGNAME' */
16527 if (!if_pg_printed
)
16528 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16529 peer
->group
->name
);
16532 /* peer is NOT a member of a peer-group */
16534 /* peer is a peer-group, declare the peer-group */
16535 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16536 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16539 if (!if_ras_printed
) {
16540 if (peer
->as_type
== AS_SPECIFIED
) {
16541 vty_out(vty
, " neighbor %s remote-as %u\n",
16543 } else if (peer
->as_type
== AS_INTERNAL
) {
16545 " neighbor %s remote-as internal\n",
16547 } else if (peer
->as_type
== AS_EXTERNAL
) {
16549 " neighbor %s remote-as external\n",
16556 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16557 vty_out(vty
, " neighbor %s local-as %u", addr
,
16558 peer
->change_local_as
);
16559 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16560 vty_out(vty
, " no-prepend");
16561 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16562 vty_out(vty
, " replace-as");
16563 vty_out(vty
, "\n");
16568 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16572 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16573 if (peer
->tx_shutdown_message
)
16574 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16575 peer
->tx_shutdown_message
);
16577 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16580 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16581 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16582 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16585 if (peer
->bfd_config
)
16586 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16589 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16590 vty_out(vty
, " neighbor %s password %s\n", addr
,
16593 /* neighbor solo */
16594 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16595 if (!peer_group_active(peer
)) {
16596 vty_out(vty
, " neighbor %s solo\n", addr
);
16601 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16602 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16605 /* Local interface name */
16606 if (peer
->ifname
) {
16607 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16610 /* TCP max segment size */
16611 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16612 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16615 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16616 vty_out(vty
, " neighbor %s passive\n", addr
);
16618 /* ebgp-multihop */
16619 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16620 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16621 && peer
->ttl
== MAXTTL
)) {
16622 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16623 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16628 /* ttl-security hops */
16629 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16630 if (!peer_group_active(peer
)
16631 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16632 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16633 addr
, peer
->gtsm_hops
);
16637 /* disable-connected-check */
16638 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16639 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16641 /* link-bw-encoding-ieee */
16642 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16643 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16646 /* extended-optional-parameters */
16647 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16648 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16651 /* enforce-first-as */
16652 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16653 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16655 /* update-source */
16656 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16657 if (peer
->update_source
)
16658 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16659 sockunion2str(peer
->update_source
, buf
,
16661 else if (peer
->update_if
)
16662 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16666 /* advertisement-interval */
16667 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16668 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16672 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16673 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16674 peer
->keepalive
, peer
->holdtime
);
16676 /* timers connect */
16677 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16678 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16680 /* need special-case handling for changed default values due to
16681 * config profile / version (because there is no "timers bgp connect"
16682 * command, we need to save this per-peer :/)
16684 else if (!peer_group_active(peer
) && !peer
->connect
&&
16685 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16686 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16687 peer
->bgp
->default_connect_retry
);
16689 /* timers delayopen */
16690 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16691 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16693 /* Save config even though flag is not set if default values have been
16696 else if (!peer_group_active(peer
) && !peer
->delayopen
16697 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16698 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16699 peer
->bgp
->default_delayopen
);
16701 /* capability dynamic */
16702 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16703 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16705 /* capability extended-nexthop */
16706 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16707 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
16710 " no neighbor %s capability extended-nexthop\n",
16712 else if (!peer
->conf_if
)
16714 " neighbor %s capability extended-nexthop\n",
16718 /* dont-capability-negotiation */
16719 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16720 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16722 /* override-capability */
16723 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16724 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16726 /* strict-capability-match */
16727 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16728 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16730 /* Sender side AS path loop detection. */
16731 if (peer
->as_path_loop_detection
)
16732 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16735 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16736 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16738 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16739 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16741 " neighbor %s graceful-restart-helper\n", addr
);
16742 } else if (CHECK_FLAG(
16743 peer
->peer_gr_new_status_flag
,
16744 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16746 " neighbor %s graceful-restart\n", addr
);
16748 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16749 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16751 peer
->peer_gr_new_status_flag
,
16752 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16753 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16759 /* BGP peer configuration display function. */
16760 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16761 struct peer
*peer
, afi_t afi
, safi_t safi
)
16763 struct peer
*g_peer
= NULL
;
16765 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16767 /* Skip dynamic neighbors. */
16768 if (peer_dynamic_neighbor(peer
))
16772 addr
= peer
->conf_if
;
16776 /************************************
16777 ****** Per AF to the neighbor ******
16778 ************************************/
16779 if (peer_group_active(peer
)) {
16780 g_peer
= peer
->group
->conf
;
16782 /* If the peer-group is active but peer is not, print a 'no
16784 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16785 vty_out(vty
, " no neighbor %s activate\n", addr
);
16788 /* If the peer-group is not active but peer is, print an
16790 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16791 vty_out(vty
, " neighbor %s activate\n", addr
);
16794 if (peer
->afc
[afi
][safi
]) {
16795 if (safi
== SAFI_ENCAP
)
16796 vty_out(vty
, " neighbor %s activate\n", addr
);
16797 else if (!bgp
->default_af
[afi
][safi
])
16798 vty_out(vty
, " neighbor %s activate\n", addr
);
16800 if (bgp
->default_af
[afi
][safi
])
16801 vty_out(vty
, " no neighbor %s activate\n",
16806 /* addpath TX knobs */
16807 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16808 switch (peer
->addpath_type
[afi
][safi
]) {
16809 case BGP_ADDPATH_ALL
:
16810 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16813 case BGP_ADDPATH_BEST_PER_AS
:
16815 " neighbor %s addpath-tx-bestpath-per-AS\n",
16818 case BGP_ADDPATH_MAX
:
16819 case BGP_ADDPATH_NONE
:
16824 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
16825 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
16827 /* ORF capability. */
16828 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16829 || peergroup_af_flag_check(peer
, afi
, safi
,
16830 PEER_FLAG_ORF_PREFIX_RM
)) {
16831 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16833 if (peergroup_af_flag_check(peer
, afi
, safi
,
16834 PEER_FLAG_ORF_PREFIX_SM
)
16835 && peergroup_af_flag_check(peer
, afi
, safi
,
16836 PEER_FLAG_ORF_PREFIX_RM
))
16837 vty_out(vty
, " both");
16838 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16839 PEER_FLAG_ORF_PREFIX_SM
))
16840 vty_out(vty
, " send");
16842 vty_out(vty
, " receive");
16843 vty_out(vty
, "\n");
16846 /* Route reflector client. */
16847 if (peergroup_af_flag_check(peer
, afi
, safi
,
16848 PEER_FLAG_REFLECTOR_CLIENT
)) {
16849 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16852 /* next-hop-self force */
16853 if (peergroup_af_flag_check(peer
, afi
, safi
,
16854 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16855 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16858 /* next-hop-self */
16859 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16860 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16863 /* remove-private-AS */
16864 if (peergroup_af_flag_check(peer
, afi
, safi
,
16865 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16866 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16870 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16871 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16872 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16876 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16877 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16878 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16881 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16882 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16883 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16887 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16888 vty_out(vty
, " neighbor %s as-override\n", addr
);
16891 /* send-community print. */
16892 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16893 PEER_FLAG_SEND_COMMUNITY
);
16894 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16895 PEER_FLAG_SEND_EXT_COMMUNITY
);
16896 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16897 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16899 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16900 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16903 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16906 " no neighbor %s send-community extended\n",
16910 vty_out(vty
, " no neighbor %s send-community large\n",
16914 /* Default information */
16915 if (peergroup_af_flag_check(peer
, afi
, safi
,
16916 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16917 vty_out(vty
, " neighbor %s default-originate", addr
);
16919 if (peer
->default_rmap
[afi
][safi
].name
)
16920 vty_out(vty
, " route-map %s",
16921 peer
->default_rmap
[afi
][safi
].name
);
16923 vty_out(vty
, "\n");
16926 /* Soft reconfiguration inbound. */
16927 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16928 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16932 /* maximum-prefix. */
16933 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16934 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16935 peer
->pmax
[afi
][safi
]);
16937 if (peer
->pmax_threshold
[afi
][safi
]
16938 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16939 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16940 if (peer_af_flag_check(peer
, afi
, safi
,
16941 PEER_FLAG_MAX_PREFIX_WARNING
))
16942 vty_out(vty
, " warning-only");
16943 if (peer
->pmax_restart
[afi
][safi
])
16944 vty_out(vty
, " restart %u",
16945 peer
->pmax_restart
[afi
][safi
]);
16946 if (peer_af_flag_check(peer
, afi
, safi
,
16947 PEER_FLAG_MAX_PREFIX_FORCE
))
16948 vty_out(vty
, " force");
16950 vty_out(vty
, "\n");
16953 /* maximum-prefix-out */
16954 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16955 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16956 addr
, peer
->pmax_out
[afi
][safi
]);
16958 /* Route server client. */
16959 if (peergroup_af_flag_check(peer
, afi
, safi
,
16960 PEER_FLAG_RSERVER_CLIENT
)) {
16961 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16964 /* Nexthop-local unchanged. */
16965 if (peergroup_af_flag_check(peer
, afi
, safi
,
16966 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16967 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16970 /* allowas-in <1-10> */
16971 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16972 if (peer_af_flag_check(peer
, afi
, safi
,
16973 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16974 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16975 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16976 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16978 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16979 peer
->allowas_in
[afi
][safi
]);
16984 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16985 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16986 peer
->weight
[afi
][safi
]);
16989 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16991 /* atribute-unchanged. */
16992 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16993 || (safi
!= SAFI_EVPN
16994 && peer_af_flag_check(peer
, afi
, safi
,
16995 PEER_FLAG_NEXTHOP_UNCHANGED
))
16996 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16998 if (!peer_group_active(peer
)
16999 || peergroup_af_flag_check(peer
, afi
, safi
,
17000 PEER_FLAG_AS_PATH_UNCHANGED
)
17001 || peergroup_af_flag_check(peer
, afi
, safi
,
17002 PEER_FLAG_NEXTHOP_UNCHANGED
)
17003 || peergroup_af_flag_check(peer
, afi
, safi
,
17004 PEER_FLAG_MED_UNCHANGED
)) {
17007 " neighbor %s attribute-unchanged%s%s%s\n",
17009 peer_af_flag_check(peer
, afi
, safi
,
17010 PEER_FLAG_AS_PATH_UNCHANGED
)
17013 peer_af_flag_check(peer
, afi
, safi
,
17014 PEER_FLAG_NEXTHOP_UNCHANGED
)
17017 peer_af_flag_check(peer
, afi
, safi
,
17018 PEER_FLAG_MED_UNCHANGED
)
17025 /* Address family based peer configuration display. */
17026 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17030 struct peer_group
*group
;
17031 struct listnode
*node
, *nnode
;
17034 vty_frame(vty
, " !\n address-family ");
17035 if (afi
== AFI_IP
) {
17036 if (safi
== SAFI_UNICAST
)
17037 vty_frame(vty
, "ipv4 unicast");
17038 else if (safi
== SAFI_LABELED_UNICAST
)
17039 vty_frame(vty
, "ipv4 labeled-unicast");
17040 else if (safi
== SAFI_MULTICAST
)
17041 vty_frame(vty
, "ipv4 multicast");
17042 else if (safi
== SAFI_MPLS_VPN
)
17043 vty_frame(vty
, "ipv4 vpn");
17044 else if (safi
== SAFI_ENCAP
)
17045 vty_frame(vty
, "ipv4 encap");
17046 else if (safi
== SAFI_FLOWSPEC
)
17047 vty_frame(vty
, "ipv4 flowspec");
17048 } else if (afi
== AFI_IP6
) {
17049 if (safi
== SAFI_UNICAST
)
17050 vty_frame(vty
, "ipv6 unicast");
17051 else if (safi
== SAFI_LABELED_UNICAST
)
17052 vty_frame(vty
, "ipv6 labeled-unicast");
17053 else if (safi
== SAFI_MULTICAST
)
17054 vty_frame(vty
, "ipv6 multicast");
17055 else if (safi
== SAFI_MPLS_VPN
)
17056 vty_frame(vty
, "ipv6 vpn");
17057 else if (safi
== SAFI_ENCAP
)
17058 vty_frame(vty
, "ipv6 encap");
17059 else if (safi
== SAFI_FLOWSPEC
)
17060 vty_frame(vty
, "ipv6 flowspec");
17061 } else if (afi
== AFI_L2VPN
) {
17062 if (safi
== SAFI_EVPN
)
17063 vty_frame(vty
, "l2vpn evpn");
17065 vty_frame(vty
, "\n");
17067 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17069 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17071 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17073 /* BGP flag dampening. */
17074 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17075 bgp_config_write_damp(vty
, afi
, safi
);
17077 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17078 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17080 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17081 /* Do not display doppelganger peers */
17082 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17083 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17086 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17087 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17089 if (safi
== SAFI_EVPN
)
17090 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17092 if (safi
== SAFI_FLOWSPEC
)
17093 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17095 if (safi
== SAFI_UNICAST
) {
17096 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17097 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17098 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17100 vty_out(vty
, " export vpn\n");
17102 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17103 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17105 vty_out(vty
, " import vpn\n");
17107 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17108 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17111 for (ALL_LIST_ELEMENTS_RO(
17112 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17114 vty_out(vty
, " import vrf %s\n", name
);
17118 vty_endframe(vty
, " exit-address-family\n");
17121 int bgp_config_write(struct vty
*vty
)
17124 struct peer_group
*group
;
17126 struct listnode
*node
, *nnode
;
17127 struct listnode
*mnode
, *mnnode
;
17131 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17132 vty_out(vty
, "bgp route-map delay-timer %u\n",
17133 bm
->rmap_update_timer
);
17135 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17136 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17137 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17138 vty_out(vty
, " %d", bm
->v_establish_wait
);
17139 vty_out(vty
, "\n");
17142 if (bm
->wait_for_fib
)
17143 vty_out(vty
, "bgp suppress-fib-pending\n");
17145 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17146 vty_out(vty
, "bgp graceful-shutdown\n");
17148 /* No-RIB (Zebra) option flag configuration */
17149 if (bgp_option_check(BGP_OPT_NO_FIB
))
17150 vty_out(vty
, "bgp no-rib\n");
17152 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17153 vty_out(vty
, "bgp send-extra-data zebra\n");
17155 /* BGP session DSCP value */
17156 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17157 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17159 /* BGP configuration. */
17160 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17162 /* skip all auto created vrf as they dont have user config */
17163 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17166 /* Router bgp ASN */
17167 vty_out(vty
, "router bgp %u", bgp
->as
);
17170 vty_out(vty
, " %s %s",
17171 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17172 ? "view" : "vrf", bgp
->name
);
17173 vty_out(vty
, "\n");
17175 /* BGP fast-external-failover. */
17176 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17177 vty_out(vty
, " no bgp fast-external-failover\n");
17179 /* BGP router ID. */
17180 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17181 vty_out(vty
, " bgp router-id %pI4\n",
17182 &bgp
->router_id_static
);
17184 /* Suppress fib pending */
17185 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17186 vty_out(vty
, " bgp suppress-fib-pending\n");
17188 /* BGP log-neighbor-changes. */
17189 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17190 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17191 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17192 CHECK_FLAG(bgp
->flags
,
17193 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17197 /* BGP configuration. */
17198 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17199 vty_out(vty
, " bgp always-compare-med\n");
17201 /* RFC8212 default eBGP policy. */
17202 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17203 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17204 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17205 CHECK_FLAG(bgp
->flags
,
17206 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17210 /* draft-ietf-idr-deprecate-as-set-confed-set */
17211 if (bgp
->reject_as_sets
)
17212 vty_out(vty
, " bgp reject-as-sets\n");
17214 /* Suppress duplicate updates if the route actually not changed
17216 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17217 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17218 vty_out(vty
, " %sbgp suppress-duplicates\n",
17219 CHECK_FLAG(bgp
->flags
,
17220 BGP_FLAG_SUPPRESS_DUPLICATES
)
17224 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17226 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17227 SAVE_BGP_HARD_ADMIN_RESET
)
17228 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17229 CHECK_FLAG(bgp
->flags
,
17230 BGP_FLAG_HARD_ADMIN_RESET
)
17234 /* BGP default <afi>-<safi> */
17235 FOREACH_AFI_SAFI (afi
, safi
) {
17236 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17237 if (!bgp
->default_af
[afi
][safi
])
17238 vty_out(vty
, " no bgp default %s\n",
17239 get_bgp_default_af_flag(afi
,
17241 } else if (bgp
->default_af
[afi
][safi
])
17242 vty_out(vty
, " bgp default %s\n",
17243 get_bgp_default_af_flag(afi
, safi
));
17246 /* BGP default local-preference. */
17247 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17248 vty_out(vty
, " bgp default local-preference %u\n",
17249 bgp
->default_local_pref
);
17251 /* BGP default show-hostname */
17252 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17253 != SAVE_BGP_SHOW_HOSTNAME
)
17254 vty_out(vty
, " %sbgp default show-hostname\n",
17255 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17259 /* BGP default show-nexthop-hostname */
17260 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17261 != SAVE_BGP_SHOW_HOSTNAME
)
17262 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17263 CHECK_FLAG(bgp
->flags
,
17264 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17268 /* BGP default subgroup-pkt-queue-max. */
17269 if (bgp
->default_subgroup_pkt_queue_max
17270 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17271 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17272 bgp
->default_subgroup_pkt_queue_max
);
17274 /* BGP client-to-client reflection. */
17275 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17276 vty_out(vty
, " no bgp client-to-client reflection\n");
17278 /* BGP cluster ID. */
17279 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17280 vty_out(vty
, " bgp cluster-id %pI4\n",
17283 /* Disable ebgp connected nexthop check */
17284 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17286 " bgp disable-ebgp-connected-route-check\n");
17288 /* Confederation identifier*/
17289 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17290 vty_out(vty
, " bgp confederation identifier %u\n",
17293 /* Confederation peer */
17294 if (bgp
->confed_peers_cnt
> 0) {
17297 vty_out(vty
, " bgp confederation peers");
17299 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17300 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17302 vty_out(vty
, "\n");
17305 /* BGP deterministic-med. */
17306 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17307 != SAVE_BGP_DETERMINISTIC_MED
)
17308 vty_out(vty
, " %sbgp deterministic-med\n",
17309 CHECK_FLAG(bgp
->flags
,
17310 BGP_FLAG_DETERMINISTIC_MED
)
17314 /* BGP update-delay. */
17315 bgp_config_write_update_delay(vty
, bgp
);
17317 if (bgp
->v_maxmed_onstartup
17318 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17319 vty_out(vty
, " bgp max-med on-startup %u",
17320 bgp
->v_maxmed_onstartup
);
17321 if (bgp
->maxmed_onstartup_value
17322 != BGP_MAXMED_VALUE_DEFAULT
)
17323 vty_out(vty
, " %u",
17324 bgp
->maxmed_onstartup_value
);
17325 vty_out(vty
, "\n");
17327 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17328 vty_out(vty
, " bgp max-med administrative");
17329 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17330 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17331 vty_out(vty
, "\n");
17335 bgp_config_write_wpkt_quanta(vty
, bgp
);
17337 bgp_config_write_rpkt_quanta(vty
, bgp
);
17339 /* coalesce time */
17340 bgp_config_write_coalesce_time(vty
, bgp
);
17342 /* BGP per-instance graceful-shutdown */
17343 /* BGP-wide settings and per-instance settings are mutually
17346 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17347 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17348 vty_out(vty
, " bgp graceful-shutdown\n");
17350 /* Long-lived Graceful Restart */
17351 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17353 " bgp long-lived-graceful-restart stale-time %u\n",
17354 bgp
->llgr_stale_time
);
17356 /* BGP graceful-restart. */
17357 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17359 " bgp graceful-restart stalepath-time %u\n",
17360 bgp
->stalepath_time
);
17362 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17363 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17364 bgp
->restart_time
);
17366 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17367 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17368 vty_out(vty
, " %sbgp graceful-restart notification\n",
17369 CHECK_FLAG(bgp
->flags
,
17370 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17374 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17376 " bgp graceful-restart select-defer-time %u\n",
17377 bgp
->select_defer_time
);
17379 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17380 vty_out(vty
, " bgp graceful-restart\n");
17382 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17383 vty_out(vty
, " bgp graceful-restart-disable\n");
17385 /* BGP graceful-restart Preserve State F bit. */
17386 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17388 " bgp graceful-restart preserve-fw-state\n");
17390 /* Stale timer for RIB */
17391 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17393 " bgp graceful-restart rib-stale-time %u\n",
17394 bgp
->rib_stale_time
);
17396 /* BGP bestpath method. */
17397 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17398 vty_out(vty
, " bgp bestpath as-path ignore\n");
17399 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17400 vty_out(vty
, " bgp bestpath as-path confed\n");
17402 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17403 if (CHECK_FLAG(bgp
->flags
,
17404 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17406 " bgp bestpath as-path multipath-relax as-set\n");
17409 " bgp bestpath as-path multipath-relax\n");
17413 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17415 " bgp route-reflector allow-outbound-policy\n");
17417 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17418 vty_out(vty
, " bgp bestpath compare-routerid\n");
17419 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17420 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17421 vty_out(vty
, " bgp bestpath med");
17422 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17423 vty_out(vty
, " confed");
17424 if (CHECK_FLAG(bgp
->flags
,
17425 BGP_FLAG_MED_MISSING_AS_WORST
))
17426 vty_out(vty
, " missing-as-worst");
17427 vty_out(vty
, "\n");
17430 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17432 " bgp bestpath peer-type multipath-relax\n");
17434 /* Link bandwidth handling. */
17435 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17436 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17437 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17438 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17439 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17440 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17442 /* BGP network import check. */
17443 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17444 != SAVE_BGP_IMPORT_CHECK
)
17445 vty_out(vty
, " %sbgp network import-check\n",
17446 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17450 /* BGP timers configuration. */
17451 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17452 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17453 vty_out(vty
, " timers bgp %u %u\n",
17454 bgp
->default_keepalive
, bgp
->default_holdtime
);
17456 /* BGP minimum holdtime configuration. */
17457 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17458 && bgp
->default_min_holdtime
!= 0)
17459 vty_out(vty
, " bgp minimum-holdtime %u\n",
17460 bgp
->default_min_holdtime
);
17462 /* Conditional advertisement timer configuration */
17463 if (bgp
->condition_check_period
17464 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17466 " bgp conditional-advertisement timer %u\n",
17467 bgp
->condition_check_period
);
17470 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17471 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17474 /* Normal neighbor configuration. */
17475 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17476 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17477 bgp_config_write_peer_global(vty
, bgp
, peer
);
17480 /* listen range and limit for dynamic BGP neighbors */
17481 bgp_config_write_listen(vty
, bgp
);
17484 * BGP default autoshutdown neighbors
17486 * This must be placed after any peer and peer-group
17487 * configuration, to avoid setting all peers to shutdown after
17488 * a daemon restart, which is undesired behavior. (see #2286)
17490 if (bgp
->autoshutdown
)
17491 vty_out(vty
, " bgp default shutdown\n");
17493 /* BGP instance administrative shutdown */
17494 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17495 vty_out(vty
, " bgp shutdown\n");
17497 if (bgp
->fast_convergence
)
17498 vty_out(vty
, " bgp fast-convergence\n");
17500 if (bgp
->srv6_enabled
) {
17501 vty_frame(vty
, " !\n segment-routing srv6\n");
17502 if (strlen(bgp
->srv6_locator_name
))
17503 vty_out(vty
, " locator %s\n",
17504 bgp
->srv6_locator_name
);
17505 vty_endframe(vty
, " exit\n");
17509 /* IPv4 unicast configuration. */
17510 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17512 /* IPv4 multicast configuration. */
17513 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17515 /* IPv4 labeled-unicast configuration. */
17516 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17518 /* IPv4 VPN configuration. */
17519 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17521 /* ENCAPv4 configuration. */
17522 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17524 /* FLOWSPEC v4 configuration. */
17525 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17527 /* IPv6 unicast configuration. */
17528 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17530 /* IPv6 multicast configuration. */
17531 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17533 /* IPv6 labeled-unicast configuration. */
17534 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17535 SAFI_LABELED_UNICAST
);
17537 /* IPv6 VPN configuration. */
17538 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17540 /* ENCAPv6 configuration. */
17541 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17543 /* FLOWSPEC v6 configuration. */
17544 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17546 /* EVPN configuration. */
17547 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17549 hook_call(bgp_inst_config_write
, bgp
, vty
);
17551 #ifdef ENABLE_BGP_VNC
17552 bgp_rfapi_cfg_write(vty
, bgp
);
17555 vty_out(vty
, "exit\n");
17556 vty_out(vty
, "!\n");
17562 /* BGP node structure. */
17563 static struct cmd_node bgp_node
= {
17566 .parent_node
= CONFIG_NODE
,
17567 .prompt
= "%s(config-router)# ",
17568 .config_write
= bgp_config_write
,
17571 static struct cmd_node bgp_ipv4_unicast_node
= {
17572 .name
= "bgp ipv4 unicast",
17573 .node
= BGP_IPV4_NODE
,
17574 .parent_node
= BGP_NODE
,
17575 .prompt
= "%s(config-router-af)# ",
17579 static struct cmd_node bgp_ipv4_multicast_node
= {
17580 .name
= "bgp ipv4 multicast",
17581 .node
= BGP_IPV4M_NODE
,
17582 .parent_node
= BGP_NODE
,
17583 .prompt
= "%s(config-router-af)# ",
17587 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17588 .name
= "bgp ipv4 labeled unicast",
17589 .node
= BGP_IPV4L_NODE
,
17590 .parent_node
= BGP_NODE
,
17591 .prompt
= "%s(config-router-af)# ",
17595 static struct cmd_node bgp_ipv6_unicast_node
= {
17596 .name
= "bgp ipv6 unicast",
17597 .node
= BGP_IPV6_NODE
,
17598 .parent_node
= BGP_NODE
,
17599 .prompt
= "%s(config-router-af)# ",
17603 static struct cmd_node bgp_ipv6_multicast_node
= {
17604 .name
= "bgp ipv6 multicast",
17605 .node
= BGP_IPV6M_NODE
,
17606 .parent_node
= BGP_NODE
,
17607 .prompt
= "%s(config-router-af)# ",
17611 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17612 .name
= "bgp ipv6 labeled unicast",
17613 .node
= BGP_IPV6L_NODE
,
17614 .parent_node
= BGP_NODE
,
17615 .prompt
= "%s(config-router-af)# ",
17619 static struct cmd_node bgp_vpnv4_node
= {
17620 .name
= "bgp vpnv4",
17621 .node
= BGP_VPNV4_NODE
,
17622 .parent_node
= BGP_NODE
,
17623 .prompt
= "%s(config-router-af)# ",
17627 static struct cmd_node bgp_vpnv6_node
= {
17628 .name
= "bgp vpnv6",
17629 .node
= BGP_VPNV6_NODE
,
17630 .parent_node
= BGP_NODE
,
17631 .prompt
= "%s(config-router-af-vpnv6)# ",
17635 static struct cmd_node bgp_evpn_node
= {
17636 .name
= "bgp evpn",
17637 .node
= BGP_EVPN_NODE
,
17638 .parent_node
= BGP_NODE
,
17639 .prompt
= "%s(config-router-evpn)# ",
17643 static struct cmd_node bgp_evpn_vni_node
= {
17644 .name
= "bgp evpn vni",
17645 .node
= BGP_EVPN_VNI_NODE
,
17646 .parent_node
= BGP_EVPN_NODE
,
17647 .prompt
= "%s(config-router-af-vni)# ",
17650 static struct cmd_node bgp_flowspecv4_node
= {
17651 .name
= "bgp ipv4 flowspec",
17652 .node
= BGP_FLOWSPECV4_NODE
,
17653 .parent_node
= BGP_NODE
,
17654 .prompt
= "%s(config-router-af)# ",
17658 static struct cmd_node bgp_flowspecv6_node
= {
17659 .name
= "bgp ipv6 flowspec",
17660 .node
= BGP_FLOWSPECV6_NODE
,
17661 .parent_node
= BGP_NODE
,
17662 .prompt
= "%s(config-router-af-vpnv6)# ",
17666 static struct cmd_node bgp_srv6_node
= {
17667 .name
= "bgp srv6",
17668 .node
= BGP_SRV6_NODE
,
17669 .parent_node
= BGP_NODE
,
17670 .prompt
= "%s(config-router-srv6)# ",
17673 static void community_list_vty(void);
17675 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17678 struct peer_group
*group
;
17679 struct listnode
*lnbgp
, *lnpeer
;
17681 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17682 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17684 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17688 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17692 struct listnode
*lnbgp
, *lnpeer
;
17694 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17695 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17696 /* only provide suggestions on the appropriate input
17698 * they'll otherwise show up multiple times */
17699 enum cmd_token_type match_type
;
17700 char *name
= peer
->host
;
17702 if (peer
->conf_if
) {
17703 match_type
= VARIABLE_TKN
;
17704 name
= peer
->conf_if
;
17705 } else if (strchr(peer
->host
, ':'))
17706 match_type
= IPV6_TKN
;
17708 match_type
= IPV4_TKN
;
17710 if (token
->type
!= match_type
)
17713 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17718 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17720 bgp_ac_peer(comps
, token
);
17722 if (token
->type
== VARIABLE_TKN
)
17723 bgp_ac_peergroup(comps
, token
);
17726 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17727 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17728 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17729 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17730 {.completions
= NULL
}};
17732 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17733 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17734 {.completions
= NULL
} };
17736 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
17738 static struct thread
*t_bgp_cfg
;
17740 bool bgp_config_inprocess(void)
17742 return thread_is_scheduled(t_bgp_cfg
);
17745 static void bgp_config_finish(struct thread
*t
)
17747 struct listnode
*node
;
17750 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
17751 hook_call(bgp_config_end
, bgp
);
17754 static void bgp_config_start(void)
17756 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
17757 THREAD_OFF(t_bgp_cfg
);
17758 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17759 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
17762 /* When we receive a hook the configuration is read,
17763 * we start a timer to make sure we postpone sending
17764 * EoR before route-maps are processed.
17765 * This is especially valid if using `bgp route-map delay-timer`.
17767 static void bgp_config_end(void)
17769 #define BGP_POST_CONFIG_DELAY_SECONDS 1
17770 uint32_t bgp_post_config_delay
=
17771 thread_is_scheduled(bm
->t_rmap_update
)
17772 ? thread_timer_remain_second(bm
->t_rmap_update
)
17773 : BGP_POST_CONFIG_DELAY_SECONDS
;
17775 /* If BGP config processing thread isn't running, then
17776 * we can return and rely it's properly handled.
17778 if (!bgp_config_inprocess())
17781 THREAD_OFF(t_bgp_cfg
);
17783 /* Start a new timer to make sure we don't send EoR
17784 * before route-maps are processed.
17786 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17787 bgp_post_config_delay
, &t_bgp_cfg
);
17790 void bgp_vty_init(void)
17792 cmd_variable_handler_register(bgp_var_neighbor
);
17793 cmd_variable_handler_register(bgp_var_peergroup
);
17795 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
17797 /* Install bgp top node. */
17798 install_node(&bgp_node
);
17799 install_node(&bgp_ipv4_unicast_node
);
17800 install_node(&bgp_ipv4_multicast_node
);
17801 install_node(&bgp_ipv4_labeled_unicast_node
);
17802 install_node(&bgp_ipv6_unicast_node
);
17803 install_node(&bgp_ipv6_multicast_node
);
17804 install_node(&bgp_ipv6_labeled_unicast_node
);
17805 install_node(&bgp_vpnv4_node
);
17806 install_node(&bgp_vpnv6_node
);
17807 install_node(&bgp_evpn_node
);
17808 install_node(&bgp_evpn_vni_node
);
17809 install_node(&bgp_flowspecv4_node
);
17810 install_node(&bgp_flowspecv6_node
);
17811 install_node(&bgp_srv6_node
);
17813 /* Install default VTY commands to new nodes. */
17814 install_default(BGP_NODE
);
17815 install_default(BGP_IPV4_NODE
);
17816 install_default(BGP_IPV4M_NODE
);
17817 install_default(BGP_IPV4L_NODE
);
17818 install_default(BGP_IPV6_NODE
);
17819 install_default(BGP_IPV6M_NODE
);
17820 install_default(BGP_IPV6L_NODE
);
17821 install_default(BGP_VPNV4_NODE
);
17822 install_default(BGP_VPNV6_NODE
);
17823 install_default(BGP_FLOWSPECV4_NODE
);
17824 install_default(BGP_FLOWSPECV6_NODE
);
17825 install_default(BGP_EVPN_NODE
);
17826 install_default(BGP_EVPN_VNI_NODE
);
17827 install_default(BGP_SRV6_NODE
);
17829 /* "bgp local-mac" hidden commands. */
17830 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17831 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17833 /* "bgp suppress-fib-pending" global */
17834 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17836 /* bgp route-map delay-timer commands. */
17837 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17838 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17840 /* bgp fast-convergence command */
17841 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
17842 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
17844 /* global bgp update-delay command */
17845 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17846 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17848 /* global bgp graceful-shutdown command */
17849 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17850 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17852 /* Dummy commands (Currently not supported) */
17853 install_element(BGP_NODE
, &no_synchronization_cmd
);
17854 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17856 /* "router bgp" commands. */
17857 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17859 /* "no router bgp" commands. */
17860 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17862 /* "bgp session-dscp command */
17863 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
17864 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
17866 /* "bgp router-id" commands. */
17867 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17868 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17870 /* "bgp suppress-fib-pending" command */
17871 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17873 /* "bgp cluster-id" commands. */
17874 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17875 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17877 /* "bgp no-rib" commands. */
17878 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17879 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17881 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17883 /* "bgp confederation" commands. */
17884 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17885 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17887 /* "bgp confederation peers" commands. */
17888 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17889 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17891 /* bgp max-med command */
17892 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17893 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17894 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17895 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17896 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17898 /* bgp disable-ebgp-connected-nh-check */
17899 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17900 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17902 /* bgp update-delay command */
17903 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17904 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17906 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17907 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17909 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17910 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17912 /* "maximum-paths" commands. */
17913 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17914 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17915 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17916 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17917 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17918 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17919 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17920 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17921 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17922 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17923 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17924 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17925 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17926 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17927 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17929 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17930 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17931 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17932 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17933 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17934 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17935 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17936 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17937 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17938 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17940 /* "timers bgp" commands. */
17941 install_element(BGP_NODE
, &bgp_timers_cmd
);
17942 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17944 /* "minimum-holdtime" commands. */
17945 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
17946 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
17948 /* route-map delay-timer commands - per instance for backwards compat.
17950 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17951 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17953 /* "bgp client-to-client reflection" commands */
17954 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17955 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17957 /* "bgp always-compare-med" commands */
17958 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17959 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17961 /* bgp ebgp-requires-policy */
17962 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17963 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17965 /* bgp suppress-duplicates */
17966 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17967 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17969 /* bgp reject-as-sets */
17970 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17971 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17973 /* "bgp deterministic-med" commands */
17974 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17975 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17977 /* "bgp graceful-restart" command */
17978 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17979 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17981 /* "bgp graceful-restart-disable" command */
17982 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17983 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17985 /* "neighbor a:b:c:d graceful-restart" command */
17986 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17987 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17989 /* "neighbor a:b:c:d graceful-restart-disable" command */
17990 install_element(BGP_NODE
,
17991 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17992 install_element(BGP_NODE
,
17993 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17995 /* "neighbor a:b:c:d graceful-restart-helper" command */
17996 install_element(BGP_NODE
,
17997 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17998 install_element(BGP_NODE
,
17999 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18001 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18002 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18003 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18004 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18005 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18006 install_element(BGP_NODE
,
18007 &no_bgp_graceful_restart_select_defer_time_cmd
);
18008 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18009 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18010 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18012 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18013 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18014 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18015 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18017 /* "bgp graceful-shutdown" commands */
18018 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18019 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18021 /* "bgp hard-administrative-reset" commands */
18022 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18024 /* "bgp long-lived-graceful-restart" commands */
18025 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18026 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18028 /* "bgp fast-external-failover" commands */
18029 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18030 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18032 /* "bgp bestpath compare-routerid" commands */
18033 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18034 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18036 /* "bgp bestpath as-path ignore" commands */
18037 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18038 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18040 /* "bgp bestpath as-path confed" commands */
18041 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18042 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18044 /* "bgp bestpath as-path multipath-relax" commands */
18045 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18046 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18048 /* "bgp bestpath peer-type multipath-relax" commands */
18049 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18050 install_element(BGP_NODE
,
18051 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18053 /* "bgp log-neighbor-changes" commands */
18054 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18055 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18057 /* "bgp bestpath med" commands */
18058 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18059 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18061 /* "bgp bestpath bandwidth" commands */
18062 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18063 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18065 /* "no bgp default <afi>-<safi>" commands. */
18066 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18068 /* "bgp network import-check" commands. */
18069 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18070 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18071 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18073 /* "bgp default local-preference" commands. */
18074 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18075 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18077 /* bgp default show-hostname */
18078 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18079 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18081 /* bgp default show-nexthop-hostname */
18082 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18083 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18085 /* "bgp default subgroup-pkt-queue-max" commands. */
18086 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18087 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18089 /* bgp ibgp-allow-policy-mods command */
18090 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18091 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18093 /* "bgp listen limit" commands. */
18094 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18095 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18097 /* "bgp listen range" commands. */
18098 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18099 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18101 /* "bgp default shutdown" command */
18102 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18104 /* "bgp shutdown" commands */
18105 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18106 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18107 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18108 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18110 /* "neighbor remote-as" commands. */
18111 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18112 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18113 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18114 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18115 install_element(BGP_NODE
,
18116 &neighbor_interface_v6only_config_remote_as_cmd
);
18117 install_element(BGP_NODE
, &no_neighbor_cmd
);
18118 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18120 /* "neighbor peer-group" commands. */
18121 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18122 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18123 install_element(BGP_NODE
,
18124 &no_neighbor_interface_peer_group_remote_as_cmd
);
18126 /* "neighbor local-as" commands. */
18127 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18128 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18129 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18130 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18132 /* "neighbor solo" commands. */
18133 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18134 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18136 /* "neighbor password" commands. */
18137 install_element(BGP_NODE
, &neighbor_password_cmd
);
18138 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18140 /* "neighbor activate" commands. */
18141 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18142 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18143 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18144 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18145 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18146 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18147 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18148 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18149 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18150 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18151 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18152 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18154 /* "no neighbor activate" commands. */
18155 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18156 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18157 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18158 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18159 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18160 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18161 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18162 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18163 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18164 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18165 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18166 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18168 /* "neighbor peer-group" set commands. */
18169 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18170 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18171 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18172 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18173 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18174 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18175 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18176 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18177 install_element(BGP_FLOWSPECV4_NODE
,
18178 &neighbor_set_peer_group_hidden_cmd
);
18179 install_element(BGP_FLOWSPECV6_NODE
,
18180 &neighbor_set_peer_group_hidden_cmd
);
18182 /* "no neighbor peer-group unset" commands. */
18183 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18184 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18185 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18186 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18187 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18188 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18189 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18190 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18191 install_element(BGP_FLOWSPECV4_NODE
,
18192 &no_neighbor_set_peer_group_hidden_cmd
);
18193 install_element(BGP_FLOWSPECV6_NODE
,
18194 &no_neighbor_set_peer_group_hidden_cmd
);
18196 /* "neighbor softreconfiguration inbound" commands.*/
18197 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18198 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18199 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18200 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18201 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18202 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18203 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18204 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18205 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18206 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18207 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18208 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18209 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18210 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18211 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18212 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18213 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18214 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18215 install_element(BGP_FLOWSPECV4_NODE
,
18216 &neighbor_soft_reconfiguration_cmd
);
18217 install_element(BGP_FLOWSPECV4_NODE
,
18218 &no_neighbor_soft_reconfiguration_cmd
);
18219 install_element(BGP_FLOWSPECV6_NODE
,
18220 &neighbor_soft_reconfiguration_cmd
);
18221 install_element(BGP_FLOWSPECV6_NODE
,
18222 &no_neighbor_soft_reconfiguration_cmd
);
18223 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18224 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18226 /* "neighbor attribute-unchanged" commands. */
18227 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18228 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18229 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18230 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18231 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18232 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18233 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18234 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18235 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18236 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18237 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18238 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18239 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18240 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18241 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18242 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18243 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18244 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18246 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18247 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18249 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18250 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18251 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18252 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18254 /* "nexthop-local unchanged" commands */
18255 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18256 install_element(BGP_IPV6_NODE
,
18257 &no_neighbor_nexthop_local_unchanged_cmd
);
18259 /* "neighbor next-hop-self" commands. */
18260 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18261 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18262 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18263 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18264 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18265 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18266 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18267 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18268 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18269 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18270 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18271 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18272 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18273 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18274 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18275 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18276 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18277 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18278 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18279 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18281 /* "neighbor next-hop-self force" commands. */
18282 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18283 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18284 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18285 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18286 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18287 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18288 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18289 install_element(BGP_IPV4_NODE
,
18290 &no_neighbor_nexthop_self_all_hidden_cmd
);
18291 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18292 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18293 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18294 install_element(BGP_IPV4M_NODE
,
18295 &no_neighbor_nexthop_self_all_hidden_cmd
);
18296 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18297 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18298 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18299 install_element(BGP_IPV4L_NODE
,
18300 &no_neighbor_nexthop_self_all_hidden_cmd
);
18301 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18302 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18303 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18304 install_element(BGP_IPV6_NODE
,
18305 &no_neighbor_nexthop_self_all_hidden_cmd
);
18306 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18307 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18308 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18309 install_element(BGP_IPV6M_NODE
,
18310 &no_neighbor_nexthop_self_all_hidden_cmd
);
18311 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18312 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18313 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18314 install_element(BGP_IPV6L_NODE
,
18315 &no_neighbor_nexthop_self_all_hidden_cmd
);
18316 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18317 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18318 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18319 install_element(BGP_VPNV4_NODE
,
18320 &no_neighbor_nexthop_self_all_hidden_cmd
);
18321 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18322 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18323 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18324 install_element(BGP_VPNV6_NODE
,
18325 &no_neighbor_nexthop_self_all_hidden_cmd
);
18326 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18327 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18329 /* "neighbor as-override" commands. */
18330 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18331 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18332 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18333 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18334 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18335 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18336 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18337 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18338 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18339 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18340 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18341 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18342 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18343 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18344 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18345 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18346 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18347 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18349 /* "neighbor remove-private-AS" commands. */
18350 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18351 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18352 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18353 install_element(BGP_NODE
,
18354 &no_neighbor_remove_private_as_all_hidden_cmd
);
18355 install_element(BGP_NODE
,
18356 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18357 install_element(BGP_NODE
,
18358 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18359 install_element(BGP_NODE
,
18360 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18363 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18364 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18365 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18366 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18367 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18368 install_element(BGP_IPV4_NODE
,
18369 &neighbor_remove_private_as_replace_as_cmd
);
18370 install_element(BGP_IPV4_NODE
,
18371 &no_neighbor_remove_private_as_replace_as_cmd
);
18372 install_element(BGP_IPV4_NODE
,
18373 &neighbor_remove_private_as_all_replace_as_cmd
);
18374 install_element(BGP_IPV4_NODE
,
18375 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18376 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18377 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18378 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18379 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18380 install_element(BGP_IPV4M_NODE
,
18381 &neighbor_remove_private_as_replace_as_cmd
);
18382 install_element(BGP_IPV4M_NODE
,
18383 &no_neighbor_remove_private_as_replace_as_cmd
);
18384 install_element(BGP_IPV4M_NODE
,
18385 &neighbor_remove_private_as_all_replace_as_cmd
);
18386 install_element(BGP_IPV4M_NODE
,
18387 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18388 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18389 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18390 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18391 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18392 install_element(BGP_IPV4L_NODE
,
18393 &neighbor_remove_private_as_replace_as_cmd
);
18394 install_element(BGP_IPV4L_NODE
,
18395 &no_neighbor_remove_private_as_replace_as_cmd
);
18396 install_element(BGP_IPV4L_NODE
,
18397 &neighbor_remove_private_as_all_replace_as_cmd
);
18398 install_element(BGP_IPV4L_NODE
,
18399 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18400 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18401 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18402 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18403 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18404 install_element(BGP_IPV6_NODE
,
18405 &neighbor_remove_private_as_replace_as_cmd
);
18406 install_element(BGP_IPV6_NODE
,
18407 &no_neighbor_remove_private_as_replace_as_cmd
);
18408 install_element(BGP_IPV6_NODE
,
18409 &neighbor_remove_private_as_all_replace_as_cmd
);
18410 install_element(BGP_IPV6_NODE
,
18411 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18412 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18413 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18414 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18415 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18416 install_element(BGP_IPV6M_NODE
,
18417 &neighbor_remove_private_as_replace_as_cmd
);
18418 install_element(BGP_IPV6M_NODE
,
18419 &no_neighbor_remove_private_as_replace_as_cmd
);
18420 install_element(BGP_IPV6M_NODE
,
18421 &neighbor_remove_private_as_all_replace_as_cmd
);
18422 install_element(BGP_IPV6M_NODE
,
18423 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18424 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18425 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18426 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18427 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18428 install_element(BGP_IPV6L_NODE
,
18429 &neighbor_remove_private_as_replace_as_cmd
);
18430 install_element(BGP_IPV6L_NODE
,
18431 &no_neighbor_remove_private_as_replace_as_cmd
);
18432 install_element(BGP_IPV6L_NODE
,
18433 &neighbor_remove_private_as_all_replace_as_cmd
);
18434 install_element(BGP_IPV6L_NODE
,
18435 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18436 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18437 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18438 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18439 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18440 install_element(BGP_VPNV4_NODE
,
18441 &neighbor_remove_private_as_replace_as_cmd
);
18442 install_element(BGP_VPNV4_NODE
,
18443 &no_neighbor_remove_private_as_replace_as_cmd
);
18444 install_element(BGP_VPNV4_NODE
,
18445 &neighbor_remove_private_as_all_replace_as_cmd
);
18446 install_element(BGP_VPNV4_NODE
,
18447 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18448 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18449 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18450 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18451 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18452 install_element(BGP_VPNV6_NODE
,
18453 &neighbor_remove_private_as_replace_as_cmd
);
18454 install_element(BGP_VPNV6_NODE
,
18455 &no_neighbor_remove_private_as_replace_as_cmd
);
18456 install_element(BGP_VPNV6_NODE
,
18457 &neighbor_remove_private_as_all_replace_as_cmd
);
18458 install_element(BGP_VPNV6_NODE
,
18459 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18461 /* "neighbor send-community" commands.*/
18462 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18463 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18464 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18465 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18466 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18467 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18468 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18469 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18470 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18471 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18472 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18473 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18474 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18475 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18476 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18477 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18478 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18479 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18480 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18481 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18482 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18483 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18484 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18485 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18486 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18487 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18488 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18489 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18490 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18491 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18492 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18493 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18494 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18495 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18496 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18497 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18499 /* "neighbor route-reflector" commands.*/
18500 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18501 install_element(BGP_NODE
,
18502 &no_neighbor_route_reflector_client_hidden_cmd
);
18503 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18504 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18505 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18506 install_element(BGP_IPV4M_NODE
,
18507 &no_neighbor_route_reflector_client_cmd
);
18508 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18509 install_element(BGP_IPV4L_NODE
,
18510 &no_neighbor_route_reflector_client_cmd
);
18511 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18512 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18513 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18514 install_element(BGP_IPV6M_NODE
,
18515 &no_neighbor_route_reflector_client_cmd
);
18516 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18517 install_element(BGP_IPV6L_NODE
,
18518 &no_neighbor_route_reflector_client_cmd
);
18519 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18520 install_element(BGP_VPNV4_NODE
,
18521 &no_neighbor_route_reflector_client_cmd
);
18522 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18523 install_element(BGP_VPNV6_NODE
,
18524 &no_neighbor_route_reflector_client_cmd
);
18525 install_element(BGP_FLOWSPECV4_NODE
,
18526 &neighbor_route_reflector_client_cmd
);
18527 install_element(BGP_FLOWSPECV4_NODE
,
18528 &no_neighbor_route_reflector_client_cmd
);
18529 install_element(BGP_FLOWSPECV6_NODE
,
18530 &neighbor_route_reflector_client_cmd
);
18531 install_element(BGP_FLOWSPECV6_NODE
,
18532 &no_neighbor_route_reflector_client_cmd
);
18533 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18534 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18536 /* "neighbor route-server" commands.*/
18537 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18538 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18539 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18540 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18541 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18542 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18543 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18544 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18545 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18546 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18547 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18548 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18549 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18550 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18551 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18552 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18553 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18554 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18555 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18556 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18557 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18558 install_element(BGP_FLOWSPECV4_NODE
,
18559 &no_neighbor_route_server_client_cmd
);
18560 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18561 install_element(BGP_FLOWSPECV6_NODE
,
18562 &no_neighbor_route_server_client_cmd
);
18564 /* "neighbor disable-addpath-rx" commands. */
18565 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18566 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18567 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18568 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18569 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18570 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18571 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18572 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18573 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18574 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18575 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18576 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18577 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18578 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18579 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18580 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18582 /* "neighbor addpath-tx-all-paths" commands.*/
18583 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18584 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18585 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18586 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18587 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18588 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18589 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18590 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18591 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18592 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18593 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18594 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18595 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18596 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18597 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18598 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18599 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18600 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18602 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18603 install_element(BGP_NODE
,
18604 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18605 install_element(BGP_NODE
,
18606 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18607 install_element(BGP_IPV4_NODE
,
18608 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18609 install_element(BGP_IPV4_NODE
,
18610 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18611 install_element(BGP_IPV4M_NODE
,
18612 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18613 install_element(BGP_IPV4M_NODE
,
18614 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18615 install_element(BGP_IPV4L_NODE
,
18616 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18617 install_element(BGP_IPV4L_NODE
,
18618 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18619 install_element(BGP_IPV6_NODE
,
18620 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18621 install_element(BGP_IPV6_NODE
,
18622 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18623 install_element(BGP_IPV6M_NODE
,
18624 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18625 install_element(BGP_IPV6M_NODE
,
18626 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18627 install_element(BGP_IPV6L_NODE
,
18628 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18629 install_element(BGP_IPV6L_NODE
,
18630 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18631 install_element(BGP_VPNV4_NODE
,
18632 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18633 install_element(BGP_VPNV4_NODE
,
18634 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18635 install_element(BGP_VPNV6_NODE
,
18636 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18637 install_element(BGP_VPNV6_NODE
,
18638 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18640 /* "neighbor sender-as-path-loop-detection" commands. */
18641 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18642 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18644 /* "neighbor passive" commands. */
18645 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18646 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18649 /* "neighbor shutdown" commands. */
18650 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18651 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18652 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18653 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18654 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18655 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18657 /* "neighbor capability extended-nexthop" commands.*/
18658 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18659 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18661 /* "neighbor capability orf prefix-list" commands.*/
18662 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18663 install_element(BGP_NODE
,
18664 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18665 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18666 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18667 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18668 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18669 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18670 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18671 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18672 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18673 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18674 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18675 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18676 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18678 /* "neighbor capability dynamic" commands.*/
18679 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18680 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18682 /* "neighbor dont-capability-negotiate" commands. */
18683 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18684 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18686 /* "neighbor ebgp-multihop" commands. */
18687 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18688 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18689 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18691 /* "neighbor disable-connected-check" commands. */
18692 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18693 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18695 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18696 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18697 install_element(BGP_NODE
,
18698 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18700 /* "neighbor extended-optional-parameters" commands. */
18701 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18702 install_element(BGP_NODE
,
18703 &no_neighbor_extended_optional_parameters_cmd
);
18705 /* "neighbor enforce-first-as" commands. */
18706 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18707 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18709 /* "neighbor description" commands. */
18710 install_element(BGP_NODE
, &neighbor_description_cmd
);
18711 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18712 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18714 /* "neighbor update-source" commands. "*/
18715 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18716 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18718 /* "neighbor default-originate" commands. */
18719 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18720 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18721 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18722 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18723 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18724 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18725 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18726 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18727 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18728 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18729 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18730 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18731 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18732 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18733 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18734 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18735 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18736 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18737 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18738 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18739 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18741 /* "neighbor port" commands. */
18742 install_element(BGP_NODE
, &neighbor_port_cmd
);
18743 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18745 /* "neighbor weight" commands. */
18746 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18747 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18749 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18750 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18751 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18752 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18753 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18754 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18755 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18756 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18757 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18758 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18759 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18760 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18761 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18762 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18763 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18764 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18766 /* "neighbor override-capability" commands. */
18767 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18768 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18770 /* "neighbor strict-capability-match" commands. */
18771 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18772 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18774 /* "neighbor timers" commands. */
18775 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18776 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18778 /* "neighbor timers connect" commands. */
18779 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18780 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18782 /* "neighbor timers delayopen" commands. */
18783 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18784 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18786 /* "neighbor advertisement-interval" commands. */
18787 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18788 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18790 /* "neighbor interface" commands. */
18791 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18792 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18794 /* "neighbor distribute" commands. */
18795 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18796 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18797 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18798 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18799 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18800 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18801 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18802 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18803 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18804 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18805 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18806 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18807 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18808 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18809 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18810 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18811 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18812 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18814 /* "neighbor prefix-list" commands. */
18815 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18816 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18817 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18818 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18819 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18820 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18821 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18822 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18823 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18824 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18825 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18826 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18827 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18828 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18829 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18830 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18831 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18832 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18833 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18834 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18835 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18836 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18838 /* "neighbor filter-list" commands. */
18839 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18840 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18841 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18842 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18843 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18844 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18845 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18846 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18847 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18848 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18849 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18850 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18851 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18852 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18853 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18854 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18855 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18856 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18857 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18858 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18859 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18860 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18862 /* "neighbor route-map" commands. */
18863 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18864 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18865 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18866 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18867 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18868 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18869 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18870 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18871 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18872 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18873 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18874 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18875 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18876 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18877 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18878 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18879 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18880 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18881 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18882 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18883 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18884 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18885 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18886 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18888 /* "neighbor unsuppress-map" commands. */
18889 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18890 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18891 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18892 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18893 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18894 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18895 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18896 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18897 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18898 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18899 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18900 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18901 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18902 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18903 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18904 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18905 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18906 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18908 /* "neighbor advertise-map" commands. */
18909 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
18910 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18911 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18912 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18913 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18914 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18915 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18916 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18917 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18918 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18920 /* neighbor maximum-prefix-out commands. */
18921 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18922 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18923 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18924 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18925 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18926 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18927 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18928 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18929 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18930 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18931 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18932 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18933 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18934 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18935 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18936 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18937 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18938 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18940 /* "neighbor maximum-prefix" commands. */
18941 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18942 install_element(BGP_NODE
,
18943 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18944 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18945 install_element(BGP_NODE
,
18946 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18947 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18948 install_element(BGP_NODE
,
18949 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18950 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18951 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18952 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18953 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18954 install_element(BGP_IPV4_NODE
,
18955 &neighbor_maximum_prefix_threshold_warning_cmd
);
18956 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18957 install_element(BGP_IPV4_NODE
,
18958 &neighbor_maximum_prefix_threshold_restart_cmd
);
18959 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18960 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18961 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18962 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18963 install_element(BGP_IPV4M_NODE
,
18964 &neighbor_maximum_prefix_threshold_warning_cmd
);
18965 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18966 install_element(BGP_IPV4M_NODE
,
18967 &neighbor_maximum_prefix_threshold_restart_cmd
);
18968 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18969 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18970 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18971 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18972 install_element(BGP_IPV4L_NODE
,
18973 &neighbor_maximum_prefix_threshold_warning_cmd
);
18974 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18975 install_element(BGP_IPV4L_NODE
,
18976 &neighbor_maximum_prefix_threshold_restart_cmd
);
18977 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18978 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18979 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18980 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18981 install_element(BGP_IPV6_NODE
,
18982 &neighbor_maximum_prefix_threshold_warning_cmd
);
18983 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18984 install_element(BGP_IPV6_NODE
,
18985 &neighbor_maximum_prefix_threshold_restart_cmd
);
18986 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18987 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18988 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18989 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18990 install_element(BGP_IPV6M_NODE
,
18991 &neighbor_maximum_prefix_threshold_warning_cmd
);
18992 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18993 install_element(BGP_IPV6M_NODE
,
18994 &neighbor_maximum_prefix_threshold_restart_cmd
);
18995 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18996 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18997 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18998 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18999 install_element(BGP_IPV6L_NODE
,
19000 &neighbor_maximum_prefix_threshold_warning_cmd
);
19001 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19002 install_element(BGP_IPV6L_NODE
,
19003 &neighbor_maximum_prefix_threshold_restart_cmd
);
19004 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19005 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19006 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19007 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19008 install_element(BGP_VPNV4_NODE
,
19009 &neighbor_maximum_prefix_threshold_warning_cmd
);
19010 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19011 install_element(BGP_VPNV4_NODE
,
19012 &neighbor_maximum_prefix_threshold_restart_cmd
);
19013 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19014 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19015 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19016 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19017 install_element(BGP_VPNV6_NODE
,
19018 &neighbor_maximum_prefix_threshold_warning_cmd
);
19019 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19020 install_element(BGP_VPNV6_NODE
,
19021 &neighbor_maximum_prefix_threshold_restart_cmd
);
19022 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19024 /* "neighbor allowas-in" */
19025 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19026 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19027 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19028 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19029 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19030 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19031 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19032 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19033 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19034 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19035 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19036 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19037 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19038 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19039 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19040 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19041 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19042 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19043 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19044 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19046 /* address-family commands. */
19047 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19048 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19049 #ifdef KEEP_OLD_VPN_COMMANDS
19050 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19051 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19052 #endif /* KEEP_OLD_VPN_COMMANDS */
19054 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19056 /* "exit-address-family" command. */
19057 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19058 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19059 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19060 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19061 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19062 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19063 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19064 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19065 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19066 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19067 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19069 /* "clear ip bgp commands" */
19070 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19072 /* clear ip bgp prefix */
19073 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19074 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19075 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19077 /* "show [ip] bgp summary" commands. */
19078 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19079 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19080 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19081 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19082 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19083 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19084 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19086 /* "show [ip] bgp neighbors" commands. */
19087 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19089 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19091 /* "show [ip] bgp peer-group" commands. */
19092 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19094 /* "show [ip] bgp paths" commands. */
19095 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19097 /* "show [ip] bgp community" commands. */
19098 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19100 /* "show ip bgp large-community" commands. */
19101 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19102 /* "show [ip] bgp attribute-info" commands. */
19103 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19104 /* "show [ip] bgp route-leak" command */
19105 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19107 /* "redistribute" commands. */
19108 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19109 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19110 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19111 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19112 install_element(BGP_NODE
,
19113 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19114 install_element(BGP_NODE
,
19115 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19116 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19117 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19118 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19119 install_element(BGP_NODE
,
19120 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19121 install_element(BGP_NODE
,
19122 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19123 install_element(BGP_NODE
,
19124 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19125 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19126 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19127 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19128 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19129 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19130 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19131 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19132 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19133 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19134 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19135 install_element(BGP_IPV4_NODE
,
19136 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19137 install_element(BGP_IPV4_NODE
,
19138 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19139 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19140 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19141 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19142 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19143 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19144 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19146 /* import|export vpn [route-map WORD] */
19147 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19148 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19150 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19151 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19153 /* ttl_security commands */
19154 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19155 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19157 /* "show [ip] bgp memory" commands. */
19158 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19160 /* "show bgp martian next-hop" */
19161 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19163 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19165 /* "show [ip] bgp views" commands. */
19166 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19168 /* "show [ip] bgp vrfs" commands. */
19169 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19171 /* Community-list. */
19172 community_list_vty();
19174 community_alias_vty();
19176 /* vpn-policy commands */
19177 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19178 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19179 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19180 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19181 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19182 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19183 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19184 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19185 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19186 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19187 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19188 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19190 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19191 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19193 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19194 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19195 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19196 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19197 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19198 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19199 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19200 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19201 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19202 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19204 /* tcp-mss command */
19205 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19206 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19208 /* srv6 commands */
19209 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19210 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19211 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19212 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19213 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19214 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19215 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19218 #include "memory.h"
19219 #include "bgp_regex.h"
19220 #include "bgp_clist.h"
19221 #include "bgp_ecommunity.h"
19223 /* VTY functions. */
19225 /* Direction value to string conversion. */
19226 static const char *community_direct_str(int direct
)
19229 case COMMUNITY_DENY
:
19231 case COMMUNITY_PERMIT
:
19238 /* Display error string. */
19239 static void community_list_perror(struct vty
*vty
, int ret
)
19242 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19243 vty_out(vty
, "%% Can't find community-list\n");
19245 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19246 vty_out(vty
, "%% Malformed community-list value\n");
19248 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19250 "%% Community name conflict, previously defined as standard community\n");
19252 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19254 "%% Community name conflict, previously defined as expanded community\n");
19259 /* "community-list" keyword help string. */
19260 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19262 /*community-list standard */
19263 DEFUN (community_list_standard
,
19264 bgp_community_list_standard_cmd
,
19265 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19268 "Community list number (standard)\n"
19269 "Add an standard community-list entry\n"
19270 "Community list name\n"
19271 "Sequence number of an entry\n"
19272 "Sequence number\n"
19273 "Specify community to reject\n"
19274 "Specify community to accept\n"
19277 char *cl_name_or_number
= NULL
;
19280 int style
= COMMUNITY_LIST_STANDARD
;
19283 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19284 seq
= argv
[idx
]->arg
;
19287 argv_find(argv
, argc
, "(1-99)", &idx
);
19288 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19289 cl_name_or_number
= argv
[idx
]->arg
;
19290 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19292 argv_find(argv
, argc
, "AA:NN", &idx
);
19293 char *str
= argv_concat(argv
, argc
, idx
);
19295 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19298 XFREE(MTYPE_TMP
, str
);
19301 /* Display error string. */
19302 community_list_perror(vty
, ret
);
19303 return CMD_WARNING_CONFIG_FAILED
;
19306 return CMD_SUCCESS
;
19309 DEFUN (no_community_list_standard_all
,
19310 no_bgp_community_list_standard_all_cmd
,
19311 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19315 "Community list number (standard)\n"
19316 "Add an standard community-list entry\n"
19317 "Community list name\n"
19318 "Sequence number of an entry\n"
19319 "Sequence number\n"
19320 "Specify community to reject\n"
19321 "Specify community to accept\n"
19324 char *cl_name_or_number
= NULL
;
19327 int style
= COMMUNITY_LIST_STANDARD
;
19331 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19332 seq
= argv
[idx
]->arg
;
19335 argv_find(argv
, argc
, "permit", &idx
);
19336 argv_find(argv
, argc
, "deny", &idx
);
19339 direct
= argv_find(argv
, argc
, "permit", &idx
)
19344 argv_find(argv
, argc
, "AA:NN", &idx
);
19345 str
= argv_concat(argv
, argc
, idx
);
19349 argv_find(argv
, argc
, "(1-99)", &idx
);
19350 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19351 cl_name_or_number
= argv
[idx
]->arg
;
19353 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19356 XFREE(MTYPE_TMP
, str
);
19359 community_list_perror(vty
, ret
);
19360 return CMD_WARNING_CONFIG_FAILED
;
19363 return CMD_SUCCESS
;
19366 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19367 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19368 NO_STR BGP_STR COMMUNITY_LIST_STR
19369 "Community list number (standard)\n"
19370 "Add an standard community-list entry\n"
19371 "Community list name\n")
19373 /*community-list expanded */
19374 DEFUN (community_list_expanded_all
,
19375 bgp_community_list_expanded_all_cmd
,
19376 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19379 "Community list number (expanded)\n"
19380 "Add an expanded community-list entry\n"
19381 "Community list name\n"
19382 "Sequence number of an entry\n"
19383 "Sequence number\n"
19384 "Specify community to reject\n"
19385 "Specify community to accept\n"
19388 char *cl_name_or_number
= NULL
;
19391 int style
= COMMUNITY_LIST_EXPANDED
;
19394 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19395 seq
= argv
[idx
]->arg
;
19399 argv_find(argv
, argc
, "(100-500)", &idx
);
19400 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19401 cl_name_or_number
= argv
[idx
]->arg
;
19402 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19404 argv_find(argv
, argc
, "AA:NN", &idx
);
19405 char *str
= argv_concat(argv
, argc
, idx
);
19407 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19410 XFREE(MTYPE_TMP
, str
);
19413 /* Display error string. */
19414 community_list_perror(vty
, ret
);
19415 return CMD_WARNING_CONFIG_FAILED
;
19418 return CMD_SUCCESS
;
19421 DEFUN (no_community_list_expanded_all
,
19422 no_bgp_community_list_expanded_all_cmd
,
19423 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19427 "Community list number (expanded)\n"
19428 "Add an expanded community-list entry\n"
19429 "Community list name\n"
19430 "Sequence number of an entry\n"
19431 "Sequence number\n"
19432 "Specify community to reject\n"
19433 "Specify community to accept\n"
19436 char *cl_name_or_number
= NULL
;
19440 int style
= COMMUNITY_LIST_EXPANDED
;
19443 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19444 seq
= argv
[idx
]->arg
;
19447 argv_find(argv
, argc
, "permit", &idx
);
19448 argv_find(argv
, argc
, "deny", &idx
);
19451 direct
= argv_find(argv
, argc
, "permit", &idx
)
19456 argv_find(argv
, argc
, "AA:NN", &idx
);
19457 str
= argv_concat(argv
, argc
, idx
);
19461 argv_find(argv
, argc
, "(100-500)", &idx
);
19462 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19463 cl_name_or_number
= argv
[idx
]->arg
;
19465 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19468 XFREE(MTYPE_TMP
, str
);
19471 community_list_perror(vty
, ret
);
19472 return CMD_WARNING_CONFIG_FAILED
;
19475 return CMD_SUCCESS
;
19478 ALIAS(no_community_list_expanded_all
,
19479 no_bgp_community_list_expanded_all_list_cmd
,
19480 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19481 NO_STR BGP_STR COMMUNITY_LIST_STR
19482 "Community list number (expanded)\n"
19483 "Add an expanded community-list entry\n"
19484 "Community list name\n")
19486 /* Return configuration string of community-list entry. */
19487 static const char *community_list_config_str(struct community_entry
*entry
)
19494 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19495 str
= community_str(entry
->u
.com
, false, false);
19496 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19497 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19499 str
= entry
->config
;
19504 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19506 struct community_entry
*entry
;
19508 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19509 if (entry
== list
->head
) {
19510 if (all_digit(list
->name
))
19511 vty_out(vty
, "Community %s list %s\n",
19512 entry
->style
== COMMUNITY_LIST_STANDARD
19514 : "(expanded) access",
19517 vty_out(vty
, "Named Community %s list %s\n",
19518 entry
->style
== COMMUNITY_LIST_STANDARD
19524 vty_out(vty
, " %s\n",
19525 community_direct_str(entry
->direct
));
19527 vty_out(vty
, " %s %s\n",
19528 community_direct_str(entry
->direct
),
19529 community_list_config_str(entry
));
19533 DEFUN (show_community_list
,
19534 show_bgp_community_list_cmd
,
19535 "show bgp community-list",
19538 "List community-list\n")
19540 struct community_list
*list
;
19541 struct community_list_master
*cm
;
19543 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19545 return CMD_SUCCESS
;
19547 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19548 community_list_show(vty
, list
);
19550 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19551 community_list_show(vty
, list
);
19553 return CMD_SUCCESS
;
19556 DEFUN (show_community_list_arg
,
19557 show_bgp_community_list_arg_cmd
,
19558 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19561 "List community-list\n"
19562 "Community-list number\n"
19563 "Community-list name\n"
19564 "Detailed information on community-list\n")
19566 int idx_comm_list
= 3;
19567 struct community_list
*list
;
19569 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19570 COMMUNITY_LIST_MASTER
);
19572 vty_out(vty
, "%% Can't find community-list\n");
19573 return CMD_WARNING
;
19576 community_list_show(vty
, list
);
19578 return CMD_SUCCESS
;
19582 * Large Community code.
19584 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19585 struct cmd_token
**argv
, int style
,
19586 int reject_all_digit_name
)
19595 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19596 seq
= argv
[idx
]->arg
;
19599 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19602 /* All digit name check. */
19604 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19605 argv_find(argv
, argc
, "(1-99)", &idx
);
19606 argv_find(argv
, argc
, "(100-500)", &idx
);
19607 cl_name
= argv
[idx
]->arg
;
19608 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19609 vty_out(vty
, "%% Community name cannot have all digits\n");
19610 return CMD_WARNING_CONFIG_FAILED
;
19614 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19615 argv_find(argv
, argc
, "LINE", &idx
);
19616 /* Concat community string argument. */
19618 str
= argv_concat(argv
, argc
, idx
);
19622 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19624 /* Free temporary community list string allocated by
19626 XFREE(MTYPE_TMP
, str
);
19629 community_list_perror(vty
, ret
);
19630 return CMD_WARNING_CONFIG_FAILED
;
19632 return CMD_SUCCESS
;
19635 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19636 struct cmd_token
**argv
, int style
)
19644 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19645 seq
= argv
[idx
]->arg
;
19648 argv_find(argv
, argc
, "permit", &idx
);
19649 argv_find(argv
, argc
, "deny", &idx
);
19652 /* Check the list direct. */
19653 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19654 direct
= COMMUNITY_PERMIT
;
19656 direct
= COMMUNITY_DENY
;
19659 argv_find(argv
, argc
, "LINE", &idx
);
19660 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19661 /* Concat community string argument. */
19662 str
= argv_concat(argv
, argc
, idx
);
19666 argv_find(argv
, argc
, "(1-99)", &idx
);
19667 argv_find(argv
, argc
, "(100-500)", &idx
);
19668 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19670 /* Unset community list. */
19671 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19674 /* Free temporary community list string allocated by
19676 XFREE(MTYPE_TMP
, str
);
19679 community_list_perror(vty
, ret
);
19680 return CMD_WARNING_CONFIG_FAILED
;
19683 return CMD_SUCCESS
;
19686 /* "large-community-list" keyword help string. */
19687 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19688 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19690 DEFUN (lcommunity_list_standard
,
19691 bgp_lcommunity_list_standard_cmd
,
19692 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19694 LCOMMUNITY_LIST_STR
19695 "Large Community list number (standard)\n"
19696 "Sequence number of an entry\n"
19697 "Sequence number\n"
19698 "Specify large community to reject\n"
19699 "Specify large community to accept\n"
19700 LCOMMUNITY_VAL_STR
)
19702 return lcommunity_list_set_vty(vty
, argc
, argv
,
19703 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19706 DEFUN (lcommunity_list_expanded
,
19707 bgp_lcommunity_list_expanded_cmd
,
19708 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19710 LCOMMUNITY_LIST_STR
19711 "Large Community list number (expanded)\n"
19712 "Sequence number of an entry\n"
19713 "Sequence number\n"
19714 "Specify large community to reject\n"
19715 "Specify large community to accept\n"
19716 "An ordered list as a regular-expression\n")
19718 return lcommunity_list_set_vty(vty
, argc
, argv
,
19719 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19722 DEFUN (lcommunity_list_name_standard
,
19723 bgp_lcommunity_list_name_standard_cmd
,
19724 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19726 LCOMMUNITY_LIST_STR
19727 "Specify standard large-community-list\n"
19728 "Large Community list name\n"
19729 "Sequence number of an entry\n"
19730 "Sequence number\n"
19731 "Specify large community to reject\n"
19732 "Specify large community to accept\n"
19733 LCOMMUNITY_VAL_STR
)
19735 return lcommunity_list_set_vty(vty
, argc
, argv
,
19736 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19739 DEFUN (lcommunity_list_name_expanded
,
19740 bgp_lcommunity_list_name_expanded_cmd
,
19741 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19743 LCOMMUNITY_LIST_STR
19744 "Specify expanded large-community-list\n"
19745 "Large Community list name\n"
19746 "Sequence number of an entry\n"
19747 "Sequence number\n"
19748 "Specify large community to reject\n"
19749 "Specify large community to accept\n"
19750 "An ordered list as a regular-expression\n")
19752 return lcommunity_list_set_vty(vty
, argc
, argv
,
19753 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19756 DEFUN (no_lcommunity_list_all
,
19757 no_bgp_lcommunity_list_all_cmd
,
19758 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19761 LCOMMUNITY_LIST_STR
19762 "Large Community list number (standard)\n"
19763 "Large Community list number (expanded)\n"
19764 "Large Community list name\n")
19766 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19767 LARGE_COMMUNITY_LIST_STANDARD
);
19770 DEFUN (no_lcommunity_list_name_standard_all
,
19771 no_bgp_lcommunity_list_name_standard_all_cmd
,
19772 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19775 LCOMMUNITY_LIST_STR
19776 "Specify standard large-community-list\n"
19777 "Large Community list name\n")
19779 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19780 LARGE_COMMUNITY_LIST_STANDARD
);
19783 DEFUN (no_lcommunity_list_name_expanded_all
,
19784 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19785 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19788 LCOMMUNITY_LIST_STR
19789 "Specify expanded large-community-list\n"
19790 "Large Community list name\n")
19792 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19793 LARGE_COMMUNITY_LIST_EXPANDED
);
19796 DEFUN (no_lcommunity_list_standard
,
19797 no_bgp_lcommunity_list_standard_cmd
,
19798 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19801 LCOMMUNITY_LIST_STR
19802 "Large Community list number (standard)\n"
19803 "Sequence number of an entry\n"
19804 "Sequence number\n"
19805 "Specify large community to reject\n"
19806 "Specify large community to accept\n"
19807 LCOMMUNITY_VAL_STR
)
19809 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19810 LARGE_COMMUNITY_LIST_STANDARD
);
19813 DEFUN (no_lcommunity_list_expanded
,
19814 no_bgp_lcommunity_list_expanded_cmd
,
19815 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19818 LCOMMUNITY_LIST_STR
19819 "Large Community list number (expanded)\n"
19820 "Sequence number of an entry\n"
19821 "Sequence number\n"
19822 "Specify large community to reject\n"
19823 "Specify large community to accept\n"
19824 "An ordered list as a regular-expression\n")
19826 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19827 LARGE_COMMUNITY_LIST_EXPANDED
);
19830 DEFUN (no_lcommunity_list_name_standard
,
19831 no_bgp_lcommunity_list_name_standard_cmd
,
19832 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19835 LCOMMUNITY_LIST_STR
19836 "Specify standard large-community-list\n"
19837 "Large Community list name\n"
19838 "Sequence number of an entry\n"
19839 "Sequence number\n"
19840 "Specify large community to reject\n"
19841 "Specify large community to accept\n"
19842 LCOMMUNITY_VAL_STR
)
19844 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19845 LARGE_COMMUNITY_LIST_STANDARD
);
19848 DEFUN (no_lcommunity_list_name_expanded
,
19849 no_bgp_lcommunity_list_name_expanded_cmd
,
19850 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19853 LCOMMUNITY_LIST_STR
19854 "Specify expanded large-community-list\n"
19855 "Large community list name\n"
19856 "Sequence number of an entry\n"
19857 "Sequence number\n"
19858 "Specify large community to reject\n"
19859 "Specify large community to accept\n"
19860 "An ordered list as a regular-expression\n")
19862 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19863 LARGE_COMMUNITY_LIST_EXPANDED
);
19866 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19868 struct community_entry
*entry
;
19870 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19871 if (entry
== list
->head
) {
19872 if (all_digit(list
->name
))
19873 vty_out(vty
, "Large community %s list %s\n",
19875 LARGE_COMMUNITY_LIST_STANDARD
19877 : "(expanded) access",
19881 "Named large community %s list %s\n",
19883 LARGE_COMMUNITY_LIST_STANDARD
19889 vty_out(vty
, " %s\n",
19890 community_direct_str(entry
->direct
));
19892 vty_out(vty
, " %s %s\n",
19893 community_direct_str(entry
->direct
),
19894 community_list_config_str(entry
));
19898 DEFUN (show_lcommunity_list
,
19899 show_bgp_lcommunity_list_cmd
,
19900 "show bgp large-community-list",
19903 "List large-community list\n")
19905 struct community_list
*list
;
19906 struct community_list_master
*cm
;
19908 cm
= community_list_master_lookup(bgp_clist
,
19909 LARGE_COMMUNITY_LIST_MASTER
);
19911 return CMD_SUCCESS
;
19913 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19914 lcommunity_list_show(vty
, list
);
19916 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19917 lcommunity_list_show(vty
, list
);
19919 return CMD_SUCCESS
;
19922 DEFUN (show_lcommunity_list_arg
,
19923 show_bgp_lcommunity_list_arg_cmd
,
19924 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
19927 "List large-community list\n"
19928 "Large-community-list number\n"
19929 "Large-community-list name\n"
19930 "Detailed information on large-community-list\n")
19932 struct community_list
*list
;
19934 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19935 LARGE_COMMUNITY_LIST_MASTER
);
19937 vty_out(vty
, "%% Can't find large-community-list\n");
19938 return CMD_WARNING
;
19941 lcommunity_list_show(vty
, list
);
19943 return CMD_SUCCESS
;
19946 /* "extcommunity-list" keyword help string. */
19947 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19948 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19950 DEFUN (extcommunity_list_standard
,
19951 bgp_extcommunity_list_standard_cmd
,
19952 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19954 EXTCOMMUNITY_LIST_STR
19955 "Extended Community list number (standard)\n"
19956 "Specify standard extcommunity-list\n"
19957 "Community list name\n"
19958 "Sequence number of an entry\n"
19959 "Sequence number\n"
19960 "Specify community to reject\n"
19961 "Specify community to accept\n"
19962 EXTCOMMUNITY_VAL_STR
)
19964 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19966 char *cl_number_or_name
= NULL
;
19971 argv_find(argv
, argc
, "(1-99)", &idx
);
19972 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19973 cl_number_or_name
= argv
[idx
]->arg
;
19975 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19976 seq
= argv
[idx
]->arg
;
19978 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19980 argv_find(argv
, argc
, "AA:NN", &idx
);
19981 char *str
= argv_concat(argv
, argc
, idx
);
19983 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19986 XFREE(MTYPE_TMP
, str
);
19989 community_list_perror(vty
, ret
);
19990 return CMD_WARNING_CONFIG_FAILED
;
19993 return CMD_SUCCESS
;
19996 DEFUN (extcommunity_list_name_expanded
,
19997 bgp_extcommunity_list_name_expanded_cmd
,
19998 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20000 EXTCOMMUNITY_LIST_STR
20001 "Extended Community list number (expanded)\n"
20002 "Specify expanded extcommunity-list\n"
20003 "Extended Community list name\n"
20004 "Sequence number of an entry\n"
20005 "Sequence number\n"
20006 "Specify community to reject\n"
20007 "Specify community to accept\n"
20008 "An ordered list as a regular-expression\n")
20010 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20012 char *cl_number_or_name
= NULL
;
20016 argv_find(argv
, argc
, "(100-500)", &idx
);
20017 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20018 cl_number_or_name
= argv
[idx
]->arg
;
20020 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20021 seq
= argv
[idx
]->arg
;
20023 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20025 argv_find(argv
, argc
, "LINE", &idx
);
20026 char *str
= argv_concat(argv
, argc
, idx
);
20028 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20031 XFREE(MTYPE_TMP
, str
);
20034 community_list_perror(vty
, ret
);
20035 return CMD_WARNING_CONFIG_FAILED
;
20038 return CMD_SUCCESS
;
20041 DEFUN (no_extcommunity_list_standard_all
,
20042 no_bgp_extcommunity_list_standard_all_cmd
,
20043 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20046 EXTCOMMUNITY_LIST_STR
20047 "Extended Community list number (standard)\n"
20048 "Specify standard extcommunity-list\n"
20049 "Community list name\n"
20050 "Sequence number of an entry\n"
20051 "Sequence number\n"
20052 "Specify community to reject\n"
20053 "Specify community to accept\n"
20054 EXTCOMMUNITY_VAL_STR
)
20056 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20058 char *cl_number_or_name
= NULL
;
20063 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20064 seq
= argv
[idx
]->arg
;
20067 argv_find(argv
, argc
, "permit", &idx
);
20068 argv_find(argv
, argc
, "deny", &idx
);
20070 direct
= argv_find(argv
, argc
, "permit", &idx
)
20075 argv_find(argv
, argc
, "AA:NN", &idx
);
20076 str
= argv_concat(argv
, argc
, idx
);
20080 argv_find(argv
, argc
, "(1-99)", &idx
);
20081 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20082 cl_number_or_name
= argv
[idx
]->arg
;
20084 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20085 seq
, direct
, style
);
20087 XFREE(MTYPE_TMP
, str
);
20090 community_list_perror(vty
, ret
);
20091 return CMD_WARNING_CONFIG_FAILED
;
20094 return CMD_SUCCESS
;
20097 ALIAS(no_extcommunity_list_standard_all
,
20098 no_bgp_extcommunity_list_standard_all_list_cmd
,
20099 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20100 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20101 "Extended Community list number (standard)\n"
20102 "Specify standard extcommunity-list\n"
20103 "Community list name\n")
20105 DEFUN (no_extcommunity_list_expanded_all
,
20106 no_bgp_extcommunity_list_expanded_all_cmd
,
20107 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20110 EXTCOMMUNITY_LIST_STR
20111 "Extended Community list number (expanded)\n"
20112 "Specify expanded extcommunity-list\n"
20113 "Extended Community list name\n"
20114 "Sequence number of an entry\n"
20115 "Sequence number\n"
20116 "Specify community to reject\n"
20117 "Specify community to accept\n"
20118 "An ordered list as a regular-expression\n")
20120 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20122 char *cl_number_or_name
= NULL
;
20127 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20128 seq
= argv
[idx
]->arg
;
20131 argv_find(argv
, argc
, "permit", &idx
);
20132 argv_find(argv
, argc
, "deny", &idx
);
20135 direct
= argv_find(argv
, argc
, "permit", &idx
)
20140 argv_find(argv
, argc
, "LINE", &idx
);
20141 str
= argv_concat(argv
, argc
, idx
);
20145 argv_find(argv
, argc
, "(100-500)", &idx
);
20146 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20147 cl_number_or_name
= argv
[idx
]->arg
;
20149 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20150 seq
, direct
, style
);
20152 XFREE(MTYPE_TMP
, str
);
20155 community_list_perror(vty
, ret
);
20156 return CMD_WARNING_CONFIG_FAILED
;
20159 return CMD_SUCCESS
;
20162 ALIAS(no_extcommunity_list_expanded_all
,
20163 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20164 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20165 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20166 "Extended Community list number (expanded)\n"
20167 "Specify expanded extcommunity-list\n"
20168 "Extended Community list name\n")
20170 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20172 struct community_entry
*entry
;
20174 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20175 if (entry
== list
->head
) {
20176 if (all_digit(list
->name
))
20177 vty_out(vty
, "Extended community %s list %s\n",
20178 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20180 : "(expanded) access",
20184 "Named extended community %s list %s\n",
20185 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20191 vty_out(vty
, " %s\n",
20192 community_direct_str(entry
->direct
));
20194 vty_out(vty
, " %s %s\n",
20195 community_direct_str(entry
->direct
),
20196 community_list_config_str(entry
));
20200 DEFUN (show_extcommunity_list
,
20201 show_bgp_extcommunity_list_cmd
,
20202 "show bgp extcommunity-list",
20205 "List extended-community list\n")
20207 struct community_list
*list
;
20208 struct community_list_master
*cm
;
20210 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20212 return CMD_SUCCESS
;
20214 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20215 extcommunity_list_show(vty
, list
);
20217 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20218 extcommunity_list_show(vty
, list
);
20220 return CMD_SUCCESS
;
20223 DEFUN (show_extcommunity_list_arg
,
20224 show_bgp_extcommunity_list_arg_cmd
,
20225 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20228 "List extended-community list\n"
20229 "Extcommunity-list number\n"
20230 "Extcommunity-list name\n"
20231 "Detailed information on extcommunity-list\n")
20233 int idx_comm_list
= 3;
20234 struct community_list
*list
;
20236 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20237 EXTCOMMUNITY_LIST_MASTER
);
20239 vty_out(vty
, "%% Can't find extcommunity-list\n");
20240 return CMD_WARNING
;
20243 extcommunity_list_show(vty
, list
);
20245 return CMD_SUCCESS
;
20248 /* Display community-list and extcommunity-list configuration. */
20249 static int community_list_config_write(struct vty
*vty
)
20251 struct community_list
*list
;
20252 struct community_entry
*entry
;
20253 struct community_list_master
*cm
;
20256 /* Community-list. */
20257 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20259 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20260 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20262 "bgp community-list %s seq %" PRId64
" %s %s\n",
20263 list
->name
, entry
->seq
,
20264 community_direct_str(entry
->direct
),
20265 community_list_config_str(entry
));
20268 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20269 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20271 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20272 entry
->style
== COMMUNITY_LIST_STANDARD
20275 list
->name
, entry
->seq
,
20276 community_direct_str(entry
->direct
),
20277 community_list_config_str(entry
));
20281 /* Extcommunity-list. */
20282 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20284 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20285 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20287 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20288 list
->name
, entry
->seq
,
20289 community_direct_str(entry
->direct
),
20290 community_list_config_str(entry
));
20293 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20294 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20296 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20297 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20300 list
->name
, entry
->seq
,
20301 community_direct_str(entry
->direct
),
20302 community_list_config_str(entry
));
20307 /* lcommunity-list. */
20308 cm
= community_list_master_lookup(bgp_clist
,
20309 LARGE_COMMUNITY_LIST_MASTER
);
20311 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20312 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20314 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20315 list
->name
, entry
->seq
,
20316 community_direct_str(entry
->direct
),
20317 community_list_config_str(entry
));
20320 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20321 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20323 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20325 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20328 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20329 community_list_config_str(entry
));
20336 static int community_list_config_write(struct vty
*vty
);
20337 static struct cmd_node community_list_node
= {
20338 .name
= "community list",
20339 .node
= COMMUNITY_LIST_NODE
,
20341 .config_write
= community_list_config_write
,
20344 static void community_list_vty(void)
20346 install_node(&community_list_node
);
20348 /* Community-list. */
20349 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20350 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20351 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20352 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20353 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20354 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20355 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20356 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20358 /* Extcommunity-list. */
20359 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20360 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20361 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20362 install_element(CONFIG_NODE
,
20363 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20364 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20365 install_element(CONFIG_NODE
,
20366 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20367 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20368 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20370 /* Large Community List */
20371 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20372 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20373 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20374 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20375 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20376 install_element(CONFIG_NODE
,
20377 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20378 install_element(CONFIG_NODE
,
20379 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20380 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20381 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20382 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20383 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20384 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20385 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20387 bgp_community_list_command_completion_setup();
20390 static struct cmd_node community_alias_node
= {
20391 .name
= "community alias",
20392 .node
= COMMUNITY_ALIAS_NODE
,
20394 .config_write
= bgp_community_alias_write
,
20397 void community_alias_vty(void)
20399 install_node(&community_alias_node
);
20401 /* Community-list. */
20402 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20404 bgp_community_alias_command_completion_setup();