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.";
926 case BGP_ERR_INVALID_ROLE_NAME
:
927 str
= "Invalid role name";
929 case BGP_ERR_INVALID_INTERNAL_ROLE
:
930 str
= "External roles can be set only on eBGP session";
934 vty_out(vty
, "%% %s\n", str
);
935 return CMD_WARNING_CONFIG_FAILED
;
940 /* BGP clear sort. */
949 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
950 safi_t safi
, int error
)
953 case BGP_ERR_AF_UNCONFIGURED
:
955 "%% BGP: Enable %s address family for the neighbor %s\n",
956 get_afi_safi_str(afi
, safi
, false), peer
->host
);
958 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
960 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
968 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
969 struct listnode
**nnode
, enum bgp_clear_type stype
)
974 /* if afi/.safi not specified, spin thru all of them */
975 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
978 enum bgp_af_index index
;
980 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
981 paf
= peer
->peer_af_array
[index
];
985 if (paf
&& paf
->subgroup
)
986 SET_FLAG(paf
->subgroup
->sflags
,
987 SUBGRP_STATUS_FORCE_UPDATES
);
990 tmp_safi
= paf
->safi
;
991 if (!peer
->afc
[tmp_afi
][tmp_safi
])
994 if (stype
== BGP_CLEAR_SOFT_NONE
)
995 ret
= peer_clear(peer
, nnode
);
997 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1000 /* if afi specified and safi not, spin thru safis on this afi */
1001 } else if (safi
== SAFI_UNSPEC
) {
1004 for (tmp_safi
= SAFI_UNICAST
;
1005 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1006 if (!peer
->afc
[afi
][tmp_safi
])
1009 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1010 if (paf
&& paf
->subgroup
)
1011 SET_FLAG(paf
->subgroup
->sflags
,
1012 SUBGRP_STATUS_FORCE_UPDATES
);
1014 if (stype
== BGP_CLEAR_SOFT_NONE
)
1015 ret
= peer_clear(peer
, nnode
);
1017 ret
= peer_clear_soft(peer
, afi
,
1020 /* both afi/safi specified, let the caller know if not defined */
1022 if (!peer
->afc
[afi
][safi
])
1025 paf
= peer_af_find(peer
, afi
, safi
);
1026 if (paf
&& paf
->subgroup
)
1027 SET_FLAG(paf
->subgroup
->sflags
,
1028 SUBGRP_STATUS_FORCE_UPDATES
);
1030 if (stype
== BGP_CLEAR_SOFT_NONE
)
1031 ret
= peer_clear(peer
, nnode
);
1033 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1039 /* `clear ip bgp' functions. */
1040 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1041 enum clear_sort sort
, enum bgp_clear_type stype
,
1048 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1050 /* Clear all neighbors. */
1052 * Pass along pointer to next node to peer_clear() when walking all
1053 * nodes on the BGP instance as that may get freed if it is a
1056 if (sort
== clear_all
) {
1057 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1059 bgp_peer_gr_flags_update(peer
);
1061 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1062 gr_router_detected
= true;
1064 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1068 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1071 if (gr_router_detected
1072 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1073 bgp_zebra_send_capabilities(bgp
, false);
1074 } else if (!gr_router_detected
1075 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1076 bgp_zebra_send_capabilities(bgp
, true);
1079 /* This is to apply read-only mode on this clear. */
1080 if (stype
== BGP_CLEAR_SOFT_NONE
)
1081 bgp
->update_delay_over
= 0;
1086 /* Clear specified neighbor. */
1087 if (sort
== clear_peer
) {
1090 /* Make sockunion for lookup. */
1091 ret
= str2sockunion(arg
, &su
);
1093 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1095 peer
= peer_lookup_by_hostname(bgp
, arg
);
1098 "Malformed address or name: %s\n",
1104 peer
= peer_lookup(bgp
, &su
);
1107 "%% BGP: Unknown neighbor - \"%s\"\n",
1113 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1114 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1116 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1118 /* if afi/safi not defined for this peer, let caller know */
1120 ret
= BGP_ERR_AF_UNCONFIGURED
;
1123 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1128 /* Clear all neighbors belonging to a specific peer-group. */
1129 if (sort
== clear_group
) {
1130 struct peer_group
*group
;
1132 group
= peer_group_lookup(bgp
, arg
);
1134 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1138 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1139 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1142 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1149 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1150 get_afi_safi_str(afi
, safi
, false), arg
);
1155 /* Clear all external (eBGP) neighbors. */
1156 if (sort
== clear_external
) {
1157 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1158 if (peer
->sort
== BGP_PEER_IBGP
)
1161 bgp_peer_gr_flags_update(peer
);
1163 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1164 gr_router_detected
= true;
1166 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1169 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1174 if (gr_router_detected
1175 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1176 bgp_zebra_send_capabilities(bgp
, false);
1177 } else if (!gr_router_detected
1178 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1179 bgp_zebra_send_capabilities(bgp
, true);
1184 "%% BGP: No external %s peer is configured\n",
1185 get_afi_safi_str(afi
, safi
, false));
1190 /* Clear all neighbors belonging to a specific AS. */
1191 if (sort
== clear_as
) {
1192 as_t as
= strtoul(arg
, NULL
, 10);
1194 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1198 bgp_peer_gr_flags_update(peer
);
1200 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1201 gr_router_detected
= true;
1203 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1206 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1211 if (gr_router_detected
1212 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1213 bgp_zebra_send_capabilities(bgp
, false);
1214 } else if (!gr_router_detected
1215 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1216 bgp_zebra_send_capabilities(bgp
, true);
1221 "%% BGP: No %s peer is configured with AS %s\n",
1222 get_afi_safi_str(afi
, safi
, false), arg
);
1230 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1231 safi_t safi
, enum clear_sort sort
,
1232 enum bgp_clear_type stype
, const char *arg
)
1236 /* BGP structure lookup. */
1238 bgp
= bgp_lookup_by_name(name
);
1240 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1244 bgp
= bgp_get_default();
1246 vty_out(vty
, "No BGP process is configured\n");
1251 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1254 /* clear soft inbound */
1255 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1260 FOREACH_AFI_SAFI (afi
, safi
)
1261 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1262 BGP_CLEAR_SOFT_IN
, NULL
);
1265 /* clear soft outbound */
1266 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1271 FOREACH_AFI_SAFI (afi
, safi
)
1272 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1273 BGP_CLEAR_SOFT_OUT
, NULL
);
1277 #ifndef VTYSH_EXTRACT_PL
1278 #include "bgpd/bgp_vty_clippy.c"
1281 DEFUN_HIDDEN (bgp_local_mac
,
1283 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1285 "Local MAC config\n"
1286 "VxLAN Network Identifier\n"
1290 "mac-mobility sequence\n"
1300 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1301 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1302 vty_out(vty
, "%% Malformed MAC address\n");
1305 memset(&ip
, 0, sizeof(ip
));
1306 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1308 bgp
= bgp_get_default();
1310 vty_out(vty
, "Default BGP instance is not there\n");
1314 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1317 vty_out(vty
, "Internal error\n");
1324 DEFUN_HIDDEN (no_bgp_local_mac
,
1325 no_bgp_local_mac_cmd
,
1326 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1329 "Local MAC config\n"
1330 "VxLAN Network Identifier\n"
1341 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1342 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1343 vty_out(vty
, "%% Malformed MAC address\n");
1346 memset(&ip
, 0, sizeof(ip
));
1348 bgp
= bgp_get_default();
1350 vty_out(vty
, "Default BGP instance is not there\n");
1354 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1356 vty_out(vty
, "Internal error\n");
1363 DEFUN (no_synchronization
,
1364 no_synchronization_cmd
,
1365 "no synchronization",
1367 "Perform IGP synchronization\n")
1372 DEFUN (no_auto_summary
,
1373 no_auto_summary_cmd
,
1376 "Enable automatic network number summarization\n")
1381 /* "router bgp" commands. */
1382 DEFUN_NOSH (router_bgp
,
1384 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1388 BGP_INSTANCE_HELP_STR
)
1391 int idx_view_vrf
= 3;
1397 const char *name
= NULL
;
1398 enum bgp_instance_type inst_type
;
1400 // "router bgp" without an ASN
1402 // Pending: Make VRF option available for ASN less config
1403 bgp
= bgp_get_default();
1406 vty_out(vty
, "%% No BGP process is configured\n");
1407 return CMD_WARNING_CONFIG_FAILED
;
1410 if (listcount(bm
->bgp
) > 1) {
1411 vty_out(vty
, "%% Please specify ASN and VRF\n");
1412 return CMD_WARNING_CONFIG_FAILED
;
1418 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1420 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1421 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1422 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1424 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1426 name
= argv
[idx_vrf
]->arg
;
1428 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1429 if (strmatch(name
, VRF_DEFAULT_NAME
))
1432 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1433 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1434 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1437 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1438 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1440 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1442 case BGP_ERR_AS_MISMATCH
:
1443 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1444 return CMD_WARNING_CONFIG_FAILED
;
1445 case BGP_ERR_INSTANCE_MISMATCH
:
1447 "BGP instance name and AS number mismatch\n");
1449 "BGP instance is already running; AS is %u\n",
1451 return CMD_WARNING_CONFIG_FAILED
;
1455 * If we just instantiated the default instance, complete
1456 * any pending VRF-VPN leaking that was configured via
1457 * earlier "router bgp X vrf FOO" blocks.
1459 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1460 vpn_leak_postchange_all();
1462 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1463 bgp_vpn_leak_export(bgp
);
1464 /* Pending: handle when user tries to change a view to vrf n vv.
1468 /* unset the auto created flag as the user config is now present */
1469 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1470 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1475 /* "no router bgp" commands. */
1476 DEFUN (no_router_bgp
,
1478 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1483 BGP_INSTANCE_HELP_STR
)
1489 const char *name
= NULL
;
1491 // "no router bgp" without an ASN
1493 // Pending: Make VRF option available for ASN less config
1494 bgp
= bgp_get_default();
1497 vty_out(vty
, "%% No BGP process is configured\n");
1498 return CMD_WARNING_CONFIG_FAILED
;
1501 if (listcount(bm
->bgp
) > 1) {
1502 vty_out(vty
, "%% Please specify ASN and VRF\n");
1503 return CMD_WARNING_CONFIG_FAILED
;
1507 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1509 return CMD_WARNING_CONFIG_FAILED
;
1512 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1515 name
= argv
[idx_vrf
]->arg
;
1516 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1517 && strmatch(name
, VRF_DEFAULT_NAME
))
1521 /* Lookup bgp structure. */
1522 bgp
= bgp_lookup(as
, name
);
1524 vty_out(vty
, "%% Can't find BGP instance\n");
1525 return CMD_WARNING_CONFIG_FAILED
;
1529 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1531 return CMD_WARNING_CONFIG_FAILED
;
1534 /* Cannot delete default instance if vrf instances exist */
1535 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1536 struct listnode
*node
;
1537 struct bgp
*tmp_bgp
;
1539 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1540 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1542 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1543 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1544 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1545 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1546 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1547 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1548 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1549 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1550 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1551 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1552 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1553 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1554 (bgp
== bgp_get_evpn() &&
1555 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1556 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1557 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1558 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1559 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1560 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1561 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1562 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1563 (hashcount(tmp_bgp
->vnihash
))) {
1565 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1566 return CMD_WARNING_CONFIG_FAILED
;
1577 /* bgp session-dscp */
1579 DEFPY (bgp_session_dscp
,
1580 bgp_session_dscp_cmd
,
1581 "bgp session-dscp (0-63)$dscp",
1583 "Override default (C6) bgp TCP session DSCP value\n"
1584 "Manually configured dscp parameter\n")
1586 bm
->tcp_dscp
= dscp
<< 2;
1591 DEFPY (no_bgp_session_dscp
,
1592 no_bgp_session_dscp_cmd
,
1593 "no bgp session-dscp [(0-63)]",
1596 "Override default (C6) bgp TCP session DSCP value\n"
1597 "Manually configured dscp parameter\n")
1599 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1604 /* BGP router-id. */
1606 DEFPY (bgp_router_id
,
1608 "bgp router-id A.B.C.D",
1610 "Override configured router identifier\n"
1611 "Manually configured router identifier\n")
1613 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1614 bgp_router_id_static_set(bgp
, router_id
);
1618 DEFPY (no_bgp_router_id
,
1619 no_bgp_router_id_cmd
,
1620 "no bgp router-id [A.B.C.D]",
1623 "Override configured router identifier\n"
1624 "Manually configured router identifier\n")
1626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1628 if (router_id_str
) {
1629 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1630 vty_out(vty
, "%% BGP router-id doesn't match\n");
1631 return CMD_WARNING_CONFIG_FAILED
;
1635 router_id
.s_addr
= 0;
1636 bgp_router_id_static_set(bgp
, router_id
);
1641 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1642 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1644 "Add community specific parameters\n"
1645 "Create an alias for a community\n"
1646 "Community (AA:BB or AA:BB:CC)\n"
1649 struct community_alias ca
= {};
1650 struct community_alias
*lookup_community
;
1651 struct community_alias
*lookup_alias
;
1652 struct community
*comm
;
1653 struct lcommunity
*lcomm
;
1654 uint8_t invalid
= 0;
1656 comm
= community_str2com(community
);
1659 community_free(&comm
);
1661 lcomm
= lcommunity_str2com(community
);
1664 lcommunity_free(&lcomm
);
1667 vty_out(vty
, "Invalid community format\n");
1671 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1672 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1674 lookup_community
= bgp_ca_community_lookup(&ca
);
1675 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1678 bgp_ca_alias_delete(&ca
);
1679 bgp_ca_community_delete(&ca
);
1682 /* Lookup if community hash table has an item
1683 * with the same alias name.
1685 strlcpy(ca
.community
, lookup_alias
->community
,
1686 sizeof(ca
.community
));
1687 if (bgp_ca_community_lookup(&ca
)) {
1689 "community (%s) already has this alias (%s)\n",
1690 lookup_alias
->community
,
1691 lookup_alias
->alias
);
1694 bgp_ca_alias_delete(&ca
);
1697 if (lookup_community
) {
1698 /* Lookup if alias hash table has an item
1699 * with the same community.
1701 strlcpy(ca
.alias
, lookup_community
->alias
,
1703 if (bgp_ca_alias_lookup(&ca
)) {
1705 "alias (%s) already has this community (%s)\n",
1706 lookup_community
->alias
,
1707 lookup_community
->community
);
1710 bgp_ca_community_delete(&ca
);
1713 bgp_ca_alias_insert(&ca
);
1714 bgp_ca_community_insert(&ca
);
1720 DEFPY (bgp_global_suppress_fib_pending
,
1721 bgp_global_suppress_fib_pending_cmd
,
1722 "[no] bgp suppress-fib-pending",
1725 "Advertise only routes that are programmed in kernel to peers globally\n")
1727 bm_wait_for_fib_set(!no
);
1732 DEFPY (bgp_suppress_fib_pending
,
1733 bgp_suppress_fib_pending_cmd
,
1734 "[no] bgp suppress-fib-pending",
1737 "Advertise only routes that are programmed in kernel to peers\n")
1739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1741 bgp_suppress_fib_pending_set(bgp
, !no
);
1746 /* BGP Cluster ID. */
1747 DEFUN (bgp_cluster_id
,
1749 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1751 "Configure Route-Reflector Cluster-id\n"
1752 "Route-Reflector Cluster-id in IP address format\n"
1753 "Route-Reflector Cluster-id as 32 bit quantity\n")
1755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1758 struct in_addr cluster
;
1760 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1762 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1763 return CMD_WARNING_CONFIG_FAILED
;
1766 bgp_cluster_id_set(bgp
, &cluster
);
1767 bgp_clear_star_soft_out(vty
, bgp
->name
);
1772 DEFUN (no_bgp_cluster_id
,
1773 no_bgp_cluster_id_cmd
,
1774 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1777 "Configure Route-Reflector Cluster-id\n"
1778 "Route-Reflector Cluster-id in IP address format\n"
1779 "Route-Reflector Cluster-id as 32 bit quantity\n")
1781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1782 bgp_cluster_id_unset(bgp
);
1783 bgp_clear_star_soft_out(vty
, bgp
->name
);
1792 "Disable BGP route installation to RIB (Zebra)\n")
1794 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1796 "%% No-RIB option is already set, nothing to do here.\n");
1800 bgp_option_norib_set_runtime();
1805 DEFPY (no_bgp_norib
,
1810 "Disable BGP route installation to RIB (Zebra)\n")
1812 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1814 "%% No-RIB option is not set, nothing to do here.\n");
1818 bgp_option_norib_unset_runtime();
1823 DEFPY (no_bgp_send_extra_data
,
1824 no_bgp_send_extra_data_cmd
,
1825 "[no] bgp send-extra-data zebra",
1828 "Extra data to Zebra for display/use\n"
1832 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1834 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1839 DEFUN (bgp_confederation_identifier
,
1840 bgp_confederation_identifier_cmd
,
1841 "bgp confederation identifier (1-4294967295)",
1843 "AS confederation parameters\n"
1845 "Set routing domain confederation AS\n")
1847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1851 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1853 bgp_confederation_id_set(bgp
, as
);
1858 DEFUN (no_bgp_confederation_identifier
,
1859 no_bgp_confederation_identifier_cmd
,
1860 "no bgp confederation identifier [(1-4294967295)]",
1863 "AS confederation parameters\n"
1865 "Set routing domain confederation AS\n")
1867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1868 bgp_confederation_id_unset(bgp
);
1873 DEFUN (bgp_confederation_peers
,
1874 bgp_confederation_peers_cmd
,
1875 "bgp confederation peers (1-4294967295)...",
1877 "AS confederation parameters\n"
1878 "Peer ASs in BGP confederation\n"
1881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1886 for (i
= idx_asn
; i
< argc
; i
++) {
1887 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1889 if (bgp
->as
== as
) {
1891 "%% Local member-AS not allowed in confed peer list\n");
1895 bgp_confederation_peers_add(bgp
, as
);
1900 DEFUN (no_bgp_confederation_peers
,
1901 no_bgp_confederation_peers_cmd
,
1902 "no bgp confederation peers (1-4294967295)...",
1905 "AS confederation parameters\n"
1906 "Peer ASs in BGP confederation\n"
1909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1914 for (i
= idx_asn
; i
< argc
; i
++) {
1915 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1917 bgp_confederation_peers_remove(bgp
, as
);
1923 * Central routine for maximum-paths configuration.
1924 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1925 * @set: 1 for setting values, 0 for removing the max-paths config.
1927 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1928 const char *mpaths
, uint16_t options
,
1931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1932 uint16_t maxpaths
= 0;
1937 afi
= bgp_node_afi(vty
);
1938 safi
= bgp_node_safi(vty
);
1941 maxpaths
= strtol(mpaths
, NULL
, 10);
1942 if (maxpaths
> multipath_num
) {
1944 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1945 maxpaths
, multipath_num
);
1946 return CMD_WARNING_CONFIG_FAILED
;
1948 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1951 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1955 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1956 (set
== 1) ? "" : "un",
1957 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1958 maxpaths
, afi
, safi
);
1959 return CMD_WARNING_CONFIG_FAILED
;
1962 bgp_recalculate_all_bestpaths(bgp
);
1967 DEFUN (bgp_maxmed_admin
,
1968 bgp_maxmed_admin_cmd
,
1969 "bgp max-med administrative ",
1971 "Advertise routes with max-med\n"
1972 "Administratively applied, for an indefinite period\n")
1974 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1976 bgp
->v_maxmed_admin
= 1;
1977 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1979 bgp_maxmed_update(bgp
);
1984 DEFUN (bgp_maxmed_admin_medv
,
1985 bgp_maxmed_admin_medv_cmd
,
1986 "bgp max-med administrative (0-4294967295)",
1988 "Advertise routes with max-med\n"
1989 "Administratively applied, for an indefinite period\n"
1990 "Max MED value to be used\n")
1992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1995 bgp
->v_maxmed_admin
= 1;
1996 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1998 bgp_maxmed_update(bgp
);
2003 DEFUN (no_bgp_maxmed_admin
,
2004 no_bgp_maxmed_admin_cmd
,
2005 "no bgp max-med administrative [(0-4294967295)]",
2008 "Advertise routes with max-med\n"
2009 "Administratively applied, for an indefinite period\n"
2010 "Max MED value to be used\n")
2012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2013 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2014 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2015 bgp_maxmed_update(bgp
);
2020 DEFUN (bgp_maxmed_onstartup
,
2021 bgp_maxmed_onstartup_cmd
,
2022 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2024 "Advertise routes with max-med\n"
2025 "Effective on a startup\n"
2026 "Time (seconds) period for max-med\n"
2027 "Max MED value to be used\n")
2029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2032 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2033 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2034 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2035 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2037 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2039 bgp_maxmed_update(bgp
);
2044 DEFUN (no_bgp_maxmed_onstartup
,
2045 no_bgp_maxmed_onstartup_cmd
,
2046 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2049 "Advertise routes with max-med\n"
2050 "Effective on a startup\n"
2051 "Time (seconds) period for max-med\n"
2052 "Max MED value to be used\n")
2054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2056 /* Cancel max-med onstartup if its on */
2057 if (bgp
->t_maxmed_onstartup
) {
2058 thread_cancel(&bgp
->t_maxmed_onstartup
);
2059 bgp
->maxmed_onstartup_over
= 1;
2062 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2063 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2065 bgp_maxmed_update(bgp
);
2070 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2071 uint16_t update_delay
,
2072 uint16_t establish_wait
)
2074 struct listnode
*node
, *nnode
;
2076 bool vrf_cfg
= false;
2079 * See if update-delay is set per-vrf and warn user to delete it
2080 * Note that we only need to check this if this is the first time
2081 * setting the global config.
2083 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2084 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2085 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2087 "%% update-delay configuration found in vrf %s\n",
2088 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2098 "%%Failed: global update-delay config not permitted\n");
2102 if (!establish_wait
) { /* update-delay <delay> */
2103 bm
->v_update_delay
= update_delay
;
2104 bm
->v_establish_wait
= bm
->v_update_delay
;
2106 /* update-delay <delay> <establish-wait> */
2107 if (update_delay
< establish_wait
) {
2109 "%%Failed: update-delay less than the establish-wait!\n");
2110 return CMD_WARNING_CONFIG_FAILED
;
2113 bm
->v_update_delay
= update_delay
;
2114 bm
->v_establish_wait
= establish_wait
;
2117 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2118 bgp
->v_update_delay
= bm
->v_update_delay
;
2119 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2125 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2127 struct listnode
*node
, *nnode
;
2130 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2131 bm
->v_establish_wait
= bm
->v_update_delay
;
2133 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2134 bgp
->v_update_delay
= bm
->v_update_delay
;
2135 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2141 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2142 uint16_t establish_wait
)
2144 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2146 /* if configured globally, per-instance config is not allowed */
2147 if (bm
->v_update_delay
) {
2149 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2150 return CMD_WARNING_CONFIG_FAILED
;
2154 if (!establish_wait
) /* update-delay <delay> */
2156 bgp
->v_update_delay
= update_delay
;
2157 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2161 /* update-delay <delay> <establish-wait> */
2162 if (update_delay
< establish_wait
) {
2164 "%%Failed: update-delay less than the establish-wait!\n");
2165 return CMD_WARNING_CONFIG_FAILED
;
2168 bgp
->v_update_delay
= update_delay
;
2169 bgp
->v_establish_wait
= establish_wait
;
2174 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2178 /* If configured globally, cannot remove from one bgp instance */
2179 if (bm
->v_update_delay
) {
2181 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2182 return CMD_WARNING_CONFIG_FAILED
;
2184 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2185 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2190 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2192 /* If configured globally, no need to display per-instance value */
2193 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2194 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2195 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2196 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2201 /* Global update-delay configuration */
2202 DEFPY (bgp_global_update_delay
,
2203 bgp_global_update_delay_cmd
,
2204 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2206 "Force initial delay for best-path and updates for all bgp instances\n"
2207 "Max delay in seconds\n"
2208 "Establish wait in seconds\n")
2210 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2213 /* Global update-delay deconfiguration */
2214 DEFPY (no_bgp_global_update_delay
,
2215 no_bgp_global_update_delay_cmd
,
2216 "no bgp update-delay [(0-3600) [(1-3600)]]",
2219 "Force initial delay for best-path and updates\n"
2220 "Max delay in seconds\n"
2221 "Establish wait in seconds\n")
2223 return bgp_global_update_delay_deconfig_vty(vty
);
2226 /* Update-delay configuration */
2228 DEFPY (bgp_update_delay
,
2229 bgp_update_delay_cmd
,
2230 "update-delay (0-3600)$delay [(1-3600)$wait]",
2231 "Force initial delay for best-path and updates\n"
2232 "Max delay in seconds\n"
2233 "Establish wait in seconds\n")
2235 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2238 /* Update-delay deconfiguration */
2239 DEFPY (no_bgp_update_delay
,
2240 no_bgp_update_delay_cmd
,
2241 "no update-delay [(0-3600) [(1-3600)]]",
2243 "Force initial delay for best-path and updates\n"
2244 "Max delay in seconds\n"
2245 "Establish wait in seconds\n")
2247 return bgp_update_delay_deconfig_vty(vty
);
2251 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2256 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2257 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2262 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2267 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2268 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2273 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2276 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2277 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2278 vty_out(vty
, " write-quanta %d\n", quanta
);
2281 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2284 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2285 if (quanta
!= BGP_READ_PACKET_MAX
)
2286 vty_out(vty
, " read-quanta %d\n", quanta
);
2289 /* Packet quanta configuration
2291 * XXX: The value set here controls the size of a stack buffer in the IO
2292 * thread. When changing these limits be careful to prevent stack overflow.
2294 * Furthermore, the maximums used here should correspond to
2295 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2297 DEFPY (bgp_wpkt_quanta
,
2298 bgp_wpkt_quanta_cmd
,
2299 "[no] write-quanta (1-64)$quanta",
2301 "How many packets to write to peer socket per run\n"
2302 "Number of packets\n")
2304 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2307 DEFPY (bgp_rpkt_quanta
,
2308 bgp_rpkt_quanta_cmd
,
2309 "[no] read-quanta (1-10)$quanta",
2311 "How many packets to read from peer socket per I/O cycle\n"
2312 "Number of packets\n")
2314 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2317 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2319 if (!bgp
->heuristic_coalesce
)
2320 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2324 DEFUN (bgp_coalesce_time
,
2325 bgp_coalesce_time_cmd
,
2326 "coalesce-time (0-4294967295)",
2327 "Subgroup coalesce timer\n"
2328 "Subgroup coalesce timer value (in ms)\n")
2330 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2334 bgp
->heuristic_coalesce
= false;
2336 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2337 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2342 DEFUN (no_bgp_coalesce_time
,
2343 no_bgp_coalesce_time_cmd
,
2344 "no coalesce-time (0-4294967295)",
2346 "Subgroup coalesce timer\n"
2347 "Subgroup coalesce timer value (in ms)\n")
2349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2351 bgp
->heuristic_coalesce
= true;
2352 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2356 /* Maximum-paths configuration */
2357 DEFUN (bgp_maxpaths
,
2359 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2360 "Forward packets over multiple paths\n"
2361 "Number of paths\n")
2364 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2365 argv
[idx_number
]->arg
, 0, 1);
2368 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2369 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2370 "Forward packets over multiple paths\n"
2371 "Number of paths\n")
2373 DEFUN (bgp_maxpaths_ibgp
,
2374 bgp_maxpaths_ibgp_cmd
,
2375 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2376 "Forward packets over multiple paths\n"
2378 "Number of paths\n")
2381 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2382 argv
[idx_number
]->arg
, 0, 1);
2385 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2386 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2387 "Forward packets over multiple paths\n"
2389 "Number of paths\n")
2391 DEFUN (bgp_maxpaths_ibgp_cluster
,
2392 bgp_maxpaths_ibgp_cluster_cmd
,
2393 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2394 "Forward packets over multiple paths\n"
2397 "Match the cluster length\n")
2400 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2401 argv
[idx_number
]->arg
, true, 1);
2404 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2405 "maximum-paths ibgp " CMD_RANGE_STR(
2406 1, MULTIPATH_NUM
) " equal-cluster-length",
2407 "Forward packets over multiple paths\n"
2410 "Match the cluster length\n")
2412 DEFUN (no_bgp_maxpaths
,
2413 no_bgp_maxpaths_cmd
,
2414 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2416 "Forward packets over multiple paths\n"
2417 "Number of paths\n")
2419 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2422 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2423 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2424 "Forward packets over multiple paths\n"
2425 "Number of paths\n")
2427 DEFUN (no_bgp_maxpaths_ibgp
,
2428 no_bgp_maxpaths_ibgp_cmd
,
2429 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2431 "Forward packets over multiple paths\n"
2434 "Match the cluster length\n")
2436 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2439 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2440 "no maximum-paths ibgp [" CMD_RANGE_STR(
2441 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2443 "Forward packets over multiple paths\n"
2446 "Match the cluster length\n")
2448 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2449 afi_t afi
, safi_t safi
)
2451 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2452 vty_out(vty
, " maximum-paths %d\n",
2453 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2456 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2457 vty_out(vty
, " maximum-paths ibgp %d",
2458 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2459 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2460 vty_out(vty
, " equal-cluster-length");
2469 "timers bgp (0-65535) (0-65535)",
2470 "Adjust routing timers\n"
2472 "Keepalive interval\n"
2475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2477 int idx_number_2
= 3;
2478 unsigned long keepalive
= 0;
2479 unsigned long holdtime
= 0;
2481 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2482 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2484 /* Holdtime value check. */
2485 if (holdtime
< 3 && holdtime
!= 0) {
2487 "%% hold time value must be either 0 or greater than 3\n");
2488 return CMD_WARNING_CONFIG_FAILED
;
2491 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2492 BGP_DEFAULT_DELAYOPEN
);
2497 DEFUN (no_bgp_timers
,
2499 "no timers bgp [(0-65535) (0-65535)]",
2501 "Adjust routing timers\n"
2503 "Keepalive interval\n"
2506 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2507 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2508 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2513 /* BGP minimum holdtime. */
2515 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2516 "bgp minimum-holdtime (1-65535)",
2517 "BGP specific commands\n"
2518 "BGP minimum holdtime\n"
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2523 unsigned long min_holdtime
;
2525 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 bgp
->default_min_holdtime
= min_holdtime
;
2532 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2533 "no bgp minimum-holdtime [(1-65535)]",
2535 "BGP specific commands\n"
2536 "BGP minimum holdtime\n"
2539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2541 bgp
->default_min_holdtime
= 0;
2546 DEFUN (bgp_client_to_client_reflection
,
2547 bgp_client_to_client_reflection_cmd
,
2548 "bgp client-to-client reflection",
2550 "Configure client to client route reflection\n"
2551 "reflection of routes allowed\n")
2553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2554 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2555 bgp_clear_star_soft_out(vty
, bgp
->name
);
2560 DEFUN (no_bgp_client_to_client_reflection
,
2561 no_bgp_client_to_client_reflection_cmd
,
2562 "no bgp client-to-client reflection",
2565 "Configure client to client route reflection\n"
2566 "reflection of routes allowed\n")
2568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2569 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2570 bgp_clear_star_soft_out(vty
, bgp
->name
);
2575 /* "bgp always-compare-med" configuration. */
2576 DEFUN (bgp_always_compare_med
,
2577 bgp_always_compare_med_cmd
,
2578 "bgp always-compare-med",
2580 "Allow comparing MED from different neighbors\n")
2582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2583 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2584 bgp_recalculate_all_bestpaths(bgp
);
2589 DEFUN (no_bgp_always_compare_med
,
2590 no_bgp_always_compare_med_cmd
,
2591 "no bgp always-compare-med",
2594 "Allow comparing MED from different neighbors\n")
2596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2597 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2598 bgp_recalculate_all_bestpaths(bgp
);
2604 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2605 "bgp ebgp-requires-policy",
2607 "Require in and out policy for eBGP peers (RFC8212)\n")
2609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2610 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2614 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2615 "no bgp ebgp-requires-policy",
2618 "Require in and out policy for eBGP peers (RFC8212)\n")
2620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2621 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2625 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2626 "bgp suppress-duplicates",
2628 "Suppress duplicate updates if the route actually not changed\n")
2630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2631 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2635 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2636 "no bgp suppress-duplicates",
2639 "Suppress duplicate updates if the route actually not changed\n")
2641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2642 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2646 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2647 "bgp reject-as-sets",
2649 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 struct listnode
*node
, *nnode
;
2655 bgp
->reject_as_sets
= true;
2657 /* Reset existing BGP sessions to reject routes
2658 * with aspath containing AS_SET or AS_CONFED_SET.
2660 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2661 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2662 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2663 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2664 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2671 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2672 "no bgp reject-as-sets",
2675 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2678 struct listnode
*node
, *nnode
;
2681 bgp
->reject_as_sets
= false;
2683 /* Reset existing BGP sessions to reject routes
2684 * with aspath containing AS_SET or AS_CONFED_SET.
2686 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2687 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2688 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2689 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2690 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2697 /* "bgp deterministic-med" configuration. */
2698 DEFUN (bgp_deterministic_med
,
2699 bgp_deterministic_med_cmd
,
2700 "bgp deterministic-med",
2702 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2707 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2708 bgp_recalculate_all_bestpaths(bgp
);
2714 DEFUN (no_bgp_deterministic_med
,
2715 no_bgp_deterministic_med_cmd
,
2716 "no bgp deterministic-med",
2719 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2721 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2722 int bestpath_per_as_used
;
2726 struct listnode
*node
, *nnode
;
2728 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2729 bestpath_per_as_used
= 0;
2731 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2732 FOREACH_AFI_SAFI (afi
, safi
)
2733 if (bgp_addpath_dmed_required(
2734 peer
->addpath_type
[afi
][safi
])) {
2735 bestpath_per_as_used
= 1;
2739 if (bestpath_per_as_used
)
2743 if (bestpath_per_as_used
) {
2745 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2746 return CMD_WARNING_CONFIG_FAILED
;
2748 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2749 bgp_recalculate_all_bestpaths(bgp
);
2756 /* "bgp graceful-restart mode" configuration. */
2757 DEFUN (bgp_graceful_restart
,
2758 bgp_graceful_restart_cmd
,
2759 "bgp graceful-restart",
2764 int ret
= BGP_GR_FAILURE
;
2766 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2767 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2771 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2773 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2776 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2777 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2779 "Graceful restart configuration changed, reset all peers to take effect\n");
2780 return bgp_vty_return(vty
, ret
);
2783 DEFUN (no_bgp_graceful_restart
,
2784 no_bgp_graceful_restart_cmd
,
2785 "no bgp graceful-restart",
2791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2793 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2794 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2796 int ret
= BGP_GR_FAILURE
;
2798 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2800 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2803 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2804 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2806 "Graceful restart configuration changed, reset all peers to take effect\n");
2808 return bgp_vty_return(vty
, ret
);
2811 DEFUN (bgp_graceful_restart_stalepath_time
,
2812 bgp_graceful_restart_stalepath_time_cmd
,
2813 "bgp graceful-restart stalepath-time (1-4095)",
2815 "Graceful restart capability parameters\n"
2816 "Set the max time to hold onto restarting peer's stale paths\n"
2817 "Delay value (seconds)\n")
2819 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2823 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2824 bgp
->stalepath_time
= stalepath
;
2828 DEFUN (bgp_graceful_restart_restart_time
,
2829 bgp_graceful_restart_restart_time_cmd
,
2830 "bgp graceful-restart restart-time (0-4095)",
2832 "Graceful restart capability parameters\n"
2833 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2834 "Delay value (seconds)\n")
2836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2841 bgp
->restart_time
= restart
;
2845 DEFUN (bgp_graceful_restart_select_defer_time
,
2846 bgp_graceful_restart_select_defer_time_cmd
,
2847 "bgp graceful-restart select-defer-time (0-3600)",
2849 "Graceful restart capability parameters\n"
2850 "Set the time to defer the BGP route selection after restart\n"
2851 "Delay value (seconds, 0 - disable)\n")
2853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2855 uint32_t defer_time
;
2857 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2858 bgp
->select_defer_time
= defer_time
;
2859 if (defer_time
== 0)
2860 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2862 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2867 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2868 no_bgp_graceful_restart_stalepath_time_cmd
,
2869 "no bgp graceful-restart stalepath-time [(1-4095)]",
2872 "Graceful restart capability parameters\n"
2873 "Set the max time to hold onto restarting peer's stale paths\n"
2874 "Delay value (seconds)\n")
2876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2878 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2882 DEFUN (no_bgp_graceful_restart_restart_time
,
2883 no_bgp_graceful_restart_restart_time_cmd
,
2884 "no bgp graceful-restart restart-time [(0-4095)]",
2887 "Graceful restart capability parameters\n"
2888 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2889 "Delay value (seconds)\n")
2891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2893 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2897 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2898 no_bgp_graceful_restart_select_defer_time_cmd
,
2899 "no bgp graceful-restart select-defer-time [(0-3600)]",
2902 "Graceful restart capability parameters\n"
2903 "Set the time to defer the BGP route selection after restart\n"
2904 "Delay value (seconds)\n")
2906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2908 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2909 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2914 DEFUN (bgp_graceful_restart_preserve_fw
,
2915 bgp_graceful_restart_preserve_fw_cmd
,
2916 "bgp graceful-restart preserve-fw-state",
2918 "Graceful restart capability parameters\n"
2919 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2922 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2926 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2927 no_bgp_graceful_restart_preserve_fw_cmd
,
2928 "no bgp graceful-restart preserve-fw-state",
2931 "Graceful restart capability parameters\n"
2932 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2935 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2939 DEFPY (bgp_graceful_restart_notification
,
2940 bgp_graceful_restart_notification_cmd
,
2941 "[no$no] bgp graceful-restart notification",
2944 "Graceful restart capability parameters\n"
2945 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
2947 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2952 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2957 DEFPY (bgp_administrative_reset
,
2958 bgp_administrative_reset_cmd
,
2959 "[no$no] bgp hard-administrative-reset",
2962 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
2964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2967 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2969 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2974 DEFUN (bgp_graceful_restart_disable
,
2975 bgp_graceful_restart_disable_cmd
,
2976 "bgp graceful-restart-disable",
2980 int ret
= BGP_GR_FAILURE
;
2982 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2984 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2988 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2990 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2993 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2995 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2997 "Graceful restart configuration changed, reset all peers to take effect\n");
2999 return bgp_vty_return(vty
, ret
);
3002 DEFUN (no_bgp_graceful_restart_disable
,
3003 no_bgp_graceful_restart_disable_cmd
,
3004 "no bgp graceful-restart-disable",
3010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3012 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3014 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3016 int ret
= BGP_GR_FAILURE
;
3018 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3020 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3023 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3025 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3027 "Graceful restart configuration changed, reset all peers to take effect\n");
3029 return bgp_vty_return(vty
, ret
);
3032 DEFUN (bgp_neighbor_graceful_restart_set
,
3033 bgp_neighbor_graceful_restart_set_cmd
,
3034 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3042 int ret
= BGP_GR_FAILURE
;
3044 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3046 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3048 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3050 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3052 return CMD_WARNING_CONFIG_FAILED
;
3054 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3056 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3057 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3059 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3061 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3063 "Graceful restart configuration changed, reset this peer to take effect\n");
3065 return bgp_vty_return(vty
, ret
);
3068 DEFUN (no_bgp_neighbor_graceful_restart
,
3069 no_bgp_neighbor_graceful_restart_set_cmd
,
3070 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3078 int ret
= BGP_GR_FAILURE
;
3081 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3083 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3085 return CMD_WARNING_CONFIG_FAILED
;
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3091 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3093 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3094 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3096 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3098 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3100 "Graceful restart configuration changed, reset this peer to take effect\n");
3102 return bgp_vty_return(vty
, ret
);
3105 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3106 bgp_neighbor_graceful_restart_helper_set_cmd
,
3107 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3110 GR_NEIGHBOR_HELPER_CMD
3115 int ret
= BGP_GR_FAILURE
;
3117 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3119 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3121 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3123 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3126 return CMD_WARNING_CONFIG_FAILED
;
3129 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3131 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3132 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3134 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3136 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3138 "Graceful restart configuration changed, reset this peer to take effect\n");
3140 return bgp_vty_return(vty
, ret
);
3143 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3144 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3145 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3149 NO_GR_NEIGHBOR_HELPER_CMD
3153 int ret
= BGP_GR_FAILURE
;
3156 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3160 return CMD_WARNING_CONFIG_FAILED
;
3162 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3164 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3166 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3168 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3169 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3171 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3173 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3175 "Graceful restart configuration changed, reset this peer to take effect\n");
3177 return bgp_vty_return(vty
, ret
);
3180 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3181 bgp_neighbor_graceful_restart_disable_set_cmd
,
3182 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3185 GR_NEIGHBOR_DISABLE_CMD
3190 int ret
= BGP_GR_FAILURE
;
3192 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3194 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3196 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3198 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3200 return CMD_WARNING_CONFIG_FAILED
;
3202 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3204 if (peer
->bgp
->t_startup
)
3205 bgp_peer_gr_flags_update(peer
);
3207 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3208 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3210 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3212 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3214 "Graceful restart configuration changed, reset this peer to take effect\n");
3216 return bgp_vty_return(vty
, ret
);
3219 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3220 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3221 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3225 NO_GR_NEIGHBOR_DISABLE_CMD
3229 int ret
= BGP_GR_FAILURE
;
3232 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3234 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3236 return CMD_WARNING_CONFIG_FAILED
;
3238 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3240 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3242 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3244 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3245 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3247 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3249 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3251 "Graceful restart configuration changed, reset this peer to take effect\n");
3253 return bgp_vty_return(vty
, ret
);
3256 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3257 bgp_graceful_restart_disable_eor_cmd
,
3258 "bgp graceful-restart disable-eor",
3260 "Graceful restart configuration parameters\n"
3261 "Disable EOR Check\n")
3263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3264 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3269 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3270 no_bgp_graceful_restart_disable_eor_cmd
,
3271 "no bgp graceful-restart disable-eor",
3274 "Graceful restart configuration parameters\n"
3275 "Disable EOR Check\n")
3277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3278 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3283 DEFUN (bgp_graceful_restart_rib_stale_time
,
3284 bgp_graceful_restart_rib_stale_time_cmd
,
3285 "bgp graceful-restart rib-stale-time (1-3600)",
3287 "Graceful restart configuration parameters\n"
3288 "Specify the stale route removal timer in rib\n"
3289 "Delay value (seconds)\n")
3291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3293 uint32_t stale_time
;
3295 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3296 bgp
->rib_stale_time
= stale_time
;
3297 /* Send the stale timer update message to RIB */
3298 if (bgp_zebra_stale_timer_update(bgp
))
3304 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3305 no_bgp_graceful_restart_rib_stale_time_cmd
,
3306 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3309 "Graceful restart configuration parameters\n"
3310 "Specify the stale route removal timer in rib\n"
3311 "Delay value (seconds)\n")
3313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3315 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3316 /* Send the stale timer update message to RIB */
3317 if (bgp_zebra_stale_timer_update(bgp
))
3323 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3324 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3326 "Enable Long-lived Graceful Restart\n"
3327 "Specifies maximum time to wait before purging long-lived stale routes\n"
3328 "Stale time value (seconds)\n")
3330 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3332 uint32_t llgr_stale_time
;
3334 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3335 bgp
->llgr_stale_time
= llgr_stale_time
;
3340 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3341 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3343 "Enable Long-lived Graceful Restart\n"
3344 "Specifies maximum time to wait before purging long-lived stale routes\n"
3345 "Stale time value (seconds)\n")
3347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3349 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3354 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3357 bgp_static_redo_import_check(bgp
);
3358 bgp_redistribute_redo(bgp
);
3359 bgp_clear_star_soft_out(vty
, bgp
->name
);
3360 bgp_clear_star_soft_in(vty
, bgp
->name
);
3363 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3365 struct listnode
*node
, *nnode
;
3367 bool vrf_cfg
= false;
3369 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3372 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3373 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3374 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3376 "%% graceful-shutdown configuration found in vrf %s\n",
3377 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3378 VRF_DEFAULT_NAME
: bgp
->name
);
3385 "%%Failed: global graceful-shutdown not permitted\n");
3389 /* Set flag globally */
3390 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3392 /* Initiate processing for all BGP instances. */
3393 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3394 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3399 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3401 struct listnode
*node
, *nnode
;
3404 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3407 /* Unset flag globally */
3408 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3410 /* Initiate processing for all BGP instances. */
3411 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3412 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3417 /* "bgp graceful-shutdown" configuration */
3418 DEFUN (bgp_graceful_shutdown
,
3419 bgp_graceful_shutdown_cmd
,
3420 "bgp graceful-shutdown",
3422 "Graceful shutdown parameters\n")
3424 if (vty
->node
== CONFIG_NODE
)
3425 return bgp_global_graceful_shutdown_config_vty(vty
);
3427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3429 /* if configured globally, per-instance config is not allowed */
3430 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3432 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3433 return CMD_WARNING_CONFIG_FAILED
;
3436 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3437 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3438 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3444 DEFUN (no_bgp_graceful_shutdown
,
3445 no_bgp_graceful_shutdown_cmd
,
3446 "no bgp graceful-shutdown",
3449 "Graceful shutdown parameters\n")
3451 if (vty
->node
== CONFIG_NODE
)
3452 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3454 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3456 /* If configured globally, cannot remove from one bgp instance */
3457 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3459 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3460 return CMD_WARNING_CONFIG_FAILED
;
3463 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3464 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3465 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3471 /* "bgp fast-external-failover" configuration. */
3472 DEFUN (bgp_fast_external_failover
,
3473 bgp_fast_external_failover_cmd
,
3474 "bgp fast-external-failover",
3476 "Immediately reset session if a link to a directly connected external peer goes down\n")
3478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3479 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3483 DEFUN (no_bgp_fast_external_failover
,
3484 no_bgp_fast_external_failover_cmd
,
3485 "no bgp fast-external-failover",
3488 "Immediately reset session if a link to a directly connected external peer goes down\n")
3490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3491 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3495 /* "bgp bestpath compare-routerid" configuration. */
3496 DEFUN (bgp_bestpath_compare_router_id
,
3497 bgp_bestpath_compare_router_id_cmd
,
3498 "bgp bestpath compare-routerid",
3500 "Change the default bestpath selection\n"
3501 "Compare router-id for identical EBGP paths\n")
3503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3504 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3505 bgp_recalculate_all_bestpaths(bgp
);
3510 DEFUN (no_bgp_bestpath_compare_router_id
,
3511 no_bgp_bestpath_compare_router_id_cmd
,
3512 "no bgp bestpath compare-routerid",
3515 "Change the default bestpath selection\n"
3516 "Compare router-id for identical EBGP paths\n")
3518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3519 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3520 bgp_recalculate_all_bestpaths(bgp
);
3525 /* "bgp bestpath as-path ignore" configuration. */
3526 DEFUN (bgp_bestpath_aspath_ignore
,
3527 bgp_bestpath_aspath_ignore_cmd
,
3528 "bgp bestpath as-path ignore",
3530 "Change the default bestpath selection\n"
3531 "AS-path attribute\n"
3532 "Ignore as-path length in selecting a route\n")
3534 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3535 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3536 bgp_recalculate_all_bestpaths(bgp
);
3541 DEFUN (no_bgp_bestpath_aspath_ignore
,
3542 no_bgp_bestpath_aspath_ignore_cmd
,
3543 "no bgp bestpath as-path ignore",
3546 "Change the default bestpath selection\n"
3547 "AS-path attribute\n"
3548 "Ignore as-path length in selecting a route\n")
3550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3551 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3552 bgp_recalculate_all_bestpaths(bgp
);
3557 /* "bgp bestpath as-path confed" configuration. */
3558 DEFUN (bgp_bestpath_aspath_confed
,
3559 bgp_bestpath_aspath_confed_cmd
,
3560 "bgp bestpath as-path confed",
3562 "Change the default bestpath selection\n"
3563 "AS-path attribute\n"
3564 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3567 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3568 bgp_recalculate_all_bestpaths(bgp
);
3573 DEFUN (no_bgp_bestpath_aspath_confed
,
3574 no_bgp_bestpath_aspath_confed_cmd
,
3575 "no bgp bestpath as-path confed",
3578 "Change the default bestpath selection\n"
3579 "AS-path attribute\n"
3580 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3583 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3584 bgp_recalculate_all_bestpaths(bgp
);
3589 /* "bgp bestpath as-path multipath-relax" configuration. */
3590 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3591 bgp_bestpath_aspath_multipath_relax_cmd
,
3592 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3594 "Change the default bestpath selection\n"
3595 "AS-path attribute\n"
3596 "Allow load sharing across routes that have different AS paths (but same length)\n"
3597 "Generate an AS_SET\n"
3598 "Do not generate an AS_SET\n")
3600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3602 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3604 /* no-as-set is now the default behavior so we can silently
3606 if (argv_find(argv
, argc
, "as-set", &idx
))
3607 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3609 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3611 bgp_recalculate_all_bestpaths(bgp
);
3616 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3617 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3618 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3621 "Change the default bestpath selection\n"
3622 "AS-path attribute\n"
3623 "Allow load sharing across routes that have different AS paths (but same length)\n"
3624 "Generate an AS_SET\n"
3625 "Do not generate an AS_SET\n")
3627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3628 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3629 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3630 bgp_recalculate_all_bestpaths(bgp
);
3635 /* "bgp bestpath peer-type multipath-relax" configuration. */
3636 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3637 bgp_bestpath_peer_type_multipath_relax_cmd
,
3638 "bgp bestpath peer-type multipath-relax",
3640 "Change the default bestpath selection\n"
3642 "Allow load sharing across routes learned from different peer types\n")
3644 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3645 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3646 bgp_recalculate_all_bestpaths(bgp
);
3651 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3652 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3653 "no bgp bestpath peer-type multipath-relax",
3655 "Change the default bestpath selection\n"
3657 "Allow load sharing across routes learned from different peer types\n")
3659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3660 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3661 bgp_recalculate_all_bestpaths(bgp
);
3666 /* "bgp log-neighbor-changes" configuration. */
3667 DEFUN (bgp_log_neighbor_changes
,
3668 bgp_log_neighbor_changes_cmd
,
3669 "bgp log-neighbor-changes",
3671 "Log neighbor up/down and reset reason\n")
3673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3674 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3678 DEFUN (no_bgp_log_neighbor_changes
,
3679 no_bgp_log_neighbor_changes_cmd
,
3680 "no bgp log-neighbor-changes",
3683 "Log neighbor up/down and reset reason\n")
3685 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3686 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3690 /* "bgp bestpath med" configuration. */
3691 DEFUN (bgp_bestpath_med
,
3692 bgp_bestpath_med_cmd
,
3693 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3695 "Change the default bestpath selection\n"
3697 "Compare MED among confederation paths\n"
3698 "Treat missing MED as the least preferred one\n"
3699 "Treat missing MED as the least preferred one\n"
3700 "Compare MED among confederation paths\n")
3702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3705 if (argv_find(argv
, argc
, "confed", &idx
))
3706 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3708 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3709 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3711 bgp_recalculate_all_bestpaths(bgp
);
3716 DEFUN (no_bgp_bestpath_med
,
3717 no_bgp_bestpath_med_cmd
,
3718 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3721 "Change the default bestpath selection\n"
3723 "Compare MED among confederation paths\n"
3724 "Treat missing MED as the least preferred one\n"
3725 "Treat missing MED as the least preferred one\n"
3726 "Compare MED among confederation paths\n")
3728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3731 if (argv_find(argv
, argc
, "confed", &idx
))
3732 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3734 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3735 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3737 bgp_recalculate_all_bestpaths(bgp
);
3742 /* "bgp bestpath bandwidth" configuration. */
3743 DEFPY (bgp_bestpath_bw
,
3744 bgp_bestpath_bw_cmd
,
3745 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3747 "Change the default bestpath selection\n"
3748 "Link Bandwidth attribute\n"
3749 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3750 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3751 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3758 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3759 return CMD_ERR_INCOMPLETE
;
3761 if (!strcmp(bw_cfg
, "ignore"))
3762 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3763 else if (!strcmp(bw_cfg
, "skip-missing"))
3764 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3765 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3766 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3768 return CMD_ERR_NO_MATCH
;
3770 /* This config is used in route install, so redo that. */
3771 FOREACH_AFI_SAFI (afi
, safi
) {
3772 if (!bgp_fibupd_safi(safi
))
3774 bgp_zebra_announce_table(bgp
, afi
, safi
);
3780 DEFPY (no_bgp_bestpath_bw
,
3781 no_bgp_bestpath_bw_cmd
,
3782 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3785 "Change the default bestpath selection\n"
3786 "Link Bandwidth attribute\n"
3787 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3788 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3789 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3795 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3797 /* This config is used in route install, so redo that. */
3798 FOREACH_AFI_SAFI (afi
, safi
) {
3799 if (!bgp_fibupd_safi(safi
))
3801 bgp_zebra_announce_table(bgp
, afi
, safi
);
3806 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3807 "[no] bgp default <ipv4-unicast|"
3810 "ipv4-labeled-unicast|"
3815 "ipv6-labeled-unicast|"
3817 "l2vpn-evpn>$afi_safi",
3820 "Configure BGP defaults\n"
3821 "Activate ipv4-unicast for a peer by default\n"
3822 "Activate ipv4-multicast for a peer by default\n"
3823 "Activate ipv4-vpn for a peer by default\n"
3824 "Activate ipv4-labeled-unicast for a peer by default\n"
3825 "Activate ipv4-flowspec for a peer by default\n"
3826 "Activate ipv6-unicast for a peer by default\n"
3827 "Activate ipv6-multicast for a peer by default\n"
3828 "Activate ipv6-vpn for a peer by default\n"
3829 "Activate ipv6-labeled-unicast for a peer by default\n"
3830 "Activate ipv6-flowspec for a peer by default\n"
3831 "Activate l2vpn-evpn for a peer by default\n")
3833 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3834 char afi_safi_str
[strlen(afi_safi
) + 1];
3835 char *afi_safi_str_tok
;
3837 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3838 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3839 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3840 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3843 if (strmatch(safi_str
, "labeled"))
3844 safi
= bgp_vty_safi_from_str("labeled-unicast");
3846 safi
= bgp_vty_safi_from_str(safi_str
);
3849 bgp
->default_af
[afi
][safi
] = false;
3851 if ((safi
== SAFI_LABELED_UNICAST
3852 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3853 || (safi
== SAFI_UNICAST
3854 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3855 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3857 bgp
->default_af
[afi
][safi
] = true;
3863 /* Display hostname in certain command outputs */
3864 DEFUN (bgp_default_show_hostname
,
3865 bgp_default_show_hostname_cmd
,
3866 "bgp default show-hostname",
3868 "Configure BGP defaults\n"
3869 "Show hostname in certain command outputs\n")
3871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3872 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3876 DEFUN (no_bgp_default_show_hostname
,
3877 no_bgp_default_show_hostname_cmd
,
3878 "no bgp default show-hostname",
3881 "Configure BGP defaults\n"
3882 "Show hostname in certain command outputs\n")
3884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3885 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3889 /* Display hostname in certain command outputs */
3890 DEFUN (bgp_default_show_nexthop_hostname
,
3891 bgp_default_show_nexthop_hostname_cmd
,
3892 "bgp default show-nexthop-hostname",
3894 "Configure BGP defaults\n"
3895 "Show hostname for nexthop in certain command outputs\n")
3897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3898 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3902 DEFUN (no_bgp_default_show_nexthop_hostname
,
3903 no_bgp_default_show_nexthop_hostname_cmd
,
3904 "no bgp default show-nexthop-hostname",
3907 "Configure BGP defaults\n"
3908 "Show hostname for nexthop in certain command outputs\n")
3910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3911 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3915 /* "bgp network import-check" configuration. */
3916 DEFUN (bgp_network_import_check
,
3917 bgp_network_import_check_cmd
,
3918 "bgp network import-check",
3920 "BGP network command\n"
3921 "Check BGP network route exists in IGP\n")
3923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3924 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3925 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3926 bgp_static_redo_import_check(bgp
);
3932 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3933 "bgp network import-check exact",
3935 "BGP network command\n"
3936 "Check BGP network route exists in IGP\n"
3937 "Match route precisely\n")
3939 DEFUN (no_bgp_network_import_check
,
3940 no_bgp_network_import_check_cmd
,
3941 "no bgp network import-check",
3944 "BGP network command\n"
3945 "Check BGP network route exists in IGP\n")
3947 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3948 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3949 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3950 bgp_static_redo_import_check(bgp
);
3956 DEFUN (bgp_default_local_preference
,
3957 bgp_default_local_preference_cmd
,
3958 "bgp default local-preference (0-4294967295)",
3960 "Configure BGP defaults\n"
3961 "local preference (higher=more preferred)\n"
3962 "Configure default local preference value\n")
3964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3966 uint32_t local_pref
;
3968 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3970 bgp_default_local_preference_set(bgp
, local_pref
);
3971 bgp_clear_star_soft_in(vty
, bgp
->name
);
3976 DEFUN (no_bgp_default_local_preference
,
3977 no_bgp_default_local_preference_cmd
,
3978 "no bgp default local-preference [(0-4294967295)]",
3981 "Configure BGP defaults\n"
3982 "local preference (higher=more preferred)\n"
3983 "Configure default local preference value\n")
3985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3986 bgp_default_local_preference_unset(bgp
);
3987 bgp_clear_star_soft_in(vty
, bgp
->name
);
3993 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3994 bgp_default_subgroup_pkt_queue_max_cmd
,
3995 "bgp default subgroup-pkt-queue-max (20-100)",
3997 "Configure BGP defaults\n"
3998 "subgroup-pkt-queue-max\n"
3999 "Configure subgroup packet queue max\n")
4001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4005 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4007 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4012 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4013 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4014 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4017 "Configure BGP defaults\n"
4018 "subgroup-pkt-queue-max\n"
4019 "Configure subgroup packet queue max\n")
4021 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4022 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4027 DEFUN (bgp_rr_allow_outbound_policy
,
4028 bgp_rr_allow_outbound_policy_cmd
,
4029 "bgp route-reflector allow-outbound-policy",
4031 "Allow modifications made by out route-map\n"
4032 "on ibgp neighbors\n")
4034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4036 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4037 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4038 update_group_announce_rrclients(bgp
);
4039 bgp_clear_star_soft_out(vty
, bgp
->name
);
4045 DEFUN (no_bgp_rr_allow_outbound_policy
,
4046 no_bgp_rr_allow_outbound_policy_cmd
,
4047 "no bgp route-reflector allow-outbound-policy",
4050 "Allow modifications made by out route-map\n"
4051 "on ibgp neighbors\n")
4053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4055 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4056 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4057 update_group_announce_rrclients(bgp
);
4058 bgp_clear_star_soft_out(vty
, bgp
->name
);
4064 DEFUN (bgp_listen_limit
,
4065 bgp_listen_limit_cmd
,
4066 "bgp listen limit (1-65535)",
4068 "BGP Dynamic Neighbors listen commands\n"
4069 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4070 "Configure Dynamic Neighbors listen limit value\n")
4072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4076 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4078 bgp_listen_limit_set(bgp
, listen_limit
);
4083 DEFUN (no_bgp_listen_limit
,
4084 no_bgp_listen_limit_cmd
,
4085 "no bgp listen limit [(1-65535)]",
4088 "BGP Dynamic Neighbors listen commands\n"
4089 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4090 "Configure Dynamic Neighbors listen limit value\n")
4092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4093 bgp_listen_limit_unset(bgp
);
4099 * Check if this listen range is already configured. Check for exact
4100 * match or overlap based on input.
4102 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4103 struct prefix
*range
, int exact
)
4105 struct listnode
*node
, *nnode
;
4106 struct listnode
*node1
, *nnode1
;
4107 struct peer_group
*group
;
4112 afi
= family2afi(range
->family
);
4113 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4114 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4117 match
= prefix_same(range
, lr
);
4119 match
= (prefix_match(range
, lr
)
4120 || prefix_match(lr
, range
));
4129 DEFUN (bgp_listen_range
,
4130 bgp_listen_range_cmd
,
4131 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4133 "Configure BGP dynamic neighbors listen range\n"
4134 "Configure BGP dynamic neighbors listen range\n"
4136 "Member of the peer-group\n"
4137 "Peer-group name\n")
4139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4140 struct prefix range
;
4141 struct peer_group
*group
, *existing_group
;
4146 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4147 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4148 char *prefix
= argv
[idx
]->arg
;
4149 argv_find(argv
, argc
, "PGNAME", &idx
);
4150 char *peergroup
= argv
[idx
]->arg
;
4152 /* Convert IP prefix string to struct prefix. */
4153 ret
= str2prefix(prefix
, &range
);
4155 vty_out(vty
, "%% Malformed listen range\n");
4156 return CMD_WARNING_CONFIG_FAILED
;
4159 afi
= family2afi(range
.family
);
4161 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4163 "%% Malformed listen range (link-local address)\n");
4164 return CMD_WARNING_CONFIG_FAILED
;
4169 /* Check if same listen range is already configured. */
4170 existing_group
= listen_range_exists(bgp
, &range
, 1);
4171 if (existing_group
) {
4172 if (strcmp(existing_group
->name
, peergroup
) == 0)
4176 "%% Same listen range is attached to peer-group %s\n",
4177 existing_group
->name
);
4178 return CMD_WARNING_CONFIG_FAILED
;
4182 /* Check if an overlapping listen range exists. */
4183 if (listen_range_exists(bgp
, &range
, 0)) {
4185 "%% Listen range overlaps with existing listen range\n");
4186 return CMD_WARNING_CONFIG_FAILED
;
4189 group
= peer_group_lookup(bgp
, peergroup
);
4191 vty_out(vty
, "%% Configure the peer-group first\n");
4192 return CMD_WARNING_CONFIG_FAILED
;
4195 ret
= peer_group_listen_range_add(group
, &range
);
4196 return bgp_vty_return(vty
, ret
);
4199 DEFUN (no_bgp_listen_range
,
4200 no_bgp_listen_range_cmd
,
4201 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4204 "Unconfigure BGP dynamic neighbors listen range\n"
4205 "Unconfigure BGP dynamic neighbors listen range\n"
4207 "Member of the peer-group\n"
4208 "Peer-group name\n")
4210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4211 struct prefix range
;
4212 struct peer_group
*group
;
4217 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4218 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4219 char *prefix
= argv
[idx
]->arg
;
4220 argv_find(argv
, argc
, "PGNAME", &idx
);
4221 char *peergroup
= argv
[idx
]->arg
;
4223 /* Convert IP prefix string to struct prefix. */
4224 ret
= str2prefix(prefix
, &range
);
4226 vty_out(vty
, "%% Malformed listen range\n");
4227 return CMD_WARNING_CONFIG_FAILED
;
4230 afi
= family2afi(range
.family
);
4232 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4234 "%% Malformed listen range (link-local address)\n");
4235 return CMD_WARNING_CONFIG_FAILED
;
4240 group
= peer_group_lookup(bgp
, peergroup
);
4242 vty_out(vty
, "%% Peer-group does not exist\n");
4243 return CMD_WARNING_CONFIG_FAILED
;
4246 ret
= peer_group_listen_range_del(group
, &range
);
4247 return bgp_vty_return(vty
, ret
);
4250 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4252 struct peer_group
*group
;
4253 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4254 struct prefix
*range
;
4257 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4258 vty_out(vty
, " bgp listen limit %d\n",
4259 bgp
->dynamic_neighbors_limit
);
4261 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4262 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4263 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4266 " bgp listen range %pFX peer-group %s\n",
4267 range
, group
->name
);
4274 DEFUN (bgp_disable_connected_route_check
,
4275 bgp_disable_connected_route_check_cmd
,
4276 "bgp disable-ebgp-connected-route-check",
4278 "Disable checking if nexthop is connected on ebgp sessions\n")
4280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4281 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4282 bgp_clear_star_soft_in(vty
, bgp
->name
);
4287 DEFUN (no_bgp_disable_connected_route_check
,
4288 no_bgp_disable_connected_route_check_cmd
,
4289 "no bgp disable-ebgp-connected-route-check",
4292 "Disable checking if nexthop is connected on ebgp sessions\n")
4294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4295 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4296 bgp_clear_star_soft_in(vty
, bgp
->name
);
4302 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4305 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4308 int as_type
= AS_SPECIFIED
;
4311 if (as_str
[0] == 'i') {
4313 as_type
= AS_INTERNAL
;
4314 } else if (as_str
[0] == 'e') {
4316 as_type
= AS_EXTERNAL
;
4318 /* Get AS number. */
4319 as
= strtoul(as_str
, NULL
, 10);
4322 /* If peer is peer group or interface peer, call proper function. */
4323 ret
= str2sockunion(peer_str
, &su
);
4327 /* Check if existing interface peer */
4328 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4330 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4332 /* if not interface peer, check peer-group settings */
4333 if (ret
< 0 && !peer
) {
4334 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4337 "%% Create the peer-group or interface first\n");
4338 return CMD_WARNING_CONFIG_FAILED
;
4343 if (peer_address_self_check(bgp
, &su
)) {
4345 "%% Can not configure the local system as neighbor\n");
4346 return CMD_WARNING_CONFIG_FAILED
;
4348 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4351 return bgp_vty_return(vty
, ret
);
4354 DEFUN (bgp_default_shutdown
,
4355 bgp_default_shutdown_cmd
,
4356 "[no] bgp default shutdown",
4359 "Configure BGP defaults\n"
4360 "Apply administrative shutdown to newly configured peers\n")
4362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4363 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4367 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4369 "Administrative shutdown of the BGP instance\n"
4370 "Add a shutdown message (RFC 8203)\n"
4371 "Shutdown message\n")
4373 char *msgstr
= NULL
;
4375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4378 msgstr
= argv_concat(argv
, argc
, 3);
4380 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4381 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4382 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4383 return CMD_WARNING_CONFIG_FAILED
;
4386 bgp_shutdown_enable(bgp
, msgstr
);
4387 XFREE(MTYPE_TMP
, msgstr
);
4392 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4393 BGP_STR
"Administrative shutdown of the BGP instance\n")
4395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4397 bgp_shutdown_enable(bgp
, NULL
);
4402 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4403 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4407 bgp_shutdown_disable(bgp
);
4412 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4413 "no bgp shutdown message MSG...", NO_STR BGP_STR
4414 "Administrative shutdown of the BGP instance\n"
4415 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4417 DEFUN (neighbor_remote_as
,
4418 neighbor_remote_as_cmd
,
4419 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4422 "Specify a BGP neighbor\n"
4424 "Internal BGP peer\n"
4425 "External BGP peer\n")
4428 int idx_remote_as
= 3;
4429 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4430 argv
[idx_remote_as
]->arg
);
4433 DEFPY (bgp_allow_martian
,
4434 bgp_allow_martian_cmd
,
4435 "[no]$no bgp allow-martian-nexthop",
4438 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4443 bgp
->allow_martian
= false;
4445 bgp
->allow_martian
= true;
4450 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4451 * sessions do not wait for hold timer expiry to bring down the sessions
4452 * when nexthop becomes unreachable
4454 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4455 BGP_STR
"Fast convergence for bgp sessions\n")
4457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4458 bgp
->fast_convergence
= true;
4463 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4464 "no bgp fast-convergence",
4465 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4468 bgp
->fast_convergence
= false;
4473 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4475 const char *peer_group_name
,
4478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4480 int as_type
= AS_UNSPECIFIED
;
4482 struct peer_group
*group
;
4485 group
= peer_group_lookup(bgp
, conf_if
);
4488 vty_out(vty
, "%% Name conflict with peer-group \n");
4489 return CMD_WARNING_CONFIG_FAILED
;
4493 if (as_str
[0] == 'i') {
4494 as_type
= AS_INTERNAL
;
4495 } else if (as_str
[0] == 'e') {
4496 as_type
= AS_EXTERNAL
;
4498 /* Get AS number. */
4499 as
= strtoul(as_str
, NULL
, 10);
4500 as_type
= AS_SPECIFIED
;
4504 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4507 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4509 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4513 vty_out(vty
, "%% BGP failed to create peer\n");
4514 return CMD_WARNING_CONFIG_FAILED
;
4518 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4520 /* Request zebra to initiate IPv6 RAs on this interface. We do
4522 * any unnumbered peer in order to not worry about run-time
4524 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4526 * gets deleted later etc.)
4529 bgp_zebra_initiate_radv(bgp
, peer
);
4532 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4533 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4535 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4537 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4539 /* v6only flag changed. Reset bgp seesion */
4540 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4541 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4542 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4543 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4545 bgp_session_reset(peer
);
4548 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4549 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4550 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4551 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4554 if (peer_group_name
) {
4555 group
= peer_group_lookup(bgp
, peer_group_name
);
4557 vty_out(vty
, "%% Configure the peer-group first\n");
4558 return CMD_WARNING_CONFIG_FAILED
;
4561 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4564 return bgp_vty_return(vty
, ret
);
4567 DEFUN (neighbor_interface_config
,
4568 neighbor_interface_config_cmd
,
4569 "neighbor WORD interface [peer-group PGNAME]",
4571 "Interface name or neighbor tag\n"
4572 "Enable BGP on interface\n"
4573 "Member of the peer-group\n"
4574 "Peer-group name\n")
4577 int idx_peer_group_word
= 4;
4579 if (argc
> idx_peer_group_word
)
4580 return peer_conf_interface_get(
4581 vty
, argv
[idx_word
]->arg
, 0,
4582 argv
[idx_peer_group_word
]->arg
, NULL
);
4584 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4588 DEFUN (neighbor_interface_config_v6only
,
4589 neighbor_interface_config_v6only_cmd
,
4590 "neighbor WORD interface v6only [peer-group PGNAME]",
4592 "Interface name or neighbor tag\n"
4593 "Enable BGP on interface\n"
4594 "Enable BGP with v6 link-local only\n"
4595 "Member of the peer-group\n"
4596 "Peer-group name\n")
4599 int idx_peer_group_word
= 5;
4601 if (argc
> idx_peer_group_word
)
4602 return peer_conf_interface_get(
4603 vty
, argv
[idx_word
]->arg
, 1,
4604 argv
[idx_peer_group_word
]->arg
, NULL
);
4606 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4610 DEFUN (neighbor_interface_config_remote_as
,
4611 neighbor_interface_config_remote_as_cmd
,
4612 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4614 "Interface name or neighbor tag\n"
4615 "Enable BGP on interface\n"
4616 "Specify a BGP neighbor\n"
4618 "Internal BGP peer\n"
4619 "External BGP peer\n")
4622 int idx_remote_as
= 4;
4623 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4624 argv
[idx_remote_as
]->arg
);
4627 DEFUN (neighbor_interface_v6only_config_remote_as
,
4628 neighbor_interface_v6only_config_remote_as_cmd
,
4629 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4631 "Interface name or neighbor tag\n"
4632 "Enable BGP with v6 link-local only\n"
4633 "Enable BGP on interface\n"
4634 "Specify a BGP neighbor\n"
4636 "Internal BGP peer\n"
4637 "External BGP peer\n")
4640 int idx_remote_as
= 5;
4641 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4642 argv
[idx_remote_as
]->arg
);
4645 DEFUN (neighbor_peer_group
,
4646 neighbor_peer_group_cmd
,
4647 "neighbor WORD peer-group",
4649 "Interface name or neighbor tag\n"
4650 "Configure peer-group\n")
4652 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4655 struct peer_group
*group
;
4657 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4659 vty_out(vty
, "%% Name conflict with interface: \n");
4660 return CMD_WARNING_CONFIG_FAILED
;
4663 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4665 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4666 return CMD_WARNING_CONFIG_FAILED
;
4674 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4678 "Specify a BGP neighbor\n"
4680 "Internal BGP peer\n"
4681 "External BGP peer\n")
4683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4687 struct peer_group
*group
;
4691 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4693 /* look up for neighbor by interface name config. */
4694 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4696 /* Request zebra to terminate IPv6 RAs on this
4699 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4700 peer_notify_unconfig(peer
);
4705 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4707 peer_group_notify_unconfig(group
);
4708 peer_group_delete(group
);
4710 vty_out(vty
, "%% Create the peer-group first\n");
4711 return CMD_WARNING_CONFIG_FAILED
;
4714 peer
= peer_lookup(bgp
, &su
);
4716 if (peer_dynamic_neighbor(peer
)) {
4718 "%% Operation not allowed on a dynamic neighbor\n");
4719 return CMD_WARNING_CONFIG_FAILED
;
4722 other
= peer
->doppelganger
;
4724 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4725 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4727 peer_notify_unconfig(peer
);
4729 if (other
&& other
->status
!= Deleted
) {
4730 peer_notify_unconfig(other
);
4739 DEFUN (no_neighbor_interface_config
,
4740 no_neighbor_interface_config_cmd
,
4741 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4745 "Configure BGP on interface\n"
4746 "Enable BGP with v6 link-local only\n"
4747 "Member of the peer-group\n"
4749 "Specify a BGP neighbor\n"
4751 "Internal BGP peer\n"
4752 "External BGP peer\n")
4754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4758 /* look up for neighbor by interface name config. */
4759 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4761 /* Request zebra to terminate IPv6 RAs on this interface. */
4763 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4764 peer_notify_unconfig(peer
);
4767 vty_out(vty
, "%% Create the bgp interface first\n");
4768 return CMD_WARNING_CONFIG_FAILED
;
4773 DEFUN (no_neighbor_peer_group
,
4774 no_neighbor_peer_group_cmd
,
4775 "no neighbor WORD peer-group",
4779 "Configure peer-group\n")
4781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4783 struct peer_group
*group
;
4785 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4787 peer_group_notify_unconfig(group
);
4788 peer_group_delete(group
);
4790 vty_out(vty
, "%% Create the peer-group first\n");
4791 return CMD_WARNING_CONFIG_FAILED
;
4796 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4797 no_neighbor_interface_peer_group_remote_as_cmd
,
4798 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4801 "Interface name or neighbor tag\n"
4802 "Specify a BGP neighbor\n"
4804 "Internal BGP peer\n"
4805 "External BGP peer\n")
4807 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4809 struct peer_group
*group
;
4812 /* look up for neighbor by interface name config. */
4813 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4815 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4819 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4821 peer_group_remote_as_delete(group
);
4823 vty_out(vty
, "%% Create the peer-group or interface first\n");
4824 return CMD_WARNING_CONFIG_FAILED
;
4829 DEFUN (neighbor_local_as
,
4830 neighbor_local_as_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4834 "Specify a local-as number\n"
4835 "AS number used as local AS\n")
4843 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4845 return CMD_WARNING_CONFIG_FAILED
;
4847 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4848 ret
= peer_local_as_set(peer
, as
, 0, 0);
4849 return bgp_vty_return(vty
, ret
);
4852 DEFUN (neighbor_local_as_no_prepend
,
4853 neighbor_local_as_no_prepend_cmd
,
4854 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4857 "Specify a local-as number\n"
4858 "AS number used as local AS\n"
4859 "Do not prepend local-as to updates from ebgp peers\n")
4867 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4869 return CMD_WARNING_CONFIG_FAILED
;
4871 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4872 ret
= peer_local_as_set(peer
, as
, 1, 0);
4873 return bgp_vty_return(vty
, ret
);
4876 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4877 neighbor_local_as_no_prepend_replace_as_cmd
,
4878 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4881 "Specify a local-as number\n"
4882 "AS number used as local AS\n"
4883 "Do not prepend local-as to updates from ebgp peers\n"
4884 "Do not prepend local-as to updates from ibgp peers\n")
4892 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4894 return CMD_WARNING_CONFIG_FAILED
;
4896 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4897 ret
= peer_local_as_set(peer
, as
, 1, 1);
4898 return bgp_vty_return(vty
, ret
);
4901 DEFUN (no_neighbor_local_as
,
4902 no_neighbor_local_as_cmd
,
4903 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4907 "Specify a local-as number\n"
4908 "AS number used as local AS\n"
4909 "Do not prepend local-as to updates from ebgp peers\n"
4910 "Do not prepend local-as to updates from ibgp peers\n")
4916 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4918 return CMD_WARNING_CONFIG_FAILED
;
4920 ret
= peer_local_as_unset(peer
);
4921 return bgp_vty_return(vty
, ret
);
4925 DEFUN (neighbor_solo
,
4927 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4930 "Solo peer - part of its own update group\n")
4936 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4938 return CMD_WARNING_CONFIG_FAILED
;
4940 ret
= update_group_adjust_soloness(peer
, 1);
4941 return bgp_vty_return(vty
, ret
);
4944 DEFUN (no_neighbor_solo
,
4945 no_neighbor_solo_cmd
,
4946 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4950 "Solo peer - part of its own update group\n")
4956 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4958 return CMD_WARNING_CONFIG_FAILED
;
4960 ret
= update_group_adjust_soloness(peer
, 0);
4961 return bgp_vty_return(vty
, ret
);
4964 DEFUN (neighbor_password
,
4965 neighbor_password_cmd
,
4966 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4977 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4979 return CMD_WARNING_CONFIG_FAILED
;
4981 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4982 return bgp_vty_return(vty
, ret
);
4985 DEFUN (no_neighbor_password
,
4986 no_neighbor_password_cmd
,
4987 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4998 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5000 return CMD_WARNING_CONFIG_FAILED
;
5002 ret
= peer_password_unset(peer
);
5003 return bgp_vty_return(vty
, ret
);
5006 DEFUN (neighbor_activate
,
5007 neighbor_activate_cmd
,
5008 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5011 "Enable the Address Family for this Neighbor\n")
5017 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5019 return CMD_WARNING_CONFIG_FAILED
;
5021 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5022 return bgp_vty_return(vty
, ret
);
5025 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5026 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5027 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5028 "Enable the Address Family for this Neighbor\n")
5030 DEFUN (no_neighbor_activate
,
5031 no_neighbor_activate_cmd
,
5032 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5036 "Enable the Address Family for this Neighbor\n")
5043 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5045 return CMD_WARNING_CONFIG_FAILED
;
5047 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5048 return bgp_vty_return(vty
, ret
);
5051 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5052 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5053 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5054 "Enable the Address Family for this Neighbor\n")
5056 DEFUN (neighbor_set_peer_group
,
5057 neighbor_set_peer_group_cmd
,
5058 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5061 "Member of the peer-group\n"
5062 "Peer-group name\n")
5064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5071 struct peer_group
*group
;
5073 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5075 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5077 vty_out(vty
, "%% Malformed address or name: %s\n",
5078 argv
[idx_peer
]->arg
);
5079 return CMD_WARNING_CONFIG_FAILED
;
5082 if (peer_address_self_check(bgp
, &su
)) {
5084 "%% Can not configure the local system as neighbor\n");
5085 return CMD_WARNING_CONFIG_FAILED
;
5088 /* Disallow for dynamic neighbor. */
5089 peer
= peer_lookup(bgp
, &su
);
5090 if (peer
&& peer_dynamic_neighbor(peer
)) {
5092 "%% Operation not allowed on a dynamic neighbor\n");
5093 return CMD_WARNING_CONFIG_FAILED
;
5097 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5099 vty_out(vty
, "%% Configure the peer-group first\n");
5100 return CMD_WARNING_CONFIG_FAILED
;
5103 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5105 return bgp_vty_return(vty
, ret
);
5108 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5109 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5110 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5111 "Member of the peer-group\n"
5112 "Peer-group name\n")
5114 DEFUN (no_neighbor_set_peer_group
,
5115 no_neighbor_set_peer_group_cmd
,
5116 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5120 "Member of the peer-group\n"
5121 "Peer-group name\n")
5123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5128 struct peer_group
*group
;
5130 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5132 return CMD_WARNING_CONFIG_FAILED
;
5134 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5136 vty_out(vty
, "%% Configure the peer-group first\n");
5137 return CMD_WARNING_CONFIG_FAILED
;
5140 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5141 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5143 peer_notify_unconfig(peer
);
5144 ret
= peer_delete(peer
);
5146 return bgp_vty_return(vty
, ret
);
5149 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5150 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5152 "Member of the peer-group\n"
5153 "Peer-group name\n")
5155 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5156 uint64_t flag
, int set
)
5161 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5163 return CMD_WARNING_CONFIG_FAILED
;
5166 * If 'neighbor <interface>', then this is for directly connected peers,
5167 * we should not accept disable-connected-check.
5169 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5171 "%s is directly connected peer, cannot accept disable-connected-check\n",
5173 return CMD_WARNING_CONFIG_FAILED
;
5176 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5177 peer_tx_shutdown_message_unset(peer
);
5180 ret
= peer_flag_set(peer
, flag
);
5182 ret
= peer_flag_unset(peer
, flag
);
5184 return bgp_vty_return(vty
, ret
);
5187 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5189 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5192 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5195 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5198 /* neighbor passive. */
5199 DEFUN (neighbor_passive
,
5200 neighbor_passive_cmd
,
5201 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5204 "Don't send open messages to this neighbor\n")
5207 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5210 DEFUN (no_neighbor_passive
,
5211 no_neighbor_passive_cmd
,
5212 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5216 "Don't send open messages to this neighbor\n")
5219 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5222 /* neighbor shutdown. */
5223 DEFUN (neighbor_shutdown_msg
,
5224 neighbor_shutdown_msg_cmd
,
5225 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5228 "Administratively shut down this neighbor\n"
5229 "Add a shutdown message (RFC 8203)\n"
5230 "Shutdown message\n")
5236 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5240 return CMD_WARNING_CONFIG_FAILED
;
5241 message
= argv_concat(argv
, argc
, 4);
5242 peer_tx_shutdown_message_set(peer
, message
);
5243 XFREE(MTYPE_TMP
, message
);
5246 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5249 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5250 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5251 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5252 "Administratively shut down this neighbor\n")
5254 DEFUN (no_neighbor_shutdown_msg
,
5255 no_neighbor_shutdown_msg_cmd
,
5256 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5260 "Administratively shut down this neighbor\n"
5261 "Remove a shutdown message (RFC 8203)\n"
5262 "Shutdown message\n")
5266 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5267 PEER_FLAG_SHUTDOWN
);
5270 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5271 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5272 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5273 "Administratively shut down this neighbor\n")
5275 DEFUN(neighbor_shutdown_rtt
,
5276 neighbor_shutdown_rtt_cmd
,
5277 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5280 "Administratively shut down this neighbor\n"
5281 "Shutdown if round-trip-time is higher than expected\n"
5282 "Round-trip-time in milliseconds\n"
5283 "Specify the number of keepalives before shutdown\n"
5284 "The number of keepalives with higher RTT to shutdown\n")
5291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5294 return CMD_WARNING_CONFIG_FAILED
;
5296 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5298 if (argv_find(argv
, argc
, "count", &idx_count
))
5299 peer
->rtt_keepalive_conf
=
5300 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5302 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5303 PEER_FLAG_RTT_SHUTDOWN
);
5306 DEFUN(no_neighbor_shutdown_rtt
,
5307 no_neighbor_shutdown_rtt_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5312 "Administratively shut down this neighbor\n"
5313 "Shutdown if round-trip-time is higher than expected\n"
5314 "Round-trip-time in milliseconds\n"
5315 "Specify the number of keepalives before shutdown\n"
5316 "The number of keepalives with higher RTT to shutdown\n")
5321 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5324 return CMD_WARNING_CONFIG_FAILED
;
5326 peer
->rtt_expected
= 0;
5327 peer
->rtt_keepalive_conf
= 1;
5329 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5330 PEER_FLAG_RTT_SHUTDOWN
);
5333 /* neighbor capability dynamic. */
5334 DEFUN (neighbor_capability_dynamic
,
5335 neighbor_capability_dynamic_cmd
,
5336 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5339 "Advertise capability to the peer\n"
5340 "Advertise dynamic capability to this neighbor\n")
5343 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5344 PEER_FLAG_DYNAMIC_CAPABILITY
);
5347 DEFUN (no_neighbor_capability_dynamic
,
5348 no_neighbor_capability_dynamic_cmd
,
5349 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5353 "Advertise capability to the peer\n"
5354 "Advertise dynamic capability to this neighbor\n")
5357 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5358 PEER_FLAG_DYNAMIC_CAPABILITY
);
5361 /* neighbor dont-capability-negotiate */
5362 DEFUN (neighbor_dont_capability_negotiate
,
5363 neighbor_dont_capability_negotiate_cmd
,
5364 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5367 "Do not perform capability negotiation\n")
5370 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5371 PEER_FLAG_DONT_CAPABILITY
);
5374 DEFUN (no_neighbor_dont_capability_negotiate
,
5375 no_neighbor_dont_capability_negotiate_cmd
,
5376 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5380 "Do not perform capability negotiation\n")
5383 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5384 PEER_FLAG_DONT_CAPABILITY
);
5387 /* neighbor capability extended next hop encoding */
5388 DEFUN (neighbor_capability_enhe
,
5389 neighbor_capability_enhe_cmd
,
5390 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5393 "Advertise capability to the peer\n"
5394 "Advertise extended next-hop capability to the peer\n")
5399 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5400 if (peer
&& peer
->conf_if
)
5403 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5404 PEER_FLAG_CAPABILITY_ENHE
);
5407 DEFUN (no_neighbor_capability_enhe
,
5408 no_neighbor_capability_enhe_cmd
,
5409 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5413 "Advertise capability to the peer\n"
5414 "Advertise extended next-hop capability to the peer\n")
5419 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5420 if (peer
&& peer
->conf_if
) {
5422 "Peer %s cannot have capability extended-nexthop turned off\n",
5423 argv
[idx_peer
]->arg
);
5424 return CMD_WARNING_CONFIG_FAILED
;
5427 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5428 PEER_FLAG_CAPABILITY_ENHE
);
5431 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5432 afi_t afi
, safi_t safi
, uint32_t flag
,
5438 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5440 return CMD_WARNING_CONFIG_FAILED
;
5443 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5445 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5447 return bgp_vty_return(vty
, ret
);
5450 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5451 afi_t afi
, safi_t safi
, uint32_t flag
)
5453 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5456 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5457 afi_t afi
, safi_t safi
, uint32_t flag
)
5459 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5462 /* neighbor capability orf prefix-list. */
5463 DEFUN (neighbor_capability_orf_prefix
,
5464 neighbor_capability_orf_prefix_cmd
,
5465 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5468 "Advertise capability to the peer\n"
5469 "Advertise ORF capability to the peer\n"
5470 "Advertise prefixlist ORF capability to this neighbor\n"
5471 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5472 "Capability to RECEIVE the ORF from this neighbor\n"
5473 "Capability to SEND the ORF to this neighbor\n")
5475 int idx_send_recv
= 5;
5476 char *peer_str
= argv
[1]->arg
;
5478 afi_t afi
= bgp_node_afi(vty
);
5479 safi_t safi
= bgp_node_safi(vty
);
5481 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5483 return CMD_WARNING_CONFIG_FAILED
;
5485 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5486 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5487 PEER_FLAG_ORF_PREFIX_SM
);
5489 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5490 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5491 PEER_FLAG_ORF_PREFIX_RM
);
5493 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5494 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5495 PEER_FLAG_ORF_PREFIX_SM
)
5496 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5497 PEER_FLAG_ORF_PREFIX_RM
);
5499 return CMD_WARNING_CONFIG_FAILED
;
5503 neighbor_capability_orf_prefix
,
5504 neighbor_capability_orf_prefix_hidden_cmd
,
5505 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5506 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5507 "Advertise capability to the peer\n"
5508 "Advertise ORF capability to the peer\n"
5509 "Advertise prefixlist ORF capability to this neighbor\n"
5510 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5511 "Capability to RECEIVE the ORF from this neighbor\n"
5512 "Capability to SEND the ORF to this neighbor\n")
5514 DEFUN (no_neighbor_capability_orf_prefix
,
5515 no_neighbor_capability_orf_prefix_cmd
,
5516 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5520 "Advertise capability to the peer\n"
5521 "Advertise ORF capability to the peer\n"
5522 "Advertise prefixlist ORF capability to this neighbor\n"
5523 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5524 "Capability to RECEIVE the ORF from this neighbor\n"
5525 "Capability to SEND the ORF to this neighbor\n")
5527 int idx_send_recv
= 6;
5528 char *peer_str
= argv
[2]->arg
;
5530 afi_t afi
= bgp_node_afi(vty
);
5531 safi_t safi
= bgp_node_safi(vty
);
5533 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5535 return CMD_WARNING_CONFIG_FAILED
;
5537 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5538 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5539 PEER_FLAG_ORF_PREFIX_SM
);
5541 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5542 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5543 PEER_FLAG_ORF_PREFIX_RM
);
5545 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5546 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5547 PEER_FLAG_ORF_PREFIX_SM
)
5548 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5549 PEER_FLAG_ORF_PREFIX_RM
);
5551 return CMD_WARNING_CONFIG_FAILED
;
5555 no_neighbor_capability_orf_prefix
,
5556 no_neighbor_capability_orf_prefix_hidden_cmd
,
5557 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5558 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5559 "Advertise capability to the peer\n"
5560 "Advertise ORF capability to the peer\n"
5561 "Advertise prefixlist ORF capability to this neighbor\n"
5562 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5563 "Capability to RECEIVE the ORF from this neighbor\n"
5564 "Capability to SEND the ORF to this neighbor\n")
5566 /* neighbor next-hop-self. */
5567 DEFUN (neighbor_nexthop_self
,
5568 neighbor_nexthop_self_cmd
,
5569 "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_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5576 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5579 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5580 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5582 "Disable the next hop calculation for this neighbor\n")
5584 /* neighbor next-hop-self. */
5585 DEFUN (neighbor_nexthop_self_force
,
5586 neighbor_nexthop_self_force_cmd
,
5587 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5590 "Disable the next hop calculation for this neighbor\n"
5591 "Set the next hop to self for reflected routes\n")
5594 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5596 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5599 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5600 neighbor_nexthop_self_force_hidden_cmd
,
5601 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5602 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5603 "Disable the next hop calculation for this neighbor\n"
5604 "Set the next hop to self for reflected routes\n")
5606 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5607 neighbor_nexthop_self_all_hidden_cmd
,
5608 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5609 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5610 "Disable the next hop calculation for this neighbor\n"
5611 "Set the next hop to self for reflected routes\n")
5613 DEFUN (no_neighbor_nexthop_self
,
5614 no_neighbor_nexthop_self_cmd
,
5615 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5619 "Disable the next hop calculation for this neighbor\n")
5622 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5623 bgp_node_afi(vty
), bgp_node_safi(vty
),
5624 PEER_FLAG_NEXTHOP_SELF
);
5627 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5628 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5629 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5630 "Disable the next hop calculation for this neighbor\n")
5632 DEFUN (no_neighbor_nexthop_self_force
,
5633 no_neighbor_nexthop_self_force_cmd
,
5634 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5638 "Disable the next hop calculation for this neighbor\n"
5639 "Set the next hop to self for reflected routes\n")
5642 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5643 bgp_node_afi(vty
), bgp_node_safi(vty
),
5644 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5647 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5648 no_neighbor_nexthop_self_force_hidden_cmd
,
5649 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5650 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5651 "Disable the next hop calculation for this neighbor\n"
5652 "Set the next hop to self for reflected routes\n")
5654 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5655 no_neighbor_nexthop_self_all_hidden_cmd
,
5656 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5657 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5658 "Disable the next hop calculation for this neighbor\n"
5659 "Set the next hop to self for reflected routes\n")
5661 /* neighbor as-override */
5662 DEFUN (neighbor_as_override
,
5663 neighbor_as_override_cmd
,
5664 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5667 "Override ASNs in outbound updates if aspath equals remote-as\n")
5670 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5671 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5674 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5675 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5676 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5677 "Override ASNs in outbound updates if aspath equals remote-as\n")
5679 DEFUN (no_neighbor_as_override
,
5680 no_neighbor_as_override_cmd
,
5681 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5685 "Override ASNs in outbound updates if aspath equals remote-as\n")
5688 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5689 bgp_node_afi(vty
), bgp_node_safi(vty
),
5690 PEER_FLAG_AS_OVERRIDE
);
5693 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5694 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5695 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5696 "Override ASNs in outbound updates if aspath equals remote-as\n")
5698 /* neighbor remove-private-AS. */
5699 DEFUN (neighbor_remove_private_as
,
5700 neighbor_remove_private_as_cmd
,
5701 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5704 "Remove private ASNs in outbound updates\n")
5707 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5709 PEER_FLAG_REMOVE_PRIVATE_AS
);
5712 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5713 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Remove private ASNs in outbound updates\n")
5717 DEFUN (neighbor_remove_private_as_all
,
5718 neighbor_remove_private_as_all_cmd
,
5719 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5722 "Remove private ASNs in outbound updates\n"
5723 "Apply to all AS numbers\n")
5726 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5728 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5731 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5732 neighbor_remove_private_as_all_hidden_cmd
,
5733 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5734 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5735 "Remove private ASNs in outbound updates\n"
5736 "Apply to all AS numbers")
5738 DEFUN (neighbor_remove_private_as_replace_as
,
5739 neighbor_remove_private_as_replace_as_cmd
,
5740 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5743 "Remove private ASNs in outbound updates\n"
5744 "Replace private ASNs with our ASN in outbound updates\n")
5747 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5749 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5752 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5753 neighbor_remove_private_as_replace_as_hidden_cmd
,
5754 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5755 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5756 "Remove private ASNs in outbound updates\n"
5757 "Replace private ASNs with our ASN in outbound updates\n")
5759 DEFUN (neighbor_remove_private_as_all_replace_as
,
5760 neighbor_remove_private_as_all_replace_as_cmd
,
5761 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5764 "Remove private ASNs in outbound updates\n"
5765 "Apply to all AS numbers\n"
5766 "Replace private ASNs with our ASN in outbound updates\n")
5769 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5771 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5775 neighbor_remove_private_as_all_replace_as
,
5776 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5777 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5778 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5779 "Remove private ASNs in outbound updates\n"
5780 "Apply to all AS numbers\n"
5781 "Replace private ASNs with our ASN in outbound updates\n")
5783 DEFUN (no_neighbor_remove_private_as
,
5784 no_neighbor_remove_private_as_cmd
,
5785 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5789 "Remove private ASNs in outbound updates\n")
5792 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5793 bgp_node_afi(vty
), bgp_node_safi(vty
),
5794 PEER_FLAG_REMOVE_PRIVATE_AS
);
5797 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5798 no_neighbor_remove_private_as_hidden_cmd
,
5799 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5800 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5801 "Remove private ASNs in outbound updates\n")
5803 DEFUN (no_neighbor_remove_private_as_all
,
5804 no_neighbor_remove_private_as_all_cmd
,
5805 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5809 "Remove private ASNs in outbound updates\n"
5810 "Apply to all AS numbers\n")
5813 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5814 bgp_node_afi(vty
), bgp_node_safi(vty
),
5815 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5818 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5819 no_neighbor_remove_private_as_all_hidden_cmd
,
5820 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5821 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5822 "Remove private ASNs in outbound updates\n"
5823 "Apply to all AS numbers\n")
5825 DEFUN (no_neighbor_remove_private_as_replace_as
,
5826 no_neighbor_remove_private_as_replace_as_cmd
,
5827 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5831 "Remove private ASNs in outbound updates\n"
5832 "Replace private ASNs with our ASN in outbound updates\n")
5835 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5836 bgp_node_afi(vty
), bgp_node_safi(vty
),
5837 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5840 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5841 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5842 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5843 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5844 "Remove private ASNs in outbound updates\n"
5845 "Replace private ASNs with our ASN in outbound updates\n")
5847 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5848 no_neighbor_remove_private_as_all_replace_as_cmd
,
5849 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5853 "Remove private ASNs in outbound updates\n"
5854 "Apply to all AS numbers\n"
5855 "Replace private ASNs with our ASN in outbound updates\n")
5858 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5859 bgp_node_afi(vty
), bgp_node_safi(vty
),
5860 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5864 no_neighbor_remove_private_as_all_replace_as
,
5865 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5866 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5867 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5868 "Remove private ASNs in outbound updates\n"
5869 "Apply to all AS numbers\n"
5870 "Replace private ASNs with our ASN in outbound updates\n")
5873 /* neighbor send-community. */
5874 DEFUN (neighbor_send_community
,
5875 neighbor_send_community_cmd
,
5876 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5879 "Send Community attribute to this neighbor\n")
5883 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5885 PEER_FLAG_SEND_COMMUNITY
);
5888 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5889 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5890 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5891 "Send Community attribute to this neighbor\n")
5893 DEFUN (no_neighbor_send_community
,
5894 no_neighbor_send_community_cmd
,
5895 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5899 "Send Community attribute to this neighbor\n")
5903 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5904 bgp_node_afi(vty
), bgp_node_safi(vty
),
5905 PEER_FLAG_SEND_COMMUNITY
);
5908 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5909 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5910 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5911 "Send Community attribute to this neighbor\n")
5913 /* neighbor send-community extended. */
5914 DEFUN (neighbor_send_community_type
,
5915 neighbor_send_community_type_cmd
,
5916 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
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 const char *type
= argv
[argc
- 1]->text
;
5927 char *peer_str
= argv
[1]->arg
;
5929 afi_t afi
= bgp_node_afi(vty
);
5930 safi_t safi
= bgp_node_safi(vty
);
5932 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5934 return CMD_WARNING_CONFIG_FAILED
;
5936 if (strmatch(type
, "standard"))
5937 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5938 PEER_FLAG_SEND_COMMUNITY
);
5940 if (strmatch(type
, "extended"))
5941 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5942 PEER_FLAG_SEND_EXT_COMMUNITY
);
5944 if (strmatch(type
, "large"))
5945 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5946 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5948 if (strmatch(type
, "both")) {
5949 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5950 PEER_FLAG_SEND_COMMUNITY
)
5951 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5952 PEER_FLAG_SEND_EXT_COMMUNITY
);
5954 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5955 PEER_FLAG_SEND_COMMUNITY
)
5956 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5957 PEER_FLAG_SEND_EXT_COMMUNITY
)
5958 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5959 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5963 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5964 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5966 "Send Community attribute to this neighbor\n"
5967 "Send Standard and Extended Community attributes\n"
5968 "Send Standard, Large and Extended Community attributes\n"
5969 "Send Extended Community attributes\n"
5970 "Send Standard Community attributes\n"
5971 "Send Large Community attributes\n")
5973 DEFUN (no_neighbor_send_community_type
,
5974 no_neighbor_send_community_type_cmd
,
5975 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5979 "Send Community attribute to this neighbor\n"
5980 "Send Standard and Extended Community attributes\n"
5981 "Send Standard, Large and Extended Community attributes\n"
5982 "Send Extended Community attributes\n"
5983 "Send Standard Community attributes\n"
5984 "Send Large Community attributes\n")
5986 const char *type
= argv
[argc
- 1]->text
;
5987 char *peer_str
= argv
[2]->arg
;
5989 afi_t afi
= bgp_node_afi(vty
);
5990 safi_t safi
= bgp_node_safi(vty
);
5992 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5994 return CMD_WARNING_CONFIG_FAILED
;
5996 if (strmatch(type
, "standard"))
5997 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5998 PEER_FLAG_SEND_COMMUNITY
);
6000 if (strmatch(type
, "extended"))
6001 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6002 PEER_FLAG_SEND_EXT_COMMUNITY
);
6004 if (strmatch(type
, "large"))
6005 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6006 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6008 if (strmatch(type
, "both")) {
6010 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6011 PEER_FLAG_SEND_COMMUNITY
)
6012 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6013 PEER_FLAG_SEND_EXT_COMMUNITY
);
6016 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6017 PEER_FLAG_SEND_COMMUNITY
)
6018 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6019 PEER_FLAG_SEND_EXT_COMMUNITY
)
6020 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6021 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6025 no_neighbor_send_community_type
,
6026 no_neighbor_send_community_type_hidden_cmd
,
6027 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6028 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6029 "Send Community attribute to this neighbor\n"
6030 "Send Standard and Extended Community attributes\n"
6031 "Send Standard, Large and Extended Community attributes\n"
6032 "Send Extended Community attributes\n"
6033 "Send Standard Community attributes\n"
6034 "Send Large Community attributes\n")
6036 /* neighbor soft-reconfig. */
6037 DEFUN (neighbor_soft_reconfiguration
,
6038 neighbor_soft_reconfiguration_cmd
,
6039 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6042 "Per neighbor soft reconfiguration\n"
6043 "Allow inbound soft reconfiguration for this neighbor\n")
6046 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6048 PEER_FLAG_SOFT_RECONFIG
);
6051 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6052 neighbor_soft_reconfiguration_hidden_cmd
,
6053 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6055 "Per neighbor soft reconfiguration\n"
6056 "Allow inbound soft reconfiguration for this neighbor\n")
6058 DEFUN (no_neighbor_soft_reconfiguration
,
6059 no_neighbor_soft_reconfiguration_cmd
,
6060 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6064 "Per neighbor soft reconfiguration\n"
6065 "Allow inbound soft reconfiguration for this neighbor\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_SOFT_RECONFIG
);
6073 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6074 no_neighbor_soft_reconfiguration_hidden_cmd
,
6075 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6076 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6077 "Per neighbor soft reconfiguration\n"
6078 "Allow inbound soft reconfiguration for this neighbor\n")
6080 DEFUN (neighbor_route_reflector_client
,
6081 neighbor_route_reflector_client_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6085 "Configure a neighbor as Route Reflector client\n")
6091 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6093 return CMD_WARNING_CONFIG_FAILED
;
6095 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6097 PEER_FLAG_REFLECTOR_CLIENT
);
6100 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6101 neighbor_route_reflector_client_hidden_cmd
,
6102 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Configure a neighbor as Route Reflector client\n")
6106 DEFUN (no_neighbor_route_reflector_client
,
6107 no_neighbor_route_reflector_client_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6112 "Configure a neighbor as Route Reflector client\n")
6115 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6116 bgp_node_afi(vty
), bgp_node_safi(vty
),
6117 PEER_FLAG_REFLECTOR_CLIENT
);
6120 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6121 no_neighbor_route_reflector_client_hidden_cmd
,
6122 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6123 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6124 "Configure a neighbor as Route Reflector client\n")
6126 /* neighbor route-server-client. */
6127 DEFUN (neighbor_route_server_client
,
6128 neighbor_route_server_client_cmd
,
6129 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6132 "Configure a neighbor as Route Server client\n")
6137 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6139 return CMD_WARNING_CONFIG_FAILED
;
6140 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6142 PEER_FLAG_RSERVER_CLIENT
);
6145 ALIAS_HIDDEN(neighbor_route_server_client
,
6146 neighbor_route_server_client_hidden_cmd
,
6147 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6148 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6149 "Configure a neighbor as Route Server client\n")
6151 DEFUN (no_neighbor_route_server_client
,
6152 no_neighbor_route_server_client_cmd
,
6153 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6157 "Configure a neighbor as Route Server client\n")
6160 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6161 bgp_node_afi(vty
), bgp_node_safi(vty
),
6162 PEER_FLAG_RSERVER_CLIENT
);
6165 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6166 no_neighbor_route_server_client_hidden_cmd
,
6167 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6168 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6169 "Configure a neighbor as Route Server client\n")
6171 DEFUN (neighbor_nexthop_local_unchanged
,
6172 neighbor_nexthop_local_unchanged_cmd
,
6173 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6176 "Configure treatment of outgoing link-local nexthop attribute\n"
6177 "Leave link-local nexthop unchanged for this peer\n")
6180 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6182 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6185 DEFUN (no_neighbor_nexthop_local_unchanged
,
6186 no_neighbor_nexthop_local_unchanged_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6191 "Configure treatment of outgoing link-local-nexthop attribute\n"
6192 "Leave link-local nexthop unchanged for this peer\n")
6195 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6196 bgp_node_afi(vty
), bgp_node_safi(vty
),
6197 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6200 DEFUN (neighbor_attr_unchanged
,
6201 neighbor_attr_unchanged_cmd
,
6202 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6205 "BGP attribute is propagated unchanged to this neighbor\n"
6206 "As-path attribute\n"
6207 "Nexthop attribute\n"
6211 char *peer_str
= argv
[1]->arg
;
6213 bool aspath
= false;
6214 bool nexthop
= false;
6216 afi_t afi
= bgp_node_afi(vty
);
6217 safi_t safi
= bgp_node_safi(vty
);
6220 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6222 return CMD_WARNING_CONFIG_FAILED
;
6224 if (argv_find(argv
, argc
, "as-path", &idx
))
6228 if (argv_find(argv
, argc
, "next-hop", &idx
))
6232 if (argv_find(argv
, argc
, "med", &idx
))
6235 /* no flags means all of them! */
6236 if (!aspath
&& !nexthop
&& !med
) {
6237 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6238 PEER_FLAG_AS_PATH_UNCHANGED
);
6239 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6240 PEER_FLAG_NEXTHOP_UNCHANGED
);
6241 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6242 PEER_FLAG_MED_UNCHANGED
);
6245 if (peer_af_flag_check(peer
, afi
, safi
,
6246 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6247 ret
|= peer_af_flag_unset_vty(
6248 vty
, peer_str
, afi
, safi
,
6249 PEER_FLAG_AS_PATH_UNCHANGED
);
6252 ret
|= peer_af_flag_set_vty(
6253 vty
, peer_str
, afi
, safi
,
6254 PEER_FLAG_AS_PATH_UNCHANGED
);
6257 if (peer_af_flag_check(peer
, afi
, safi
,
6258 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6259 ret
|= peer_af_flag_unset_vty(
6260 vty
, peer_str
, afi
, safi
,
6261 PEER_FLAG_NEXTHOP_UNCHANGED
);
6264 ret
|= peer_af_flag_set_vty(
6265 vty
, peer_str
, afi
, safi
,
6266 PEER_FLAG_NEXTHOP_UNCHANGED
);
6269 if (peer_af_flag_check(peer
, afi
, safi
,
6270 PEER_FLAG_MED_UNCHANGED
)) {
6271 ret
|= peer_af_flag_unset_vty(
6272 vty
, peer_str
, afi
, safi
,
6273 PEER_FLAG_MED_UNCHANGED
);
6276 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6277 PEER_FLAG_MED_UNCHANGED
);
6284 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6285 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6286 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6287 "BGP attribute is propagated unchanged to this neighbor\n"
6288 "As-path attribute\n"
6289 "Nexthop attribute\n"
6292 DEFUN (no_neighbor_attr_unchanged
,
6293 no_neighbor_attr_unchanged_cmd
,
6294 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6298 "BGP attribute is propagated unchanged to this neighbor\n"
6299 "As-path attribute\n"
6300 "Nexthop attribute\n"
6304 char *peer_str
= argv
[2]->arg
;
6306 bool aspath
= false;
6307 bool nexthop
= false;
6309 afi_t afi
= bgp_node_afi(vty
);
6310 safi_t safi
= bgp_node_safi(vty
);
6313 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6315 return CMD_WARNING_CONFIG_FAILED
;
6317 if (argv_find(argv
, argc
, "as-path", &idx
))
6321 if (argv_find(argv
, argc
, "next-hop", &idx
))
6325 if (argv_find(argv
, argc
, "med", &idx
))
6328 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6329 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6330 PEER_FLAG_AS_PATH_UNCHANGED
)
6331 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6332 PEER_FLAG_NEXTHOP_UNCHANGED
)
6333 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6334 PEER_FLAG_MED_UNCHANGED
);
6337 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6338 PEER_FLAG_AS_PATH_UNCHANGED
);
6341 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6342 PEER_FLAG_NEXTHOP_UNCHANGED
);
6345 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6346 PEER_FLAG_MED_UNCHANGED
);
6352 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6353 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6354 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6355 "BGP attribute is propagated unchanged to this neighbor\n"
6356 "As-path attribute\n"
6357 "Nexthop attribute\n"
6360 /* EBGP multihop configuration. */
6361 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6362 const char *ttl_str
)
6367 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6369 return CMD_WARNING_CONFIG_FAILED
;
6372 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6377 ttl
= strtoul(ttl_str
, NULL
, 10);
6379 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6382 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6386 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6388 return CMD_WARNING_CONFIG_FAILED
;
6390 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6393 /* neighbor ebgp-multihop. */
6394 DEFUN (neighbor_ebgp_multihop
,
6395 neighbor_ebgp_multihop_cmd
,
6396 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6399 "Allow EBGP neighbors not on directly connected networks\n")
6402 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6405 DEFUN (neighbor_ebgp_multihop_ttl
,
6406 neighbor_ebgp_multihop_ttl_cmd
,
6407 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6410 "Allow EBGP neighbors not on directly connected networks\n"
6411 "maximum hop count\n")
6415 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6416 argv
[idx_number
]->arg
);
6419 DEFUN (no_neighbor_ebgp_multihop
,
6420 no_neighbor_ebgp_multihop_cmd
,
6421 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6425 "Allow EBGP neighbors not on directly connected networks\n"
6426 "maximum hop count\n")
6429 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6432 static uint8_t get_role_by_name(const char *role_str
)
6434 if (strncmp(role_str
, "peer", 2) == 0)
6436 if (strncmp(role_str
, "provider", 2) == 0)
6437 return ROLE_PROVIDER
;
6438 if (strncmp(role_str
, "customer", 2) == 0)
6439 return ROLE_CUSTOMER
;
6440 if (strncmp(role_str
, "rs-server", 4) == 0)
6441 return ROLE_RS_SERVER
;
6442 if (strncmp(role_str
, "rs-client", 4) == 0)
6443 return ROLE_RS_CLIENT
;
6444 return ROLE_UNDEFINED
;
6447 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6448 const char *role_str
, bool strict_mode
)
6452 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6454 return CMD_WARNING_CONFIG_FAILED
;
6455 uint8_t role
= get_role_by_name(role_str
);
6457 if (role
== ROLE_UNDEFINED
)
6458 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6459 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6462 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6466 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6468 return CMD_WARNING_CONFIG_FAILED
;
6469 return bgp_vty_return(vty
, peer_role_unset(peer
));
6472 DEFPY(neighbor_role
,
6474 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6477 "Set session role\n"
6483 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6487 DEFPY(neighbor_role_strict
,
6488 neighbor_role_strict_cmd
,
6489 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6492 "Set session role\n"
6494 "Use additional restriction on peer\n")
6499 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6503 DEFPY(no_neighbor_role
,
6504 no_neighbor_role_cmd
,
6505 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6509 "Set session role\n"
6511 "Use additional restriction on peer\n")
6515 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6518 /* disable-connected-check */
6519 DEFUN (neighbor_disable_connected_check
,
6520 neighbor_disable_connected_check_cmd
,
6521 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6524 "one-hop away EBGP peer using loopback address\n"
6525 "Enforce EBGP neighbors perform multihop\n")
6528 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6529 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6532 DEFUN (no_neighbor_disable_connected_check
,
6533 no_neighbor_disable_connected_check_cmd
,
6534 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6538 "one-hop away EBGP peer using loopback address\n"
6539 "Enforce EBGP neighbors perform multihop\n")
6542 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6543 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6546 /* disable-link-bw-encoding-ieee */
6547 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6548 neighbor_disable_link_bw_encoding_ieee_cmd
,
6549 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6550 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6551 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6555 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6556 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6559 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6560 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6561 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6562 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6563 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6567 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6568 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6571 /* extended-optional-parameters */
6572 DEFUN(neighbor_extended_optional_parameters
,
6573 neighbor_extended_optional_parameters_cmd
,
6574 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6575 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6576 "Force the extended optional parameters format for OPEN messages\n")
6580 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6581 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6584 DEFUN(no_neighbor_extended_optional_parameters
,
6585 no_neighbor_extended_optional_parameters_cmd
,
6586 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6587 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6588 "Force the extended optional parameters format for OPEN messages\n")
6592 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6593 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6596 /* enforce-first-as */
6597 DEFUN (neighbor_enforce_first_as
,
6598 neighbor_enforce_first_as_cmd
,
6599 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6602 "Enforce the first AS for EBGP routes\n")
6606 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6607 PEER_FLAG_ENFORCE_FIRST_AS
);
6610 DEFUN (no_neighbor_enforce_first_as
,
6611 no_neighbor_enforce_first_as_cmd
,
6612 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6616 "Enforce the first AS for EBGP routes\n")
6620 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6621 PEER_FLAG_ENFORCE_FIRST_AS
);
6625 DEFUN (neighbor_description
,
6626 neighbor_description_cmd
,
6627 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6630 "Neighbor specific description\n"
6631 "Up to 80 characters describing this neighbor\n")
6638 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6640 return CMD_WARNING_CONFIG_FAILED
;
6642 str
= argv_concat(argv
, argc
, idx_line
);
6644 peer_description_set(peer
, str
);
6646 XFREE(MTYPE_TMP
, str
);
6651 DEFUN (no_neighbor_description
,
6652 no_neighbor_description_cmd
,
6653 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6657 "Neighbor specific description\n")
6662 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6664 return CMD_WARNING_CONFIG_FAILED
;
6666 peer_description_unset(peer
);
6671 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6672 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6673 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6674 "Neighbor specific description\n"
6675 "Up to 80 characters describing this neighbor\n")
6677 /* Neighbor update-source. */
6678 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6679 const char *source_str
)
6685 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6687 return CMD_WARNING_CONFIG_FAILED
;
6693 if (str2sockunion(source_str
, &su
) == 0)
6694 peer_update_source_addr_set(peer
, &su
);
6696 if (str2prefix(source_str
, &p
)) {
6698 "%% Invalid update-source, remove prefix length \n");
6699 return CMD_WARNING_CONFIG_FAILED
;
6701 peer_update_source_if_set(peer
, source_str
);
6704 peer_update_source_unset(peer
);
6709 #define BGP_UPDATE_SOURCE_HELP_STR \
6712 "Interface name (requires zebra to be running)\n"
6714 DEFUN (neighbor_update_source
,
6715 neighbor_update_source_cmd
,
6716 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6719 "Source of routing updates\n"
6720 BGP_UPDATE_SOURCE_HELP_STR
)
6724 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6725 argv
[idx_peer_2
]->arg
);
6728 DEFUN (no_neighbor_update_source
,
6729 no_neighbor_update_source_cmd
,
6730 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6734 "Source of routing updates\n"
6735 BGP_UPDATE_SOURCE_HELP_STR
)
6738 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6741 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6742 afi_t afi
, safi_t safi
,
6743 const char *rmap
, int set
)
6747 struct route_map
*route_map
= NULL
;
6749 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6751 return CMD_WARNING_CONFIG_FAILED
;
6755 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6756 ret
= peer_default_originate_set(peer
, afi
, safi
,
6759 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6761 return bgp_vty_return(vty
, ret
);
6764 /* neighbor default-originate. */
6765 DEFUN (neighbor_default_originate
,
6766 neighbor_default_originate_cmd
,
6767 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6770 "Originate default route to this neighbor\n")
6773 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6775 bgp_node_safi(vty
), NULL
, 1);
6778 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6779 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6780 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6781 "Originate default route to this neighbor\n")
6783 DEFUN (neighbor_default_originate_rmap
,
6784 neighbor_default_originate_rmap_cmd
,
6785 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6788 "Originate default route to this neighbor\n"
6789 "Route-map to specify criteria to originate default\n"
6794 return peer_default_originate_set_vty(
6795 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6796 argv
[idx_word
]->arg
, 1);
6800 neighbor_default_originate_rmap
,
6801 neighbor_default_originate_rmap_hidden_cmd
,
6802 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6804 "Originate default route to this neighbor\n"
6805 "Route-map to specify criteria to originate default\n"
6808 DEFUN (no_neighbor_default_originate
,
6809 no_neighbor_default_originate_cmd
,
6810 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6814 "Originate default route to this neighbor\n"
6815 "Route-map to specify criteria to originate default\n"
6819 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6821 bgp_node_safi(vty
), NULL
, 0);
6825 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6826 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6828 "Originate default route to this neighbor\n"
6829 "Route-map to specify criteria to originate default\n"
6833 /* Set neighbor's BGP port. */
6834 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6835 const char *port_str
)
6841 peer
= peer_lookup_vty(vty
, ip_str
);
6843 return CMD_WARNING_CONFIG_FAILED
;
6846 sp
= getservbyname("bgp", "tcp");
6847 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6849 port
= strtoul(port_str
, NULL
, 10);
6852 peer_port_set(peer
, port
);
6857 /* Set specified peer's BGP port. */
6858 DEFUN (neighbor_port
,
6860 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6863 "Neighbor's BGP port\n"
6864 "TCP port number\n")
6868 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6869 argv
[idx_number
]->arg
);
6872 DEFUN (no_neighbor_port
,
6873 no_neighbor_port_cmd
,
6874 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6878 "Neighbor's BGP port\n"
6879 "TCP port number\n")
6882 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6886 /* neighbor weight. */
6887 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6888 safi_t safi
, const char *weight_str
)
6892 unsigned long weight
;
6894 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6896 return CMD_WARNING_CONFIG_FAILED
;
6898 weight
= strtoul(weight_str
, NULL
, 10);
6900 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6901 return bgp_vty_return(vty
, ret
);
6904 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6910 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6912 return CMD_WARNING_CONFIG_FAILED
;
6914 ret
= peer_weight_unset(peer
, afi
, safi
);
6915 return bgp_vty_return(vty
, ret
);
6918 DEFUN (neighbor_weight
,
6919 neighbor_weight_cmd
,
6920 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6923 "Set default weight for routes from this neighbor\n"
6928 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6929 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6932 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6933 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6935 "Set default weight for routes from this neighbor\n"
6938 DEFUN (no_neighbor_weight
,
6939 no_neighbor_weight_cmd
,
6940 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6944 "Set default weight for routes from this neighbor\n"
6948 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6949 bgp_node_afi(vty
), bgp_node_safi(vty
));
6952 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6953 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6954 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6955 "Set default weight for routes from this neighbor\n"
6959 /* Override capability negotiation. */
6960 DEFUN (neighbor_override_capability
,
6961 neighbor_override_capability_cmd
,
6962 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6965 "Override capability negotiation result\n")
6968 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6969 PEER_FLAG_OVERRIDE_CAPABILITY
);
6972 DEFUN (no_neighbor_override_capability
,
6973 no_neighbor_override_capability_cmd
,
6974 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6978 "Override capability negotiation result\n")
6981 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6982 PEER_FLAG_OVERRIDE_CAPABILITY
);
6985 DEFUN (neighbor_strict_capability
,
6986 neighbor_strict_capability_cmd
,
6987 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6990 "Strict capability negotiation match\n")
6994 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6995 PEER_FLAG_STRICT_CAP_MATCH
);
6998 DEFUN (no_neighbor_strict_capability
,
6999 no_neighbor_strict_capability_cmd
,
7000 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7004 "Strict capability negotiation match\n")
7008 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7009 PEER_FLAG_STRICT_CAP_MATCH
);
7012 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7013 const char *keep_str
, const char *hold_str
)
7020 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7022 return CMD_WARNING_CONFIG_FAILED
;
7024 keepalive
= strtoul(keep_str
, NULL
, 10);
7025 holdtime
= strtoul(hold_str
, NULL
, 10);
7027 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7029 return bgp_vty_return(vty
, ret
);
7032 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7037 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7039 return CMD_WARNING_CONFIG_FAILED
;
7041 ret
= peer_timers_unset(peer
);
7043 return bgp_vty_return(vty
, ret
);
7046 DEFUN (neighbor_timers
,
7047 neighbor_timers_cmd
,
7048 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7051 "BGP per neighbor timers\n"
7052 "Keepalive interval\n"
7057 int idx_number_2
= 4;
7058 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7059 argv
[idx_number
]->arg
,
7060 argv
[idx_number_2
]->arg
);
7063 DEFUN (no_neighbor_timers
,
7064 no_neighbor_timers_cmd
,
7065 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7069 "BGP per neighbor timers\n"
7070 "Keepalive interval\n"
7074 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7078 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7079 const char *time_str
)
7085 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7087 return CMD_WARNING_CONFIG_FAILED
;
7089 connect
= strtoul(time_str
, NULL
, 10);
7091 ret
= peer_timers_connect_set(peer
, connect
);
7093 return bgp_vty_return(vty
, ret
);
7096 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7101 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7103 return CMD_WARNING_CONFIG_FAILED
;
7105 ret
= peer_timers_connect_unset(peer
);
7107 return bgp_vty_return(vty
, ret
);
7110 DEFUN (neighbor_timers_connect
,
7111 neighbor_timers_connect_cmd
,
7112 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7115 "BGP per neighbor timers\n"
7116 "BGP connect timer\n"
7121 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7122 argv
[idx_number
]->arg
);
7125 DEFUN (no_neighbor_timers_connect
,
7126 no_neighbor_timers_connect_cmd
,
7127 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7131 "BGP per neighbor timers\n"
7132 "BGP connect timer\n"
7136 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7139 DEFPY (neighbor_timers_delayopen
,
7140 neighbor_timers_delayopen_cmd
,
7141 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7144 "BGP per neighbor timers\n"
7145 "RFC 4271 DelayOpenTimer\n"
7146 "DelayOpenTime timer interval\n")
7150 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7152 return CMD_WARNING_CONFIG_FAILED
;
7155 if (peer_timers_delayopen_unset(peer
))
7156 return CMD_WARNING_CONFIG_FAILED
;
7158 if (peer_timers_delayopen_set(peer
, interval
))
7159 return CMD_WARNING_CONFIG_FAILED
;
7165 DEFPY (no_neighbor_timers_delayopen
,
7166 no_neighbor_timers_delayopen_cmd
,
7167 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7171 "BGP per neighbor timers\n"
7172 "RFC 4271 DelayOpenTimer\n"
7173 "DelayOpenTime timer interval\n")
7177 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7179 return CMD_WARNING_CONFIG_FAILED
;
7181 if (peer_timers_delayopen_unset(peer
))
7182 return CMD_WARNING_CONFIG_FAILED
;
7187 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7188 const char *time_str
, int set
)
7192 uint32_t routeadv
= 0;
7194 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7196 return CMD_WARNING_CONFIG_FAILED
;
7199 routeadv
= strtoul(time_str
, NULL
, 10);
7202 ret
= peer_advertise_interval_set(peer
, routeadv
);
7204 ret
= peer_advertise_interval_unset(peer
);
7206 return bgp_vty_return(vty
, ret
);
7209 DEFUN (neighbor_advertise_interval
,
7210 neighbor_advertise_interval_cmd
,
7211 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7214 "Minimum interval between sending BGP routing updates\n"
7215 "time in seconds\n")
7219 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7220 argv
[idx_number
]->arg
, 1);
7223 DEFUN (no_neighbor_advertise_interval
,
7224 no_neighbor_advertise_interval_cmd
,
7225 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7229 "Minimum interval between sending BGP routing updates\n"
7230 "time in seconds\n")
7233 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7237 /* Time to wait before processing route-map updates */
7238 DEFUN (bgp_set_route_map_delay_timer
,
7239 bgp_set_route_map_delay_timer_cmd
,
7240 "bgp route-map delay-timer (0-600)",
7242 "BGP route-map delay timer\n"
7243 "Time in secs to wait before processing route-map changes\n"
7244 "0 disables the timer, no route updates happen when route-maps change\n")
7247 uint32_t rmap_delay_timer
;
7249 if (argv
[idx_number
]->arg
) {
7250 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7251 bm
->rmap_update_timer
= rmap_delay_timer
;
7253 /* if the dynamic update handling is being disabled, and a timer
7255 * running, stop the timer and act as if the timer has already
7258 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7259 BGP_TIMER_OFF(bm
->t_rmap_update
);
7260 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7265 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7266 return CMD_WARNING_CONFIG_FAILED
;
7270 DEFUN (no_bgp_set_route_map_delay_timer
,
7271 no_bgp_set_route_map_delay_timer_cmd
,
7272 "no bgp route-map delay-timer [(0-600)]",
7275 "Default BGP route-map delay timer\n"
7276 "Reset to default time to wait for processing route-map changes\n"
7277 "0 disables the timer, no route updates happen when route-maps change\n")
7280 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7285 /* neighbor interface */
7286 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7291 peer
= peer_lookup_vty(vty
, ip_str
);
7292 if (!peer
|| peer
->conf_if
) {
7293 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7294 return CMD_WARNING_CONFIG_FAILED
;
7298 peer_interface_set(peer
, str
);
7300 peer_interface_unset(peer
);
7305 DEFUN (neighbor_interface
,
7306 neighbor_interface_cmd
,
7307 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7316 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7319 DEFUN (no_neighbor_interface
,
7320 no_neighbor_interface_cmd
,
7321 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7330 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7333 DEFUN (neighbor_distribute_list
,
7334 neighbor_distribute_list_cmd
,
7335 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7338 "Filter updates to/from this neighbor\n"
7339 "IP Access-list name\n"
7340 "Filter incoming updates\n"
7341 "Filter outgoing updates\n")
7348 const char *pstr
= argv
[idx_peer
]->arg
;
7349 const char *acl
= argv
[idx_acl
]->arg
;
7350 const char *inout
= argv
[argc
- 1]->text
;
7352 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7354 return CMD_WARNING_CONFIG_FAILED
;
7356 /* Check filter direction. */
7357 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7358 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7361 return bgp_vty_return(vty
, ret
);
7365 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7366 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7367 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7368 "Filter updates to/from this neighbor\n"
7369 "IP Access-list name\n"
7370 "Filter incoming updates\n"
7371 "Filter outgoing updates\n")
7373 DEFUN (no_neighbor_distribute_list
,
7374 no_neighbor_distribute_list_cmd
,
7375 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7379 "Filter updates to/from this neighbor\n"
7380 "IP Access-list name\n"
7381 "Filter incoming updates\n"
7382 "Filter outgoing updates\n")
7388 const char *pstr
= argv
[idx_peer
]->arg
;
7389 const char *inout
= argv
[argc
- 1]->text
;
7391 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7393 return CMD_WARNING_CONFIG_FAILED
;
7395 /* Check filter direction. */
7396 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7397 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7400 return bgp_vty_return(vty
, ret
);
7404 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7405 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7406 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7407 "Filter updates to/from this neighbor\n"
7408 "IP Access-list name\n"
7409 "Filter incoming updates\n"
7410 "Filter outgoing updates\n")
7412 /* Set prefix list to the peer. */
7413 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7414 afi_t afi
, safi_t safi
,
7415 const char *name_str
,
7416 const char *direct_str
)
7419 int direct
= FILTER_IN
;
7422 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7424 return CMD_WARNING_CONFIG_FAILED
;
7426 /* Check filter direction. */
7427 if (strncmp(direct_str
, "i", 1) == 0)
7429 else if (strncmp(direct_str
, "o", 1) == 0)
7430 direct
= FILTER_OUT
;
7432 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7434 return bgp_vty_return(vty
, ret
);
7437 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7438 afi_t afi
, safi_t safi
,
7439 const char *direct_str
)
7443 int direct
= FILTER_IN
;
7445 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7447 return CMD_WARNING_CONFIG_FAILED
;
7449 /* Check filter direction. */
7450 if (strncmp(direct_str
, "i", 1) == 0)
7452 else if (strncmp(direct_str
, "o", 1) == 0)
7453 direct
= FILTER_OUT
;
7455 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7457 return bgp_vty_return(vty
, ret
);
7460 DEFUN (neighbor_prefix_list
,
7461 neighbor_prefix_list_cmd
,
7462 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7465 "Filter updates to/from this neighbor\n"
7466 "Name of a prefix list\n"
7467 "Filter incoming updates\n"
7468 "Filter outgoing updates\n")
7473 return peer_prefix_list_set_vty(
7474 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7475 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7478 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7479 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7480 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7481 "Filter updates to/from this neighbor\n"
7482 "Name of a prefix list\n"
7483 "Filter incoming updates\n"
7484 "Filter outgoing updates\n")
7486 DEFUN (no_neighbor_prefix_list
,
7487 no_neighbor_prefix_list_cmd
,
7488 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7492 "Filter updates to/from this neighbor\n"
7493 "Name of a prefix list\n"
7494 "Filter incoming updates\n"
7495 "Filter outgoing updates\n")
7499 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7500 bgp_node_afi(vty
), bgp_node_safi(vty
),
7501 argv
[idx_in_out
]->arg
);
7504 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7505 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7506 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7507 "Filter updates to/from this neighbor\n"
7508 "Name of a prefix list\n"
7509 "Filter incoming updates\n"
7510 "Filter outgoing updates\n")
7512 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7513 safi_t safi
, const char *name_str
,
7514 const char *direct_str
)
7518 int direct
= FILTER_IN
;
7520 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7522 return CMD_WARNING_CONFIG_FAILED
;
7524 /* Check filter direction. */
7525 if (strncmp(direct_str
, "i", 1) == 0)
7527 else if (strncmp(direct_str
, "o", 1) == 0)
7528 direct
= FILTER_OUT
;
7530 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7532 return bgp_vty_return(vty
, ret
);
7535 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7536 safi_t safi
, const char *direct_str
)
7540 int direct
= FILTER_IN
;
7542 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7544 return CMD_WARNING_CONFIG_FAILED
;
7546 /* Check filter direction. */
7547 if (strncmp(direct_str
, "i", 1) == 0)
7549 else if (strncmp(direct_str
, "o", 1) == 0)
7550 direct
= FILTER_OUT
;
7552 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7554 return bgp_vty_return(vty
, ret
);
7557 DEFUN (neighbor_filter_list
,
7558 neighbor_filter_list_cmd
,
7559 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7562 "Establish BGP filters\n"
7563 "AS path access-list name\n"
7564 "Filter incoming routes\n"
7565 "Filter outgoing routes\n")
7570 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7571 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7572 argv
[idx_in_out
]->arg
);
7575 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7576 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7578 "Establish BGP filters\n"
7579 "AS path access-list name\n"
7580 "Filter incoming routes\n"
7581 "Filter outgoing routes\n")
7583 DEFUN (no_neighbor_filter_list
,
7584 no_neighbor_filter_list_cmd
,
7585 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7589 "Establish BGP filters\n"
7590 "AS path access-list name\n"
7591 "Filter incoming routes\n"
7592 "Filter outgoing routes\n")
7596 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7597 bgp_node_afi(vty
), bgp_node_safi(vty
),
7598 argv
[idx_in_out
]->arg
);
7601 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7602 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7603 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7604 "Establish BGP filters\n"
7605 "AS path access-list name\n"
7606 "Filter incoming routes\n"
7607 "Filter outgoing routes\n")
7609 /* Set advertise-map to the peer. */
7610 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7611 afi_t afi
, safi_t safi
,
7612 const char *advertise_str
,
7613 const char *condition_str
, bool condition
,
7616 int ret
= CMD_WARNING_CONFIG_FAILED
;
7618 struct route_map
*advertise_map
;
7619 struct route_map
*condition_map
;
7621 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7625 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7626 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7629 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7630 advertise_map
, condition_str
,
7631 condition_map
, condition
);
7633 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7634 advertise_map
, condition_str
,
7635 condition_map
, condition
);
7637 return bgp_vty_return(vty
, ret
);
7640 DEFPY (bgp_condadv_period
,
7641 bgp_condadv_period_cmd
,
7642 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7645 "Conditional advertisement settings\n"
7646 "Set period to rescan BGP table to check if condition is met\n"
7647 "Period between BGP table scans, in seconds; default 60\n")
7649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7651 bgp
->condition_check_period
=
7652 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7657 DEFPY (neighbor_advertise_map
,
7658 neighbor_advertise_map_cmd
,
7659 "[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",
7663 "Route-map to conditionally advertise routes\n"
7664 "Name of advertise map\n"
7665 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7666 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7667 "Name of the exist or non exist map\n")
7669 bool condition
= CONDITION_EXIST
;
7671 if (!strcmp(exist
, "non-exist-map"))
7672 condition
= CONDITION_NON_EXIST
;
7674 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7675 bgp_node_safi(vty
), advertise_str
,
7676 condition_str
, condition
, !no
);
7679 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7680 "[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",
7681 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7682 "Route-map to conditionally advertise routes\n"
7683 "Name of advertise map\n"
7684 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7685 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7686 "Name of the exist or non exist map\n")
7688 /* Set route-map to the peer. */
7689 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7690 afi_t afi
, safi_t safi
, const char *name_str
,
7691 const char *direct_str
)
7695 int direct
= RMAP_IN
;
7696 struct route_map
*route_map
;
7698 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7700 return CMD_WARNING_CONFIG_FAILED
;
7702 /* Check filter direction. */
7703 if (strncmp(direct_str
, "in", 2) == 0)
7705 else if (strncmp(direct_str
, "o", 1) == 0)
7708 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7709 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7711 return bgp_vty_return(vty
, ret
);
7714 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7715 afi_t afi
, safi_t safi
,
7716 const char *direct_str
)
7720 int direct
= RMAP_IN
;
7722 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7724 return CMD_WARNING_CONFIG_FAILED
;
7726 /* Check filter direction. */
7727 if (strncmp(direct_str
, "in", 2) == 0)
7729 else if (strncmp(direct_str
, "o", 1) == 0)
7732 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7734 return bgp_vty_return(vty
, ret
);
7737 DEFUN (neighbor_route_map
,
7738 neighbor_route_map_cmd
,
7739 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7742 "Apply route map to neighbor\n"
7743 "Name of route map\n"
7744 "Apply map to incoming routes\n"
7745 "Apply map to outbound routes\n")
7750 return peer_route_map_set_vty(
7751 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7752 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7755 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7756 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7757 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7758 "Apply route map to neighbor\n"
7759 "Name of route map\n"
7760 "Apply map to incoming routes\n"
7761 "Apply map to outbound routes\n")
7763 DEFUN (no_neighbor_route_map
,
7764 no_neighbor_route_map_cmd
,
7765 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7769 "Apply route map to neighbor\n"
7770 "Name of route map\n"
7771 "Apply map to incoming routes\n"
7772 "Apply map to outbound routes\n")
7776 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7777 bgp_node_afi(vty
), bgp_node_safi(vty
),
7778 argv
[idx_in_out
]->arg
);
7781 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7782 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7783 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7784 "Apply route map to neighbor\n"
7785 "Name of route map\n"
7786 "Apply map to incoming routes\n"
7787 "Apply map to outbound routes\n")
7789 /* Set unsuppress-map to the peer. */
7790 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7791 afi_t afi
, safi_t safi
,
7792 const char *name_str
)
7796 struct route_map
*route_map
;
7798 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7800 return CMD_WARNING_CONFIG_FAILED
;
7802 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7803 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7805 return bgp_vty_return(vty
, ret
);
7808 /* Unset route-map from the peer. */
7809 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7810 afi_t afi
, safi_t safi
)
7815 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7817 return CMD_WARNING_CONFIG_FAILED
;
7819 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7821 return bgp_vty_return(vty
, ret
);
7824 DEFUN (neighbor_unsuppress_map
,
7825 neighbor_unsuppress_map_cmd
,
7826 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7829 "Route-map to selectively unsuppress suppressed routes\n"
7830 "Name of route map\n")
7834 return peer_unsuppress_map_set_vty(
7835 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7836 argv
[idx_word
]->arg
);
7839 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7840 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7841 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7842 "Route-map to selectively unsuppress suppressed routes\n"
7843 "Name of route map\n")
7845 DEFUN (no_neighbor_unsuppress_map
,
7846 no_neighbor_unsuppress_map_cmd
,
7847 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7851 "Route-map to selectively unsuppress suppressed routes\n"
7852 "Name of route map\n")
7855 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7857 bgp_node_safi(vty
));
7860 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7861 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7862 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7863 "Route-map to selectively unsuppress suppressed routes\n"
7864 "Name of route map\n")
7866 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7867 afi_t afi
, safi_t safi
,
7868 const char *num_str
,
7869 const char *threshold_str
, int warning
,
7870 const char *restart_str
,
7871 const char *force_str
)
7879 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7881 return CMD_WARNING_CONFIG_FAILED
;
7883 max
= strtoul(num_str
, NULL
, 10);
7885 threshold
= atoi(threshold_str
);
7887 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7890 restart
= atoi(restart_str
);
7894 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7895 restart
, force_str
? true : false);
7897 return bgp_vty_return(vty
, ret
);
7900 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7901 afi_t afi
, safi_t safi
)
7906 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7908 return CMD_WARNING_CONFIG_FAILED
;
7910 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7912 return bgp_vty_return(vty
, ret
);
7915 /* Maximum number of prefix to be sent to the neighbor. */
7916 DEFUN(neighbor_maximum_prefix_out
,
7917 neighbor_maximum_prefix_out_cmd
,
7918 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7921 "Maximum number of prefixes to be sent to this peer\n"
7922 "Maximum no. of prefix limit\n")
7929 afi_t afi
= bgp_node_afi(vty
);
7930 safi_t safi
= bgp_node_safi(vty
);
7932 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7934 return CMD_WARNING_CONFIG_FAILED
;
7936 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7938 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7940 return bgp_vty_return(vty
, ret
);
7943 DEFUN(no_neighbor_maximum_prefix_out
,
7944 no_neighbor_maximum_prefix_out_cmd
,
7945 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7949 "Maximum number of prefixes to be sent to this peer\n"
7950 "Maximum no. of prefix limit\n")
7955 afi_t afi
= bgp_node_afi(vty
);
7956 safi_t safi
= bgp_node_safi(vty
);
7958 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7960 return CMD_WARNING_CONFIG_FAILED
;
7962 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
7964 return bgp_vty_return(vty
, ret
);
7967 /* Maximum number of prefix configuration. Prefix count is different
7968 for each peer configuration. So this configuration can be set for
7969 each peer configuration. */
7970 DEFUN (neighbor_maximum_prefix
,
7971 neighbor_maximum_prefix_cmd
,
7972 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7975 "Maximum number of prefix accept from this peer\n"
7976 "maximum no. of prefix limit\n"
7977 "Force checking all received routes not only accepted\n")
7984 if (argv_find(argv
, argc
, "force", &idx_force
))
7985 force
= argv
[idx_force
]->arg
;
7987 return peer_maximum_prefix_set_vty(
7988 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7989 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7992 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7993 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7994 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7995 "Maximum number of prefix accept from this peer\n"
7996 "maximum no. of prefix limit\n"
7997 "Force checking all received routes not only accepted\n")
7999 DEFUN (neighbor_maximum_prefix_threshold
,
8000 neighbor_maximum_prefix_threshold_cmd
,
8001 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8004 "Maximum number of prefix accept from this peer\n"
8005 "maximum no. of prefix limit\n"
8006 "Threshold value (%) at which to generate a warning msg\n"
8007 "Force checking all received routes not only accepted\n")
8011 int idx_number_2
= 4;
8015 if (argv_find(argv
, argc
, "force", &idx_force
))
8016 force
= argv
[idx_force
]->arg
;
8018 return peer_maximum_prefix_set_vty(
8019 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8020 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8024 neighbor_maximum_prefix_threshold
,
8025 neighbor_maximum_prefix_threshold_hidden_cmd
,
8026 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8027 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8028 "Maximum number of prefix accept from this peer\n"
8029 "maximum no. of prefix limit\n"
8030 "Threshold value (%) at which to generate a warning msg\n"
8031 "Force checking all received routes not only accepted\n")
8033 DEFUN (neighbor_maximum_prefix_warning
,
8034 neighbor_maximum_prefix_warning_cmd
,
8035 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8038 "Maximum number of prefix accept from this peer\n"
8039 "maximum no. of prefix limit\n"
8040 "Only give warning message when limit is exceeded\n"
8041 "Force checking all received routes not only accepted\n")
8048 if (argv_find(argv
, argc
, "force", &idx_force
))
8049 force
= argv
[idx_force
]->arg
;
8051 return peer_maximum_prefix_set_vty(
8052 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8053 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8057 neighbor_maximum_prefix_warning
,
8058 neighbor_maximum_prefix_warning_hidden_cmd
,
8059 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8060 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8061 "Maximum number of prefix accept from this peer\n"
8062 "maximum no. of prefix limit\n"
8063 "Only give warning message when limit is exceeded\n"
8064 "Force checking all received routes not only accepted\n")
8066 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8067 neighbor_maximum_prefix_threshold_warning_cmd
,
8068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8071 "Maximum number of prefix accept from this peer\n"
8072 "maximum no. of prefix limit\n"
8073 "Threshold value (%) at which to generate a warning msg\n"
8074 "Only give warning message when limit is exceeded\n"
8075 "Force checking all received routes not only accepted\n")
8079 int idx_number_2
= 4;
8083 if (argv_find(argv
, argc
, "force", &idx_force
))
8084 force
= argv
[idx_force
]->arg
;
8086 return peer_maximum_prefix_set_vty(
8087 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8088 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8092 neighbor_maximum_prefix_threshold_warning
,
8093 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8094 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8095 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8096 "Maximum number of prefix accept from this peer\n"
8097 "maximum no. of prefix limit\n"
8098 "Threshold value (%) at which to generate a warning msg\n"
8099 "Only give warning message when limit is exceeded\n"
8100 "Force checking all received routes not only accepted\n")
8102 DEFUN (neighbor_maximum_prefix_restart
,
8103 neighbor_maximum_prefix_restart_cmd
,
8104 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8107 "Maximum number of prefix accept from this peer\n"
8108 "maximum no. of prefix limit\n"
8109 "Restart bgp connection after limit is exceeded\n"
8110 "Restart interval in minutes\n"
8111 "Force checking all received routes not only accepted\n")
8115 int idx_number_2
= 5;
8119 if (argv_find(argv
, argc
, "force", &idx_force
))
8120 force
= argv
[idx_force
]->arg
;
8122 return peer_maximum_prefix_set_vty(
8123 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8124 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8128 neighbor_maximum_prefix_restart
,
8129 neighbor_maximum_prefix_restart_hidden_cmd
,
8130 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8131 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8132 "Maximum number of prefix accept from this peer\n"
8133 "maximum no. of prefix limit\n"
8134 "Restart bgp connection after limit is exceeded\n"
8135 "Restart interval in minutes\n"
8136 "Force checking all received routes not only accepted\n")
8138 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8139 neighbor_maximum_prefix_threshold_restart_cmd
,
8140 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8143 "Maximum number of prefixes to accept from this peer\n"
8144 "maximum no. of prefix limit\n"
8145 "Threshold value (%) at which to generate a warning msg\n"
8146 "Restart bgp connection after limit is exceeded\n"
8147 "Restart interval in minutes\n"
8148 "Force checking all received routes not only accepted\n")
8152 int idx_number_2
= 4;
8153 int idx_number_3
= 6;
8157 if (argv_find(argv
, argc
, "force", &idx_force
))
8158 force
= argv
[idx_force
]->arg
;
8160 return peer_maximum_prefix_set_vty(
8161 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8162 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8163 argv
[idx_number_3
]->arg
, force
);
8167 neighbor_maximum_prefix_threshold_restart
,
8168 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8169 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8170 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8171 "Maximum number of prefixes to accept from this peer\n"
8172 "maximum no. of prefix limit\n"
8173 "Threshold value (%) at which to generate a warning msg\n"
8174 "Restart bgp connection after limit is exceeded\n"
8175 "Restart interval in minutes\n"
8176 "Force checking all received routes not only accepted\n")
8178 DEFUN (no_neighbor_maximum_prefix
,
8179 no_neighbor_maximum_prefix_cmd
,
8180 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8184 "Maximum number of prefixes to accept from this peer\n"
8185 "maximum no. of prefix limit\n"
8186 "Threshold value (%) at which to generate a warning msg\n"
8187 "Restart bgp connection after limit is exceeded\n"
8188 "Restart interval in minutes\n"
8189 "Only give warning message when limit is exceeded\n"
8190 "Force checking all received routes not only accepted\n")
8193 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8195 bgp_node_safi(vty
));
8199 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8200 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8201 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8202 "Maximum number of prefixes to accept from this peer\n"
8203 "maximum no. of prefix limit\n"
8204 "Threshold value (%) at which to generate a warning msg\n"
8205 "Restart bgp connection after limit is exceeded\n"
8206 "Restart interval in minutes\n"
8207 "Only give warning message when limit is exceeded\n"
8208 "Force checking all received routes not only accepted\n")
8211 /* "neighbor allowas-in" */
8212 DEFUN (neighbor_allowas_in
,
8213 neighbor_allowas_in_cmd
,
8214 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8217 "Accept as-path with my AS present in it\n"
8218 "Number of occurrences of AS number\n"
8219 "Only accept my AS in the as-path if the route was originated in my AS\n")
8222 int idx_number_origin
= 3;
8228 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8230 return CMD_WARNING_CONFIG_FAILED
;
8232 if (argc
<= idx_number_origin
)
8235 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8238 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8241 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8244 return bgp_vty_return(vty
, ret
);
8248 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8249 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8250 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8251 "Accept as-path with my AS present in it\n"
8252 "Number of occurrences of AS number\n"
8253 "Only accept my AS in the as-path if the route was originated in my AS\n")
8255 DEFUN (no_neighbor_allowas_in
,
8256 no_neighbor_allowas_in_cmd
,
8257 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8261 "allow local ASN appears in aspath attribute\n"
8262 "Number of occurrences of AS number\n"
8263 "Only accept my AS in the as-path if the route was originated in my AS\n")
8269 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8271 return CMD_WARNING_CONFIG_FAILED
;
8273 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8274 bgp_node_safi(vty
));
8276 return bgp_vty_return(vty
, ret
);
8280 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8281 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8282 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8283 "allow local ASN appears in aspath attribute\n"
8284 "Number of occurrences of AS number\n"
8285 "Only accept my AS in the as-path if the route was originated in my AS\n")
8287 DEFUN (neighbor_ttl_security
,
8288 neighbor_ttl_security_cmd
,
8289 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8292 "BGP ttl-security parameters\n"
8293 "Specify the maximum number of hops to the BGP peer\n"
8294 "Number of hops to BGP peer\n")
8301 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8303 return CMD_WARNING_CONFIG_FAILED
;
8305 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8308 * If 'neighbor swpX', then this is for directly connected peers,
8309 * we should not accept a ttl-security hops value greater than 1.
8311 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8313 "%s is directly connected peer, hops cannot exceed 1\n",
8314 argv
[idx_peer
]->arg
);
8315 return CMD_WARNING_CONFIG_FAILED
;
8318 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8321 DEFUN (no_neighbor_ttl_security
,
8322 no_neighbor_ttl_security_cmd
,
8323 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8327 "BGP ttl-security parameters\n"
8328 "Specify the maximum number of hops to the BGP peer\n"
8329 "Number of hops to BGP peer\n")
8334 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8336 return CMD_WARNING_CONFIG_FAILED
;
8338 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8341 /* disable-addpath-rx */
8342 DEFUN(neighbor_disable_addpath_rx
,
8343 neighbor_disable_addpath_rx_cmd
,
8344 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8347 "Do not accept additional paths\n")
8349 char *peer_str
= argv
[1]->arg
;
8351 afi_t afi
= bgp_node_afi(vty
);
8352 safi_t safi
= bgp_node_safi(vty
);
8354 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8356 return CMD_WARNING_CONFIG_FAILED
;
8358 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8359 PEER_FLAG_DISABLE_ADDPATH_RX
);
8362 DEFUN(no_neighbor_disable_addpath_rx
,
8363 no_neighbor_disable_addpath_rx_cmd
,
8364 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8368 "Do not accept additional paths\n")
8370 char *peer_str
= argv
[2]->arg
;
8372 afi_t afi
= bgp_node_afi(vty
);
8373 safi_t safi
= bgp_node_safi(vty
);
8375 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8377 return CMD_WARNING_CONFIG_FAILED
;
8379 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8380 PEER_FLAG_DISABLE_ADDPATH_RX
);
8383 DEFUN (neighbor_addpath_tx_all_paths
,
8384 neighbor_addpath_tx_all_paths_cmd
,
8385 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8388 "Use addpath to advertise all paths to a neighbor\n")
8393 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8395 return CMD_WARNING_CONFIG_FAILED
;
8397 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8402 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8403 neighbor_addpath_tx_all_paths_hidden_cmd
,
8404 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8405 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8406 "Use addpath to advertise all paths to a neighbor\n")
8408 DEFUN (no_neighbor_addpath_tx_all_paths
,
8409 no_neighbor_addpath_tx_all_paths_cmd
,
8410 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8414 "Use addpath to advertise all paths to a neighbor\n")
8419 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8421 return CMD_WARNING_CONFIG_FAILED
;
8423 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8424 != BGP_ADDPATH_ALL
) {
8426 "%% Peer not currently configured to transmit all paths.");
8427 return CMD_WARNING_CONFIG_FAILED
;
8430 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8436 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8437 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8438 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8439 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8440 "Use addpath to advertise all paths to a neighbor\n")
8442 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8443 neighbor_addpath_tx_bestpath_per_as_cmd
,
8444 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8447 "Use addpath to advertise the bestpath per each neighboring AS\n")
8452 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8454 return CMD_WARNING_CONFIG_FAILED
;
8456 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8457 BGP_ADDPATH_BEST_PER_AS
);
8462 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8463 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8464 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8465 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8466 "Use addpath to advertise the bestpath per each neighboring AS\n")
8468 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8469 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8470 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8474 "Use addpath to advertise the bestpath per each neighboring AS\n")
8479 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8481 return CMD_WARNING_CONFIG_FAILED
;
8483 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8484 != BGP_ADDPATH_BEST_PER_AS
) {
8486 "%% Peer not currently configured to transmit all best path per as.");
8487 return CMD_WARNING_CONFIG_FAILED
;
8490 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8496 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8497 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8498 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8499 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8500 "Use addpath to advertise the bestpath per each neighboring AS\n")
8503 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8504 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8507 "Detect AS loops before sending to neighbor\n")
8511 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8513 return CMD_WARNING_CONFIG_FAILED
;
8515 peer
->as_path_loop_detection
= true;
8521 no_neighbor_aspath_loop_detection
,
8522 no_neighbor_aspath_loop_detection_cmd
,
8523 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8527 "Detect AS loops before sending to neighbor\n")
8531 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8533 return CMD_WARNING_CONFIG_FAILED
;
8535 peer
->as_path_loop_detection
= false;
8540 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8541 struct ecommunity
**list
, bool is_rt6
)
8543 struct ecommunity
*ecom
= NULL
;
8544 struct ecommunity
*ecomadd
;
8546 for (; argc
; --argc
, ++argv
) {
8548 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8549 ECOMMUNITY_ROUTE_TARGET
,
8552 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8553 ECOMMUNITY_ROUTE_TARGET
,
8556 vty_out(vty
, "Malformed community-list value\n");
8558 ecommunity_free(&ecom
);
8559 return CMD_WARNING_CONFIG_FAILED
;
8563 ecommunity_merge(ecom
, ecomadd
);
8564 ecommunity_free(&ecomadd
);
8571 ecommunity_free(&*list
);
8579 * v2vimport is true if we are handling a `import vrf ...` command
8581 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8585 switch (vty
->node
) {
8594 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8599 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8600 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8601 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8602 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8604 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8608 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8609 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8610 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8611 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8613 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8620 DEFPY (af_rd_vpn_export
,
8621 af_rd_vpn_export_cmd
,
8622 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8624 "Specify route distinguisher\n"
8625 "Between current address-family and vpn\n"
8626 "For routes leaked from current address-family to vpn\n"
8627 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8630 struct prefix_rd prd
;
8636 if (argv_find(argv
, argc
, "no", &idx
))
8640 ret
= str2prefix_rd(rd_str
, &prd
);
8642 vty_out(vty
, "%% Malformed rd\n");
8643 return CMD_WARNING_CONFIG_FAILED
;
8647 afi
= vpn_policy_getafi(vty
, bgp
, false);
8649 return CMD_WARNING_CONFIG_FAILED
;
8652 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8654 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8655 bgp_get_default(), bgp
);
8658 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8659 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8660 BGP_VPN_POLICY_TOVPN_RD_SET
);
8662 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8663 BGP_VPN_POLICY_TOVPN_RD_SET
);
8666 /* post-change: re-export vpn routes */
8667 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8668 bgp_get_default(), bgp
);
8673 ALIAS (af_rd_vpn_export
,
8674 af_no_rd_vpn_export_cmd
,
8677 "Specify route distinguisher\n"
8678 "Between current address-family and vpn\n"
8679 "For routes leaked from current address-family to vpn\n")
8681 DEFPY (af_label_vpn_export
,
8682 af_label_vpn_export_cmd
,
8683 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8685 "label value for VRF\n"
8686 "Between current address-family and vpn\n"
8687 "For routes leaked from current address-family to vpn\n"
8688 "Label Value <0-1048575>\n"
8689 "Automatically assign a label\n")
8691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8692 mpls_label_t label
= MPLS_LABEL_NONE
;
8697 if (argv_find(argv
, argc
, "no", &idx
))
8700 /* If "no ...", squash trailing parameter */
8706 label
= label_val
; /* parser should force unsigned */
8709 afi
= vpn_policy_getafi(vty
, bgp
, false);
8711 return CMD_WARNING_CONFIG_FAILED
;
8714 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8715 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8720 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8722 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8723 bgp_get_default(), bgp
);
8725 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8726 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8728 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8731 * label has previously been automatically
8732 * assigned by labelpool: release it
8734 * NB if tovpn_label == MPLS_LABEL_NONE it
8735 * means the automatic assignment is in flight
8736 * and therefore the labelpool callback must
8737 * detect that the auto label is not needed.
8740 bgp_lp_release(LP_TYPE_VRF
,
8741 &bgp
->vpn_policy
[afi
],
8742 bgp
->vpn_policy
[afi
].tovpn_label
);
8744 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8745 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8748 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8750 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8751 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8752 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8753 vpn_leak_label_callback
);
8756 /* post-change: re-export vpn routes */
8757 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8758 bgp_get_default(), bgp
);
8760 hook_call(bgp_snmp_update_last_changed
, bgp
);
8764 DEFPY (af_sid_vpn_export
,
8765 af_sid_vpn_export_cmd
,
8766 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8768 "sid value for VRF\n"
8769 "Between current address-family and vpn\n"
8770 "For routes leaked from current address-family to vpn\n"
8771 "Sid allocation index\n"
8772 "Automatically assign a label\n")
8774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8780 if (argv_find(argv
, argc
, "no", &idx
))
8782 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8783 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8785 afi
= vpn_policy_getafi(vty
, bgp
, false);
8787 return CMD_WARNING_CONFIG_FAILED
;
8791 vty_out(vty
, "It's not implemented\n");
8792 return CMD_WARNING_CONFIG_FAILED
;
8795 /* skip when it's already configured */
8796 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8797 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8798 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8802 * mode change between sid_idx and sid_auto isn't supported.
8803 * user must negate sid vpn export when they want to change the mode
8805 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8806 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8807 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8808 vty_out(vty
, "it's already configured as %s.\n",
8809 sid_auto
? "auto-mode" : "idx-mode");
8810 return CMD_WARNING_CONFIG_FAILED
;
8814 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8815 bgp_get_default(), bgp
);
8818 /* SID allocation auto-mode */
8820 zlog_debug("%s: auto sid alloc.", __func__
);
8821 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8822 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8824 /* SID allocation index-mode */
8826 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8827 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8831 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8832 bgp_get_default(), bgp
);
8836 ALIAS (af_label_vpn_export
,
8837 af_no_label_vpn_export_cmd
,
8838 "no label vpn export",
8840 "label value for VRF\n"
8841 "Between current address-family and vpn\n"
8842 "For routes leaked from current address-family to vpn\n")
8844 DEFPY (af_nexthop_vpn_export
,
8845 af_nexthop_vpn_export_cmd
,
8846 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8848 "Specify next hop to use for VRF advertised prefixes\n"
8849 "Between current address-family and vpn\n"
8850 "For routes leaked from current address-family to vpn\n"
8854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8860 vty_out(vty
, "%% Nexthop required\n");
8861 return CMD_WARNING_CONFIG_FAILED
;
8863 if (!sockunion2hostprefix(nexthop_su
, &p
))
8864 return CMD_WARNING_CONFIG_FAILED
;
8867 afi
= vpn_policy_getafi(vty
, bgp
, false);
8869 return CMD_WARNING_CONFIG_FAILED
;
8872 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8874 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8875 bgp_get_default(), bgp
);
8878 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8879 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8880 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8882 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8883 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8886 /* post-change: re-export vpn routes */
8887 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8888 bgp_get_default(), bgp
);
8893 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8895 if (!strcmp(dstr
, "import")) {
8896 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8897 } else if (!strcmp(dstr
, "export")) {
8898 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8899 } else if (!strcmp(dstr
, "both")) {
8900 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8901 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8903 vty_out(vty
, "%% direction parse error\n");
8904 return CMD_WARNING_CONFIG_FAILED
;
8909 DEFPY (af_rt_vpn_imexport
,
8910 af_rt_vpn_imexport_cmd
,
8911 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8913 "Specify route target list\n"
8914 "Specify route target list\n"
8915 "Between current address-family and vpn\n"
8916 "For routes leaked from vpn to current address-family: match any\n"
8917 "For routes leaked from current address-family to vpn: set\n"
8918 "both import: match any and export: set\n"
8919 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8923 struct ecommunity
*ecom
= NULL
;
8924 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8925 enum vpn_policy_direction dir
;
8930 if (argv_find(argv
, argc
, "no", &idx
))
8933 afi
= vpn_policy_getafi(vty
, bgp
, false);
8935 return CMD_WARNING_CONFIG_FAILED
;
8937 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8938 if (ret
!= CMD_SUCCESS
)
8942 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8943 vty_out(vty
, "%% Missing RTLIST\n");
8944 return CMD_WARNING_CONFIG_FAILED
;
8946 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8947 if (ret
!= CMD_SUCCESS
) {
8952 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8956 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8959 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8961 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8962 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8963 ecommunity_dup(ecom
);
8965 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8967 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8968 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8971 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8975 ecommunity_free(&ecom
);
8980 ALIAS (af_rt_vpn_imexport
,
8981 af_no_rt_vpn_imexport_cmd
,
8982 "no <rt|route-target> vpn <import|export|both>$direction_str",
8984 "Specify route target list\n"
8985 "Specify route target list\n"
8986 "Between current address-family and vpn\n"
8987 "For routes leaked from vpn to current address-family\n"
8988 "For routes leaked from current address-family to vpn\n"
8989 "both import and export\n")
8991 DEFPY (af_route_map_vpn_imexport
,
8992 af_route_map_vpn_imexport_cmd
,
8993 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8994 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8996 "Specify route map\n"
8997 "Between current address-family and vpn\n"
8998 "For routes leaked from vpn to current address-family\n"
8999 "For routes leaked from current address-family to vpn\n"
9000 "name of route-map\n")
9002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9004 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9005 enum vpn_policy_direction dir
;
9010 if (argv_find(argv
, argc
, "no", &idx
))
9013 afi
= vpn_policy_getafi(vty
, bgp
, false);
9015 return CMD_WARNING_CONFIG_FAILED
;
9017 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9018 if (ret
!= CMD_SUCCESS
)
9021 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9025 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9028 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9029 XFREE(MTYPE_ROUTE_MAP_NAME
,
9030 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9031 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9032 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9033 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9034 route_map_lookup_warn_noexist(vty
, rmap_str
);
9035 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9038 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9039 XFREE(MTYPE_ROUTE_MAP_NAME
,
9040 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9041 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9042 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9045 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9051 ALIAS (af_route_map_vpn_imexport
,
9052 af_no_route_map_vpn_imexport_cmd
,
9053 "no route-map vpn <import|export>$direction_str",
9055 "Specify route map\n"
9056 "Between current address-family and vpn\n"
9057 "For routes leaked from vpn to current address-family\n"
9058 "For routes leaked from current address-family to vpn\n")
9060 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9061 "import vrf route-map RMAP$rmap_str",
9062 "Import routes from another VRF\n"
9063 "Vrf routes being filtered\n"
9064 "Specify route map\n"
9065 "name of route-map\n")
9067 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9068 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9070 struct bgp
*bgp_default
;
9072 afi
= vpn_policy_getafi(vty
, bgp
, true);
9074 return CMD_WARNING_CONFIG_FAILED
;
9076 bgp_default
= bgp_get_default();
9081 /* Auto-create assuming the same AS */
9082 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9083 BGP_INSTANCE_TYPE_DEFAULT
);
9087 "VRF default is not configured as a bgp instance\n");
9092 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9094 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9095 XFREE(MTYPE_ROUTE_MAP_NAME
,
9096 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9097 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9098 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9099 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9100 route_map_lookup_warn_noexist(vty
, rmap_str
);
9101 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9104 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9105 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9107 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9112 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9113 "no import vrf route-map [RMAP$rmap_str]",
9115 "Import routes from another VRF\n"
9116 "Vrf routes being filtered\n"
9117 "Specify route map\n"
9118 "name of route-map\n")
9120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9121 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9124 afi
= vpn_policy_getafi(vty
, bgp
, true);
9126 return CMD_WARNING_CONFIG_FAILED
;
9128 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9130 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9131 XFREE(MTYPE_ROUTE_MAP_NAME
,
9132 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9133 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9134 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9136 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9137 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9138 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9140 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9145 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9146 "[no] import vrf VIEWVRFNAME$import_name",
9148 "Import routes from another VRF\n"
9149 "VRF to import from\n"
9150 "The name of the VRF\n")
9152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9153 struct listnode
*node
;
9154 struct bgp
*vrf_bgp
, *bgp_default
;
9157 bool remove
= false;
9160 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9164 if (import_name
== NULL
) {
9165 vty_out(vty
, "%% Missing import name\n");
9169 if (strcmp(import_name
, "route-map") == 0) {
9170 vty_out(vty
, "%% Must include route-map name\n");
9174 if (argv_find(argv
, argc
, "no", &idx
))
9177 afi
= vpn_policy_getafi(vty
, bgp
, true);
9179 return CMD_WARNING_CONFIG_FAILED
;
9181 safi
= bgp_node_safi(vty
);
9183 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9184 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9185 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9186 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9187 remove
? "unimport" : "import", import_name
);
9191 bgp_default
= bgp_get_default();
9193 /* Auto-create assuming the same AS */
9194 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9195 BGP_INSTANCE_TYPE_DEFAULT
);
9199 "VRF default is not configured as a bgp instance\n");
9204 vrf_bgp
= bgp_lookup_by_name(import_name
);
9206 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9207 vrf_bgp
= bgp_default
;
9209 /* Auto-create assuming the same AS */
9210 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9214 "VRF %s is not configured as a bgp instance\n",
9221 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9223 /* Already importing from "import_vrf"? */
9224 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9226 if (strcmp(vname
, import_name
) == 0)
9230 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9236 /* This command is valid only in a bgp vrf instance or the default instance */
9237 DEFPY (bgp_imexport_vpn
,
9238 bgp_imexport_vpn_cmd
,
9239 "[no] <import|export>$direction_str vpn",
9241 "Import routes to this address-family\n"
9242 "Export routes from this address-family\n"
9243 "to/from default instance VPN RIB\n")
9245 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9252 enum vpn_policy_direction dir
;
9254 if (argv_find(argv
, argc
, "no", &idx
))
9257 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9258 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9260 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9261 return CMD_WARNING_CONFIG_FAILED
;
9264 afi
= bgp_node_afi(vty
);
9265 safi
= bgp_node_safi(vty
);
9266 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9267 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9268 return CMD_WARNING_CONFIG_FAILED
;
9271 if (!strcmp(direction_str
, "import")) {
9272 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9273 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9274 } else if (!strcmp(direction_str
, "export")) {
9275 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9276 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9278 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9279 return CMD_WARNING_CONFIG_FAILED
;
9282 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9285 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9286 if (!previous_state
) {
9287 /* trigger export current vrf */
9288 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9291 if (previous_state
) {
9292 /* trigger un-export current vrf */
9293 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9295 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9298 hook_call(bgp_snmp_init_stats
, bgp
);
9303 DEFPY (af_routetarget_import
,
9304 af_routetarget_import_cmd
,
9305 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9307 "Specify route target list\n"
9308 "Specify route target list\n"
9309 "Specify route target list\n"
9310 "Specify route target list\n"
9311 "Flow-spec redirect type route target\n"
9312 "Import routes to this address-family\n"
9313 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9317 struct ecommunity
*ecom
= NULL
;
9319 int idx
= 0, idx_unused
= 0;
9323 if (argv_find(argv
, argc
, "no", &idx
))
9326 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9327 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9330 afi
= vpn_policy_getafi(vty
, bgp
, false);
9332 return CMD_WARNING_CONFIG_FAILED
;
9334 if (rt6
&& afi
!= AFI_IP6
)
9335 return CMD_WARNING_CONFIG_FAILED
;
9338 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9339 vty_out(vty
, "%% Missing RTLIST\n");
9340 return CMD_WARNING_CONFIG_FAILED
;
9342 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9343 if (ret
!= CMD_SUCCESS
)
9348 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9349 ecommunity_free(&bgp
->vpn_policy
[afi
]
9350 .import_redirect_rtlist
);
9351 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9352 ecommunity_dup(ecom
);
9354 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9355 ecommunity_free(&bgp
->vpn_policy
[afi
]
9356 .import_redirect_rtlist
);
9357 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9361 ecommunity_free(&ecom
);
9366 DEFUN_NOSH (address_family_ipv4_safi
,
9367 address_family_ipv4_safi_cmd
,
9368 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9369 "Enter Address Family command mode\n"
9371 BGP_SAFI_WITH_LABEL_HELP_STR
)
9375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9376 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9377 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9378 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9379 && safi
!= SAFI_EVPN
) {
9381 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9382 return CMD_WARNING_CONFIG_FAILED
;
9384 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9386 vty
->node
= BGP_IPV4_NODE
;
9391 DEFUN_NOSH (address_family_ipv6_safi
,
9392 address_family_ipv6_safi_cmd
,
9393 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9394 "Enter Address Family command mode\n"
9396 BGP_SAFI_WITH_LABEL_HELP_STR
)
9399 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9400 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9401 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9402 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9403 && safi
!= SAFI_EVPN
) {
9405 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9406 return CMD_WARNING_CONFIG_FAILED
;
9408 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9410 vty
->node
= BGP_IPV6_NODE
;
9415 #ifdef KEEP_OLD_VPN_COMMANDS
9416 DEFUN_NOSH (address_family_vpnv4
,
9417 address_family_vpnv4_cmd
,
9418 "address-family vpnv4 [unicast]",
9419 "Enter Address Family command mode\n"
9421 "Address Family modifier\n")
9423 vty
->node
= BGP_VPNV4_NODE
;
9427 DEFUN_NOSH (address_family_vpnv6
,
9428 address_family_vpnv6_cmd
,
9429 "address-family vpnv6 [unicast]",
9430 "Enter Address Family command mode\n"
9432 "Address Family modifier\n")
9434 vty
->node
= BGP_VPNV6_NODE
;
9437 #endif /* KEEP_OLD_VPN_COMMANDS */
9439 DEFUN_NOSH (address_family_evpn
,
9440 address_family_evpn_cmd
,
9441 "address-family l2vpn evpn",
9442 "Enter Address Family command mode\n"
9444 "Address Family modifier\n")
9446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9447 vty
->node
= BGP_EVPN_NODE
;
9451 DEFUN_NOSH (bgp_segment_routing_srv6
,
9452 bgp_segment_routing_srv6_cmd
,
9453 "segment-routing srv6",
9454 "Segment-Routing configuration\n"
9455 "Segment-Routing SRv6 configuration\n")
9457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9458 bgp
->srv6_enabled
= true;
9459 vty
->node
= BGP_SRV6_NODE
;
9463 DEFUN (no_bgp_segment_routing_srv6
,
9464 no_bgp_segment_routing_srv6_cmd
,
9465 "no segment-routing srv6",
9467 "Segment-Routing configuration\n"
9468 "Segment-Routing SRv6 configuration\n")
9470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9472 if (strlen(bgp
->srv6_locator_name
) > 0)
9473 if (bgp_srv6_locator_unset(bgp
) < 0)
9474 return CMD_WARNING_CONFIG_FAILED
;
9476 bgp
->srv6_enabled
= false;
9480 DEFPY (bgp_srv6_locator
,
9481 bgp_srv6_locator_cmd
,
9482 "locator NAME$name",
9483 "Specify SRv6 locator\n"
9484 "Specify SRv6 locator\n")
9486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9489 if (strlen(bgp
->srv6_locator_name
) > 0
9490 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9491 vty_out(vty
, "srv6 locator is already configured\n");
9492 return CMD_WARNING_CONFIG_FAILED
;
9495 snprintf(bgp
->srv6_locator_name
,
9496 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9498 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9500 return CMD_WARNING_CONFIG_FAILED
;
9505 DEFPY (no_bgp_srv6_locator
,
9506 no_bgp_srv6_locator_cmd
,
9507 "no locator NAME$name",
9509 "Specify SRv6 locator\n"
9510 "Specify SRv6 locator\n")
9512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9514 /* when locator isn't configured, do nothing */
9515 if (strlen(bgp
->srv6_locator_name
) < 1)
9518 /* name validation */
9519 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9520 vty_out(vty
, "%% No srv6 locator is configured\n");
9521 return CMD_WARNING_CONFIG_FAILED
;
9525 if (bgp_srv6_locator_unset(bgp
) < 0)
9526 return CMD_WARNING_CONFIG_FAILED
;
9531 DEFPY (show_bgp_srv6
,
9533 "show bgp segment-routing srv6",
9536 "BGP Segment Routing\n"
9537 "BGP Segment Routing SRv6\n")
9540 struct listnode
*node
;
9541 struct srv6_locator_chunk
*chunk
;
9542 struct bgp_srv6_function
*func
;
9543 struct in6_addr
*tovpn4_sid
;
9544 struct in6_addr
*tovpn6_sid
;
9546 char buf_tovpn4_sid
[256];
9547 char buf_tovpn6_sid
[256];
9549 bgp
= bgp_get_default();
9553 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9554 vty_out(vty
, "locator_chunks:\n");
9555 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9556 prefix2str(&chunk
->prefix
, buf
, sizeof(buf
));
9557 vty_out(vty
, "- %s\n", buf
);
9560 vty_out(vty
, "functions:\n");
9561 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9562 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9563 vty_out(vty
, "- sid: %s\n", buf
);
9564 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9567 vty_out(vty
, "bgps:\n");
9568 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9569 vty_out(vty
, "- name: %s\n",
9570 bgp
->name
? bgp
->name
: "default");
9572 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9573 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9575 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9576 sizeof(buf_tovpn4_sid
));
9578 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9579 sizeof(buf_tovpn6_sid
));
9581 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9582 tovpn4_sid
? buf_tovpn4_sid
: "none");
9583 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9584 tovpn6_sid
? buf_tovpn6_sid
: "none");
9590 DEFUN_NOSH (exit_address_family
,
9591 exit_address_family_cmd
,
9592 "exit-address-family",
9593 "Exit from Address Family configuration mode\n")
9595 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9596 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9597 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9598 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9599 || vty
->node
== BGP_EVPN_NODE
9600 || vty
->node
== BGP_FLOWSPECV4_NODE
9601 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9602 vty
->node
= BGP_NODE
;
9606 /* Recalculate bestpath and re-advertise a prefix */
9607 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9608 const char *ip_str
, afi_t afi
, safi_t safi
,
9609 struct prefix_rd
*prd
)
9612 struct prefix match
;
9613 struct bgp_dest
*dest
;
9614 struct bgp_dest
*rm
;
9616 struct bgp_table
*table
;
9617 struct bgp_table
*rib
;
9619 /* BGP structure lookup. */
9621 bgp
= bgp_lookup_by_name(view_name
);
9623 vty_out(vty
, "%% Can't find BGP instance %s\n",
9628 bgp
= bgp_get_default();
9630 vty_out(vty
, "%% No BGP process is configured\n");
9635 /* Check IP address argument. */
9636 ret
= str2prefix(ip_str
, &match
);
9638 vty_out(vty
, "%% address is malformed\n");
9642 match
.family
= afi2family(afi
);
9643 rib
= bgp
->rib
[afi
][safi
];
9645 if (safi
== SAFI_MPLS_VPN
) {
9646 for (dest
= bgp_table_top(rib
); dest
;
9647 dest
= bgp_route_next(dest
)) {
9648 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9650 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9653 table
= bgp_dest_get_bgp_table_info(dest
);
9657 rm
= bgp_node_match(table
, &match
);
9659 const struct prefix
*rm_p
=
9660 bgp_dest_get_prefix(rm
);
9662 if (rm_p
->prefixlen
== match
.prefixlen
) {
9664 BGP_NODE_USER_CLEAR
);
9665 bgp_process(bgp
, rm
, afi
, safi
);
9667 bgp_dest_unlock_node(rm
);
9671 dest
= bgp_node_match(rib
, &match
);
9673 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9675 if (dest_p
->prefixlen
== match
.prefixlen
) {
9676 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9677 bgp_process(bgp
, dest
, afi
, safi
);
9679 bgp_dest_unlock_node(dest
);
9686 /* one clear bgp command to rule them all */
9687 DEFUN (clear_ip_bgp_all
,
9688 clear_ip_bgp_all_cmd
,
9689 "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>]",
9693 BGP_INSTANCE_HELP_STR
9696 BGP_SAFI_WITH_LABEL_HELP_STR
9697 "Address Family modifier\n"
9699 "BGP IPv4 neighbor to clear\n"
9700 "BGP IPv6 neighbor to clear\n"
9701 "BGP neighbor on interface to clear\n"
9702 "Clear peers with the AS number\n"
9703 "Clear all external peers\n"
9704 "Clear all members of peer-group\n"
9705 "BGP peer-group name\n"
9710 "Push out prefix-list ORF and do inbound soft reconfig\n"
9712 "Reset message statistics\n")
9716 afi_t afi
= AFI_UNSPEC
;
9717 safi_t safi
= SAFI_UNSPEC
;
9718 enum clear_sort clr_sort
= clear_peer
;
9719 enum bgp_clear_type clr_type
;
9720 char *clr_arg
= NULL
;
9724 /* clear [ip] bgp */
9725 if (argv_find(argv
, argc
, "ip", &idx
))
9728 /* [<vrf> VIEWVRFNAME] */
9729 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9730 vrf
= argv
[idx
+ 1]->arg
;
9732 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9734 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9735 /* [<view> VIEWVRFNAME] */
9736 vrf
= argv
[idx
+ 1]->arg
;
9739 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9740 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9741 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9743 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9744 if (argv_find(argv
, argc
, "*", &idx
)) {
9745 clr_sort
= clear_all
;
9746 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9747 clr_sort
= clear_peer
;
9748 clr_arg
= argv
[idx
]->arg
;
9749 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9750 clr_sort
= clear_peer
;
9751 clr_arg
= argv
[idx
]->arg
;
9752 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9753 clr_sort
= clear_group
;
9755 clr_arg
= argv
[idx
]->arg
;
9756 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9757 clr_sort
= clear_peer
;
9758 clr_arg
= argv
[idx
]->arg
;
9759 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9760 clr_sort
= clear_peer
;
9761 clr_arg
= argv
[idx
]->arg
;
9762 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9763 clr_sort
= clear_as
;
9764 clr_arg
= argv
[idx
]->arg
;
9765 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9766 clr_sort
= clear_external
;
9769 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9770 if (argv_find(argv
, argc
, "soft", &idx
)) {
9771 if (argv_find(argv
, argc
, "in", &idx
)
9772 || argv_find(argv
, argc
, "out", &idx
))
9773 clr_type
= strmatch(argv
[idx
]->text
, "in")
9775 : BGP_CLEAR_SOFT_OUT
;
9777 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9778 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9779 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9780 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9781 : BGP_CLEAR_SOFT_IN
;
9782 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9783 clr_type
= BGP_CLEAR_SOFT_OUT
;
9784 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9785 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9787 clr_type
= BGP_CLEAR_SOFT_NONE
;
9789 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9792 DEFUN (clear_ip_bgp_prefix
,
9793 clear_ip_bgp_prefix_cmd
,
9794 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9798 BGP_INSTANCE_HELP_STR
9799 "Clear bestpath and re-advertise\n"
9803 char *prefix
= NULL
;
9807 /* [<view|vrf> VIEWVRFNAME] */
9808 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9809 vrf
= argv
[idx
+ 1]->arg
;
9811 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9813 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9814 /* [<view> VIEWVRFNAME] */
9815 vrf
= argv
[idx
+ 1]->arg
;
9819 prefix
= argv
[argc
- 1]->arg
;
9821 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9824 DEFUN (clear_bgp_ipv6_safi_prefix
,
9825 clear_bgp_ipv6_safi_prefix_cmd
,
9826 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9832 "Clear bestpath and re-advertise\n"
9836 int idx_ipv6_prefix
= 0;
9837 safi_t safi
= SAFI_UNICAST
;
9838 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9839 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9841 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9842 return bgp_clear_prefix(
9843 vty
, NULL
, prefix
, AFI_IP6
,
9847 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9848 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9849 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9853 BGP_INSTANCE_HELP_STR
9856 "Clear bestpath and re-advertise\n"
9860 int idx_vrfview
= 0;
9861 int idx_ipv6_prefix
= 0;
9862 safi_t safi
= SAFI_UNICAST
;
9863 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9864 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9865 char *vrfview
= NULL
;
9867 /* [<view|vrf> VIEWVRFNAME] */
9868 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9869 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9870 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9872 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9873 /* [<view> VIEWVRFNAME] */
9874 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9876 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9878 return bgp_clear_prefix(
9879 vty
, vrfview
, prefix
,
9880 AFI_IP6
, safi
, NULL
);
9883 DEFUN (show_bgp_views
,
9885 "show [ip] bgp views",
9889 "Show the defined BGP views\n")
9891 struct list
*inst
= bm
->bgp
;
9892 struct listnode
*node
;
9895 vty_out(vty
, "Defined BGP views:\n");
9896 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9898 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9900 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9907 DEFUN (show_bgp_vrfs
,
9909 "show [ip] bgp vrfs [json]",
9916 char buf
[ETHER_ADDR_STRLEN
];
9917 struct list
*inst
= bm
->bgp
;
9918 struct listnode
*node
;
9920 bool uj
= use_json(argc
, argv
);
9921 json_object
*json
= NULL
;
9922 json_object
*json_vrfs
= NULL
;
9926 json
= json_object_new_object();
9927 json_vrfs
= json_object_new_object();
9930 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9931 const char *name
, *type
;
9933 struct listnode
*node2
, *nnode2
;
9934 int peers_cfg
, peers_estb
;
9935 json_object
*json_vrf
= NULL
;
9938 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9942 if (!uj
&& count
== 1) {
9944 "%4s %-5s %-16s %9s %10s %-37s\n",
9945 "Type", "Id", "routerId", "#PeersCfg",
9946 "#PeersEstb", "Name");
9947 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9948 "L3-VNI", "RouterMAC", "Interface");
9951 peers_cfg
= peers_estb
= 0;
9953 json_vrf
= json_object_new_object();
9956 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9957 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9960 if (peer_established(peer
))
9964 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9965 name
= VRF_DEFAULT_NAME
;
9974 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9976 : (int64_t)bgp
->vrf_id
;
9977 char buf
[BUFSIZ
] = {0};
9979 json_object_string_add(json_vrf
, "type", type
);
9980 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9981 json_object_string_addf(json_vrf
, "routerId", "%pI4",
9983 json_object_int_add(json_vrf
, "numConfiguredPeers",
9985 json_object_int_add(json_vrf
, "numEstablishedPeers",
9988 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9989 json_object_string_add(
9991 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9992 json_object_string_add(json_vrf
, "interface",
9993 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9995 json_object_object_add(json_vrfs
, name
, json_vrf
);
9997 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
9999 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10000 : (int)bgp
->vrf_id
,
10001 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10002 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10004 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10005 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10011 json_object_object_add(json
, "vrfs", json_vrfs
);
10013 json_object_int_add(json
, "totalVrfs", count
);
10015 vty_json(vty
, json
);
10019 "\nTotal number of VRFs (including default): %d\n",
10023 return CMD_SUCCESS
;
10026 DEFUN (show_bgp_mac_hash
,
10027 show_bgp_mac_hash_cmd
,
10028 "show bgp mac hash",
10032 "Mac Address database\n")
10034 bgp_mac_dump_table(vty
);
10036 return CMD_SUCCESS
;
10039 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10041 struct vty
*vty
= (struct vty
*)args
;
10042 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10044 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10047 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10049 vty_out(vty
, "self nexthop database:\n");
10050 bgp_nexthop_show_address_hash(vty
, bgp
);
10052 vty_out(vty
, "Tunnel-ip database:\n");
10053 hash_iterate(bgp
->tip_hash
,
10054 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10058 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10059 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10060 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10061 "martian next-hops\n"
10062 "martian next-hop database\n")
10064 struct bgp
*bgp
= NULL
;
10068 /* [<vrf> VIEWVRFNAME] */
10069 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10070 name
= argv
[idx
+ 1]->arg
;
10071 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10073 } else if (argv_find(argv
, argc
, "view", &idx
))
10074 /* [<view> VIEWVRFNAME] */
10075 name
= argv
[idx
+ 1]->arg
;
10077 bgp
= bgp_lookup_by_name(name
);
10079 bgp
= bgp_get_default();
10082 vty_out(vty
, "%% No BGP process is configured\n");
10083 return CMD_WARNING
;
10085 bgp_show_martian_nexthops(vty
, bgp
);
10087 return CMD_SUCCESS
;
10090 DEFUN (show_bgp_memory
,
10091 show_bgp_memory_cmd
,
10092 "show [ip] bgp memory",
10096 "Global BGP memory statistics\n")
10098 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10099 unsigned long count
;
10101 /* RIB related usage stats */
10102 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10103 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10104 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10105 count
* sizeof(struct bgp_dest
)));
10107 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10108 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10109 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10110 count
* sizeof(struct bgp_path_info
)));
10111 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10112 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10115 memstrbuf
, sizeof(memstrbuf
),
10116 count
* sizeof(struct bgp_path_info_extra
)));
10118 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10119 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10120 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10121 count
* sizeof(struct bgp_static
)));
10123 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10124 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10125 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10126 count
* sizeof(struct bpacket
)));
10129 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10130 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10131 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10132 count
* sizeof(struct bgp_adj_in
)));
10133 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10134 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10135 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10136 count
* sizeof(struct bgp_adj_out
)));
10138 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10139 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10141 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10142 count
* sizeof(struct bgp_nexthop_cache
)));
10144 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10145 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10147 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10148 count
* sizeof(struct bgp_damp_info
)));
10151 count
= attr_count();
10152 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10153 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10154 count
* sizeof(struct attr
)));
10156 if ((count
= attr_unknown_count()))
10157 vty_out(vty
, "%ld unknown attributes\n", count
);
10159 /* AS_PATH attributes */
10160 count
= aspath_count();
10161 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10162 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10163 count
* sizeof(struct aspath
)));
10165 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10166 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10167 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10168 count
* sizeof(struct assegment
)));
10170 /* Other attributes */
10171 if ((count
= community_count()))
10172 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10173 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10174 count
* sizeof(struct community
)));
10175 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10176 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10177 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10178 count
* sizeof(struct ecommunity
)));
10179 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10181 "%ld BGP large-community entries, using %s of memory\n",
10182 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10183 count
* sizeof(struct lcommunity
)));
10185 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10186 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10187 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10188 count
* sizeof(struct cluster_list
)));
10190 /* Peer related usage */
10191 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10192 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10193 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10194 count
* sizeof(struct peer
)));
10196 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10197 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10198 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10199 count
* sizeof(struct peer_group
)));
10202 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10203 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10204 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10205 count
* sizeof(regex_t
)));
10206 return CMD_SUCCESS
;
10209 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10211 json_object
*bestpath
= json_object_new_object();
10213 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10214 json_object_string_add(bestpath
, "asPath", "ignore");
10216 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10217 json_object_string_add(bestpath
, "asPath", "confed");
10219 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10220 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10221 json_object_string_add(bestpath
, "multiPathRelax",
10224 json_object_string_add(bestpath
, "multiPathRelax",
10227 json_object_string_add(bestpath
, "multiPathRelax", "false");
10229 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10230 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10232 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10233 json_object_string_add(bestpath
, "compareRouterId", "true");
10234 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10235 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10236 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10237 json_object_string_add(bestpath
, "med", "confed");
10238 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10239 json_object_string_add(bestpath
, "med",
10240 "missing-as-worst");
10242 json_object_string_add(bestpath
, "med", "true");
10245 json_object_object_add(json
, "bestPath", bestpath
);
10248 /* Print the error code/subcode for why the peer is down */
10249 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10250 json_object
*json_peer
, bool use_json
)
10252 const char *code_str
;
10253 const char *subcode_str
;
10256 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10257 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10258 char errorcodesubcode_hexstr
[5];
10259 char errorcodesubcode_str
[256];
10261 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10262 subcode_str
= bgp_notify_subcode_str(
10264 peer
->notify
.subcode
);
10266 snprintf(errorcodesubcode_hexstr
,
10267 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10268 peer
->notify
.code
, peer
->notify
.subcode
);
10269 json_object_string_add(json_peer
,
10270 "lastErrorCodeSubcode",
10271 errorcodesubcode_hexstr
);
10272 snprintf(errorcodesubcode_str
, 255, "%s%s",
10273 code_str
, subcode_str
);
10274 json_object_string_add(json_peer
,
10275 "lastNotificationReason",
10276 errorcodesubcode_str
);
10277 json_object_boolean_add(json_peer
,
10278 "lastNotificationHardReset",
10279 peer
->notify
.hard_reset
);
10280 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10281 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10282 && (peer
->notify
.subcode
10283 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10284 || peer
->notify
.subcode
10285 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10286 && peer
->notify
.length
) {
10288 const char *msg_str
;
10290 msg_str
= bgp_notify_admin_message(
10291 msgbuf
, sizeof(msgbuf
),
10292 (uint8_t *)peer
->notify
.data
,
10293 peer
->notify
.length
);
10295 json_object_string_add(
10297 "lastShutdownDescription",
10302 json_object_string_add(json_peer
, "lastResetDueTo",
10303 peer_down_str
[(int)peer
->last_reset
]);
10304 json_object_int_add(json_peer
, "lastResetCode",
10307 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10308 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10309 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10311 bgp_notify_subcode_str(peer
->notify
.code
,
10312 peer
->notify
.subcode
);
10313 vty_out(vty
, " Notification %s (%s%s%s)\n",
10314 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10317 code_str
, subcode_str
,
10318 peer
->notify
.hard_reset
10319 ? bgp_notify_subcode_str(
10321 BGP_NOTIFY_CEASE_HARD_RESET
)
10324 vty_out(vty
, " %s\n",
10325 peer_down_str
[(int)peer
->last_reset
]);
10330 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10333 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10336 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10337 struct peer
*peer
, json_object
*json_peer
,
10338 int max_neighbor_width
, bool use_json
)
10340 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10344 if (peer_dynamic_neighbor(peer
))
10345 json_object_boolean_true_add(json_peer
,
10347 if (peer
->hostname
)
10348 json_object_string_add(json_peer
, "hostname",
10351 if (peer
->domainname
)
10352 json_object_string_add(json_peer
, "domainname",
10354 json_object_int_add(json_peer
, "connectionsEstablished",
10355 peer
->established
);
10356 json_object_int_add(json_peer
, "connectionsDropped",
10358 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10359 use_json
, json_peer
);
10360 if (peer_established(peer
))
10361 json_object_string_add(json_peer
, "lastResetDueTo",
10362 "AFI/SAFI Not Negotiated");
10364 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10367 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10369 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10370 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10371 peer
->hostname
, peer
->host
);
10373 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10375 /* pad the neighbor column with spaces */
10376 if (len
< max_neighbor_width
)
10377 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10379 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10381 peer_uptime(peer
->uptime
, timebuf
,
10382 BGP_UPTIME_LEN
, 0, NULL
));
10383 if (peer_established(peer
))
10384 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10386 bgp_show_peer_reset(vty
, peer
, NULL
,
10391 /* Strip peer's description to the given size. */
10392 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10394 static char stripped
[BUFSIZ
];
10395 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10397 strlcpy(stripped
, desc
, len
+ 1);
10402 /* Determine whether var peer should be filtered out of the summary. */
10403 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10404 struct peer
*fpeer
, int as_type
,
10408 /* filter neighbor XXXX */
10409 if (fpeer
&& fpeer
!= peer
)
10412 /* filter remote-as (internal|external) */
10413 if (as_type
!= AS_UNSPECIFIED
) {
10414 if (peer
->as_type
== AS_SPECIFIED
) {
10415 if (as_type
== AS_INTERNAL
) {
10416 if (peer
->as
!= peer
->local_as
)
10418 } else if (peer
->as
== peer
->local_as
)
10420 } else if (as_type
!= peer
->as_type
)
10422 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10428 /* Show BGP peer's summary information.
10430 * Peer's description is stripped according to if `wide` option is given
10433 * When adding new columns to `show bgp summary` output, please make
10434 * sure `Desc` is the lastest column to show because it can contain
10435 * whitespaces and the whole output will be tricky.
10437 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10438 struct peer
*fpeer
, int as_type
, as_t as
,
10439 uint16_t show_flags
)
10442 struct listnode
*node
, *nnode
;
10443 unsigned int count
= 0, dn_count
= 0;
10444 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10445 char neighbor_buf
[VTY_BUFSIZ
];
10446 int neighbor_col_default_width
= 16;
10447 int len
, failed_count
= 0;
10448 unsigned int filtered_count
= 0;
10449 int max_neighbor_width
= 0;
10451 json_object
*json
= NULL
;
10452 json_object
*json_peer
= NULL
;
10453 json_object
*json_peers
= NULL
;
10454 struct peer_af
*paf
;
10455 struct bgp_filter
*filter
;
10456 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10457 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10458 bool show_established
=
10459 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10460 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10461 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10463 /* labeled-unicast routes are installed in the unicast table so in order
10465 * display the correct PfxRcd value we must look at SAFI_UNICAST
10468 if (safi
== SAFI_LABELED_UNICAST
)
10469 pfx_rcd_safi
= SAFI_UNICAST
;
10471 pfx_rcd_safi
= safi
;
10474 json
= json_object_new_object();
10475 json_peers
= json_object_new_object();
10476 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10477 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10484 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10487 if (peer
->afc
[afi
][safi
]) {
10488 /* See if we have at least a single failed peer */
10489 if (bgp_has_peer_failed(peer
, afi
, safi
))
10493 if (peer_dynamic_neighbor(peer
))
10498 /* Loop over all neighbors that will be displayed to determine
10500 * characters are needed for the Neighbor column
10502 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10503 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10510 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10513 if (peer
->afc
[afi
][safi
]) {
10514 memset(dn_flag
, '\0', sizeof(dn_flag
));
10515 if (peer_dynamic_neighbor(peer
))
10519 && CHECK_FLAG(bgp
->flags
,
10520 BGP_FLAG_SHOW_HOSTNAME
))
10521 snprintf(neighbor_buf
,
10522 sizeof(neighbor_buf
),
10523 "%s%s(%s) ", dn_flag
,
10524 peer
->hostname
, peer
->host
);
10526 snprintf(neighbor_buf
,
10527 sizeof(neighbor_buf
), "%s%s ",
10528 dn_flag
, peer
->host
);
10530 len
= strlen(neighbor_buf
);
10532 if (len
> max_neighbor_width
)
10533 max_neighbor_width
= len
;
10535 /* See if we have at least a single failed peer */
10536 if (bgp_has_peer_failed(peer
, afi
, safi
))
10542 /* Originally we displayed the Neighbor column as 16
10543 * characters wide so make that the default
10545 if (max_neighbor_width
< neighbor_col_default_width
)
10546 max_neighbor_width
= neighbor_col_default_width
;
10549 if (show_failed
&& !failed_count
) {
10551 json_object_int_add(json
, "failedPeersCount", 0);
10552 json_object_int_add(json
, "dynamicPeers", dn_count
);
10553 json_object_int_add(json
, "totalPeers", count
);
10555 vty_json(vty
, json
);
10557 vty_out(vty
, "%% No failed BGP neighbors found\n");
10559 return CMD_SUCCESS
;
10562 count
= 0; /* Reset the value as its used again */
10563 filtered_count
= 0;
10565 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10566 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10569 if (!peer
->afc
[afi
][safi
])
10573 unsigned long ents
;
10574 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10577 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10579 : (int64_t)bgp
->vrf_id
;
10581 /* Usage summary and header */
10583 json_object_string_addf(json
, "routerId",
10586 json_object_int_add(json
, "as", bgp
->as
);
10587 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10588 json_object_string_add(
10591 == BGP_INSTANCE_TYPE_DEFAULT
)
10596 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10597 &bgp
->router_id
, bgp
->as
,
10598 bgp
->vrf_id
== VRF_UNKNOWN
10600 : (int)bgp
->vrf_id
);
10601 vty_out(vty
, "\n");
10604 if (bgp_update_delay_configured(bgp
)) {
10606 json_object_int_add(
10607 json
, "updateDelayLimit",
10608 bgp
->v_update_delay
);
10610 if (bgp
->v_update_delay
10611 != bgp
->v_establish_wait
)
10612 json_object_int_add(
10614 "updateDelayEstablishWait",
10615 bgp
->v_establish_wait
);
10617 if (bgp_update_delay_active(bgp
)) {
10618 json_object_string_add(
10620 "updateDelayFirstNeighbor",
10621 bgp
->update_delay_begin_time
);
10622 json_object_boolean_true_add(
10624 "updateDelayInProgress");
10626 if (bgp
->update_delay_over
) {
10627 json_object_string_add(
10629 "updateDelayFirstNeighbor",
10630 bgp
->update_delay_begin_time
);
10631 json_object_string_add(
10633 "updateDelayBestpathResumed",
10634 bgp
->update_delay_end_time
);
10635 json_object_string_add(
10637 "updateDelayZebraUpdateResume",
10638 bgp
->update_delay_zebra_resume_time
);
10639 json_object_string_add(
10641 "updateDelayPeerUpdateResume",
10642 bgp
->update_delay_peers_resume_time
);
10647 "Read-only mode update-delay limit: %d seconds\n",
10648 bgp
->v_update_delay
);
10649 if (bgp
->v_update_delay
10650 != bgp
->v_establish_wait
)
10652 " Establish wait: %d seconds\n",
10653 bgp
->v_establish_wait
);
10655 if (bgp_update_delay_active(bgp
)) {
10657 " First neighbor established: %s\n",
10658 bgp
->update_delay_begin_time
);
10660 " Delay in progress\n");
10662 if (bgp
->update_delay_over
) {
10664 " First neighbor established: %s\n",
10665 bgp
->update_delay_begin_time
);
10667 " Best-paths resumed: %s\n",
10668 bgp
->update_delay_end_time
);
10670 " zebra update resumed: %s\n",
10671 bgp
->update_delay_zebra_resume_time
);
10673 " peers update resumed: %s\n",
10674 bgp
->update_delay_peers_resume_time
);
10681 if (bgp_maxmed_onstartup_configured(bgp
)
10682 && bgp
->maxmed_active
)
10683 json_object_boolean_true_add(
10684 json
, "maxMedOnStartup");
10685 if (bgp
->v_maxmed_admin
)
10686 json_object_boolean_true_add(
10687 json
, "maxMedAdministrative");
10689 json_object_int_add(
10690 json
, "tableVersion",
10691 bgp_table_version(bgp
->rib
[afi
][safi
]));
10693 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10694 json_object_int_add(json
, "ribCount", ents
);
10695 json_object_int_add(
10697 ents
* sizeof(struct bgp_dest
));
10699 ents
= bgp
->af_peer_count
[afi
][safi
];
10700 json_object_int_add(json
, "peerCount", ents
);
10701 json_object_int_add(json
, "peerMemory",
10702 ents
* sizeof(struct peer
));
10704 if ((ents
= listcount(bgp
->group
))) {
10705 json_object_int_add(
10706 json
, "peerGroupCount", ents
);
10707 json_object_int_add(
10708 json
, "peerGroupMemory",
10709 ents
* sizeof(struct
10713 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10714 BGP_CONFIG_DAMPENING
))
10715 json_object_boolean_true_add(
10716 json
, "dampeningEnabled");
10719 if (bgp_maxmed_onstartup_configured(bgp
)
10720 && bgp
->maxmed_active
)
10722 "Max-med on-startup active\n");
10723 if (bgp
->v_maxmed_admin
)
10725 "Max-med administrative active\n");
10728 "BGP table version %" PRIu64
10731 bgp
->rib
[afi
][safi
]));
10733 ents
= bgp_table_count(
10734 bgp
->rib
[afi
][safi
]);
10736 "RIB entries %ld, using %s of memory\n",
10746 /* Peer related usage */
10747 ents
= bgp
->af_peer_count
[afi
][safi
];
10749 "Peers %ld, using %s of memory\n",
10759 if ((ents
= listcount(bgp
->group
)))
10761 "Peer groups %ld, using %s of memory\n",
10771 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10772 BGP_CONFIG_DAMPENING
))
10774 "Dampening enabled.\n");
10777 vty_out(vty
, "\n");
10779 /* Subtract 8 here because 'Neighbor' is
10781 vty_out(vty
, "Neighbor");
10782 vty_out(vty
, "%*s",
10783 max_neighbor_width
- 8, " ");
10785 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10790 paf
= peer_af_find(peer
, afi
, safi
);
10791 filter
= &peer
->filter
[afi
][safi
];
10794 /* Works for both failed & successful cases */
10795 if (peer_dynamic_neighbor(peer
))
10800 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10806 bgp_has_peer_failed(peer
, afi
, safi
)) {
10807 json_peer
= json_object_new_object();
10808 bgp_show_failed_summary(vty
, bgp
, peer
,
10809 json_peer
, 0, use_json
);
10810 } else if (!show_failed
) {
10811 if (show_established
10812 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10817 json_peer
= json_object_new_object();
10818 if (peer_dynamic_neighbor(peer
)) {
10819 json_object_boolean_true_add(json_peer
,
10823 if (peer
->hostname
)
10824 json_object_string_add(json_peer
, "hostname",
10827 if (peer
->domainname
)
10828 json_object_string_add(json_peer
, "domainname",
10831 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10832 json_object_int_add(
10833 json_peer
, "localAs",
10834 peer
->change_local_as
10835 ? peer
->change_local_as
10837 json_object_int_add(json_peer
, "version", 4);
10838 json_object_int_add(json_peer
, "msgRcvd",
10839 PEER_TOTAL_RX(peer
));
10840 json_object_int_add(json_peer
, "msgSent",
10841 PEER_TOTAL_TX(peer
));
10843 atomic_size_t outq_count
, inq_count
;
10844 outq_count
= atomic_load_explicit(
10845 &peer
->obuf
->count
,
10846 memory_order_relaxed
);
10847 inq_count
= atomic_load_explicit(
10848 &peer
->ibuf
->count
,
10849 memory_order_relaxed
);
10851 json_object_int_add(json_peer
, "tableVersion",
10852 peer
->version
[afi
][safi
]);
10853 json_object_int_add(json_peer
, "outq",
10855 json_object_int_add(json_peer
, "inq",
10857 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10858 use_json
, json_peer
);
10860 json_object_int_add(json_peer
, "pfxRcd",
10861 peer
->pcount
[afi
][pfx_rcd_safi
]);
10863 if (paf
&& PAF_SUBGRP(paf
))
10864 json_object_int_add(
10865 json_peer
, "pfxSnt",
10866 (PAF_SUBGRP(paf
))->scount
);
10868 json_object_int_add(json_peer
, "pfxSnt",
10871 /* BGP FSM state */
10872 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10873 || CHECK_FLAG(peer
->bgp
->flags
,
10874 BGP_FLAG_SHUTDOWN
))
10875 json_object_string_add(json_peer
,
10878 else if (peer
->afc_recv
[afi
][safi
])
10879 json_object_string_add(
10880 json_peer
, "state",
10881 lookup_msg(bgp_status_msg
,
10882 peer
->status
, NULL
));
10883 else if (CHECK_FLAG(
10885 PEER_STATUS_PREFIX_OVERFLOW
))
10886 json_object_string_add(json_peer
,
10890 json_object_string_add(
10891 json_peer
, "state",
10892 lookup_msg(bgp_status_msg
,
10893 peer
->status
, NULL
));
10895 /* BGP peer state */
10896 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10897 || CHECK_FLAG(peer
->bgp
->flags
,
10898 BGP_FLAG_SHUTDOWN
))
10899 json_object_string_add(json_peer
,
10902 else if (CHECK_FLAG(
10904 PEER_STATUS_PREFIX_OVERFLOW
))
10905 json_object_string_add(json_peer
,
10908 else if (CHECK_FLAG(peer
->flags
,
10909 PEER_FLAG_PASSIVE
))
10910 json_object_string_add(json_peer
,
10913 else if (CHECK_FLAG(peer
->sflags
,
10914 PEER_STATUS_NSF_WAIT
))
10915 json_object_string_add(json_peer
,
10918 else if (CHECK_FLAG(
10920 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10921 && (!bgp_inbound_policy_exists(peer
,
10923 || !bgp_outbound_policy_exists(
10925 json_object_string_add(json_peer
,
10929 json_object_string_add(
10930 json_peer
, "peerState", "OK");
10932 json_object_int_add(json_peer
, "connectionsEstablished",
10933 peer
->established
);
10934 json_object_int_add(json_peer
, "connectionsDropped",
10937 json_object_string_add(
10938 json_peer
, "desc", peer
->desc
);
10940 /* Avoid creating empty peer dicts in JSON */
10941 if (json_peer
== NULL
)
10945 json_object_string_add(json_peer
, "idType",
10947 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10948 json_object_string_add(json_peer
, "idType",
10950 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10951 json_object_string_add(json_peer
, "idType",
10953 json_object_object_add(json_peers
, peer
->host
,
10956 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10962 bgp_has_peer_failed(peer
, afi
, safi
)) {
10963 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10964 max_neighbor_width
,
10966 } else if (!show_failed
) {
10967 if (show_established
10968 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10973 if ((count
- filtered_count
) == 1) {
10974 /* display headline before the first
10976 vty_out(vty
, "\n");
10978 /* Subtract 8 here because 'Neighbor' is
10980 vty_out(vty
, "Neighbor");
10981 vty_out(vty
, "%*s",
10982 max_neighbor_width
- 8, " ");
10985 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10986 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10989 memset(dn_flag
, '\0', sizeof(dn_flag
));
10990 if (peer_dynamic_neighbor(peer
)) {
10995 && CHECK_FLAG(bgp
->flags
,
10996 BGP_FLAG_SHOW_HOSTNAME
))
10997 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11001 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11003 /* pad the neighbor column with spaces */
11004 if (len
< max_neighbor_width
)
11005 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11008 atomic_size_t outq_count
, inq_count
;
11009 outq_count
= atomic_load_explicit(
11010 &peer
->obuf
->count
,
11011 memory_order_relaxed
);
11012 inq_count
= atomic_load_explicit(
11013 &peer
->ibuf
->count
,
11014 memory_order_relaxed
);
11018 "4 %10u %10u %9u %9u %8" PRIu64
11021 peer
->change_local_as
11022 ? peer
->change_local_as
11024 PEER_TOTAL_RX(peer
),
11025 PEER_TOTAL_TX(peer
),
11026 peer
->version
[afi
][safi
],
11027 inq_count
, outq_count
,
11028 peer_uptime(peer
->uptime
,
11033 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11035 peer
->as
, PEER_TOTAL_RX(peer
),
11036 PEER_TOTAL_TX(peer
),
11037 peer
->version
[afi
][safi
],
11038 inq_count
, outq_count
,
11039 peer_uptime(peer
->uptime
,
11044 if (peer_established(peer
)) {
11045 if (peer
->afc_recv
[afi
][safi
]) {
11048 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11049 && !bgp_inbound_policy_exists(
11051 vty_out(vty
, " %12s",
11060 vty_out(vty
, " NoNeg");
11063 if (paf
&& PAF_SUBGRP(paf
)) {
11066 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11067 && !bgp_outbound_policy_exists(
11069 vty_out(vty
, " %8s",
11078 vty_out(vty
, " NoNeg");
11081 if (CHECK_FLAG(peer
->flags
,
11082 PEER_FLAG_SHUTDOWN
)
11083 || CHECK_FLAG(peer
->bgp
->flags
,
11084 BGP_FLAG_SHUTDOWN
))
11085 vty_out(vty
, " Idle (Admin)");
11086 else if (CHECK_FLAG(
11088 PEER_STATUS_PREFIX_OVERFLOW
))
11089 vty_out(vty
, " Idle (PfxCt)");
11091 vty_out(vty
, " %12s",
11092 lookup_msg(bgp_status_msg
,
11093 peer
->status
, NULL
));
11095 vty_out(vty
, " %8u", 0);
11097 /* Make sure `Desc` column is the lastest in
11101 vty_out(vty
, " %s",
11102 bgp_peer_description_stripped(
11104 show_wide
? 64 : 20));
11106 vty_out(vty
, " N/A");
11107 vty_out(vty
, "\n");
11114 json_object_object_add(json
, "peers", json_peers
);
11115 json_object_int_add(json
, "failedPeers", failed_count
);
11116 json_object_int_add(json
, "displayedPeers",
11117 count
- filtered_count
);
11118 json_object_int_add(json
, "totalPeers", count
);
11119 json_object_int_add(json
, "dynamicPeers", dn_count
);
11122 bgp_show_bestpath_json(bgp
, json
);
11124 vty_json(vty
, json
);
11127 if (filtered_count
== count
)
11128 vty_out(vty
, "\n%% No matching neighbor\n");
11131 vty_out(vty
, "\nDisplayed neighbors %d",
11133 else if (as_type
!= AS_UNSPECIFIED
|| as
11134 || fpeer
|| show_established
)
11135 vty_out(vty
, "\nDisplayed neighbors %d",
11136 count
- filtered_count
);
11138 vty_out(vty
, "\nTotal number of neighbors %d\n",
11142 vty_out(vty
, "No %s neighbor is configured\n",
11143 get_afi_safi_str(afi
, safi
, false));
11147 vty_out(vty
, "* - dynamic neighbor\n");
11148 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11149 dn_count
, bgp
->dynamic_neighbors_limit
);
11153 return CMD_SUCCESS
;
11156 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11157 int safi
, struct peer
*fpeer
, int as_type
,
11158 as_t as
, uint16_t show_flags
)
11161 int afi_wildcard
= (afi
== AFI_MAX
);
11162 int safi_wildcard
= (safi
== SAFI_MAX
);
11163 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11164 bool nbr_output
= false;
11165 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11167 if (use_json
&& is_wildcard
)
11168 vty_out(vty
, "{\n");
11170 afi
= 1; /* AFI_IP */
11171 while (afi
< AFI_MAX
) {
11173 safi
= 1; /* SAFI_UNICAST */
11174 while (safi
< SAFI_MAX
) {
11175 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11180 * So limit output to those afi/safi
11182 * actualy have something interesting in
11187 vty_out(vty
, ",\n");
11191 vty_out(vty
, "\"%s\":",
11192 get_afi_safi_str(afi
,
11197 "\n%s Summary (%s):\n",
11198 get_afi_safi_str(afi
,
11204 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11205 as_type
, as
, show_flags
);
11208 if (!safi_wildcard
)
11216 if (use_json
&& is_wildcard
)
11217 vty_out(vty
, "}\n");
11218 else if (!nbr_output
) {
11220 vty_out(vty
, "{}\n");
11222 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11227 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11229 const char *neighbor
,
11230 int as_type
, as_t as
,
11231 uint16_t show_flags
)
11233 struct listnode
*node
, *nnode
;
11235 struct peer
*fpeer
= NULL
;
11237 bool nbr_output
= false;
11238 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11241 vty_out(vty
, "{\n");
11243 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11247 vty_out(vty
, ",\n");
11251 vty_out(vty
, "\"%s\":",
11252 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11257 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11262 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11267 vty_out(vty
, "}\n");
11268 else if (!nbr_output
)
11269 vty_out(vty
, "%% BGP instance not found\n");
11272 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11273 safi_t safi
, const char *neighbor
, int as_type
,
11274 as_t as
, uint16_t show_flags
)
11277 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11278 struct peer
*fpeer
= NULL
;
11281 if (strmatch(name
, "all")) {
11282 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11285 return CMD_SUCCESS
;
11287 bgp
= bgp_lookup_by_name(name
);
11291 vty_out(vty
, "{}\n");
11294 "%% BGP instance not found\n");
11295 return CMD_WARNING
;
11299 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11302 return CMD_WARNING
;
11304 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11305 as_type
, as
, show_flags
);
11306 return CMD_SUCCESS
;
11310 bgp
= bgp_get_default();
11314 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11317 return CMD_WARNING
;
11319 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11323 vty_out(vty
, "{}\n");
11325 vty_out(vty
, "%% BGP instance not found\n");
11326 return CMD_WARNING
;
11329 return CMD_SUCCESS
;
11332 /* `show [ip] bgp summary' commands. */
11333 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11334 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11335 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11336 "]] [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]",
11337 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11338 BGP_SAFI_WITH_LABEL_HELP_STR
11339 "Display the entries for all address families\n"
11340 "Summary of BGP neighbor status\n"
11341 "Show only sessions in Established state\n"
11342 "Show only sessions not in Established state\n"
11343 "Show only the specified neighbor session\n"
11344 "Neighbor to display information about\n"
11345 "Neighbor to display information about\n"
11346 "Neighbor on BGP configured interface\n"
11347 "Show only the specified remote AS sessions\n"
11349 "Internal (iBGP) AS sessions\n"
11350 "External (eBGP) AS sessions\n"
11351 "Shorten the information on BGP instances\n"
11352 "Increase table width for longer output\n" JSON_STR
)
11355 afi_t afi
= AFI_MAX
;
11356 safi_t safi
= SAFI_MAX
;
11357 as_t as
= 0; /* 0 means AS filter not set */
11358 int as_type
= AS_UNSPECIFIED
;
11359 uint16_t show_flags
= 0;
11363 /* show [ip] bgp */
11364 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11366 /* [<vrf> VIEWVRFNAME] */
11367 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11368 vrf
= argv
[idx
+ 1]->arg
;
11369 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11371 } else if (argv_find(argv
, argc
, "view", &idx
))
11372 /* [<view> VIEWVRFNAME] */
11373 vrf
= argv
[idx
+ 1]->arg
;
11374 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11375 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11376 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11379 if (argv_find(argv
, argc
, "failed", &idx
))
11380 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11382 if (argv_find(argv
, argc
, "established", &idx
))
11383 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11385 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11386 if (argv
[idx
+ 1]->arg
[0] == 'i')
11387 as_type
= AS_INTERNAL
;
11388 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11389 as_type
= AS_EXTERNAL
;
11391 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11394 if (argv_find(argv
, argc
, "terse", &idx
))
11395 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11397 if (argv_find(argv
, argc
, "wide", &idx
))
11398 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11400 if (argv_find(argv
, argc
, "json", &idx
))
11401 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11403 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11407 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11410 return get_afi_safi_json_str(afi
, safi
);
11412 return get_afi_safi_vty_str(afi
, safi
);
11416 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11417 afi_t afi
, safi_t safi
,
11418 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11419 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11420 bool use_json
, json_object
*json_pref
)
11423 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11424 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11426 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11427 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11428 json_object_string_add(json_pref
, "sendMode",
11429 "advertisedAndReceived");
11430 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11431 json_object_string_add(json_pref
, "sendMode",
11433 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11434 json_object_string_add(json_pref
, "sendMode",
11437 vty_out(vty
, " Send-mode: ");
11438 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11439 vty_out(vty
, "advertised");
11440 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11441 vty_out(vty
, "%sreceived",
11442 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11446 vty_out(vty
, "\n");
11451 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11452 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11454 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11455 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11456 json_object_string_add(json_pref
, "recvMode",
11457 "advertisedAndReceived");
11458 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11459 json_object_string_add(json_pref
, "recvMode",
11461 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11462 json_object_string_add(json_pref
, "recvMode",
11465 vty_out(vty
, " Receive-mode: ");
11466 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11467 vty_out(vty
, "advertised");
11468 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11469 vty_out(vty
, "%sreceived",
11470 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11474 vty_out(vty
, "\n");
11479 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11487 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11488 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11489 && (peer_established(p
))) {
11490 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11491 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11495 json_object_boolean_add(json
, "rBit", rbit
);
11496 json_object_boolean_add(json
, "nBit", nbit
);
11498 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11499 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11503 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11508 const char *mode
= "NotApplicable";
11511 vty_out(vty
, "\n Remote GR Mode: ");
11513 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11514 && (peer_established(peer
))) {
11516 if ((peer
->nsf_af_count
== 0)
11517 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11521 } else if (peer
->nsf_af_count
== 0
11522 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11526 } else if (peer
->nsf_af_count
!= 0
11527 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11534 json_object_string_add(json
, "remoteGrMode", mode
);
11536 vty_out(vty
, mode
, "\n");
11539 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11544 const char *mode
= "Invalid";
11547 vty_out(vty
, " Local GR Mode: ");
11549 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11551 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11553 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11555 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11556 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11558 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11560 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11567 json_object_string_add(json
, "localGrMode", mode
);
11569 vty_out(vty
, mode
, "\n");
11573 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11574 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11578 json_object
*json_afi_safi
= NULL
;
11579 json_object
*json_timer
= NULL
;
11580 json_object
*json_endofrib_status
= NULL
;
11581 bool eor_flag
= false;
11583 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11584 if (!peer
->afc
[afi
][safi
])
11587 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11588 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11592 json_afi_safi
= json_object_new_object();
11593 json_endofrib_status
= json_object_new_object();
11594 json_timer
= json_object_new_object();
11597 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11603 vty_out(vty
, " %s:\n",
11604 get_afi_safi_str(afi
, safi
, false));
11606 vty_out(vty
, " F bit: ");
11609 if (peer
->nsf
[afi
][safi
] &&
11610 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11611 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11614 json_object_boolean_true_add(json_afi_safi
,
11617 vty_out(vty
, "True\n");
11620 json_object_boolean_false_add(json_afi_safi
,
11623 vty_out(vty
, "False\n");
11627 vty_out(vty
, " End-of-RIB sent: ");
11629 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11630 PEER_STATUS_EOR_SEND
)) {
11632 json_object_boolean_true_add(
11633 json_endofrib_status
, "endOfRibSend");
11635 PRINT_EOR_JSON(eor_flag
);
11637 vty_out(vty
, "Yes\n");
11639 " End-of-RIB sent after update: ");
11641 PRINT_EOR(eor_flag
);
11645 json_object_boolean_false_add(
11646 json_endofrib_status
, "endOfRibSend");
11647 json_object_boolean_false_add(
11648 json_endofrib_status
,
11649 "endOfRibSentAfterUpdate");
11651 vty_out(vty
, "No\n");
11653 " End-of-RIB sent after update: ");
11654 vty_out(vty
, "No\n");
11659 vty_out(vty
, " End-of-RIB received: ");
11661 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11662 PEER_STATUS_EOR_RECEIVED
)) {
11664 json_object_boolean_true_add(
11665 json_endofrib_status
, "endOfRibRecv");
11667 vty_out(vty
, "Yes\n");
11670 json_object_boolean_false_add(
11671 json_endofrib_status
, "endOfRibRecv");
11673 vty_out(vty
, "No\n");
11677 json_object_int_add(json_timer
, "stalePathTimer",
11678 peer
->bgp
->stalepath_time
);
11680 if (peer
->t_gr_stale
!= NULL
) {
11681 json_object_int_add(json_timer
,
11682 "stalePathTimerRemaining",
11683 thread_timer_remain_second(
11684 peer
->t_gr_stale
));
11687 /* Display Configured Selection
11688 * Deferral only when when
11689 * Gr mode is enabled.
11691 if (CHECK_FLAG(peer
->flags
,
11692 PEER_FLAG_GRACEFUL_RESTART
)) {
11693 json_object_int_add(json_timer
,
11694 "selectionDeferralTimer",
11695 peer
->bgp
->stalepath_time
);
11698 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11701 json_object_int_add(
11703 "selectionDeferralTimerRemaining",
11704 thread_timer_remain_second(
11705 peer
->bgp
->gr_info
[afi
][safi
]
11706 .t_select_deferral
));
11709 vty_out(vty
, " Timers:\n");
11711 " Configured Stale Path Time(sec): %u\n",
11712 peer
->bgp
->stalepath_time
);
11714 if (peer
->t_gr_stale
!= NULL
)
11716 " Stale Path Remaining(sec): %ld\n",
11717 thread_timer_remain_second(
11718 peer
->t_gr_stale
));
11719 /* Display Configured Selection
11720 * Deferral only when when
11721 * Gr mode is enabled.
11723 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11725 " Configured Selection Deferral Time(sec): %u\n",
11726 peer
->bgp
->select_defer_time
);
11728 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11731 " Selection Deferral Time Remaining(sec): %ld\n",
11732 thread_timer_remain_second(
11733 peer
->bgp
->gr_info
[afi
][safi
]
11734 .t_select_deferral
));
11737 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11738 json_endofrib_status
);
11739 json_object_object_add(json_afi_safi
, "timers",
11741 json_object_object_add(
11742 json
, get_afi_safi_str(afi
, safi
, true),
11748 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11754 json_object
*json_timer
= NULL
;
11756 json_timer
= json_object_new_object();
11758 json_object_int_add(json_timer
, "configuredRestartTimer",
11759 p
->bgp
->restart_time
);
11761 json_object_int_add(json_timer
, "receivedRestartTimer",
11764 if (p
->t_gr_restart
!= NULL
)
11765 json_object_int_add(
11766 json_timer
, "restartTimerRemaining",
11767 thread_timer_remain_second(p
->t_gr_restart
));
11769 json_object_object_add(json
, "timers", json_timer
);
11772 vty_out(vty
, " Timers:\n");
11773 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11774 p
->bgp
->restart_time
);
11776 vty_out(vty
, " Received Restart Time(sec): %u\n",
11778 if (p
->t_gr_restart
!= NULL
)
11779 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11780 thread_timer_remain_second(p
->t_gr_restart
));
11781 if (p
->t_gr_restart
!= NULL
) {
11782 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11783 thread_timer_remain_second(p
->t_gr_restart
));
11788 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11789 bool use_json
, json_object
*json
)
11791 char dn_flag
[2] = {0};
11792 /* '*' + v6 address of neighbor */
11793 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11795 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11800 json_object_string_addf(json
, "neighborAddr", "%pSU",
11803 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11806 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11810 json_object_string_add(json
, "neighborAddr",
11813 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11816 /* more gr info in new format */
11817 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11820 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11821 safi_t safi
, bool use_json
,
11822 json_object
*json_neigh
)
11824 struct bgp_filter
*filter
;
11825 struct peer_af
*paf
;
11826 char orf_pfx_name
[BUFSIZ
];
11828 json_object
*json_af
= NULL
;
11829 json_object
*json_prefA
= NULL
;
11830 json_object
*json_prefB
= NULL
;
11831 json_object
*json_addr
= NULL
;
11832 json_object
*json_advmap
= NULL
;
11835 json_addr
= json_object_new_object();
11836 json_af
= json_object_new_object();
11837 filter
= &p
->filter
[afi
][safi
];
11839 if (peer_group_active(p
))
11840 json_object_string_add(json_addr
, "peerGroupMember",
11843 paf
= peer_af_find(p
, afi
, safi
);
11844 if (paf
&& PAF_SUBGRP(paf
)) {
11845 json_object_int_add(json_addr
, "updateGroupId",
11846 PAF_UPDGRP(paf
)->id
);
11847 json_object_int_add(json_addr
, "subGroupId",
11848 PAF_SUBGRP(paf
)->id
);
11849 json_object_int_add(json_addr
, "packetQueueLength",
11850 bpacket_queue_virtual_length(paf
));
11853 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11854 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11855 PEER_CAP_ORF_PREFIX_SM_RCV
)
11856 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11857 PEER_CAP_ORF_PREFIX_RM_ADV
)
11858 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11859 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11860 json_object_int_add(json_af
, "orfType",
11862 json_prefA
= json_object_new_object();
11863 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11864 PEER_CAP_ORF_PREFIX_SM_ADV
,
11865 PEER_CAP_ORF_PREFIX_RM_ADV
,
11866 PEER_CAP_ORF_PREFIX_SM_RCV
,
11867 PEER_CAP_ORF_PREFIX_RM_RCV
,
11868 use_json
, json_prefA
);
11869 json_object_object_add(json_af
, "orfPrefixList",
11873 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11874 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11875 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11876 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11877 PEER_CAP_ORF_PREFIX_RM_ADV
)
11878 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11879 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11880 json_object_int_add(json_af
, "orfOldType",
11881 ORF_TYPE_PREFIX_OLD
);
11882 json_prefB
= json_object_new_object();
11883 bgp_show_peer_afi_orf_cap(
11884 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11885 PEER_CAP_ORF_PREFIX_RM_ADV
,
11886 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11887 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11889 json_object_object_add(json_af
, "orfOldPrefixList",
11893 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11894 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11895 PEER_CAP_ORF_PREFIX_SM_RCV
)
11896 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11897 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11898 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11899 PEER_CAP_ORF_PREFIX_RM_ADV
)
11900 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11901 PEER_CAP_ORF_PREFIX_RM_RCV
)
11902 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11903 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11904 json_object_object_add(json_addr
, "afDependentCap",
11907 json_object_free(json_af
);
11909 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11910 p
->host
, afi
, safi
);
11911 orf_pfx_count
= prefix_bgp_show_prefix_list(
11912 NULL
, afi
, orf_pfx_name
, use_json
);
11914 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11915 PEER_STATUS_ORF_PREFIX_SEND
)
11916 || orf_pfx_count
) {
11917 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11918 PEER_STATUS_ORF_PREFIX_SEND
))
11919 json_object_boolean_true_add(json_neigh
,
11922 json_object_int_add(json_addr
, "orfRecvCounter",
11925 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11926 PEER_STATUS_ORF_WAIT_REFRESH
))
11927 json_object_string_add(
11928 json_addr
, "orfFirstUpdate",
11929 "deferredUntilORFOrRouteRefreshRecvd");
11931 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11932 PEER_FLAG_REFLECTOR_CLIENT
))
11933 json_object_boolean_true_add(json_addr
,
11934 "routeReflectorClient");
11935 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11936 PEER_FLAG_RSERVER_CLIENT
))
11937 json_object_boolean_true_add(json_addr
,
11938 "routeServerClient");
11939 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11940 json_object_boolean_true_add(json_addr
,
11941 "inboundSoftConfigPermit");
11943 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11944 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11945 json_object_boolean_true_add(
11947 "privateAsNumsAllReplacedInUpdatesToNbr");
11948 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11949 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11950 json_object_boolean_true_add(
11952 "privateAsNumsReplacedInUpdatesToNbr");
11953 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11954 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11955 json_object_boolean_true_add(
11957 "privateAsNumsAllRemovedInUpdatesToNbr");
11958 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11959 PEER_FLAG_REMOVE_PRIVATE_AS
))
11960 json_object_boolean_true_add(
11962 "privateAsNumsRemovedInUpdatesToNbr");
11964 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11965 json_object_boolean_true_add(
11967 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11970 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11971 json_object_string_add(json_addr
,
11972 "overrideASNsInOutboundUpdates",
11973 "ifAspathEqualRemoteAs");
11975 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11976 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11977 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11978 json_object_boolean_true_add(json_addr
,
11979 "routerAlwaysNextHop");
11980 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11981 PEER_FLAG_AS_PATH_UNCHANGED
))
11982 json_object_boolean_true_add(
11983 json_addr
, "unchangedAsPathPropogatedToNbr");
11984 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11985 PEER_FLAG_NEXTHOP_UNCHANGED
))
11986 json_object_boolean_true_add(
11987 json_addr
, "unchangedNextHopPropogatedToNbr");
11988 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11989 json_object_boolean_true_add(
11990 json_addr
, "unchangedMedPropogatedToNbr");
11991 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11992 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11993 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11994 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11995 PEER_FLAG_SEND_COMMUNITY
)
11996 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11997 PEER_FLAG_SEND_EXT_COMMUNITY
))
11998 json_object_string_add(json_addr
,
11999 "commAttriSentToNbr",
12000 "extendedAndStandard");
12001 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12002 PEER_FLAG_SEND_EXT_COMMUNITY
))
12003 json_object_string_add(json_addr
,
12004 "commAttriSentToNbr",
12007 json_object_string_add(json_addr
,
12008 "commAttriSentToNbr",
12011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12012 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12013 if (p
->default_rmap
[afi
][safi
].name
)
12014 json_object_string_add(
12015 json_addr
, "defaultRouteMap",
12016 p
->default_rmap
[afi
][safi
].name
);
12018 if (paf
&& PAF_SUBGRP(paf
)
12019 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12020 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12021 json_object_boolean_true_add(json_addr
,
12024 json_object_boolean_true_add(json_addr
,
12028 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12029 if (is_evpn_enabled())
12030 json_object_boolean_true_add(
12031 json_addr
, "advertiseAllVnis");
12034 if (filter
->plist
[FILTER_IN
].name
12035 || filter
->dlist
[FILTER_IN
].name
12036 || filter
->aslist
[FILTER_IN
].name
12037 || filter
->map
[RMAP_IN
].name
)
12038 json_object_boolean_true_add(json_addr
,
12039 "inboundPathPolicyConfig");
12040 if (filter
->plist
[FILTER_OUT
].name
12041 || filter
->dlist
[FILTER_OUT
].name
12042 || filter
->aslist
[FILTER_OUT
].name
12043 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12044 json_object_boolean_true_add(
12045 json_addr
, "outboundPathPolicyConfig");
12048 if (filter
->plist
[FILTER_IN
].name
)
12049 json_object_string_add(json_addr
,
12050 "incomingUpdatePrefixFilterList",
12051 filter
->plist
[FILTER_IN
].name
);
12052 if (filter
->plist
[FILTER_OUT
].name
)
12053 json_object_string_add(json_addr
,
12054 "outgoingUpdatePrefixFilterList",
12055 filter
->plist
[FILTER_OUT
].name
);
12057 /* distribute-list */
12058 if (filter
->dlist
[FILTER_IN
].name
)
12059 json_object_string_add(
12060 json_addr
, "incomingUpdateNetworkFilterList",
12061 filter
->dlist
[FILTER_IN
].name
);
12062 if (filter
->dlist
[FILTER_OUT
].name
)
12063 json_object_string_add(
12064 json_addr
, "outgoingUpdateNetworkFilterList",
12065 filter
->dlist
[FILTER_OUT
].name
);
12068 if (filter
->aslist
[FILTER_IN
].name
)
12069 json_object_string_add(json_addr
,
12070 "incomingUpdateAsPathFilterList",
12071 filter
->aslist
[FILTER_IN
].name
);
12072 if (filter
->aslist
[FILTER_OUT
].name
)
12073 json_object_string_add(json_addr
,
12074 "outgoingUpdateAsPathFilterList",
12075 filter
->aslist
[FILTER_OUT
].name
);
12078 if (filter
->map
[RMAP_IN
].name
)
12079 json_object_string_add(
12080 json_addr
, "routeMapForIncomingAdvertisements",
12081 filter
->map
[RMAP_IN
].name
);
12082 if (filter
->map
[RMAP_OUT
].name
)
12083 json_object_string_add(
12084 json_addr
, "routeMapForOutgoingAdvertisements",
12085 filter
->map
[RMAP_OUT
].name
);
12087 /* ebgp-requires-policy (inbound) */
12088 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12089 && !bgp_inbound_policy_exists(p
, filter
))
12090 json_object_string_add(
12091 json_addr
, "inboundEbgpRequiresPolicy",
12092 "Inbound updates discarded due to missing policy");
12094 /* ebgp-requires-policy (outbound) */
12095 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12096 && (!bgp_outbound_policy_exists(p
, filter
)))
12097 json_object_string_add(
12098 json_addr
, "outboundEbgpRequiresPolicy",
12099 "Outbound updates discarded due to missing policy");
12101 /* unsuppress-map */
12102 if (filter
->usmap
.name
)
12103 json_object_string_add(json_addr
,
12104 "selectiveUnsuppressRouteMap",
12105 filter
->usmap
.name
);
12107 /* advertise-map */
12108 if (filter
->advmap
.aname
) {
12109 json_advmap
= json_object_new_object();
12110 json_object_string_add(json_advmap
, "condition",
12111 filter
->advmap
.condition
12114 json_object_string_add(json_advmap
, "conditionMap",
12115 filter
->advmap
.cname
);
12116 json_object_string_add(json_advmap
, "advertiseMap",
12117 filter
->advmap
.aname
);
12118 json_object_string_add(
12119 json_advmap
, "advertiseStatus",
12120 filter
->advmap
.update_type
==
12121 UPDATE_TYPE_ADVERTISE
12124 json_object_object_add(json_addr
, "advertiseMap",
12128 /* Receive prefix count */
12129 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12130 p
->pcount
[afi
][safi
]);
12131 if (paf
&& PAF_SUBGRP(paf
))
12132 json_object_int_add(json_addr
, "sentPrefixCounter",
12133 (PAF_SUBGRP(paf
))->scount
);
12135 /* Maximum prefix */
12136 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12137 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12138 p
->pmax_out
[afi
][safi
]);
12140 /* Maximum prefix */
12141 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12142 json_object_int_add(json_addr
, "prefixAllowedMax",
12143 p
->pmax
[afi
][safi
]);
12144 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12145 PEER_FLAG_MAX_PREFIX_WARNING
))
12146 json_object_boolean_true_add(
12147 json_addr
, "prefixAllowedMaxWarning");
12148 json_object_int_add(json_addr
,
12149 "prefixAllowedWarningThresh",
12150 p
->pmax_threshold
[afi
][safi
]);
12151 if (p
->pmax_restart
[afi
][safi
])
12152 json_object_int_add(
12154 "prefixAllowedRestartIntervalMsecs",
12155 p
->pmax_restart
[afi
][safi
] * 60000);
12157 json_object_object_add(json_neigh
,
12158 get_afi_safi_str(afi
, safi
, true),
12162 filter
= &p
->filter
[afi
][safi
];
12164 vty_out(vty
, " For address family: %s\n",
12165 get_afi_safi_str(afi
, safi
, false));
12167 if (peer_group_active(p
))
12168 vty_out(vty
, " %s peer-group member\n",
12171 paf
= peer_af_find(p
, afi
, safi
);
12172 if (paf
&& PAF_SUBGRP(paf
)) {
12173 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12174 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12175 vty_out(vty
, " Packet Queue length %d\n",
12176 bpacket_queue_virtual_length(paf
));
12178 vty_out(vty
, " Not part of any update group\n");
12180 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12181 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12182 PEER_CAP_ORF_PREFIX_SM_RCV
)
12183 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12184 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12185 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12186 PEER_CAP_ORF_PREFIX_RM_ADV
)
12187 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12188 PEER_CAP_ORF_PREFIX_RM_RCV
)
12189 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12190 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12191 vty_out(vty
, " AF-dependant capabilities:\n");
12193 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12194 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12195 PEER_CAP_ORF_PREFIX_SM_RCV
)
12196 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12197 PEER_CAP_ORF_PREFIX_RM_ADV
)
12198 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12199 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12201 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12203 bgp_show_peer_afi_orf_cap(
12204 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12205 PEER_CAP_ORF_PREFIX_RM_ADV
,
12206 PEER_CAP_ORF_PREFIX_SM_RCV
,
12207 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12209 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12210 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12211 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12212 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12213 PEER_CAP_ORF_PREFIX_RM_ADV
)
12214 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12215 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12217 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12218 ORF_TYPE_PREFIX_OLD
);
12219 bgp_show_peer_afi_orf_cap(
12220 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12221 PEER_CAP_ORF_PREFIX_RM_ADV
,
12222 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12223 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12226 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12227 p
->host
, afi
, safi
);
12228 orf_pfx_count
= prefix_bgp_show_prefix_list(
12229 NULL
, afi
, orf_pfx_name
, use_json
);
12231 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12232 PEER_STATUS_ORF_PREFIX_SEND
)
12233 || orf_pfx_count
) {
12234 vty_out(vty
, " Outbound Route Filter (ORF):");
12235 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12236 PEER_STATUS_ORF_PREFIX_SEND
))
12237 vty_out(vty
, " sent;");
12239 vty_out(vty
, " received (%d entries)",
12241 vty_out(vty
, "\n");
12243 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12244 PEER_STATUS_ORF_WAIT_REFRESH
))
12246 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12248 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12249 PEER_FLAG_REFLECTOR_CLIENT
))
12250 vty_out(vty
, " Route-Reflector Client\n");
12251 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12252 PEER_FLAG_RSERVER_CLIENT
))
12253 vty_out(vty
, " Route-Server Client\n");
12254 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12256 " Inbound soft reconfiguration allowed\n");
12258 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12259 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12261 " Private AS numbers (all) replaced in updates to this neighbor\n");
12262 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12263 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12265 " Private AS numbers replaced in updates to this neighbor\n");
12266 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12267 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12269 " Private AS numbers (all) removed in updates to this neighbor\n");
12270 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12271 PEER_FLAG_REMOVE_PRIVATE_AS
))
12273 " Private AS numbers removed in updates to this neighbor\n");
12275 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12276 vty_out(vty
, " %s\n",
12277 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12278 ->human_description
);
12280 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12282 " Override ASNs in outbound updates if aspath equals remote-as\n");
12284 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12285 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12286 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12287 vty_out(vty
, " NEXT_HOP is always this router\n");
12288 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12289 PEER_FLAG_AS_PATH_UNCHANGED
))
12291 " AS_PATH is propagated unchanged to this neighbor\n");
12292 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12293 PEER_FLAG_NEXTHOP_UNCHANGED
))
12295 " NEXT_HOP is propagated unchanged to this neighbor\n");
12296 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12298 " MED is propagated unchanged to this neighbor\n");
12299 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12300 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12301 PEER_FLAG_SEND_EXT_COMMUNITY
)
12302 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12303 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12305 " Community attribute sent to this neighbor");
12306 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12307 PEER_FLAG_SEND_COMMUNITY
)
12308 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12309 PEER_FLAG_SEND_EXT_COMMUNITY
)
12310 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12311 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12312 vty_out(vty
, "(all)\n");
12313 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12314 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12315 vty_out(vty
, "(large)\n");
12316 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12317 PEER_FLAG_SEND_EXT_COMMUNITY
))
12318 vty_out(vty
, "(extended)\n");
12320 vty_out(vty
, "(standard)\n");
12322 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12323 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12324 vty_out(vty
, " Default information originate,");
12326 if (p
->default_rmap
[afi
][safi
].name
)
12327 vty_out(vty
, " default route-map %s%s,",
12328 p
->default_rmap
[afi
][safi
].map
? "*"
12330 p
->default_rmap
[afi
][safi
].name
);
12331 if (paf
&& PAF_SUBGRP(paf
)
12332 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12333 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12334 vty_out(vty
, " default sent\n");
12336 vty_out(vty
, " default not sent\n");
12339 /* advertise-vni-all */
12340 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12341 if (is_evpn_enabled())
12342 vty_out(vty
, " advertise-all-vni\n");
12345 if (filter
->plist
[FILTER_IN
].name
12346 || filter
->dlist
[FILTER_IN
].name
12347 || filter
->aslist
[FILTER_IN
].name
12348 || filter
->map
[RMAP_IN
].name
)
12349 vty_out(vty
, " Inbound path policy configured\n");
12350 if (filter
->plist
[FILTER_OUT
].name
12351 || filter
->dlist
[FILTER_OUT
].name
12352 || filter
->aslist
[FILTER_OUT
].name
12353 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12354 vty_out(vty
, " Outbound path policy configured\n");
12357 if (filter
->plist
[FILTER_IN
].name
)
12359 " Incoming update prefix filter list is %s%s\n",
12360 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12361 filter
->plist
[FILTER_IN
].name
);
12362 if (filter
->plist
[FILTER_OUT
].name
)
12364 " Outgoing update prefix filter list is %s%s\n",
12365 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12366 filter
->plist
[FILTER_OUT
].name
);
12368 /* distribute-list */
12369 if (filter
->dlist
[FILTER_IN
].name
)
12371 " Incoming update network filter list is %s%s\n",
12372 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12373 filter
->dlist
[FILTER_IN
].name
);
12374 if (filter
->dlist
[FILTER_OUT
].name
)
12376 " Outgoing update network filter list is %s%s\n",
12377 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12378 filter
->dlist
[FILTER_OUT
].name
);
12381 if (filter
->aslist
[FILTER_IN
].name
)
12383 " Incoming update AS path filter list is %s%s\n",
12384 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12385 filter
->aslist
[FILTER_IN
].name
);
12386 if (filter
->aslist
[FILTER_OUT
].name
)
12388 " Outgoing update AS path filter list is %s%s\n",
12389 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12390 filter
->aslist
[FILTER_OUT
].name
);
12393 if (filter
->map
[RMAP_IN
].name
)
12395 " Route map for incoming advertisements is %s%s\n",
12396 filter
->map
[RMAP_IN
].map
? "*" : "",
12397 filter
->map
[RMAP_IN
].name
);
12398 if (filter
->map
[RMAP_OUT
].name
)
12400 " Route map for outgoing advertisements is %s%s\n",
12401 filter
->map
[RMAP_OUT
].map
? "*" : "",
12402 filter
->map
[RMAP_OUT
].name
);
12404 /* ebgp-requires-policy (inbound) */
12405 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12406 && !bgp_inbound_policy_exists(p
, filter
))
12408 " Inbound updates discarded due to missing policy\n");
12410 /* ebgp-requires-policy (outbound) */
12411 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12412 && !bgp_outbound_policy_exists(p
, filter
))
12414 " Outbound updates discarded due to missing policy\n");
12416 /* unsuppress-map */
12417 if (filter
->usmap
.name
)
12419 " Route map for selective unsuppress is %s%s\n",
12420 filter
->usmap
.map
? "*" : "",
12421 filter
->usmap
.name
);
12423 /* advertise-map */
12424 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12426 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12427 filter
->advmap
.condition
? "EXIST"
12429 filter
->advmap
.cmap
? "*" : "",
12430 filter
->advmap
.cname
,
12431 filter
->advmap
.amap
? "*" : "",
12432 filter
->advmap
.aname
,
12433 filter
->advmap
.update_type
==
12434 UPDATE_TYPE_ADVERTISE
12438 /* Receive prefix count */
12439 vty_out(vty
, " %u accepted prefixes\n",
12440 p
->pcount
[afi
][safi
]);
12442 /* maximum-prefix-out */
12443 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12444 PEER_FLAG_MAX_PREFIX_OUT
))
12446 " Maximum allowed prefixes sent %u\n",
12447 p
->pmax_out
[afi
][safi
]);
12449 /* Maximum prefix */
12450 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12452 " Maximum prefixes allowed %u%s\n",
12453 p
->pmax
[afi
][safi
],
12454 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12455 PEER_FLAG_MAX_PREFIX_WARNING
)
12456 ? " (warning-only)"
12458 vty_out(vty
, " Threshold for warning message %d%%",
12459 p
->pmax_threshold
[afi
][safi
]);
12460 if (p
->pmax_restart
[afi
][safi
])
12461 vty_out(vty
, ", restart interval %d min",
12462 p
->pmax_restart
[afi
][safi
]);
12463 vty_out(vty
, "\n");
12466 vty_out(vty
, "\n");
12470 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12474 char buf1
[PREFIX2STR_BUFFER
];
12475 char timebuf
[BGP_UPTIME_LEN
];
12481 json_object
*json_neigh
= NULL
;
12483 uint32_t sync_tcp_mss
;
12488 json_neigh
= json_object_new_object();
12490 memset(dn_flag
, '\0', sizeof(dn_flag
));
12491 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12495 if (p
->conf_if
) /* Configured interface name. */
12496 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12498 else /* Configured IP address. */
12499 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12504 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12505 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12507 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12508 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12511 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12513 if (p
->change_local_as
)
12514 json_object_int_add(json_neigh
, "localAs",
12515 p
->change_local_as
);
12517 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12519 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12520 json_object_boolean_true_add(json_neigh
,
12521 "localAsNoPrepend");
12523 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12524 json_object_boolean_true_add(json_neigh
,
12525 "localAsReplaceAs");
12527 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12528 || (p
->as_type
== AS_INTERNAL
))
12529 vty_out(vty
, "remote AS %u, ", p
->as
);
12531 vty_out(vty
, "remote AS Unspecified, ");
12532 vty_out(vty
, "local AS %u%s%s, ",
12533 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12534 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12537 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12541 /* peer type internal or confed-internal */
12542 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12544 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12545 json_object_boolean_true_add(
12546 json_neigh
, "nbrConfedInternalLink");
12548 json_object_boolean_true_add(json_neigh
,
12549 "nbrInternalLink");
12551 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12552 vty_out(vty
, "confed-internal link\n");
12554 vty_out(vty
, "internal link\n");
12556 /* peer type external or confed-external */
12557 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12559 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12560 json_object_boolean_true_add(
12561 json_neigh
, "nbrConfedExternalLink");
12563 json_object_boolean_true_add(json_neigh
,
12564 "nbrExternalLink");
12566 if (bgp_confederation_peers_check(bgp
, p
->as
))
12567 vty_out(vty
, "confed-external link\n");
12569 vty_out(vty
, "external link\n");
12573 json_object_boolean_true_add(json_neigh
,
12574 "nbrUnspecifiedLink");
12576 vty_out(vty
, "unspecified link\n");
12581 json_object_string_add(json_neigh
, "localRole",
12582 bgp_get_name_by_role(p
->local_role
));
12583 json_object_string_add(json_neigh
, "remoteRole",
12584 bgp_get_name_by_role(p
->remote_role
));
12586 vty_out(vty
, " Local Role: %s\n",
12587 bgp_get_name_by_role(p
->local_role
));
12588 vty_out(vty
, " Remote Role: %s\n",
12589 bgp_get_name_by_role(p
->remote_role
));
12596 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12598 vty_out(vty
, " Description: %s\n", p
->desc
);
12604 json_object_string_add(json_neigh
, "hostname",
12608 json_object_string_add(json_neigh
, "domainname",
12611 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12612 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12615 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12622 json_object_string_add(json_neigh
, "peerGroup",
12626 struct prefix prefix
, *range
= NULL
;
12628 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12629 range
= peer_group_lookup_dynamic_neighbor_range(
12630 p
->group
, &prefix
);
12633 json_object_string_addf(
12635 "peerSubnetRangeGroup", "%pFX",
12641 " Member of peer-group %s for session parameters\n",
12645 struct prefix prefix
, *range
= NULL
;
12647 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12648 range
= peer_group_lookup_dynamic_neighbor_range(
12649 p
->group
, &prefix
);
12653 " Belongs to the subnet range group: %pFX\n",
12661 /* Administrative shutdown. */
12662 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12663 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12664 json_object_boolean_true_add(json_neigh
,
12668 json_object_int_add(json_neigh
, "bgpVersion", 4);
12669 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12671 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12674 /* Confederation */
12675 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12676 && bgp_confederation_peers_check(bgp
, p
->as
))
12677 json_object_boolean_true_add(json_neigh
,
12681 json_object_string_add(
12682 json_neigh
, "bgpState",
12683 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12685 if (peer_established(p
)) {
12688 uptime
= bgp_clock();
12689 uptime
-= p
->uptime
;
12690 epoch_tbuf
= time(NULL
) - uptime
;
12692 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12694 json_object_string_add(json_neigh
, "bgpTimerUpString",
12695 peer_uptime(p
->uptime
, timebuf
,
12698 json_object_int_add(json_neigh
,
12699 "bgpTimerUpEstablishedEpoch",
12703 else if (p
->status
== Active
) {
12704 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12705 json_object_string_add(json_neigh
, "bgpStateIs",
12707 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12708 json_object_string_add(json_neigh
, "bgpStateIs",
12716 uptime
= bgp_clock();
12717 uptime
-= p
->readtime
;
12718 gmtime_r(&uptime
, &tm
);
12720 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12721 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12722 + (tm
.tm_hour
* 3600000));
12724 uptime
= bgp_clock();
12725 uptime
-= p
->last_write
;
12726 gmtime_r(&uptime
, &tm
);
12728 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12729 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12730 + (tm
.tm_hour
* 3600000));
12732 uptime
= bgp_clock();
12733 uptime
-= p
->update_time
;
12734 gmtime_r(&uptime
, &tm
);
12736 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12737 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12738 + (tm
.tm_hour
* 3600000));
12740 /* Configured timer values. */
12741 json_object_int_add(json_neigh
,
12742 "bgpTimerConfiguredHoldTimeMsecs",
12743 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12744 ? p
->holdtime
* 1000
12745 : bgp
->default_holdtime
* 1000);
12746 json_object_int_add(json_neigh
,
12747 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12748 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12749 ? p
->keepalive
* 1000
12750 : bgp
->default_keepalive
* 1000);
12751 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12752 p
->v_holdtime
* 1000);
12753 json_object_int_add(json_neigh
,
12754 "bgpTimerKeepAliveIntervalMsecs",
12755 p
->v_keepalive
* 1000);
12756 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12757 json_object_int_add(json_neigh
,
12758 "bgpTimerDelayOpenTimeMsecs",
12759 p
->v_delayopen
* 1000);
12762 /* Configured and Synced tcp-mss value for peer */
12763 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12764 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12765 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12767 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12771 /* Extended Optional Parameters Length for BGP OPEN Message */
12772 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12773 json_object_boolean_true_add(
12774 json_neigh
, "extendedOptionalParametersLength");
12776 json_object_boolean_false_add(
12777 json_neigh
, "extendedOptionalParametersLength");
12779 /* Conditional advertisements */
12780 json_object_int_add(
12782 "bgpTimerConfiguredConditionalAdvertisementsSec",
12783 bgp
->condition_check_period
);
12784 if (thread_is_scheduled(bgp
->t_condition_check
))
12785 json_object_int_add(
12787 "bgpTimerUntilConditionalAdvertisementsSec",
12788 thread_timer_remain_second(
12789 bgp
->t_condition_check
));
12791 /* Administrative shutdown. */
12792 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12793 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12794 vty_out(vty
, " Administratively shut down\n");
12797 vty_out(vty
, " BGP version 4");
12798 vty_out(vty
, ", remote router ID %s",
12799 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12800 vty_out(vty
, ", local router ID %s\n",
12801 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12804 /* Confederation */
12805 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12806 && bgp_confederation_peers_check(bgp
, p
->as
))
12808 " Neighbor under common administration\n");
12811 vty_out(vty
, " BGP state = %s",
12812 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12814 if (peer_established(p
))
12815 vty_out(vty
, ", up for %8s",
12816 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12819 else if (p
->status
== Active
) {
12820 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12821 vty_out(vty
, " (passive)");
12822 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12823 vty_out(vty
, " (NSF passive)");
12825 vty_out(vty
, "\n");
12828 vty_out(vty
, " Last read %s",
12829 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12831 vty_out(vty
, ", Last write %s\n",
12832 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12835 /* Configured timer values. */
12837 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12838 p
->v_holdtime
, p
->v_keepalive
);
12839 vty_out(vty
, " Configured hold time is %d seconds",
12840 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12842 : bgp
->default_holdtime
);
12843 vty_out(vty
, ", keepalive interval is %d seconds\n",
12844 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12846 : bgp
->default_keepalive
);
12847 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12849 " Configured DelayOpenTime is %d seconds\n",
12852 /* Configured and synced tcp-mss value for peer */
12853 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12854 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12855 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12856 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12859 /* Extended Optional Parameters Length for BGP OPEN Message */
12860 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12862 " Extended Optional Parameters Length is enabled\n");
12864 /* Conditional advertisements */
12866 " Configured conditional advertisements interval is %d seconds\n",
12867 bgp
->condition_check_period
);
12868 if (thread_is_scheduled(bgp
->t_condition_check
))
12870 " Time until conditional advertisements begin is %lu seconds\n",
12871 thread_timer_remain_second(
12872 bgp
->t_condition_check
));
12875 if (peer_established(p
) &&
12876 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12878 json_object
*json_cap
= NULL
;
12880 json_cap
= json_object_new_object();
12883 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12884 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12885 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12886 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12887 json_object_string_add(
12888 json_cap
, "4byteAs",
12889 "advertisedAndReceived");
12890 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12891 json_object_string_add(json_cap
,
12894 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12895 json_object_string_add(json_cap
,
12900 /* Extended Message Support */
12901 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12902 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12903 json_object_string_add(json_cap
,
12905 "advertisedAndReceived");
12906 else if (CHECK_FLAG(p
->cap
,
12907 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12908 json_object_string_add(json_cap
,
12911 else if (CHECK_FLAG(p
->cap
,
12912 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12913 json_object_string_add(json_cap
,
12918 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12919 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12920 json_object
*json_add
= NULL
;
12921 const char *print_store
;
12923 json_add
= json_object_new_object();
12925 FOREACH_AFI_SAFI (afi
, safi
) {
12926 json_object
*json_sub
= NULL
;
12927 json_sub
= json_object_new_object();
12928 print_store
= get_afi_safi_str(
12932 p
->af_cap
[afi
][safi
],
12933 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12935 p
->af_cap
[afi
][safi
],
12936 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12940 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12944 PEER_CAP_ADDPATH_AF_TX_RCV
))
12945 json_object_boolean_true_add(
12947 "txAdvertisedAndReceived");
12952 PEER_CAP_ADDPATH_AF_TX_ADV
))
12953 json_object_boolean_true_add(
12960 PEER_CAP_ADDPATH_AF_TX_RCV
))
12961 json_object_boolean_true_add(
12967 p
->af_cap
[afi
][safi
],
12968 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12970 p
->af_cap
[afi
][safi
],
12971 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12975 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12979 PEER_CAP_ADDPATH_AF_RX_RCV
))
12980 json_object_boolean_true_add(
12982 "rxAdvertisedAndReceived");
12987 PEER_CAP_ADDPATH_AF_RX_ADV
))
12988 json_object_boolean_true_add(
12995 PEER_CAP_ADDPATH_AF_RX_RCV
))
12996 json_object_boolean_true_add(
13002 p
->af_cap
[afi
][safi
],
13003 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13005 p
->af_cap
[afi
][safi
],
13006 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13008 p
->af_cap
[afi
][safi
],
13009 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13011 p
->af_cap
[afi
][safi
],
13012 PEER_CAP_ADDPATH_AF_RX_RCV
))
13013 json_object_object_add(
13014 json_add
, print_store
,
13017 json_object_free(json_sub
);
13020 json_object_object_add(json_cap
, "addPath",
13025 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13026 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13027 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13028 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13029 json_object_string_add(
13030 json_cap
, "dynamic",
13031 "advertisedAndReceived");
13032 else if (CHECK_FLAG(p
->cap
,
13033 PEER_CAP_DYNAMIC_ADV
))
13034 json_object_string_add(json_cap
,
13037 else if (CHECK_FLAG(p
->cap
,
13038 PEER_CAP_DYNAMIC_RCV
))
13039 json_object_string_add(json_cap
,
13045 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13046 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13047 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13048 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13049 json_object_string_add(
13051 "advertisedAndReceived");
13052 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13053 json_object_string_add(json_cap
, "role",
13055 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13056 json_object_string_add(json_cap
, "role",
13060 /* Extended nexthop */
13061 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13062 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13063 json_object
*json_nxt
= NULL
;
13064 const char *print_store
;
13067 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13068 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13069 json_object_string_add(
13070 json_cap
, "extendedNexthop",
13071 "advertisedAndReceived");
13072 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13073 json_object_string_add(
13074 json_cap
, "extendedNexthop",
13076 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13077 json_object_string_add(
13078 json_cap
, "extendedNexthop",
13081 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13082 json_nxt
= json_object_new_object();
13084 for (safi
= SAFI_UNICAST
;
13085 safi
< SAFI_MAX
; safi
++) {
13089 PEER_CAP_ENHE_AF_RCV
)) {
13095 json_object_string_add(
13098 "recieved"); /* misspelled for compatibility */
13101 json_object_object_add(
13103 "extendedNexthopFamililesByPeer",
13108 /* Long-lived Graceful Restart */
13109 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13110 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13111 json_object
*json_llgr
= NULL
;
13112 const char *afi_safi_str
;
13114 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13115 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13116 json_object_string_add(
13118 "longLivedGracefulRestart",
13119 "advertisedAndReceived");
13120 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13121 json_object_string_add(
13123 "longLivedGracefulRestart",
13125 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13126 json_object_string_add(
13128 "longLivedGracefulRestart",
13131 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13132 json_llgr
= json_object_new_object();
13134 FOREACH_AFI_SAFI (afi
, safi
) {
13138 PEER_CAP_ENHE_AF_RCV
)) {
13144 json_object_string_add(
13150 json_object_object_add(
13152 "longLivedGracefulRestartByPeer",
13157 /* Route Refresh */
13158 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13159 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13160 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13161 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13162 (CHECK_FLAG(p
->cap
,
13163 PEER_CAP_REFRESH_NEW_RCV
) ||
13165 PEER_CAP_REFRESH_OLD_RCV
))) {
13168 PEER_CAP_REFRESH_OLD_RCV
) &&
13171 PEER_CAP_REFRESH_NEW_RCV
))
13172 json_object_string_add(
13175 "advertisedAndReceivedOldNew");
13179 PEER_CAP_REFRESH_OLD_RCV
))
13180 json_object_string_add(
13183 "advertisedAndReceivedOld");
13185 json_object_string_add(
13188 "advertisedAndReceivedNew");
13190 } else if (CHECK_FLAG(p
->cap
,
13191 PEER_CAP_REFRESH_ADV
))
13192 json_object_string_add(json_cap
,
13195 else if (CHECK_FLAG(p
->cap
,
13196 PEER_CAP_REFRESH_NEW_RCV
) ||
13198 PEER_CAP_REFRESH_OLD_RCV
))
13199 json_object_string_add(json_cap
,
13204 /* Enhanced Route Refresh */
13205 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13206 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13207 if (CHECK_FLAG(p
->cap
,
13208 PEER_CAP_ENHANCED_RR_ADV
) &&
13210 PEER_CAP_ENHANCED_RR_RCV
))
13211 json_object_string_add(
13213 "enhancedRouteRefresh",
13214 "advertisedAndReceived");
13215 else if (CHECK_FLAG(p
->cap
,
13216 PEER_CAP_ENHANCED_RR_ADV
))
13217 json_object_string_add(
13219 "enhancedRouteRefresh",
13221 else if (CHECK_FLAG(p
->cap
,
13222 PEER_CAP_ENHANCED_RR_RCV
))
13223 json_object_string_add(
13225 "enhancedRouteRefresh",
13229 /* Multiprotocol Extensions */
13230 json_object
*json_multi
= NULL
;
13232 json_multi
= json_object_new_object();
13234 FOREACH_AFI_SAFI (afi
, safi
) {
13235 if (p
->afc_adv
[afi
][safi
] ||
13236 p
->afc_recv
[afi
][safi
]) {
13237 json_object
*json_exten
= NULL
;
13238 json_exten
= json_object_new_object();
13240 if (p
->afc_adv
[afi
][safi
] &&
13241 p
->afc_recv
[afi
][safi
])
13242 json_object_boolean_true_add(
13244 "advertisedAndReceived");
13245 else if (p
->afc_adv
[afi
][safi
])
13246 json_object_boolean_true_add(
13249 else if (p
->afc_recv
[afi
][safi
])
13250 json_object_boolean_true_add(
13251 json_exten
, "received");
13253 json_object_object_add(
13255 get_afi_safi_str(afi
, safi
,
13260 json_object_object_add(json_cap
,
13261 "multiprotocolExtensions",
13264 /* Hostname capabilities */
13265 json_object
*json_hname
= NULL
;
13267 json_hname
= json_object_new_object();
13269 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13270 json_object_string_add(
13271 json_hname
, "advHostName",
13272 bgp
->peer_self
->hostname
13273 ? bgp
->peer_self
->hostname
13275 json_object_string_add(
13276 json_hname
, "advDomainName",
13277 bgp
->peer_self
->domainname
13278 ? bgp
->peer_self
->domainname
13283 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13284 json_object_string_add(
13285 json_hname
, "rcvHostName",
13286 p
->hostname
? p
->hostname
: "n/a");
13287 json_object_string_add(
13288 json_hname
, "rcvDomainName",
13289 p
->domainname
? p
->domainname
: "n/a");
13292 json_object_object_add(json_cap
, "hostName",
13295 /* Graceful Restart */
13296 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13297 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13298 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13299 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13300 json_object_string_add(
13301 json_cap
, "gracefulRestart",
13302 "advertisedAndReceived");
13303 else if (CHECK_FLAG(p
->cap
,
13304 PEER_CAP_RESTART_ADV
))
13305 json_object_string_add(
13307 "gracefulRestartCapability",
13309 else if (CHECK_FLAG(p
->cap
,
13310 PEER_CAP_RESTART_RCV
))
13311 json_object_string_add(
13313 "gracefulRestartCapability",
13316 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13317 int restart_af_count
= 0;
13318 json_object
*json_restart
= NULL
;
13319 json_restart
= json_object_new_object();
13321 json_object_int_add(
13323 "gracefulRestartRemoteTimerMsecs",
13324 p
->v_gr_restart
* 1000);
13326 FOREACH_AFI_SAFI (afi
, safi
) {
13330 PEER_CAP_RESTART_AF_RCV
)) {
13331 json_object
*json_sub
=
13334 json_object_new_object();
13340 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13341 json_object_boolean_true_add(
13344 restart_af_count
++;
13345 json_object_object_add(
13354 if (!restart_af_count
) {
13355 json_object_string_add(
13357 "addressFamiliesByPeer",
13359 json_object_free(json_restart
);
13361 json_object_object_add(
13363 "addressFamiliesByPeer",
13367 json_object_object_add(
13368 json_neigh
, "neighborCapabilities", json_cap
);
13370 vty_out(vty
, " Neighbor capabilities:\n");
13373 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13374 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13375 vty_out(vty
, " 4 Byte AS:");
13376 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13377 vty_out(vty
, " advertised");
13378 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13379 vty_out(vty
, " %sreceived",
13384 vty_out(vty
, "\n");
13387 /* Extended Message Support */
13388 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13389 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13390 vty_out(vty
, " Extended Message:");
13391 if (CHECK_FLAG(p
->cap
,
13392 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13393 vty_out(vty
, " advertised");
13394 if (CHECK_FLAG(p
->cap
,
13395 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13396 vty_out(vty
, " %sreceived",
13399 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13402 vty_out(vty
, "\n");
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13407 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13408 vty_out(vty
, " AddPath:\n");
13410 FOREACH_AFI_SAFI (afi
, safi
) {
13412 p
->af_cap
[afi
][safi
],
13413 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13415 p
->af_cap
[afi
][safi
],
13416 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13417 vty_out(vty
, " %s: TX ",
13425 PEER_CAP_ADDPATH_AF_TX_ADV
))
13432 PEER_CAP_ADDPATH_AF_TX_RCV
))
13439 PEER_CAP_ADDPATH_AF_TX_ADV
)
13443 vty_out(vty
, "\n");
13447 p
->af_cap
[afi
][safi
],
13448 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13450 p
->af_cap
[afi
][safi
],
13451 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13452 vty_out(vty
, " %s: RX ",
13460 PEER_CAP_ADDPATH_AF_RX_ADV
))
13467 PEER_CAP_ADDPATH_AF_RX_RCV
))
13474 PEER_CAP_ADDPATH_AF_RX_ADV
)
13478 vty_out(vty
, "\n");
13484 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13485 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13486 vty_out(vty
, " Dynamic:");
13487 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13488 vty_out(vty
, " advertised");
13489 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13490 vty_out(vty
, " %sreceived",
13492 PEER_CAP_DYNAMIC_ADV
)
13495 vty_out(vty
, "\n");
13499 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13500 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13501 vty_out(vty
, " Role:");
13502 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13503 vty_out(vty
, " advertised");
13504 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13505 vty_out(vty
, " %sreceived",
13510 vty_out(vty
, "\n");
13513 /* Extended nexthop */
13514 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13515 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13516 vty_out(vty
, " Extended nexthop:");
13517 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13518 vty_out(vty
, " advertised");
13519 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13520 vty_out(vty
, " %sreceived",
13525 vty_out(vty
, "\n");
13527 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13529 " Address families by peer:\n ");
13530 for (safi
= SAFI_UNICAST
;
13531 safi
< SAFI_MAX
; safi
++)
13535 PEER_CAP_ENHE_AF_RCV
))
13545 /* Long-lived Graceful Restart */
13546 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13547 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13549 " Long-lived Graceful Restart:");
13550 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13551 vty_out(vty
, " advertised");
13552 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13553 vty_out(vty
, " %sreceived",
13558 vty_out(vty
, "\n");
13560 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13562 " Address families by peer:\n");
13563 FOREACH_AFI_SAFI (afi
, safi
)
13567 PEER_CAP_LLGR_AF_RCV
))
13577 /* Route Refresh */
13578 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13579 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13580 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13581 vty_out(vty
, " Route refresh:");
13582 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13583 vty_out(vty
, " advertised");
13584 if (CHECK_FLAG(p
->cap
,
13585 PEER_CAP_REFRESH_NEW_RCV
) ||
13587 PEER_CAP_REFRESH_OLD_RCV
))
13588 vty_out(vty
, " %sreceived(%s)",
13590 PEER_CAP_REFRESH_ADV
)
13595 PEER_CAP_REFRESH_OLD_RCV
) &&
13598 PEER_CAP_REFRESH_NEW_RCV
))
13602 PEER_CAP_REFRESH_OLD_RCV
)
13606 vty_out(vty
, "\n");
13609 /* Enhanced Route Refresh */
13610 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13611 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13612 vty_out(vty
, " Enhanced Route Refresh:");
13613 if (CHECK_FLAG(p
->cap
,
13614 PEER_CAP_ENHANCED_RR_ADV
))
13615 vty_out(vty
, " advertised");
13616 if (CHECK_FLAG(p
->cap
,
13617 PEER_CAP_ENHANCED_RR_RCV
))
13618 vty_out(vty
, " %sreceived",
13620 PEER_CAP_REFRESH_ADV
)
13623 vty_out(vty
, "\n");
13626 /* Multiprotocol Extensions */
13627 FOREACH_AFI_SAFI (afi
, safi
)
13628 if (p
->afc_adv
[afi
][safi
] ||
13629 p
->afc_recv
[afi
][safi
]) {
13630 vty_out(vty
, " Address Family %s:",
13631 get_afi_safi_str(afi
, safi
,
13633 if (p
->afc_adv
[afi
][safi
])
13634 vty_out(vty
, " advertised");
13635 if (p
->afc_recv
[afi
][safi
])
13636 vty_out(vty
, " %sreceived",
13637 p
->afc_adv
[afi
][safi
]
13640 vty_out(vty
, "\n");
13643 /* Hostname capability */
13644 vty_out(vty
, " Hostname Capability:");
13646 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13648 " advertised (name: %s,domain name: %s)",
13649 bgp
->peer_self
->hostname
13650 ? bgp
->peer_self
->hostname
13652 bgp
->peer_self
->domainname
13653 ? bgp
->peer_self
->domainname
13656 vty_out(vty
, " not advertised");
13659 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13661 " received (name: %s,domain name: %s)",
13662 p
->hostname
? p
->hostname
: "n/a",
13663 p
->domainname
? p
->domainname
: "n/a");
13665 vty_out(vty
, " not received");
13668 vty_out(vty
, "\n");
13670 /* Graceful Restart */
13671 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13672 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13674 " Graceful Restart Capability:");
13675 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13676 vty_out(vty
, " advertised");
13677 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13678 vty_out(vty
, " %sreceived",
13680 PEER_CAP_RESTART_ADV
)
13683 vty_out(vty
, "\n");
13685 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13686 int restart_af_count
= 0;
13689 " Remote Restart timer is %d seconds\n",
13692 " Address families by peer:\n ");
13694 FOREACH_AFI_SAFI (afi
, safi
)
13698 PEER_CAP_RESTART_AF_RCV
)) {
13699 vty_out(vty
, "%s%s(%s)",
13711 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13713 : "not preserved");
13714 restart_af_count
++;
13716 if (!restart_af_count
)
13717 vty_out(vty
, "none");
13718 vty_out(vty
, "\n");
13720 } /* Graceful Restart */
13724 /* graceful restart information */
13725 json_object
*json_grace
= NULL
;
13726 json_object
*json_grace_send
= NULL
;
13727 json_object
*json_grace_recv
= NULL
;
13728 int eor_send_af_count
= 0;
13729 int eor_receive_af_count
= 0;
13732 json_grace
= json_object_new_object();
13733 json_grace_send
= json_object_new_object();
13734 json_grace_recv
= json_object_new_object();
13736 if ((peer_established(p
)) &&
13737 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13738 FOREACH_AFI_SAFI (afi
, safi
) {
13739 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13740 PEER_STATUS_EOR_SEND
)) {
13741 json_object_boolean_true_add(
13743 get_afi_safi_str(afi
, safi
,
13745 eor_send_af_count
++;
13748 FOREACH_AFI_SAFI (afi
, safi
) {
13749 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13750 PEER_STATUS_EOR_RECEIVED
)) {
13751 json_object_boolean_true_add(
13753 get_afi_safi_str(afi
, safi
,
13755 eor_receive_af_count
++;
13759 json_object_object_add(json_grace
, "endOfRibSend",
13761 json_object_object_add(json_grace
, "endOfRibRecv",
13765 if (p
->t_gr_restart
)
13766 json_object_int_add(
13767 json_grace
, "gracefulRestartTimerMsecs",
13768 thread_timer_remain_second(p
->t_gr_restart
) *
13772 json_object_int_add(
13773 json_grace
, "gracefulStalepathTimerMsecs",
13774 thread_timer_remain_second(p
->t_gr_stale
) *
13776 /* more gr info in new format */
13777 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13778 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13781 vty_out(vty
, " Graceful restart information:\n");
13782 if ((peer_established(p
)) &&
13783 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13785 vty_out(vty
, " End-of-RIB send: ");
13786 FOREACH_AFI_SAFI (afi
, safi
) {
13787 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13788 PEER_STATUS_EOR_SEND
)) {
13789 vty_out(vty
, "%s%s",
13790 eor_send_af_count
? ", " : "",
13791 get_afi_safi_str(afi
, safi
,
13793 eor_send_af_count
++;
13796 vty_out(vty
, "\n");
13797 vty_out(vty
, " End-of-RIB received: ");
13798 FOREACH_AFI_SAFI (afi
, safi
) {
13799 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13800 PEER_STATUS_EOR_RECEIVED
)) {
13801 vty_out(vty
, "%s%s",
13802 eor_receive_af_count
? ", "
13804 get_afi_safi_str(afi
, safi
,
13806 eor_receive_af_count
++;
13809 vty_out(vty
, "\n");
13812 if (p
->t_gr_restart
)
13814 " The remaining time of restart timer is %ld\n",
13815 thread_timer_remain_second(p
->t_gr_restart
));
13819 " The remaining time of stalepath timer is %ld\n",
13820 thread_timer_remain_second(p
->t_gr_stale
));
13822 /* more gr info in new format */
13823 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13827 json_object
*json_stat
= NULL
;
13828 json_stat
= json_object_new_object();
13829 /* Packet counts. */
13831 atomic_size_t outq_count
, inq_count
;
13832 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13833 memory_order_relaxed
);
13834 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13835 memory_order_relaxed
);
13837 json_object_int_add(json_stat
, "depthInq",
13838 (unsigned long)inq_count
);
13839 json_object_int_add(json_stat
, "depthOutq",
13840 (unsigned long)outq_count
);
13841 json_object_int_add(json_stat
, "opensSent",
13842 atomic_load_explicit(&p
->open_out
,
13843 memory_order_relaxed
));
13844 json_object_int_add(json_stat
, "opensRecv",
13845 atomic_load_explicit(&p
->open_in
,
13846 memory_order_relaxed
));
13847 json_object_int_add(json_stat
, "notificationsSent",
13848 atomic_load_explicit(&p
->notify_out
,
13849 memory_order_relaxed
));
13850 json_object_int_add(json_stat
, "notificationsRecv",
13851 atomic_load_explicit(&p
->notify_in
,
13852 memory_order_relaxed
));
13853 json_object_int_add(json_stat
, "updatesSent",
13854 atomic_load_explicit(&p
->update_out
,
13855 memory_order_relaxed
));
13856 json_object_int_add(json_stat
, "updatesRecv",
13857 atomic_load_explicit(&p
->update_in
,
13858 memory_order_relaxed
));
13859 json_object_int_add(json_stat
, "keepalivesSent",
13860 atomic_load_explicit(&p
->keepalive_out
,
13861 memory_order_relaxed
));
13862 json_object_int_add(json_stat
, "keepalivesRecv",
13863 atomic_load_explicit(&p
->keepalive_in
,
13864 memory_order_relaxed
));
13865 json_object_int_add(json_stat
, "routeRefreshSent",
13866 atomic_load_explicit(&p
->refresh_out
,
13867 memory_order_relaxed
));
13868 json_object_int_add(json_stat
, "routeRefreshRecv",
13869 atomic_load_explicit(&p
->refresh_in
,
13870 memory_order_relaxed
));
13871 json_object_int_add(json_stat
, "capabilitySent",
13872 atomic_load_explicit(&p
->dynamic_cap_out
,
13873 memory_order_relaxed
));
13874 json_object_int_add(json_stat
, "capabilityRecv",
13875 atomic_load_explicit(&p
->dynamic_cap_in
,
13876 memory_order_relaxed
));
13877 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13878 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13879 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13881 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13882 notify_out
, notify_in
, update_out
, update_in
,
13883 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13884 dynamic_cap_out
, dynamic_cap_in
;
13885 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13886 memory_order_relaxed
);
13887 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13888 memory_order_relaxed
);
13889 open_out
= atomic_load_explicit(&p
->open_out
,
13890 memory_order_relaxed
);
13892 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13893 notify_out
= atomic_load_explicit(&p
->notify_out
,
13894 memory_order_relaxed
);
13895 notify_in
= atomic_load_explicit(&p
->notify_in
,
13896 memory_order_relaxed
);
13897 update_out
= atomic_load_explicit(&p
->update_out
,
13898 memory_order_relaxed
);
13899 update_in
= atomic_load_explicit(&p
->update_in
,
13900 memory_order_relaxed
);
13901 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13902 memory_order_relaxed
);
13903 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13904 memory_order_relaxed
);
13905 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13906 memory_order_relaxed
);
13907 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13908 memory_order_relaxed
);
13909 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13910 memory_order_relaxed
);
13911 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13912 memory_order_relaxed
);
13914 /* Packet counts. */
13915 vty_out(vty
, " Message statistics:\n");
13916 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13917 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13918 vty_out(vty
, " Sent Rcvd\n");
13919 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13921 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13923 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13925 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13927 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13929 vty_out(vty
, " Capability: %10zu %10zu\n",
13930 dynamic_cap_out
, dynamic_cap_in
);
13931 vty_out(vty
, " Total: %10u %10u\n",
13932 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13936 /* advertisement-interval */
13937 json_object_int_add(json_neigh
,
13938 "minBtwnAdvertisementRunsTimerMsecs",
13939 p
->v_routeadv
* 1000);
13941 /* Update-source. */
13942 if (p
->update_if
|| p
->update_source
) {
13944 json_object_string_add(json_neigh
,
13947 else if (p
->update_source
)
13948 json_object_string_addf(json_neigh
,
13949 "updateSource", "%pSU",
13953 /* advertisement-interval */
13955 " Minimum time between advertisement runs is %d seconds\n",
13958 /* Update-source. */
13959 if (p
->update_if
|| p
->update_source
) {
13960 vty_out(vty
, " Update source is ");
13962 vty_out(vty
, "%s", p
->update_if
);
13963 else if (p
->update_source
)
13964 vty_out(vty
, "%pSU", p
->update_source
);
13965 vty_out(vty
, "\n");
13968 vty_out(vty
, "\n");
13971 /* Address Family Information */
13972 json_object
*json_hold
= NULL
;
13975 json_hold
= json_object_new_object();
13977 FOREACH_AFI_SAFI (afi
, safi
)
13978 if (p
->afc
[afi
][safi
])
13979 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13983 json_object_object_add(json_neigh
, "addressFamilyInfo",
13985 json_object_int_add(json_neigh
, "connectionsEstablished",
13987 json_object_int_add(json_neigh
, "connectionsDropped",
13990 vty_out(vty
, " Connections established %d; dropped %d\n",
13991 p
->established
, p
->dropped
);
13993 if (!p
->last_reset
) {
13995 json_object_string_add(json_neigh
, "lastReset",
13998 vty_out(vty
, " Last reset never\n");
14004 uptime
= bgp_clock();
14005 uptime
-= p
->resettime
;
14006 gmtime_r(&uptime
, &tm
);
14008 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14010 + (tm
.tm_min
* 60000)
14011 + (tm
.tm_hour
* 3600000));
14012 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14014 vty_out(vty
, " Last reset %s, ",
14015 peer_uptime(p
->resettime
, timebuf
,
14016 BGP_UPTIME_LEN
, 0, NULL
));
14018 bgp_show_peer_reset(vty
, p
, NULL
, false);
14019 if (p
->last_reset_cause_size
) {
14020 msg
= p
->last_reset_cause
;
14022 " Message received that caused BGP to send a NOTIFICATION:\n ");
14023 for (i
= 1; i
<= p
->last_reset_cause_size
;
14025 vty_out(vty
, "%02X", *msg
++);
14027 if (i
!= p
->last_reset_cause_size
) {
14029 vty_out(vty
, "\n ");
14030 } else if (i
% 4 == 0) {
14035 vty_out(vty
, "\n");
14040 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14042 json_object_boolean_true_add(json_neigh
,
14043 "prefixesConfigExceedMax");
14046 " Peer had exceeded the max. no. of prefixes configured.\n");
14048 if (p
->t_pmax_restart
) {
14050 json_object_boolean_true_add(
14051 json_neigh
, "reducePrefixNumFrom");
14052 json_object_int_add(json_neigh
,
14053 "restartInTimerMsec",
14054 thread_timer_remain_second(
14059 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14060 p
->host
, thread_timer_remain_second(
14061 p
->t_pmax_restart
));
14064 json_object_boolean_true_add(
14066 "reducePrefixNumAndClearIpBgp");
14069 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14074 /* EBGP Multihop and GTSM */
14075 if (p
->sort
!= BGP_PEER_IBGP
) {
14077 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14078 json_object_int_add(json_neigh
,
14079 "externalBgpNbrMaxHopsAway",
14082 json_object_int_add(json_neigh
,
14083 "externalBgpNbrMaxHopsAway",
14086 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14088 " External BGP neighbor may be up to %d hops away.\n",
14092 " External BGP neighbor may be up to %d hops away.\n",
14097 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14098 json_object_int_add(json_neigh
,
14099 "internalBgpNbrMaxHopsAway",
14102 json_object_int_add(json_neigh
,
14103 "internalBgpNbrMaxHopsAway",
14106 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14108 " Internal BGP neighbor may be up to %d hops away.\n",
14112 " Internal BGP neighbor may be up to %d hops away.\n",
14117 /* Local address. */
14120 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14122 json_object_int_add(json_neigh
, "portLocal",
14123 ntohs(p
->su_local
->sin
.sin_port
));
14125 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14126 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14129 json_object_string_add(json_neigh
, "hostLocal",
14131 json_object_int_add(json_neigh
, "portLocal", -1);
14135 /* Remote address. */
14136 if (p
->su_remote
) {
14138 json_object_string_addf(json_neigh
, "hostForeign",
14139 "%pSU", p
->su_remote
);
14140 json_object_int_add(json_neigh
, "portForeign",
14141 ntohs(p
->su_remote
->sin
.sin_port
));
14143 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14145 ntohs(p
->su_remote
->sin
.sin_port
));
14148 json_object_string_add(json_neigh
, "hostForeign",
14150 json_object_int_add(json_neigh
, "portForeign", -1);
14154 /* Nexthop display. */
14157 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14159 json_object_string_addf(json_neigh
, "nexthopGlobal",
14160 "%pI6", &p
->nexthop
.v6_global
);
14161 json_object_string_addf(json_neigh
, "nexthopLocal",
14162 "%pI6", &p
->nexthop
.v6_local
);
14163 if (p
->shared_network
)
14164 json_object_string_add(json_neigh
,
14168 json_object_string_add(json_neigh
,
14170 "nonSharedNetwork");
14172 vty_out(vty
, "Nexthop: %s\n",
14173 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14175 vty_out(vty
, "Nexthop global: %s\n",
14176 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14178 vty_out(vty
, "Nexthop local: %s\n",
14179 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14181 vty_out(vty
, "BGP connection: %s\n",
14182 p
->shared_network
? "shared network"
14183 : "non shared network");
14187 /* Timer information. */
14189 json_object_int_add(json_neigh
, "connectRetryTimer",
14191 if (peer_established(p
) && p
->rtt
)
14192 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14195 json_object_int_add(
14196 json_neigh
, "nextStartTimerDueInMsecs",
14197 thread_timer_remain_second(p
->t_start
) * 1000);
14199 json_object_int_add(
14200 json_neigh
, "nextConnectTimerDueInMsecs",
14201 thread_timer_remain_second(p
->t_connect
)
14203 if (p
->t_routeadv
) {
14204 json_object_int_add(json_neigh
, "mraiInterval",
14206 json_object_int_add(
14207 json_neigh
, "mraiTimerExpireInMsecs",
14208 thread_timer_remain_second(p
->t_routeadv
)
14212 json_object_int_add(json_neigh
, "authenticationEnabled",
14216 json_object_string_add(json_neigh
, "readThread", "on");
14218 json_object_string_add(json_neigh
, "readThread", "off");
14220 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14221 json_object_string_add(json_neigh
, "writeThread", "on");
14223 json_object_string_add(json_neigh
, "writeThread",
14226 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14228 if (peer_established(p
) && p
->rtt
)
14229 vty_out(vty
, "Estimated round trip time: %d ms\n",
14232 vty_out(vty
, "Next start timer due in %ld seconds\n",
14233 thread_timer_remain_second(p
->t_start
));
14235 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14236 thread_timer_remain_second(p
->t_connect
));
14239 "MRAI (interval %u) timer expires in %ld seconds\n",
14241 thread_timer_remain_second(p
->t_routeadv
));
14243 vty_out(vty
, "Peer Authentication Enabled\n");
14245 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14246 p
->t_read
? "on" : "off",
14247 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14252 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14253 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14254 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14257 vty_out(vty
, "\n");
14259 /* BFD information. */
14261 bgp_bfd_show_info(vty
, p
, json_neigh
);
14264 if (p
->conf_if
) /* Configured interface name. */
14265 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14266 else /* Configured IP address. */
14267 json_object_object_add(json
, p
->host
, json_neigh
);
14271 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14272 enum show_type type
,
14273 union sockunion
*su
,
14274 const char *conf_if
, afi_t afi
,
14277 struct listnode
*node
, *nnode
;
14280 safi_t safi
= SAFI_UNICAST
;
14281 json_object
*json
= NULL
;
14282 json_object
*json_neighbor
= NULL
;
14285 json
= json_object_new_object();
14286 json_neighbor
= json_object_new_object();
14289 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14291 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14294 if ((peer
->afc
[afi
][safi
]) == 0)
14297 if (type
== show_all
) {
14298 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14302 json_object_object_add(json
, peer
->host
,
14304 json_neighbor
= NULL
;
14307 } else if (type
== show_peer
) {
14310 && !strcmp(peer
->conf_if
, conf_if
))
14312 && !strcmp(peer
->hostname
, conf_if
))) {
14314 bgp_show_peer_gr_status(vty
, peer
,
14319 if (sockunion_same(&peer
->su
, su
)) {
14321 bgp_show_peer_gr_status(vty
, peer
,
14326 if (use_json
&& find
)
14327 json_object_object_add(json
, peer
->host
,
14332 json_neighbor
= NULL
;
14337 if (type
== show_peer
&& !find
) {
14339 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14341 vty_out(vty
, "%% No such neighbor\n");
14345 json_object_free(json_neighbor
);
14346 vty_json(vty
, json
);
14348 vty_out(vty
, "\n");
14351 return CMD_SUCCESS
;
14354 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14355 enum show_type type
, union sockunion
*su
,
14356 const char *conf_if
, bool use_json
,
14359 struct listnode
*node
, *nnode
;
14362 bool nbr_output
= false;
14363 afi_t afi
= AFI_MAX
;
14364 safi_t safi
= SAFI_MAX
;
14366 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14368 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14372 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14373 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14378 bgp_show_peer(vty
, peer
, use_json
, json
);
14384 && !strcmp(peer
->conf_if
, conf_if
))
14386 && !strcmp(peer
->hostname
, conf_if
))) {
14388 bgp_show_peer(vty
, peer
, use_json
,
14392 if (sockunion_same(&peer
->su
, su
)) {
14394 bgp_show_peer(vty
, peer
, use_json
,
14399 case show_ipv4_peer
:
14400 case show_ipv6_peer
:
14401 FOREACH_SAFI (safi
) {
14402 if (peer
->afc
[afi
][safi
]) {
14405 && !strcmp(peer
->conf_if
, conf_if
))
14407 && !strcmp(peer
->hostname
, conf_if
))) {
14409 bgp_show_peer(vty
, peer
, use_json
,
14414 if (sockunion_same(&peer
->su
, su
)) {
14416 bgp_show_peer(vty
, peer
, use_json
,
14424 case show_ipv4_all
:
14425 case show_ipv6_all
:
14426 FOREACH_SAFI (safi
) {
14427 if (peer
->afc
[afi
][safi
]) {
14428 bgp_show_peer(vty
, peer
, use_json
, json
);
14437 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14438 type
== show_ipv6_peer
) && !find
) {
14440 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14442 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14445 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14446 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14447 vty_out(vty
, "%% No BGP neighbors found\n");
14450 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14451 json
, JSON_C_TO_STRING_PRETTY
));
14453 vty_out(vty
, "\n");
14456 return CMD_SUCCESS
;
14459 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14460 enum show_type type
,
14461 const char *ip_str
,
14462 afi_t afi
, bool use_json
)
14467 union sockunion su
;
14469 bgp
= bgp_get_default();
14475 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14479 ret
= str2sockunion(ip_str
, &su
);
14481 bgp_show_neighbor_graceful_restart(
14482 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14484 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14485 NULL
, afi
, use_json
);
14487 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14491 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14492 enum show_type type
,
14493 const char *ip_str
,
14496 struct listnode
*node
, *nnode
;
14498 union sockunion su
;
14499 json_object
*json
= NULL
;
14500 int ret
, is_first
= 1;
14501 bool nbr_output
= false;
14504 vty_out(vty
, "{\n");
14506 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14509 if (!(json
= json_object_new_object())) {
14511 EC_BGP_JSON_MEM_ERROR
,
14512 "Unable to allocate memory for JSON object");
14514 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14518 json_object_int_add(json
, "vrfId",
14519 (bgp
->vrf_id
== VRF_UNKNOWN
)
14521 : (int64_t)bgp
->vrf_id
);
14522 json_object_string_add(
14524 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14529 vty_out(vty
, ",\n");
14533 vty_out(vty
, "\"%s\":",
14534 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14538 vty_out(vty
, "\nInstance %s:\n",
14539 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14544 if (type
== show_peer
|| type
== show_ipv4_peer
||
14545 type
== show_ipv6_peer
) {
14546 ret
= str2sockunion(ip_str
, &su
);
14548 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14551 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14554 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14557 json_object_free(json
);
14562 vty_out(vty
, "}\n");
14563 else if (!nbr_output
)
14564 vty_out(vty
, "%% BGP instance not found\n");
14567 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14568 enum show_type type
, const char *ip_str
,
14573 union sockunion su
;
14574 json_object
*json
= NULL
;
14577 if (strmatch(name
, "all")) {
14578 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14580 return CMD_SUCCESS
;
14582 bgp
= bgp_lookup_by_name(name
);
14585 json
= json_object_new_object();
14586 vty_json(vty
, json
);
14589 "%% BGP instance not found\n");
14591 return CMD_WARNING
;
14595 bgp
= bgp_get_default();
14599 json
= json_object_new_object();
14601 ret
= str2sockunion(ip_str
, &su
);
14603 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14606 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14609 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14612 json_object_free(json
);
14615 vty_out(vty
, "{}\n");
14617 vty_out(vty
, "%% BGP instance not found\n");
14620 return CMD_SUCCESS
;
14625 /* "show [ip] bgp neighbors graceful-restart" commands. */
14626 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14627 show_ip_bgp_neighbors_graceful_restart_cmd
,
14628 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14634 "Neighbor to display information about\n"
14635 "Neighbor to display information about\n"
14636 "Neighbor on BGP configured interface\n"
14640 char *sh_arg
= NULL
;
14641 enum show_type sh_type
;
14643 afi_t afi
= AFI_MAX
;
14644 bool uj
= use_json(argc
, argv
);
14646 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14651 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14652 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14653 || argv_find(argv
, argc
, "WORD", &idx
)) {
14654 sh_type
= show_peer
;
14655 sh_arg
= argv
[idx
]->arg
;
14657 sh_type
= show_all
;
14659 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14660 return CMD_SUCCESS
;
14663 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14667 /* "show [ip] bgp neighbors" commands. */
14668 DEFUN (show_ip_bgp_neighbors
,
14669 show_ip_bgp_neighbors_cmd
,
14670 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14674 BGP_INSTANCE_HELP_STR
14677 "Detailed information on TCP and BGP neighbor connections\n"
14678 "Neighbor to display information about\n"
14679 "Neighbor to display information about\n"
14680 "Neighbor on BGP configured interface\n"
14684 char *sh_arg
= NULL
;
14685 enum show_type sh_type
;
14686 afi_t afi
= AFI_MAX
;
14688 bool uj
= use_json(argc
, argv
);
14692 /* [<vrf> VIEWVRFNAME] */
14693 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14694 vrf
= argv
[idx
+ 1]->arg
;
14695 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14697 } else if (argv_find(argv
, argc
, "view", &idx
))
14698 /* [<view> VIEWVRFNAME] */
14699 vrf
= argv
[idx
+ 1]->arg
;
14703 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14704 sh_type
= show_ipv4_all
;
14706 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14707 sh_type
= show_ipv6_all
;
14710 sh_type
= show_all
;
14713 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14714 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14715 || argv_find(argv
, argc
, "WORD", &idx
)) {
14716 sh_type
= show_peer
;
14717 sh_arg
= argv
[idx
]->arg
;
14720 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14721 sh_type
= show_ipv4_peer
;
14722 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14723 sh_type
= show_ipv6_peer
;
14726 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14729 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14730 paths' and `show ip mbgp paths'. Those functions results are the
14732 DEFUN (show_ip_bgp_paths
,
14733 show_ip_bgp_paths_cmd
,
14734 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14739 "Path information\n")
14741 vty_out(vty
, "Address Refcnt Path\n");
14742 aspath_print_all_vty(vty
);
14743 return CMD_SUCCESS
;
14748 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14751 struct community
*com
;
14753 com
= (struct community
*)bucket
->data
;
14754 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14755 community_str(com
, false, false));
14758 /* Show BGP's community internal data. */
14759 DEFUN (show_ip_bgp_community_info
,
14760 show_ip_bgp_community_info_cmd
,
14761 "show [ip] bgp community-info",
14765 "List all bgp community information\n")
14767 vty_out(vty
, "Address Refcnt Community\n");
14769 hash_iterate(community_hash(),
14770 (void (*)(struct hash_bucket
*,
14771 void *))community_show_all_iterator
,
14774 return CMD_SUCCESS
;
14777 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14780 struct lcommunity
*lcom
;
14782 lcom
= (struct lcommunity
*)bucket
->data
;
14783 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14784 lcommunity_str(lcom
, false, false));
14787 /* Show BGP's community internal data. */
14788 DEFUN (show_ip_bgp_lcommunity_info
,
14789 show_ip_bgp_lcommunity_info_cmd
,
14790 "show ip bgp large-community-info",
14794 "List all bgp large-community information\n")
14796 vty_out(vty
, "Address Refcnt Large-community\n");
14798 hash_iterate(lcommunity_hash(),
14799 (void (*)(struct hash_bucket
*,
14800 void *))lcommunity_show_all_iterator
,
14803 return CMD_SUCCESS
;
14805 /* Graceful Restart */
14807 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14814 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14816 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14818 switch (bgp_global_gr_mode
) {
14820 case GLOBAL_HELPER
:
14821 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14825 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14828 case GLOBAL_DISABLE
:
14829 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14832 case GLOBAL_INVALID
:
14834 "Global BGP GR Mode Invalid\n");
14837 vty_out(vty
, "\n");
14840 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14841 enum show_type type
,
14842 const char *ip_str
,
14843 afi_t afi
, bool use_json
)
14845 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14848 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14850 bgp_show_neighbor_graceful_restart_vty(
14851 vty
, type
, ip_str
, afi
, use_json
);
14854 } else if (afi
!= AFI_MAX
) {
14855 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14858 return CMD_ERR_INCOMPLETE
;
14861 return CMD_SUCCESS
;
14863 /* Graceful Restart */
14865 DEFUN (show_ip_bgp_attr_info
,
14866 show_ip_bgp_attr_info_cmd
,
14867 "show [ip] bgp attribute-info",
14871 "List all bgp attribute information\n")
14873 attr_show_all(vty
);
14874 return CMD_SUCCESS
;
14877 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14878 afi_t afi
, safi_t safi
,
14879 bool use_json
, json_object
*json
)
14882 struct listnode
*node
;
14884 char buf1
[INET6_ADDRSTRLEN
];
14886 enum vpn_policy_direction dir
;
14889 json_object
*json_import_vrfs
= NULL
;
14890 json_object
*json_export_vrfs
= NULL
;
14892 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14895 vty_json(vty
, json
);
14897 return CMD_WARNING
;
14900 /* Provide context for the block */
14901 json_object_string_add(json
, "vrf", name
? name
: "default");
14902 json_object_string_add(json
, "afiSafi",
14903 get_afi_safi_str(afi
, safi
, true));
14905 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14906 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14907 json_object_string_add(json
, "importFromVrfs", "none");
14908 json_object_string_add(json
, "importRts", "none");
14910 json_import_vrfs
= json_object_new_array();
14912 for (ALL_LIST_ELEMENTS_RO(
14913 bgp
->vpn_policy
[afi
].import_vrf
,
14915 json_object_array_add(json_import_vrfs
,
14916 json_object_new_string(vname
));
14918 json_object_object_add(json
, "importFromVrfs",
14920 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14921 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14922 ecom_str
= ecommunity_ecom2str(
14923 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14924 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14925 json_object_string_add(json
, "importRts",
14927 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14929 json_object_string_add(json
, "importRts",
14933 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14934 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14935 json_object_string_add(json
, "exportToVrfs", "none");
14936 json_object_string_add(json
, "routeDistinguisher",
14938 json_object_string_add(json
, "exportRts", "none");
14940 json_export_vrfs
= json_object_new_array();
14942 for (ALL_LIST_ELEMENTS_RO(
14943 bgp
->vpn_policy
[afi
].export_vrf
,
14945 json_object_array_add(json_export_vrfs
,
14946 json_object_new_string(vname
));
14947 json_object_object_add(json
, "exportToVrfs",
14949 json_object_string_add(json
, "routeDistinguisher",
14950 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14951 buf1
, RD_ADDRSTRLEN
));
14953 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14954 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14955 ecom_str
= ecommunity_ecom2str(
14956 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14957 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14958 json_object_string_add(json
, "exportRts",
14960 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14962 json_object_string_add(json
, "exportRts",
14967 vty_json(vty
, json
);
14970 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14973 vty_out(vty
, "%% No such BGP instance exist\n");
14974 return CMD_WARNING
;
14977 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14978 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14980 "This VRF is not importing %s routes from any other VRF\n",
14981 get_afi_safi_str(afi
, safi
, false));
14984 "This VRF is importing %s routes from the following VRFs:\n",
14985 get_afi_safi_str(afi
, safi
, false));
14987 for (ALL_LIST_ELEMENTS_RO(
14988 bgp
->vpn_policy
[afi
].import_vrf
,
14990 vty_out(vty
, " %s\n", vname
);
14992 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14994 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14995 ecom_str
= ecommunity_ecom2str(
14996 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14997 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14998 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15000 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15002 vty_out(vty
, "Import RT(s):\n");
15005 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15006 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15008 "This VRF is not exporting %s routes to any other VRF\n",
15009 get_afi_safi_str(afi
, safi
, false));
15012 "This VRF is exporting %s routes to the following VRFs:\n",
15013 get_afi_safi_str(afi
, safi
, false));
15015 for (ALL_LIST_ELEMENTS_RO(
15016 bgp
->vpn_policy
[afi
].export_vrf
,
15018 vty_out(vty
, " %s\n", vname
);
15020 vty_out(vty
, "RD: %s\n",
15021 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15022 buf1
, RD_ADDRSTRLEN
));
15024 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15025 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15026 ecom_str
= ecommunity_ecom2str(
15027 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15028 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15029 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15030 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15032 vty_out(vty
, "Import RT(s):\n");
15036 return CMD_SUCCESS
;
15039 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15040 safi_t safi
, bool use_json
)
15042 struct listnode
*node
, *nnode
;
15044 char *vrf_name
= NULL
;
15045 json_object
*json
= NULL
;
15046 json_object
*json_vrf
= NULL
;
15047 json_object
*json_vrfs
= NULL
;
15050 json
= json_object_new_object();
15051 json_vrfs
= json_object_new_object();
15054 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15056 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15057 vrf_name
= bgp
->name
;
15060 json_vrf
= json_object_new_object();
15062 vty_out(vty
, "\nInstance %s:\n",
15063 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15064 ? VRF_DEFAULT_NAME
: bgp
->name
);
15066 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15068 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15069 json_object_object_add(json_vrfs
,
15070 VRF_DEFAULT_NAME
, json_vrf
);
15072 json_object_object_add(json_vrfs
, vrf_name
,
15078 json_object_object_add(json
, "vrfs", json_vrfs
);
15079 vty_json(vty
, json
);
15082 return CMD_SUCCESS
;
15085 /* "show [ip] bgp route-leak" command. */
15086 DEFUN (show_ip_bgp_route_leak
,
15087 show_ip_bgp_route_leak_cmd
,
15088 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15092 BGP_INSTANCE_HELP_STR
15095 "Route leaking information\n"
15099 afi_t afi
= AFI_MAX
;
15100 safi_t safi
= SAFI_MAX
;
15102 bool uj
= use_json(argc
, argv
);
15104 json_object
*json
= NULL
;
15106 /* show [ip] bgp */
15107 if (argv_find(argv
, argc
, "ip", &idx
)) {
15109 safi
= SAFI_UNICAST
;
15111 /* [vrf VIEWVRFNAME] */
15112 if (argv_find(argv
, argc
, "view", &idx
)) {
15114 "%% This command is not applicable to BGP views\n");
15115 return CMD_WARNING
;
15118 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15119 vrf
= argv
[idx
+ 1]->arg
;
15120 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15123 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15124 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15125 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15127 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15129 "%% This command is applicable only for unicast ipv4|ipv6\n");
15130 return CMD_WARNING
;
15133 if (vrf
&& strmatch(vrf
, "all"))
15134 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15137 json
= json_object_new_object();
15139 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15142 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15145 struct listnode
*node
, *nnode
;
15148 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15149 vty_out(vty
, "\nInstance %s:\n",
15150 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15153 update_group_show(bgp
, afi
, safi
, vty
, 0);
15157 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15158 int safi
, uint64_t subgrp_id
)
15163 if (strmatch(name
, "all")) {
15164 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15165 return CMD_SUCCESS
;
15167 bgp
= bgp_lookup_by_name(name
);
15170 bgp
= bgp_get_default();
15174 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15175 return CMD_SUCCESS
;
15178 DEFUN (show_ip_bgp_updgrps
,
15179 show_ip_bgp_updgrps_cmd
,
15180 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15184 BGP_INSTANCE_HELP_STR
15186 BGP_SAFI_WITH_LABEL_HELP_STR
15187 "Detailed info about dynamic update groups\n"
15188 "Specific subgroup to display detailed info for\n")
15191 afi_t afi
= AFI_IP6
;
15192 safi_t safi
= SAFI_UNICAST
;
15193 uint64_t subgrp_id
= 0;
15197 /* show [ip] bgp */
15198 if (argv_find(argv
, argc
, "ip", &idx
))
15200 /* [<vrf> VIEWVRFNAME] */
15201 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15202 vrf
= argv
[idx
+ 1]->arg
;
15203 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15205 } else if (argv_find(argv
, argc
, "view", &idx
))
15206 /* [<view> VIEWVRFNAME] */
15207 vrf
= argv
[idx
+ 1]->arg
;
15208 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15209 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15210 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15213 /* get subgroup id, if provided */
15215 if (argv
[idx
]->type
== VARIABLE_TKN
)
15216 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15218 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15221 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15222 show_bgp_instance_all_ipv6_updgrps_cmd
,
15223 "show [ip] bgp <view|vrf> all update-groups",
15227 BGP_INSTANCE_ALL_HELP_STR
15228 "Detailed info about dynamic update groups\n")
15230 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15231 return CMD_SUCCESS
;
15234 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15235 show_bgp_l2vpn_evpn_updgrps_cmd
,
15236 "show [ip] bgp l2vpn evpn update-groups",
15240 "l2vpn address family\n"
15241 "evpn sub-address family\n"
15242 "Detailed info about dynamic update groups\n")
15245 uint64_t subgrp_id
= 0;
15247 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15248 return CMD_SUCCESS
;
15251 DEFUN (show_bgp_updgrps_stats
,
15252 show_bgp_updgrps_stats_cmd
,
15253 "show [ip] bgp update-groups statistics",
15257 "Detailed info about dynamic update groups\n"
15262 bgp
= bgp_get_default();
15264 update_group_show_stats(bgp
, vty
);
15266 return CMD_SUCCESS
;
15269 DEFUN (show_bgp_instance_updgrps_stats
,
15270 show_bgp_instance_updgrps_stats_cmd
,
15271 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15275 BGP_INSTANCE_HELP_STR
15276 "Detailed info about dynamic update groups\n"
15282 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15284 update_group_show_stats(bgp
, vty
);
15286 return CMD_SUCCESS
;
15289 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15290 afi_t afi
, safi_t safi
,
15291 const char *what
, uint64_t subgrp_id
)
15296 bgp
= bgp_lookup_by_name(name
);
15298 bgp
= bgp_get_default();
15301 if (!strcmp(what
, "advertise-queue"))
15302 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15304 else if (!strcmp(what
, "advertised-routes"))
15305 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15307 else if (!strcmp(what
, "packet-queue"))
15308 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15313 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15314 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15315 "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",
15316 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15318 "Detailed info about dynamic update groups\n"
15319 "Specific subgroup to display info for\n"
15320 "Advertisement queue\n"
15321 "Announced routes\n"
15324 uint64_t subgrp_id
= 0;
15328 subgrp_id
= strtoull(sgid
, NULL
, 10);
15333 afiz
= bgp_vty_afi_from_str(afi
);
15337 afiz
= bgp_vty_afi_from_str(afi
);
15338 if (afiz
!= AFI_IP
)
15340 "%% Cannot specify both 'ip' and 'ipv6'\n");
15341 return CMD_WARNING
;
15344 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15346 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15347 return CMD_SUCCESS
;
15350 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15353 struct listnode
*node
, *nnode
;
15354 struct prefix
*range
;
15359 const char *peer_status
;
15363 json_object
*json_peer_group
= NULL
;
15364 json_object
*json_peer_group_afc
= NULL
;
15365 json_object
*json_peer_group_members
= NULL
;
15366 json_object
*json_peer_group_dynamic
= NULL
;
15367 json_object
*json_peer_group_dynamic_af
= NULL
;
15368 json_object
*json_peer_group_ranges
= NULL
;
15370 conf
= group
->conf
;
15373 json_peer_group
= json_object_new_object();
15374 json_peer_group_afc
= json_object_new_array();
15377 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15379 json_object_int_add(json_peer_group
, "remoteAs",
15382 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15383 group
->name
, conf
->as
);
15384 } else if (conf
->as_type
== AS_INTERNAL
) {
15386 json_object_int_add(json_peer_group
, "remoteAs",
15389 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15390 group
->name
, group
->bgp
->as
);
15393 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15396 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15398 json_object_string_add(json_peer_group
, "type",
15401 vty_out(vty
, " Peer-group type is internal\n");
15404 json_object_string_add(json_peer_group
, "type",
15407 vty_out(vty
, " Peer-group type is external\n");
15410 /* Display AFs configured. */
15412 vty_out(vty
, " Configured address-families:");
15414 FOREACH_AFI_SAFI (afi
, safi
) {
15415 if (conf
->afc
[afi
][safi
]) {
15418 json_object_array_add(
15419 json_peer_group_afc
,
15420 json_object_new_string(get_afi_safi_str(
15421 afi
, safi
, false)));
15423 vty_out(vty
, " %s;",
15424 get_afi_safi_str(afi
, safi
, false));
15429 json_object_object_add(json_peer_group
,
15430 "addressFamiliesConfigured",
15431 json_peer_group_afc
);
15434 vty_out(vty
, " none\n");
15436 vty_out(vty
, "\n");
15439 /* Display listen ranges (for dynamic neighbors), if any */
15440 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15441 lr_count
= listcount(group
->listen_range
[afi
]);
15444 if (!json_peer_group_dynamic
)
15445 json_peer_group_dynamic
=
15446 json_object_new_object();
15448 json_peer_group_dynamic_af
=
15449 json_object_new_object();
15450 json_peer_group_ranges
=
15451 json_object_new_array();
15452 json_object_int_add(json_peer_group_dynamic_af
,
15453 "count", lr_count
);
15455 vty_out(vty
, " %d %s listen range(s)\n",
15456 lr_count
, afi2str(afi
));
15459 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15464 snprintfrr(buf
, sizeof(buf
), "%pFX",
15467 json_object_array_add(
15468 json_peer_group_ranges
,
15469 json_object_new_string(buf
));
15471 vty_out(vty
, " %pFX\n", range
);
15476 json_object_object_add(
15477 json_peer_group_dynamic_af
, "ranges",
15478 json_peer_group_ranges
);
15480 json_object_object_add(
15481 json_peer_group_dynamic
, afi2str(afi
),
15482 json_peer_group_dynamic_af
);
15487 if (json_peer_group_dynamic
)
15488 json_object_object_add(json_peer_group
, "dynamicRanges",
15489 json_peer_group_dynamic
);
15491 /* Display group members and their status */
15492 if (listcount(group
->peer
)) {
15494 json_peer_group_members
= json_object_new_object();
15496 vty_out(vty
, " Peer-group members:\n");
15497 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15498 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15499 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15500 peer_status
= "Idle (Admin)";
15501 else if (CHECK_FLAG(peer
->sflags
,
15502 PEER_STATUS_PREFIX_OVERFLOW
))
15503 peer_status
= "Idle (PfxCt)";
15505 peer_status
= lookup_msg(bgp_status_msg
,
15506 peer
->status
, NULL
);
15508 dynamic
= peer_dynamic_neighbor(peer
);
15511 json_object
*json_peer_group_member
=
15512 json_object_new_object();
15514 json_object_string_add(json_peer_group_member
,
15515 "status", peer_status
);
15518 json_object_boolean_true_add(
15519 json_peer_group_member
,
15522 json_object_object_add(json_peer_group_members
,
15524 json_peer_group_member
);
15526 vty_out(vty
, " %s %s %s \n", peer
->host
,
15527 dynamic
? "(dynamic)" : "",
15532 json_object_object_add(json_peer_group
, "members",
15533 json_peer_group_members
);
15537 json_object_object_add(json
, group
->name
, json_peer_group
);
15539 return CMD_SUCCESS
;
15542 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15543 const char *group_name
, bool uj
)
15546 struct listnode
*node
, *nnode
;
15547 struct peer_group
*group
;
15548 bool found
= false;
15549 json_object
*json
= NULL
;
15552 json
= json_object_new_object();
15554 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15558 vty_json(vty
, json
);
15560 vty_out(vty
, "%% BGP instance not found\n");
15562 return CMD_WARNING
;
15565 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15567 if (strmatch(group
->name
, group_name
)) {
15568 bgp_show_one_peer_group(vty
, group
, json
);
15573 bgp_show_one_peer_group(vty
, group
, json
);
15577 if (group_name
&& !found
&& !uj
)
15578 vty_out(vty
, "%% No such peer-group\n");
15581 vty_json(vty
, json
);
15583 return CMD_SUCCESS
;
15586 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15587 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15588 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15589 "Detailed information on BGP peer groups\n"
15590 "Peer group name\n" JSON_STR
)
15594 bool uj
= use_json(argc
, argv
);
15596 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15598 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15600 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15604 /* Redistribute VTY commands. */
15606 DEFUN (bgp_redistribute_ipv4
,
15607 bgp_redistribute_ipv4_cmd
,
15608 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15609 "Redistribute information from another routing protocol\n"
15610 FRR_IP_REDIST_HELP_STR_BGPD
)
15612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15613 int idx_protocol
= 1;
15616 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15618 vty_out(vty
, "%% Invalid route type\n");
15619 return CMD_WARNING_CONFIG_FAILED
;
15622 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15623 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15627 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15628 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15629 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15631 DEFUN (bgp_redistribute_ipv4_rmap
,
15632 bgp_redistribute_ipv4_rmap_cmd
,
15633 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15634 "Redistribute information from another routing protocol\n"
15635 FRR_IP_REDIST_HELP_STR_BGPD
15636 "Route map reference\n"
15637 "Pointer to route-map entries\n")
15639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15640 int idx_protocol
= 1;
15643 struct bgp_redist
*red
;
15645 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15646 vty
, argv
[idx_word
]->arg
);
15648 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15650 vty_out(vty
, "%% Invalid route type\n");
15651 return CMD_WARNING_CONFIG_FAILED
;
15654 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15656 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15657 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15661 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15662 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15663 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15664 "Route map reference\n"
15665 "Pointer to route-map entries\n")
15667 DEFUN (bgp_redistribute_ipv4_metric
,
15668 bgp_redistribute_ipv4_metric_cmd
,
15669 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15670 "Redistribute information from another routing protocol\n"
15671 FRR_IP_REDIST_HELP_STR_BGPD
15672 "Metric for redistributed routes\n"
15673 "Default metric\n")
15675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15676 int idx_protocol
= 1;
15677 int idx_number
= 3;
15680 struct bgp_redist
*red
;
15683 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15685 vty_out(vty
, "%% Invalid route type\n");
15686 return CMD_WARNING_CONFIG_FAILED
;
15688 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15690 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15691 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15692 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15696 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15697 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15698 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15699 "Metric for redistributed routes\n"
15700 "Default metric\n")
15702 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15703 bgp_redistribute_ipv4_rmap_metric_cmd
,
15704 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15705 "Redistribute information from another routing protocol\n"
15706 FRR_IP_REDIST_HELP_STR_BGPD
15707 "Route map reference\n"
15708 "Pointer to route-map entries\n"
15709 "Metric for redistributed routes\n"
15710 "Default metric\n")
15712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15713 int idx_protocol
= 1;
15715 int idx_number
= 5;
15718 struct bgp_redist
*red
;
15720 struct route_map
*route_map
=
15721 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15723 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15725 vty_out(vty
, "%% Invalid route type\n");
15726 return CMD_WARNING_CONFIG_FAILED
;
15728 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15730 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15732 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15733 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15734 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15738 bgp_redistribute_ipv4_rmap_metric
,
15739 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15740 "redistribute " FRR_IP_REDIST_STR_BGPD
15741 " route-map RMAP_NAME metric (0-4294967295)",
15742 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15743 "Route map reference\n"
15744 "Pointer to route-map entries\n"
15745 "Metric for redistributed routes\n"
15746 "Default metric\n")
15748 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15749 bgp_redistribute_ipv4_metric_rmap_cmd
,
15750 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15751 "Redistribute information from another routing protocol\n"
15752 FRR_IP_REDIST_HELP_STR_BGPD
15753 "Metric for redistributed routes\n"
15755 "Route map reference\n"
15756 "Pointer to route-map entries\n")
15758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15759 int idx_protocol
= 1;
15760 int idx_number
= 3;
15764 struct bgp_redist
*red
;
15766 struct route_map
*route_map
=
15767 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15769 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15771 vty_out(vty
, "%% Invalid route type\n");
15772 return CMD_WARNING_CONFIG_FAILED
;
15774 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15776 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15777 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15779 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15780 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15784 bgp_redistribute_ipv4_metric_rmap
,
15785 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15786 "redistribute " FRR_IP_REDIST_STR_BGPD
15787 " metric (0-4294967295) route-map RMAP_NAME",
15788 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15789 "Metric for redistributed routes\n"
15791 "Route map reference\n"
15792 "Pointer to route-map entries\n")
15794 DEFUN (bgp_redistribute_ipv4_ospf
,
15795 bgp_redistribute_ipv4_ospf_cmd
,
15796 "redistribute <ospf|table> (1-65535)",
15797 "Redistribute information from another routing protocol\n"
15798 "Open Shortest Path First (OSPFv2)\n"
15799 "Non-main Kernel Routing Table\n"
15800 "Instance ID/Table ID\n")
15802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15803 int idx_ospf_table
= 1;
15804 int idx_number
= 2;
15805 unsigned short instance
;
15806 unsigned short protocol
;
15808 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15810 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15811 protocol
= ZEBRA_ROUTE_OSPF
;
15813 protocol
= ZEBRA_ROUTE_TABLE
;
15815 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15816 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15819 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15820 "redistribute <ospf|table> (1-65535)",
15821 "Redistribute information from another routing protocol\n"
15822 "Open Shortest Path First (OSPFv2)\n"
15823 "Non-main Kernel Routing Table\n"
15824 "Instance ID/Table ID\n")
15826 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15827 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15828 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15829 "Redistribute information from another routing protocol\n"
15830 "Open Shortest Path First (OSPFv2)\n"
15831 "Non-main Kernel Routing Table\n"
15832 "Instance ID/Table ID\n"
15833 "Route map reference\n"
15834 "Pointer to route-map entries\n")
15836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15837 int idx_ospf_table
= 1;
15838 int idx_number
= 2;
15840 struct bgp_redist
*red
;
15841 unsigned short instance
;
15844 struct route_map
*route_map
=
15845 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15847 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15848 protocol
= ZEBRA_ROUTE_OSPF
;
15850 protocol
= ZEBRA_ROUTE_TABLE
;
15852 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15853 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15855 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15856 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15859 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15860 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15861 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15862 "Redistribute information from another routing protocol\n"
15863 "Open Shortest Path First (OSPFv2)\n"
15864 "Non-main Kernel Routing Table\n"
15865 "Instance ID/Table ID\n"
15866 "Route map reference\n"
15867 "Pointer to route-map entries\n")
15869 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15870 bgp_redistribute_ipv4_ospf_metric_cmd
,
15871 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15872 "Redistribute information from another routing protocol\n"
15873 "Open Shortest Path First (OSPFv2)\n"
15874 "Non-main Kernel Routing Table\n"
15875 "Instance ID/Table ID\n"
15876 "Metric for redistributed routes\n"
15877 "Default metric\n")
15879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15880 int idx_ospf_table
= 1;
15881 int idx_number
= 2;
15882 int idx_number_2
= 4;
15884 struct bgp_redist
*red
;
15885 unsigned short instance
;
15889 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15890 protocol
= ZEBRA_ROUTE_OSPF
;
15892 protocol
= ZEBRA_ROUTE_TABLE
;
15894 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15895 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15897 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15898 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15900 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15903 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15904 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15905 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15906 "Redistribute information from another routing protocol\n"
15907 "Open Shortest Path First (OSPFv2)\n"
15908 "Non-main Kernel Routing Table\n"
15909 "Instance ID/Table ID\n"
15910 "Metric for redistributed routes\n"
15911 "Default metric\n")
15913 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15914 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15915 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15916 "Redistribute information from another routing protocol\n"
15917 "Open Shortest Path First (OSPFv2)\n"
15918 "Non-main Kernel Routing Table\n"
15919 "Instance ID/Table ID\n"
15920 "Route map reference\n"
15921 "Pointer to route-map entries\n"
15922 "Metric for redistributed routes\n"
15923 "Default metric\n")
15925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15926 int idx_ospf_table
= 1;
15927 int idx_number
= 2;
15929 int idx_number_2
= 6;
15931 struct bgp_redist
*red
;
15932 unsigned short instance
;
15935 struct route_map
*route_map
=
15936 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15938 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15939 protocol
= ZEBRA_ROUTE_OSPF
;
15941 protocol
= ZEBRA_ROUTE_TABLE
;
15943 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15944 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15946 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15948 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15949 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15951 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15955 bgp_redistribute_ipv4_ospf_rmap_metric
,
15956 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15957 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15958 "Redistribute information from another routing protocol\n"
15959 "Open Shortest Path First (OSPFv2)\n"
15960 "Non-main Kernel Routing Table\n"
15961 "Instance ID/Table ID\n"
15962 "Route map reference\n"
15963 "Pointer to route-map entries\n"
15964 "Metric for redistributed routes\n"
15965 "Default metric\n")
15967 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15968 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15969 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
15970 "Redistribute information from another routing protocol\n"
15971 "Open Shortest Path First (OSPFv2)\n"
15972 "Non-main Kernel Routing Table\n"
15973 "Instance ID/Table ID\n"
15974 "Metric for redistributed routes\n"
15976 "Route map reference\n"
15977 "Pointer to route-map entries\n")
15979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15980 int idx_ospf_table
= 1;
15981 int idx_number
= 2;
15982 int idx_number_2
= 4;
15985 struct bgp_redist
*red
;
15986 unsigned short instance
;
15989 struct route_map
*route_map
=
15990 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15992 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15993 protocol
= ZEBRA_ROUTE_OSPF
;
15995 protocol
= ZEBRA_ROUTE_TABLE
;
15997 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15998 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16000 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16001 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16004 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16005 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16009 bgp_redistribute_ipv4_ospf_metric_rmap
,
16010 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16011 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16012 "Redistribute information from another routing protocol\n"
16013 "Open Shortest Path First (OSPFv2)\n"
16014 "Non-main Kernel Routing Table\n"
16015 "Instance ID/Table ID\n"
16016 "Metric for redistributed routes\n"
16018 "Route map reference\n"
16019 "Pointer to route-map entries\n")
16021 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16022 no_bgp_redistribute_ipv4_ospf_cmd
,
16023 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16025 "Redistribute information from another routing protocol\n"
16026 "Open Shortest Path First (OSPFv2)\n"
16027 "Non-main Kernel Routing Table\n"
16028 "Instance ID/Table ID\n"
16029 "Metric for redistributed routes\n"
16031 "Route map reference\n"
16032 "Pointer to route-map entries\n")
16034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16035 int idx_ospf_table
= 2;
16036 int idx_number
= 3;
16037 unsigned short instance
;
16040 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16041 protocol
= ZEBRA_ROUTE_OSPF
;
16043 protocol
= ZEBRA_ROUTE_TABLE
;
16045 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16046 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16050 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16051 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16053 "Redistribute information from another routing protocol\n"
16054 "Open Shortest Path First (OSPFv2)\n"
16055 "Non-main Kernel Routing Table\n"
16056 "Instance ID/Table ID\n"
16057 "Metric for redistributed routes\n"
16059 "Route map reference\n"
16060 "Pointer to route-map entries\n")
16062 DEFUN (no_bgp_redistribute_ipv4
,
16063 no_bgp_redistribute_ipv4_cmd
,
16064 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16066 "Redistribute information from another routing protocol\n"
16067 FRR_IP_REDIST_HELP_STR_BGPD
16068 "Metric for redistributed routes\n"
16070 "Route map reference\n"
16071 "Pointer to route-map entries\n")
16073 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16074 int idx_protocol
= 2;
16077 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16079 vty_out(vty
, "%% Invalid route type\n");
16080 return CMD_WARNING_CONFIG_FAILED
;
16082 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16086 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16087 "no redistribute " FRR_IP_REDIST_STR_BGPD
16088 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16090 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16091 "Metric for redistributed routes\n"
16093 "Route map reference\n"
16094 "Pointer to route-map entries\n")
16096 DEFUN (bgp_redistribute_ipv6
,
16097 bgp_redistribute_ipv6_cmd
,
16098 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16099 "Redistribute information from another routing protocol\n"
16100 FRR_IP6_REDIST_HELP_STR_BGPD
)
16102 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16103 int idx_protocol
= 1;
16106 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16108 vty_out(vty
, "%% Invalid route type\n");
16109 return CMD_WARNING_CONFIG_FAILED
;
16112 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16113 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16116 DEFUN (bgp_redistribute_ipv6_rmap
,
16117 bgp_redistribute_ipv6_rmap_cmd
,
16118 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16119 "Redistribute information from another routing protocol\n"
16120 FRR_IP6_REDIST_HELP_STR_BGPD
16121 "Route map reference\n"
16122 "Pointer to route-map entries\n")
16124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16125 int idx_protocol
= 1;
16128 struct bgp_redist
*red
;
16130 struct route_map
*route_map
=
16131 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16133 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16135 vty_out(vty
, "%% Invalid route type\n");
16136 return CMD_WARNING_CONFIG_FAILED
;
16139 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16141 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16142 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16145 DEFUN (bgp_redistribute_ipv6_metric
,
16146 bgp_redistribute_ipv6_metric_cmd
,
16147 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16148 "Redistribute information from another routing protocol\n"
16149 FRR_IP6_REDIST_HELP_STR_BGPD
16150 "Metric for redistributed routes\n"
16151 "Default metric\n")
16153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16154 int idx_protocol
= 1;
16155 int idx_number
= 3;
16158 struct bgp_redist
*red
;
16161 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16163 vty_out(vty
, "%% Invalid route type\n");
16164 return CMD_WARNING_CONFIG_FAILED
;
16166 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16168 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16169 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16170 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16173 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16174 bgp_redistribute_ipv6_rmap_metric_cmd
,
16175 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16176 "Redistribute information from another routing protocol\n"
16177 FRR_IP6_REDIST_HELP_STR_BGPD
16178 "Route map reference\n"
16179 "Pointer to route-map entries\n"
16180 "Metric for redistributed routes\n"
16181 "Default metric\n")
16183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16184 int idx_protocol
= 1;
16186 int idx_number
= 5;
16189 struct bgp_redist
*red
;
16191 struct route_map
*route_map
=
16192 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16194 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16196 vty_out(vty
, "%% Invalid route type\n");
16197 return CMD_WARNING_CONFIG_FAILED
;
16199 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16201 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16203 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16204 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16206 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16209 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16210 bgp_redistribute_ipv6_metric_rmap_cmd
,
16211 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16212 "Redistribute information from another routing protocol\n"
16213 FRR_IP6_REDIST_HELP_STR_BGPD
16214 "Metric for redistributed routes\n"
16216 "Route map reference\n"
16217 "Pointer to route-map entries\n")
16219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16220 int idx_protocol
= 1;
16221 int idx_number
= 3;
16225 struct bgp_redist
*red
;
16227 struct route_map
*route_map
=
16228 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16230 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16232 vty_out(vty
, "%% Invalid route type\n");
16233 return CMD_WARNING_CONFIG_FAILED
;
16235 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16237 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16238 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16241 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16242 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16245 DEFUN (no_bgp_redistribute_ipv6
,
16246 no_bgp_redistribute_ipv6_cmd
,
16247 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16249 "Redistribute information from another routing protocol\n"
16250 FRR_IP6_REDIST_HELP_STR_BGPD
16251 "Metric for redistributed routes\n"
16253 "Route map reference\n"
16254 "Pointer to route-map entries\n")
16256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16257 int idx_protocol
= 2;
16260 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16262 vty_out(vty
, "%% Invalid route type\n");
16263 return CMD_WARNING_CONFIG_FAILED
;
16266 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16269 /* Neighbor update tcp-mss. */
16270 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16271 const char *tcp_mss_str
)
16274 uint32_t tcp_mss_val
= 0;
16276 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16278 return CMD_WARNING_CONFIG_FAILED
;
16281 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16282 peer_tcp_mss_set(peer
, tcp_mss_val
);
16284 peer_tcp_mss_unset(peer
);
16287 return CMD_SUCCESS
;
16290 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16291 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16292 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16293 "TCP max segment size\n"
16296 int peer_index
= 1;
16300 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16301 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16302 argv
[mss_index
]->arg
);
16305 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16306 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16308 "TCP max segment size\n"
16311 int peer_index
= 2;
16314 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16315 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16318 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16319 afi_t afi
, safi_t safi
)
16323 /* Unicast redistribution only. */
16324 if (safi
!= SAFI_UNICAST
)
16327 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16328 /* Redistribute BGP does not make sense. */
16329 if (i
!= ZEBRA_ROUTE_BGP
) {
16330 struct list
*red_list
;
16331 struct listnode
*node
;
16332 struct bgp_redist
*red
;
16334 red_list
= bgp
->redist
[afi
][i
];
16338 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16339 /* "redistribute" configuration. */
16340 vty_out(vty
, " redistribute %s",
16341 zebra_route_string(i
));
16343 vty_out(vty
, " %d", red
->instance
);
16344 if (red
->redist_metric_flag
)
16345 vty_out(vty
, " metric %u",
16346 red
->redist_metric
);
16347 if (red
->rmap
.name
)
16348 vty_out(vty
, " route-map %s",
16350 vty_out(vty
, "\n");
16356 /* peer-group helpers for config-write */
16358 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16360 if (!peer_group_active(peer
)) {
16361 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16362 return !CHECK_FLAG(peer
->flags
, flag
);
16364 return !!CHECK_FLAG(peer
->flags
, flag
);
16367 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16370 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16373 if (!peer_group_active(peer
)) {
16374 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16375 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16377 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16380 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16383 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16384 uint8_t type
, int direct
)
16386 struct bgp_filter
*filter
;
16388 if (peer_group_active(peer
))
16389 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16392 filter
= &peer
->filter
[afi
][safi
];
16394 case PEER_FT_DISTRIBUTE_LIST
:
16395 return !!(filter
->dlist
[direct
].name
);
16396 case PEER_FT_FILTER_LIST
:
16397 return !!(filter
->aslist
[direct
].name
);
16398 case PEER_FT_PREFIX_LIST
:
16399 return !!(filter
->plist
[direct
].name
);
16400 case PEER_FT_ROUTE_MAP
:
16401 return !!(filter
->map
[direct
].name
);
16402 case PEER_FT_UNSUPPRESS_MAP
:
16403 return !!(filter
->usmap
.name
);
16404 case PEER_FT_ADVERTISE_MAP
:
16405 return !!(filter
->advmap
.aname
16406 && ((filter
->advmap
.condition
== direct
)
16407 && filter
->advmap
.cname
));
16413 /* Return true if the addpath type is set for peer and different from
16416 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16419 enum bgp_addpath_strat type
, g_type
;
16421 type
= peer
->addpath_type
[afi
][safi
];
16423 if (type
!= BGP_ADDPATH_NONE
) {
16424 if (peer_group_active(peer
)) {
16425 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16427 if (type
!= g_type
)
16439 /* This is part of the address-family block (unicast only) */
16440 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16444 uint32_t tovpn_sid_index
= 0;
16446 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16447 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16448 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16449 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16450 bgp
->vpn_policy
[afi
]
16451 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16453 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16454 bgp
->vpn_policy
[afi
]
16455 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16457 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16458 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16459 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16460 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16463 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16464 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16466 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16469 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16470 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16471 bgp
->vpn_policy
[afi
].tovpn_label
);
16475 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16476 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16477 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16478 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16479 } else if (tovpn_sid_index
!= 0) {
16480 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16484 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16485 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16486 char buf
[RD_ADDRSTRLEN
];
16487 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16488 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16491 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16492 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16494 char buf
[PREFIX_STRLEN
];
16495 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16496 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16499 vty_out(vty
, "%*snexthop vpn export %s\n",
16503 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16504 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16506 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16507 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16509 char *b
= ecommunity_ecom2str(
16510 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16511 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16512 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16513 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16515 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16516 char *b
= ecommunity_ecom2str(
16517 bgp
->vpn_policy
[afi
]
16518 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16519 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16520 ECOMMUNITY_ROUTE_TARGET
);
16521 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16522 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16524 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16525 char *b
= ecommunity_ecom2str(
16526 bgp
->vpn_policy
[afi
]
16527 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16528 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16529 ECOMMUNITY_ROUTE_TARGET
);
16530 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16531 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16535 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16536 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16537 bgp
->vpn_policy
[afi
]
16538 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16540 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16541 char *b
= ecommunity_ecom2str(
16542 bgp
->vpn_policy
[afi
]
16543 .import_redirect_rtlist
,
16544 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16545 ECOMMUNITY_ROUTE_TARGET
);
16547 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16548 != ECOMMUNITY_SIZE
)
16549 vty_out(vty
, "%*srt6 redirect import %s\n",
16552 vty_out(vty
, "%*srt redirect import %s\n",
16554 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16558 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16559 afi_t afi
, safi_t safi
)
16561 struct bgp_filter
*filter
;
16565 filter
= &peer
->filter
[afi
][safi
];
16567 /* distribute-list. */
16568 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16570 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16571 filter
->dlist
[FILTER_IN
].name
);
16573 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16575 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16576 filter
->dlist
[FILTER_OUT
].name
);
16579 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16581 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16582 filter
->plist
[FILTER_IN
].name
);
16584 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16586 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16587 filter
->plist
[FILTER_OUT
].name
);
16590 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16591 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16592 filter
->map
[RMAP_IN
].name
);
16594 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16596 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16597 filter
->map
[RMAP_OUT
].name
);
16599 /* unsuppress-map */
16600 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16601 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16602 filter
->usmap
.name
);
16604 /* advertise-map : always applied in OUT direction*/
16605 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16606 CONDITION_NON_EXIST
))
16608 " neighbor %s advertise-map %s non-exist-map %s\n",
16609 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16611 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16613 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16614 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16617 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16619 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16620 filter
->aslist
[FILTER_IN
].name
);
16622 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16624 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16625 filter
->aslist
[FILTER_OUT
].name
);
16628 /* BGP peer configuration display function. */
16629 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16632 struct peer
*g_peer
= NULL
;
16634 int if_pg_printed
= false;
16635 int if_ras_printed
= false;
16637 /* Skip dynamic neighbors. */
16638 if (peer_dynamic_neighbor(peer
))
16642 addr
= peer
->conf_if
;
16646 /************************************
16647 ****** Global to the neighbor ******
16648 ************************************/
16649 if (peer
->conf_if
) {
16650 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16651 vty_out(vty
, " neighbor %s interface v6only", addr
);
16653 vty_out(vty
, " neighbor %s interface", addr
);
16655 if (peer_group_active(peer
)) {
16656 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16657 if_pg_printed
= true;
16658 } else if (peer
->as_type
== AS_SPECIFIED
) {
16659 vty_out(vty
, " remote-as %u", peer
->as
);
16660 if_ras_printed
= true;
16661 } else if (peer
->as_type
== AS_INTERNAL
) {
16662 vty_out(vty
, " remote-as internal");
16663 if_ras_printed
= true;
16664 } else if (peer
->as_type
== AS_EXTERNAL
) {
16665 vty_out(vty
, " remote-as external");
16666 if_ras_printed
= true;
16669 vty_out(vty
, "\n");
16672 /* remote-as and peer-group */
16673 /* peer is a member of a peer-group */
16674 if (peer_group_active(peer
)) {
16675 g_peer
= peer
->group
->conf
;
16677 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16678 if (peer
->as_type
== AS_SPECIFIED
) {
16679 vty_out(vty
, " neighbor %s remote-as %u\n",
16681 } else if (peer
->as_type
== AS_INTERNAL
) {
16683 " neighbor %s remote-as internal\n",
16685 } else if (peer
->as_type
== AS_EXTERNAL
) {
16687 " neighbor %s remote-as external\n",
16692 /* For swpX peers we displayed the peer-group
16693 * via 'neighbor swpX interface peer-group PGNAME' */
16694 if (!if_pg_printed
)
16695 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16696 peer
->group
->name
);
16699 /* peer is NOT a member of a peer-group */
16701 /* peer is a peer-group, declare the peer-group */
16702 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16703 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16706 if (!if_ras_printed
) {
16707 if (peer
->as_type
== AS_SPECIFIED
) {
16708 vty_out(vty
, " neighbor %s remote-as %u\n",
16710 } else if (peer
->as_type
== AS_INTERNAL
) {
16712 " neighbor %s remote-as internal\n",
16714 } else if (peer
->as_type
== AS_EXTERNAL
) {
16716 " neighbor %s remote-as external\n",
16723 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16724 vty_out(vty
, " neighbor %s local-as %u", addr
,
16725 peer
->change_local_as
);
16726 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16727 vty_out(vty
, " no-prepend");
16728 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16729 vty_out(vty
, " replace-as");
16730 vty_out(vty
, "\n");
16735 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16739 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16740 if (peer
->tx_shutdown_message
)
16741 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16742 peer
->tx_shutdown_message
);
16744 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16747 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16748 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16749 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16752 if (peer
->bfd_config
)
16753 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16756 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16757 vty_out(vty
, " neighbor %s password %s\n", addr
,
16760 /* neighbor solo */
16761 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16762 if (!peer_group_active(peer
)) {
16763 vty_out(vty
, " neighbor %s solo\n", addr
);
16768 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16769 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16772 /* Local interface name */
16773 if (peer
->ifname
) {
16774 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16777 /* TCP max segment size */
16778 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16779 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16782 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16783 vty_out(vty
, " neighbor %s passive\n", addr
);
16785 /* ebgp-multihop */
16786 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16787 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16788 && peer
->ttl
== MAXTTL
)) {
16789 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16790 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16796 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16797 peer
->local_role
!= ROLE_UNDEFINED
)
16798 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16799 bgp_get_name_by_role(peer
->local_role
),
16800 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16804 /* ttl-security hops */
16805 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16806 if (!peer_group_active(peer
)
16807 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16808 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16809 addr
, peer
->gtsm_hops
);
16813 /* disable-connected-check */
16814 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16815 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16817 /* link-bw-encoding-ieee */
16818 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16819 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16822 /* extended-optional-parameters */
16823 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16824 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16827 /* enforce-first-as */
16828 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16829 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16831 /* update-source */
16832 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16833 if (peer
->update_source
)
16834 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16835 peer
->update_source
);
16836 else if (peer
->update_if
)
16837 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16841 /* advertisement-interval */
16842 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16843 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16847 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16848 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16849 peer
->keepalive
, peer
->holdtime
);
16851 /* timers connect */
16852 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16853 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16855 /* need special-case handling for changed default values due to
16856 * config profile / version (because there is no "timers bgp connect"
16857 * command, we need to save this per-peer :/)
16859 else if (!peer_group_active(peer
) && !peer
->connect
&&
16860 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16861 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16862 peer
->bgp
->default_connect_retry
);
16864 /* timers delayopen */
16865 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16866 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16868 /* Save config even though flag is not set if default values have been
16871 else if (!peer_group_active(peer
) && !peer
->delayopen
16872 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16873 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16874 peer
->bgp
->default_delayopen
);
16876 /* capability dynamic */
16877 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16878 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16880 /* capability extended-nexthop */
16881 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16882 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
16885 " no neighbor %s capability extended-nexthop\n",
16887 else if (!peer
->conf_if
)
16889 " neighbor %s capability extended-nexthop\n",
16893 /* dont-capability-negotiation */
16894 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16895 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16897 /* override-capability */
16898 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16899 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16901 /* strict-capability-match */
16902 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16903 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16905 /* Sender side AS path loop detection. */
16906 if (peer
->as_path_loop_detection
)
16907 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16910 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16911 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16913 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16914 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16916 " neighbor %s graceful-restart-helper\n", addr
);
16917 } else if (CHECK_FLAG(
16918 peer
->peer_gr_new_status_flag
,
16919 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16921 " neighbor %s graceful-restart\n", addr
);
16923 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16924 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16926 peer
->peer_gr_new_status_flag
,
16927 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16928 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16934 /* BGP peer configuration display function. */
16935 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16936 struct peer
*peer
, afi_t afi
, safi_t safi
)
16938 struct peer
*g_peer
= NULL
;
16940 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16942 /* Skip dynamic neighbors. */
16943 if (peer_dynamic_neighbor(peer
))
16947 addr
= peer
->conf_if
;
16951 /************************************
16952 ****** Per AF to the neighbor ******
16953 ************************************/
16954 if (peer_group_active(peer
)) {
16955 g_peer
= peer
->group
->conf
;
16957 /* If the peer-group is active but peer is not, print a 'no
16959 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16960 vty_out(vty
, " no neighbor %s activate\n", addr
);
16963 /* If the peer-group is not active but peer is, print an
16965 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16966 vty_out(vty
, " neighbor %s activate\n", addr
);
16969 if (peer
->afc
[afi
][safi
]) {
16970 if (safi
== SAFI_ENCAP
)
16971 vty_out(vty
, " neighbor %s activate\n", addr
);
16972 else if (!bgp
->default_af
[afi
][safi
])
16973 vty_out(vty
, " neighbor %s activate\n", addr
);
16975 if (bgp
->default_af
[afi
][safi
])
16976 vty_out(vty
, " no neighbor %s activate\n",
16981 /* addpath TX knobs */
16982 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16983 switch (peer
->addpath_type
[afi
][safi
]) {
16984 case BGP_ADDPATH_ALL
:
16985 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16988 case BGP_ADDPATH_BEST_PER_AS
:
16990 " neighbor %s addpath-tx-bestpath-per-AS\n",
16993 case BGP_ADDPATH_MAX
:
16994 case BGP_ADDPATH_NONE
:
16999 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17000 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17002 /* ORF capability. */
17003 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17004 || peergroup_af_flag_check(peer
, afi
, safi
,
17005 PEER_FLAG_ORF_PREFIX_RM
)) {
17006 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17008 if (peergroup_af_flag_check(peer
, afi
, safi
,
17009 PEER_FLAG_ORF_PREFIX_SM
)
17010 && peergroup_af_flag_check(peer
, afi
, safi
,
17011 PEER_FLAG_ORF_PREFIX_RM
))
17012 vty_out(vty
, " both");
17013 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17014 PEER_FLAG_ORF_PREFIX_SM
))
17015 vty_out(vty
, " send");
17017 vty_out(vty
, " receive");
17018 vty_out(vty
, "\n");
17021 /* Route reflector client. */
17022 if (peergroup_af_flag_check(peer
, afi
, safi
,
17023 PEER_FLAG_REFLECTOR_CLIENT
)) {
17024 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17027 /* next-hop-self force */
17028 if (peergroup_af_flag_check(peer
, afi
, safi
,
17029 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17030 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17033 /* next-hop-self */
17034 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17035 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17038 /* remove-private-AS */
17039 if (peergroup_af_flag_check(peer
, afi
, safi
,
17040 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17041 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17045 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17046 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17047 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17051 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17052 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17053 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17056 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17057 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17058 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17062 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17063 vty_out(vty
, " neighbor %s as-override\n", addr
);
17066 /* send-community print. */
17067 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17068 PEER_FLAG_SEND_COMMUNITY
);
17069 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17070 PEER_FLAG_SEND_EXT_COMMUNITY
);
17071 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17072 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17074 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17075 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17078 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17081 " no neighbor %s send-community extended\n",
17085 vty_out(vty
, " no neighbor %s send-community large\n",
17089 /* Default information */
17090 if (peergroup_af_flag_check(peer
, afi
, safi
,
17091 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17092 vty_out(vty
, " neighbor %s default-originate", addr
);
17094 if (peer
->default_rmap
[afi
][safi
].name
)
17095 vty_out(vty
, " route-map %s",
17096 peer
->default_rmap
[afi
][safi
].name
);
17098 vty_out(vty
, "\n");
17101 /* Soft reconfiguration inbound. */
17102 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17103 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17107 /* maximum-prefix. */
17108 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17109 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17110 peer
->pmax
[afi
][safi
]);
17112 if (peer
->pmax_threshold
[afi
][safi
]
17113 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17114 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17115 if (peer_af_flag_check(peer
, afi
, safi
,
17116 PEER_FLAG_MAX_PREFIX_WARNING
))
17117 vty_out(vty
, " warning-only");
17118 if (peer
->pmax_restart
[afi
][safi
])
17119 vty_out(vty
, " restart %u",
17120 peer
->pmax_restart
[afi
][safi
]);
17121 if (peer_af_flag_check(peer
, afi
, safi
,
17122 PEER_FLAG_MAX_PREFIX_FORCE
))
17123 vty_out(vty
, " force");
17125 vty_out(vty
, "\n");
17128 /* maximum-prefix-out */
17129 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17130 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17131 addr
, peer
->pmax_out
[afi
][safi
]);
17133 /* Route server client. */
17134 if (peergroup_af_flag_check(peer
, afi
, safi
,
17135 PEER_FLAG_RSERVER_CLIENT
)) {
17136 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17139 /* Nexthop-local unchanged. */
17140 if (peergroup_af_flag_check(peer
, afi
, safi
,
17141 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17142 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17145 /* allowas-in <1-10> */
17146 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17147 if (peer_af_flag_check(peer
, afi
, safi
,
17148 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17149 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17150 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17151 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17153 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17154 peer
->allowas_in
[afi
][safi
]);
17159 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17160 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17161 peer
->weight
[afi
][safi
]);
17164 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17166 /* atribute-unchanged. */
17167 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17168 || (safi
!= SAFI_EVPN
17169 && peer_af_flag_check(peer
, afi
, safi
,
17170 PEER_FLAG_NEXTHOP_UNCHANGED
))
17171 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17173 if (!peer_group_active(peer
)
17174 || peergroup_af_flag_check(peer
, afi
, safi
,
17175 PEER_FLAG_AS_PATH_UNCHANGED
)
17176 || peergroup_af_flag_check(peer
, afi
, safi
,
17177 PEER_FLAG_NEXTHOP_UNCHANGED
)
17178 || peergroup_af_flag_check(peer
, afi
, safi
,
17179 PEER_FLAG_MED_UNCHANGED
)) {
17182 " neighbor %s attribute-unchanged%s%s%s\n",
17184 peer_af_flag_check(peer
, afi
, safi
,
17185 PEER_FLAG_AS_PATH_UNCHANGED
)
17188 peer_af_flag_check(peer
, afi
, safi
,
17189 PEER_FLAG_NEXTHOP_UNCHANGED
)
17192 peer_af_flag_check(peer
, afi
, safi
,
17193 PEER_FLAG_MED_UNCHANGED
)
17200 /* Address family based peer configuration display. */
17201 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17205 struct peer_group
*group
;
17206 struct listnode
*node
, *nnode
;
17209 vty_frame(vty
, " !\n address-family ");
17210 if (afi
== AFI_IP
) {
17211 if (safi
== SAFI_UNICAST
)
17212 vty_frame(vty
, "ipv4 unicast");
17213 else if (safi
== SAFI_LABELED_UNICAST
)
17214 vty_frame(vty
, "ipv4 labeled-unicast");
17215 else if (safi
== SAFI_MULTICAST
)
17216 vty_frame(vty
, "ipv4 multicast");
17217 else if (safi
== SAFI_MPLS_VPN
)
17218 vty_frame(vty
, "ipv4 vpn");
17219 else if (safi
== SAFI_ENCAP
)
17220 vty_frame(vty
, "ipv4 encap");
17221 else if (safi
== SAFI_FLOWSPEC
)
17222 vty_frame(vty
, "ipv4 flowspec");
17223 } else if (afi
== AFI_IP6
) {
17224 if (safi
== SAFI_UNICAST
)
17225 vty_frame(vty
, "ipv6 unicast");
17226 else if (safi
== SAFI_LABELED_UNICAST
)
17227 vty_frame(vty
, "ipv6 labeled-unicast");
17228 else if (safi
== SAFI_MULTICAST
)
17229 vty_frame(vty
, "ipv6 multicast");
17230 else if (safi
== SAFI_MPLS_VPN
)
17231 vty_frame(vty
, "ipv6 vpn");
17232 else if (safi
== SAFI_ENCAP
)
17233 vty_frame(vty
, "ipv6 encap");
17234 else if (safi
== SAFI_FLOWSPEC
)
17235 vty_frame(vty
, "ipv6 flowspec");
17236 } else if (afi
== AFI_L2VPN
) {
17237 if (safi
== SAFI_EVPN
)
17238 vty_frame(vty
, "l2vpn evpn");
17240 vty_frame(vty
, "\n");
17242 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17244 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17246 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17248 /* BGP flag dampening. */
17249 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17250 bgp_config_write_damp(vty
, afi
, safi
);
17252 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17253 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17255 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17256 /* Do not display doppelganger peers */
17257 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17258 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17261 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17262 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17264 if (safi
== SAFI_EVPN
)
17265 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17267 if (safi
== SAFI_FLOWSPEC
)
17268 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17270 if (safi
== SAFI_UNICAST
) {
17271 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17272 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17273 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17275 vty_out(vty
, " export vpn\n");
17277 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17278 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17280 vty_out(vty
, " import vpn\n");
17282 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17283 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17286 for (ALL_LIST_ELEMENTS_RO(
17287 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17289 vty_out(vty
, " import vrf %s\n", name
);
17293 vty_endframe(vty
, " exit-address-family\n");
17296 int bgp_config_write(struct vty
*vty
)
17299 struct peer_group
*group
;
17301 struct listnode
*node
, *nnode
;
17302 struct listnode
*mnode
, *mnnode
;
17306 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17307 vty_out(vty
, "bgp route-map delay-timer %u\n",
17308 bm
->rmap_update_timer
);
17310 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17311 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17312 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17313 vty_out(vty
, " %d", bm
->v_establish_wait
);
17314 vty_out(vty
, "\n");
17317 if (bm
->wait_for_fib
)
17318 vty_out(vty
, "bgp suppress-fib-pending\n");
17320 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17321 vty_out(vty
, "bgp graceful-shutdown\n");
17323 /* No-RIB (Zebra) option flag configuration */
17324 if (bgp_option_check(BGP_OPT_NO_FIB
))
17325 vty_out(vty
, "bgp no-rib\n");
17327 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17328 vty_out(vty
, "bgp send-extra-data zebra\n");
17330 /* BGP session DSCP value */
17331 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17332 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17334 /* BGP configuration. */
17335 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17337 /* skip all auto created vrf as they dont have user config */
17338 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17341 /* Router bgp ASN */
17342 vty_out(vty
, "router bgp %u", bgp
->as
);
17345 vty_out(vty
, " %s %s",
17346 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17347 ? "view" : "vrf", bgp
->name
);
17348 vty_out(vty
, "\n");
17350 /* BGP fast-external-failover. */
17351 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17352 vty_out(vty
, " no bgp fast-external-failover\n");
17354 /* BGP router ID. */
17355 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17356 vty_out(vty
, " bgp router-id %pI4\n",
17357 &bgp
->router_id_static
);
17359 /* Suppress fib pending */
17360 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17361 vty_out(vty
, " bgp suppress-fib-pending\n");
17363 /* BGP log-neighbor-changes. */
17364 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17365 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17366 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17367 CHECK_FLAG(bgp
->flags
,
17368 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17372 /* BGP configuration. */
17373 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17374 vty_out(vty
, " bgp always-compare-med\n");
17376 /* RFC8212 default eBGP policy. */
17377 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17378 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17379 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17380 CHECK_FLAG(bgp
->flags
,
17381 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17385 /* draft-ietf-idr-deprecate-as-set-confed-set */
17386 if (bgp
->reject_as_sets
)
17387 vty_out(vty
, " bgp reject-as-sets\n");
17389 /* Suppress duplicate updates if the route actually not changed
17391 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17392 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17393 vty_out(vty
, " %sbgp suppress-duplicates\n",
17394 CHECK_FLAG(bgp
->flags
,
17395 BGP_FLAG_SUPPRESS_DUPLICATES
)
17399 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17401 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17402 SAVE_BGP_HARD_ADMIN_RESET
)
17403 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17404 CHECK_FLAG(bgp
->flags
,
17405 BGP_FLAG_HARD_ADMIN_RESET
)
17409 /* BGP default <afi>-<safi> */
17410 FOREACH_AFI_SAFI (afi
, safi
) {
17411 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17412 if (!bgp
->default_af
[afi
][safi
])
17413 vty_out(vty
, " no bgp default %s\n",
17414 get_bgp_default_af_flag(afi
,
17416 } else if (bgp
->default_af
[afi
][safi
])
17417 vty_out(vty
, " bgp default %s\n",
17418 get_bgp_default_af_flag(afi
, safi
));
17421 /* BGP default local-preference. */
17422 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17423 vty_out(vty
, " bgp default local-preference %u\n",
17424 bgp
->default_local_pref
);
17426 /* BGP default show-hostname */
17427 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17428 != SAVE_BGP_SHOW_HOSTNAME
)
17429 vty_out(vty
, " %sbgp default show-hostname\n",
17430 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17434 /* BGP default show-nexthop-hostname */
17435 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17436 != SAVE_BGP_SHOW_HOSTNAME
)
17437 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17438 CHECK_FLAG(bgp
->flags
,
17439 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17443 /* BGP default subgroup-pkt-queue-max. */
17444 if (bgp
->default_subgroup_pkt_queue_max
17445 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17446 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17447 bgp
->default_subgroup_pkt_queue_max
);
17449 /* BGP client-to-client reflection. */
17450 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17451 vty_out(vty
, " no bgp client-to-client reflection\n");
17453 /* BGP cluster ID. */
17454 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17455 vty_out(vty
, " bgp cluster-id %pI4\n",
17458 /* Disable ebgp connected nexthop check */
17459 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17461 " bgp disable-ebgp-connected-route-check\n");
17463 /* Confederation identifier*/
17464 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17465 vty_out(vty
, " bgp confederation identifier %u\n",
17468 /* Confederation peer */
17469 if (bgp
->confed_peers_cnt
> 0) {
17472 vty_out(vty
, " bgp confederation peers");
17474 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17475 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17477 vty_out(vty
, "\n");
17480 /* BGP deterministic-med. */
17481 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17482 != SAVE_BGP_DETERMINISTIC_MED
)
17483 vty_out(vty
, " %sbgp deterministic-med\n",
17484 CHECK_FLAG(bgp
->flags
,
17485 BGP_FLAG_DETERMINISTIC_MED
)
17489 /* BGP update-delay. */
17490 bgp_config_write_update_delay(vty
, bgp
);
17492 if (bgp
->v_maxmed_onstartup
17493 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17494 vty_out(vty
, " bgp max-med on-startup %u",
17495 bgp
->v_maxmed_onstartup
);
17496 if (bgp
->maxmed_onstartup_value
17497 != BGP_MAXMED_VALUE_DEFAULT
)
17498 vty_out(vty
, " %u",
17499 bgp
->maxmed_onstartup_value
);
17500 vty_out(vty
, "\n");
17502 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17503 vty_out(vty
, " bgp max-med administrative");
17504 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17505 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17506 vty_out(vty
, "\n");
17510 bgp_config_write_wpkt_quanta(vty
, bgp
);
17512 bgp_config_write_rpkt_quanta(vty
, bgp
);
17514 /* coalesce time */
17515 bgp_config_write_coalesce_time(vty
, bgp
);
17517 /* BGP per-instance graceful-shutdown */
17518 /* BGP-wide settings and per-instance settings are mutually
17521 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17523 vty_out(vty
, " bgp graceful-shutdown\n");
17525 /* Long-lived Graceful Restart */
17526 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17528 " bgp long-lived-graceful-restart stale-time %u\n",
17529 bgp
->llgr_stale_time
);
17531 /* BGP graceful-restart. */
17532 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17534 " bgp graceful-restart stalepath-time %u\n",
17535 bgp
->stalepath_time
);
17537 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17538 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17539 bgp
->restart_time
);
17541 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17542 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17543 vty_out(vty
, " %sbgp graceful-restart notification\n",
17544 CHECK_FLAG(bgp
->flags
,
17545 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17549 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17551 " bgp graceful-restart select-defer-time %u\n",
17552 bgp
->select_defer_time
);
17554 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17555 vty_out(vty
, " bgp graceful-restart\n");
17557 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17558 vty_out(vty
, " bgp graceful-restart-disable\n");
17560 /* BGP graceful-restart Preserve State F bit. */
17561 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17563 " bgp graceful-restart preserve-fw-state\n");
17565 /* Stale timer for RIB */
17566 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17568 " bgp graceful-restart rib-stale-time %u\n",
17569 bgp
->rib_stale_time
);
17571 /* BGP bestpath method. */
17572 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17573 vty_out(vty
, " bgp bestpath as-path ignore\n");
17574 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17575 vty_out(vty
, " bgp bestpath as-path confed\n");
17577 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17578 if (CHECK_FLAG(bgp
->flags
,
17579 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17581 " bgp bestpath as-path multipath-relax as-set\n");
17584 " bgp bestpath as-path multipath-relax\n");
17588 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17590 " bgp route-reflector allow-outbound-policy\n");
17592 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17593 vty_out(vty
, " bgp bestpath compare-routerid\n");
17594 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17595 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17596 vty_out(vty
, " bgp bestpath med");
17597 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17598 vty_out(vty
, " confed");
17599 if (CHECK_FLAG(bgp
->flags
,
17600 BGP_FLAG_MED_MISSING_AS_WORST
))
17601 vty_out(vty
, " missing-as-worst");
17602 vty_out(vty
, "\n");
17605 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17607 " bgp bestpath peer-type multipath-relax\n");
17609 /* Link bandwidth handling. */
17610 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17611 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17612 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17613 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17614 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17615 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17617 /* BGP network import check. */
17618 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17619 != SAVE_BGP_IMPORT_CHECK
)
17620 vty_out(vty
, " %sbgp network import-check\n",
17621 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17625 /* BGP timers configuration. */
17626 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17627 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17628 vty_out(vty
, " timers bgp %u %u\n",
17629 bgp
->default_keepalive
, bgp
->default_holdtime
);
17631 /* BGP minimum holdtime configuration. */
17632 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17633 && bgp
->default_min_holdtime
!= 0)
17634 vty_out(vty
, " bgp minimum-holdtime %u\n",
17635 bgp
->default_min_holdtime
);
17637 /* Conditional advertisement timer configuration */
17638 if (bgp
->condition_check_period
17639 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17641 " bgp conditional-advertisement timer %u\n",
17642 bgp
->condition_check_period
);
17645 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17646 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17649 /* Normal neighbor configuration. */
17650 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17651 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17652 bgp_config_write_peer_global(vty
, bgp
, peer
);
17655 /* listen range and limit for dynamic BGP neighbors */
17656 bgp_config_write_listen(vty
, bgp
);
17659 * BGP default autoshutdown neighbors
17661 * This must be placed after any peer and peer-group
17662 * configuration, to avoid setting all peers to shutdown after
17663 * a daemon restart, which is undesired behavior. (see #2286)
17665 if (bgp
->autoshutdown
)
17666 vty_out(vty
, " bgp default shutdown\n");
17668 /* BGP instance administrative shutdown */
17669 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17670 vty_out(vty
, " bgp shutdown\n");
17672 if (bgp
->allow_martian
)
17673 vty_out(vty
, " bgp allow-martian-nexthop\n");
17675 if (bgp
->fast_convergence
)
17676 vty_out(vty
, " bgp fast-convergence\n");
17678 if (bgp
->srv6_enabled
) {
17679 vty_frame(vty
, " !\n segment-routing srv6\n");
17680 if (strlen(bgp
->srv6_locator_name
))
17681 vty_out(vty
, " locator %s\n",
17682 bgp
->srv6_locator_name
);
17683 vty_endframe(vty
, " exit\n");
17687 /* IPv4 unicast configuration. */
17688 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17690 /* IPv4 multicast configuration. */
17691 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17693 /* IPv4 labeled-unicast configuration. */
17694 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17696 /* IPv4 VPN configuration. */
17697 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17699 /* ENCAPv4 configuration. */
17700 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17702 /* FLOWSPEC v4 configuration. */
17703 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17705 /* IPv6 unicast configuration. */
17706 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17708 /* IPv6 multicast configuration. */
17709 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17711 /* IPv6 labeled-unicast configuration. */
17712 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17713 SAFI_LABELED_UNICAST
);
17715 /* IPv6 VPN configuration. */
17716 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17718 /* ENCAPv6 configuration. */
17719 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17721 /* FLOWSPEC v6 configuration. */
17722 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17724 /* EVPN configuration. */
17725 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17727 hook_call(bgp_inst_config_write
, bgp
, vty
);
17729 #ifdef ENABLE_BGP_VNC
17730 bgp_rfapi_cfg_write(vty
, bgp
);
17733 vty_out(vty
, "exit\n");
17734 vty_out(vty
, "!\n");
17740 /* BGP node structure. */
17741 static struct cmd_node bgp_node
= {
17744 .parent_node
= CONFIG_NODE
,
17745 .prompt
= "%s(config-router)# ",
17746 .config_write
= bgp_config_write
,
17749 static struct cmd_node bgp_ipv4_unicast_node
= {
17750 .name
= "bgp ipv4 unicast",
17751 .node
= BGP_IPV4_NODE
,
17752 .parent_node
= BGP_NODE
,
17753 .prompt
= "%s(config-router-af)# ",
17757 static struct cmd_node bgp_ipv4_multicast_node
= {
17758 .name
= "bgp ipv4 multicast",
17759 .node
= BGP_IPV4M_NODE
,
17760 .parent_node
= BGP_NODE
,
17761 .prompt
= "%s(config-router-af)# ",
17765 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17766 .name
= "bgp ipv4 labeled unicast",
17767 .node
= BGP_IPV4L_NODE
,
17768 .parent_node
= BGP_NODE
,
17769 .prompt
= "%s(config-router-af)# ",
17773 static struct cmd_node bgp_ipv6_unicast_node
= {
17774 .name
= "bgp ipv6 unicast",
17775 .node
= BGP_IPV6_NODE
,
17776 .parent_node
= BGP_NODE
,
17777 .prompt
= "%s(config-router-af)# ",
17781 static struct cmd_node bgp_ipv6_multicast_node
= {
17782 .name
= "bgp ipv6 multicast",
17783 .node
= BGP_IPV6M_NODE
,
17784 .parent_node
= BGP_NODE
,
17785 .prompt
= "%s(config-router-af)# ",
17789 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17790 .name
= "bgp ipv6 labeled unicast",
17791 .node
= BGP_IPV6L_NODE
,
17792 .parent_node
= BGP_NODE
,
17793 .prompt
= "%s(config-router-af)# ",
17797 static struct cmd_node bgp_vpnv4_node
= {
17798 .name
= "bgp vpnv4",
17799 .node
= BGP_VPNV4_NODE
,
17800 .parent_node
= BGP_NODE
,
17801 .prompt
= "%s(config-router-af)# ",
17805 static struct cmd_node bgp_vpnv6_node
= {
17806 .name
= "bgp vpnv6",
17807 .node
= BGP_VPNV6_NODE
,
17808 .parent_node
= BGP_NODE
,
17809 .prompt
= "%s(config-router-af-vpnv6)# ",
17813 static struct cmd_node bgp_evpn_node
= {
17814 .name
= "bgp evpn",
17815 .node
= BGP_EVPN_NODE
,
17816 .parent_node
= BGP_NODE
,
17817 .prompt
= "%s(config-router-evpn)# ",
17821 static struct cmd_node bgp_evpn_vni_node
= {
17822 .name
= "bgp evpn vni",
17823 .node
= BGP_EVPN_VNI_NODE
,
17824 .parent_node
= BGP_EVPN_NODE
,
17825 .prompt
= "%s(config-router-af-vni)# ",
17828 static struct cmd_node bgp_flowspecv4_node
= {
17829 .name
= "bgp ipv4 flowspec",
17830 .node
= BGP_FLOWSPECV4_NODE
,
17831 .parent_node
= BGP_NODE
,
17832 .prompt
= "%s(config-router-af)# ",
17836 static struct cmd_node bgp_flowspecv6_node
= {
17837 .name
= "bgp ipv6 flowspec",
17838 .node
= BGP_FLOWSPECV6_NODE
,
17839 .parent_node
= BGP_NODE
,
17840 .prompt
= "%s(config-router-af-vpnv6)# ",
17844 static struct cmd_node bgp_srv6_node
= {
17845 .name
= "bgp srv6",
17846 .node
= BGP_SRV6_NODE
,
17847 .parent_node
= BGP_NODE
,
17848 .prompt
= "%s(config-router-srv6)# ",
17851 static void community_list_vty(void);
17853 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17856 struct peer_group
*group
;
17857 struct listnode
*lnbgp
, *lnpeer
;
17859 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17860 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17862 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17866 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17870 struct listnode
*lnbgp
, *lnpeer
;
17872 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17873 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17874 /* only provide suggestions on the appropriate input
17876 * they'll otherwise show up multiple times */
17877 enum cmd_token_type match_type
;
17878 char *name
= peer
->host
;
17880 if (peer
->conf_if
) {
17881 match_type
= VARIABLE_TKN
;
17882 name
= peer
->conf_if
;
17883 } else if (strchr(peer
->host
, ':'))
17884 match_type
= IPV6_TKN
;
17886 match_type
= IPV4_TKN
;
17888 if (token
->type
!= match_type
)
17891 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17896 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17898 bgp_ac_peer(comps
, token
);
17900 if (token
->type
== VARIABLE_TKN
)
17901 bgp_ac_peergroup(comps
, token
);
17904 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17905 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17906 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17907 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17908 {.completions
= NULL
}};
17910 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17911 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17912 {.completions
= NULL
} };
17914 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
17916 static struct thread
*t_bgp_cfg
;
17918 bool bgp_config_inprocess(void)
17920 return thread_is_scheduled(t_bgp_cfg
);
17923 static void bgp_config_finish(struct thread
*t
)
17925 struct listnode
*node
;
17928 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
17929 hook_call(bgp_config_end
, bgp
);
17932 static void bgp_config_start(void)
17934 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
17935 THREAD_OFF(t_bgp_cfg
);
17936 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17937 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
17940 /* When we receive a hook the configuration is read,
17941 * we start a timer to make sure we postpone sending
17942 * EoR before route-maps are processed.
17943 * This is especially valid if using `bgp route-map delay-timer`.
17945 static void bgp_config_end(void)
17947 #define BGP_POST_CONFIG_DELAY_SECONDS 1
17948 uint32_t bgp_post_config_delay
=
17949 thread_is_scheduled(bm
->t_rmap_update
)
17950 ? thread_timer_remain_second(bm
->t_rmap_update
)
17951 : BGP_POST_CONFIG_DELAY_SECONDS
;
17953 /* If BGP config processing thread isn't running, then
17954 * we can return and rely it's properly handled.
17956 if (!bgp_config_inprocess())
17959 THREAD_OFF(t_bgp_cfg
);
17961 /* Start a new timer to make sure we don't send EoR
17962 * before route-maps are processed.
17964 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17965 bgp_post_config_delay
, &t_bgp_cfg
);
17968 void bgp_vty_init(void)
17970 cmd_variable_handler_register(bgp_var_neighbor
);
17971 cmd_variable_handler_register(bgp_var_peergroup
);
17973 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
17975 /* Install bgp top node. */
17976 install_node(&bgp_node
);
17977 install_node(&bgp_ipv4_unicast_node
);
17978 install_node(&bgp_ipv4_multicast_node
);
17979 install_node(&bgp_ipv4_labeled_unicast_node
);
17980 install_node(&bgp_ipv6_unicast_node
);
17981 install_node(&bgp_ipv6_multicast_node
);
17982 install_node(&bgp_ipv6_labeled_unicast_node
);
17983 install_node(&bgp_vpnv4_node
);
17984 install_node(&bgp_vpnv6_node
);
17985 install_node(&bgp_evpn_node
);
17986 install_node(&bgp_evpn_vni_node
);
17987 install_node(&bgp_flowspecv4_node
);
17988 install_node(&bgp_flowspecv6_node
);
17989 install_node(&bgp_srv6_node
);
17991 /* Install default VTY commands to new nodes. */
17992 install_default(BGP_NODE
);
17993 install_default(BGP_IPV4_NODE
);
17994 install_default(BGP_IPV4M_NODE
);
17995 install_default(BGP_IPV4L_NODE
);
17996 install_default(BGP_IPV6_NODE
);
17997 install_default(BGP_IPV6M_NODE
);
17998 install_default(BGP_IPV6L_NODE
);
17999 install_default(BGP_VPNV4_NODE
);
18000 install_default(BGP_VPNV6_NODE
);
18001 install_default(BGP_FLOWSPECV4_NODE
);
18002 install_default(BGP_FLOWSPECV6_NODE
);
18003 install_default(BGP_EVPN_NODE
);
18004 install_default(BGP_EVPN_VNI_NODE
);
18005 install_default(BGP_SRV6_NODE
);
18007 /* "bgp local-mac" hidden commands. */
18008 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18009 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18011 /* "bgp suppress-fib-pending" global */
18012 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18014 /* bgp route-map delay-timer commands. */
18015 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18016 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18018 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18020 /* bgp fast-convergence command */
18021 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18022 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18024 /* global bgp update-delay command */
18025 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18026 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18028 /* global bgp graceful-shutdown command */
18029 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18030 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18032 /* Dummy commands (Currently not supported) */
18033 install_element(BGP_NODE
, &no_synchronization_cmd
);
18034 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18036 /* "router bgp" commands. */
18037 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18039 /* "no router bgp" commands. */
18040 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18042 /* "bgp session-dscp command */
18043 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18044 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18046 /* "bgp router-id" commands. */
18047 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18048 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18050 /* "bgp suppress-fib-pending" command */
18051 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18053 /* "bgp cluster-id" commands. */
18054 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18055 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18057 /* "bgp no-rib" commands. */
18058 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18059 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18061 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18063 /* "bgp confederation" commands. */
18064 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18065 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18067 /* "bgp confederation peers" commands. */
18068 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18069 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18071 /* bgp max-med command */
18072 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18073 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18074 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18075 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18076 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18078 /* "neighbor role" commands. */
18079 install_element(BGP_NODE
, &neighbor_role_cmd
);
18080 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18081 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18083 /* bgp disable-ebgp-connected-nh-check */
18084 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18085 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18087 /* bgp update-delay command */
18088 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18089 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18091 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18092 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18094 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18095 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18097 /* "maximum-paths" commands. */
18098 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18099 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18100 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18101 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18102 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18103 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18104 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18105 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18106 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18107 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18108 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18109 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18110 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18111 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18112 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18114 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18115 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18116 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18117 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18118 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18119 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18120 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18121 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18122 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18123 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18125 /* "timers bgp" commands. */
18126 install_element(BGP_NODE
, &bgp_timers_cmd
);
18127 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18129 /* "minimum-holdtime" commands. */
18130 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18131 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18133 /* route-map delay-timer commands - per instance for backwards compat.
18135 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18136 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18138 /* "bgp client-to-client reflection" commands */
18139 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18140 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18142 /* "bgp always-compare-med" commands */
18143 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18144 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18146 /* bgp ebgp-requires-policy */
18147 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18148 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18150 /* bgp suppress-duplicates */
18151 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18152 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18154 /* bgp reject-as-sets */
18155 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18156 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18158 /* "bgp deterministic-med" commands */
18159 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18160 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18162 /* "bgp graceful-restart" command */
18163 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18164 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18166 /* "bgp graceful-restart-disable" command */
18167 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18168 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18170 /* "neighbor a:b:c:d graceful-restart" command */
18171 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18172 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18174 /* "neighbor a:b:c:d graceful-restart-disable" command */
18175 install_element(BGP_NODE
,
18176 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18177 install_element(BGP_NODE
,
18178 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18180 /* "neighbor a:b:c:d graceful-restart-helper" command */
18181 install_element(BGP_NODE
,
18182 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18183 install_element(BGP_NODE
,
18184 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18186 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18187 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18188 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18189 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18190 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18191 install_element(BGP_NODE
,
18192 &no_bgp_graceful_restart_select_defer_time_cmd
);
18193 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18194 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18195 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18197 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18198 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18199 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18200 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18202 /* "bgp graceful-shutdown" commands */
18203 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18204 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18206 /* "bgp hard-administrative-reset" commands */
18207 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18209 /* "bgp long-lived-graceful-restart" commands */
18210 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18211 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18213 /* "bgp fast-external-failover" commands */
18214 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18215 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18217 /* "bgp bestpath compare-routerid" commands */
18218 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18219 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18221 /* "bgp bestpath as-path ignore" commands */
18222 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18223 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18225 /* "bgp bestpath as-path confed" commands */
18226 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18227 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18229 /* "bgp bestpath as-path multipath-relax" commands */
18230 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18231 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18233 /* "bgp bestpath peer-type multipath-relax" commands */
18234 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18235 install_element(BGP_NODE
,
18236 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18238 /* "bgp log-neighbor-changes" commands */
18239 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18240 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18242 /* "bgp bestpath med" commands */
18243 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18244 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18246 /* "bgp bestpath bandwidth" commands */
18247 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18248 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18250 /* "no bgp default <afi>-<safi>" commands. */
18251 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18253 /* "bgp network import-check" commands. */
18254 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18255 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18256 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18258 /* "bgp default local-preference" commands. */
18259 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18260 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18262 /* bgp default show-hostname */
18263 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18264 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18266 /* bgp default show-nexthop-hostname */
18267 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18268 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18270 /* "bgp default subgroup-pkt-queue-max" commands. */
18271 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18272 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18274 /* bgp ibgp-allow-policy-mods command */
18275 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18276 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18278 /* "bgp listen limit" commands. */
18279 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18280 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18282 /* "bgp listen range" commands. */
18283 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18284 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18286 /* "bgp default shutdown" command */
18287 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18289 /* "bgp shutdown" commands */
18290 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18291 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18292 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18293 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18295 /* "neighbor remote-as" commands. */
18296 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18297 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18298 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18299 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18300 install_element(BGP_NODE
,
18301 &neighbor_interface_v6only_config_remote_as_cmd
);
18302 install_element(BGP_NODE
, &no_neighbor_cmd
);
18303 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18305 /* "neighbor peer-group" commands. */
18306 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18307 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18308 install_element(BGP_NODE
,
18309 &no_neighbor_interface_peer_group_remote_as_cmd
);
18311 /* "neighbor local-as" commands. */
18312 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18313 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18314 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18315 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18317 /* "neighbor solo" commands. */
18318 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18319 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18321 /* "neighbor password" commands. */
18322 install_element(BGP_NODE
, &neighbor_password_cmd
);
18323 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18325 /* "neighbor activate" commands. */
18326 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18327 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18328 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18329 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18330 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18331 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18332 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18333 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18334 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18335 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18336 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18337 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18339 /* "no neighbor activate" commands. */
18340 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18341 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18342 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18343 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18344 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18345 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18346 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18347 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18348 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18349 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18350 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18351 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18353 /* "neighbor peer-group" set commands. */
18354 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18355 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18356 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18357 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18358 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18359 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18360 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18361 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18362 install_element(BGP_FLOWSPECV4_NODE
,
18363 &neighbor_set_peer_group_hidden_cmd
);
18364 install_element(BGP_FLOWSPECV6_NODE
,
18365 &neighbor_set_peer_group_hidden_cmd
);
18367 /* "no neighbor peer-group unset" commands. */
18368 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18369 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18370 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18371 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18372 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18373 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18374 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18375 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18376 install_element(BGP_FLOWSPECV4_NODE
,
18377 &no_neighbor_set_peer_group_hidden_cmd
);
18378 install_element(BGP_FLOWSPECV6_NODE
,
18379 &no_neighbor_set_peer_group_hidden_cmd
);
18381 /* "neighbor softreconfiguration inbound" commands.*/
18382 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18383 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18384 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18385 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18386 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18387 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18388 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18389 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18390 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18391 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18392 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18393 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18394 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18395 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18396 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18397 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18398 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18399 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18400 install_element(BGP_FLOWSPECV4_NODE
,
18401 &neighbor_soft_reconfiguration_cmd
);
18402 install_element(BGP_FLOWSPECV4_NODE
,
18403 &no_neighbor_soft_reconfiguration_cmd
);
18404 install_element(BGP_FLOWSPECV6_NODE
,
18405 &neighbor_soft_reconfiguration_cmd
);
18406 install_element(BGP_FLOWSPECV6_NODE
,
18407 &no_neighbor_soft_reconfiguration_cmd
);
18408 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18409 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18411 /* "neighbor attribute-unchanged" commands. */
18412 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18413 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18414 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18415 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18416 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18417 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18418 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18419 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18420 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18421 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18422 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18423 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18424 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18425 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18426 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18427 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18428 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18429 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18431 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18432 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18434 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18435 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18436 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18437 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18439 /* "nexthop-local unchanged" commands */
18440 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18441 install_element(BGP_IPV6_NODE
,
18442 &no_neighbor_nexthop_local_unchanged_cmd
);
18444 /* "neighbor next-hop-self" commands. */
18445 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18446 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18447 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18448 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18449 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18450 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18451 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18452 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18453 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18454 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18455 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18456 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18457 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18458 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18459 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18460 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18461 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18462 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18463 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18464 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18466 /* "neighbor next-hop-self force" commands. */
18467 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18468 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18469 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18470 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18471 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18472 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18473 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18474 install_element(BGP_IPV4_NODE
,
18475 &no_neighbor_nexthop_self_all_hidden_cmd
);
18476 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18477 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18478 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18479 install_element(BGP_IPV4M_NODE
,
18480 &no_neighbor_nexthop_self_all_hidden_cmd
);
18481 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18482 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18483 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18484 install_element(BGP_IPV4L_NODE
,
18485 &no_neighbor_nexthop_self_all_hidden_cmd
);
18486 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18487 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18488 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18489 install_element(BGP_IPV6_NODE
,
18490 &no_neighbor_nexthop_self_all_hidden_cmd
);
18491 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18492 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18493 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18494 install_element(BGP_IPV6M_NODE
,
18495 &no_neighbor_nexthop_self_all_hidden_cmd
);
18496 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18497 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18498 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18499 install_element(BGP_IPV6L_NODE
,
18500 &no_neighbor_nexthop_self_all_hidden_cmd
);
18501 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18502 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18503 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18504 install_element(BGP_VPNV4_NODE
,
18505 &no_neighbor_nexthop_self_all_hidden_cmd
);
18506 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18507 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18508 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18509 install_element(BGP_VPNV6_NODE
,
18510 &no_neighbor_nexthop_self_all_hidden_cmd
);
18511 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18512 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18514 /* "neighbor as-override" commands. */
18515 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18516 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18517 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18518 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18519 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18520 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18521 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18522 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18523 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18524 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18525 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18526 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18527 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18528 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18529 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18530 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18531 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18532 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18534 /* "neighbor remove-private-AS" commands. */
18535 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18536 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18537 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18538 install_element(BGP_NODE
,
18539 &no_neighbor_remove_private_as_all_hidden_cmd
);
18540 install_element(BGP_NODE
,
18541 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18542 install_element(BGP_NODE
,
18543 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18544 install_element(BGP_NODE
,
18545 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18548 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18549 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18550 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18551 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18552 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18553 install_element(BGP_IPV4_NODE
,
18554 &neighbor_remove_private_as_replace_as_cmd
);
18555 install_element(BGP_IPV4_NODE
,
18556 &no_neighbor_remove_private_as_replace_as_cmd
);
18557 install_element(BGP_IPV4_NODE
,
18558 &neighbor_remove_private_as_all_replace_as_cmd
);
18559 install_element(BGP_IPV4_NODE
,
18560 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18561 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18562 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18563 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18564 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18565 install_element(BGP_IPV4M_NODE
,
18566 &neighbor_remove_private_as_replace_as_cmd
);
18567 install_element(BGP_IPV4M_NODE
,
18568 &no_neighbor_remove_private_as_replace_as_cmd
);
18569 install_element(BGP_IPV4M_NODE
,
18570 &neighbor_remove_private_as_all_replace_as_cmd
);
18571 install_element(BGP_IPV4M_NODE
,
18572 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18573 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18574 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18575 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18576 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18577 install_element(BGP_IPV4L_NODE
,
18578 &neighbor_remove_private_as_replace_as_cmd
);
18579 install_element(BGP_IPV4L_NODE
,
18580 &no_neighbor_remove_private_as_replace_as_cmd
);
18581 install_element(BGP_IPV4L_NODE
,
18582 &neighbor_remove_private_as_all_replace_as_cmd
);
18583 install_element(BGP_IPV4L_NODE
,
18584 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18585 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18586 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18587 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18588 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18589 install_element(BGP_IPV6_NODE
,
18590 &neighbor_remove_private_as_replace_as_cmd
);
18591 install_element(BGP_IPV6_NODE
,
18592 &no_neighbor_remove_private_as_replace_as_cmd
);
18593 install_element(BGP_IPV6_NODE
,
18594 &neighbor_remove_private_as_all_replace_as_cmd
);
18595 install_element(BGP_IPV6_NODE
,
18596 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18597 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18598 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18599 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18600 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18601 install_element(BGP_IPV6M_NODE
,
18602 &neighbor_remove_private_as_replace_as_cmd
);
18603 install_element(BGP_IPV6M_NODE
,
18604 &no_neighbor_remove_private_as_replace_as_cmd
);
18605 install_element(BGP_IPV6M_NODE
,
18606 &neighbor_remove_private_as_all_replace_as_cmd
);
18607 install_element(BGP_IPV6M_NODE
,
18608 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18609 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18610 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18611 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18612 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18613 install_element(BGP_IPV6L_NODE
,
18614 &neighbor_remove_private_as_replace_as_cmd
);
18615 install_element(BGP_IPV6L_NODE
,
18616 &no_neighbor_remove_private_as_replace_as_cmd
);
18617 install_element(BGP_IPV6L_NODE
,
18618 &neighbor_remove_private_as_all_replace_as_cmd
);
18619 install_element(BGP_IPV6L_NODE
,
18620 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18621 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18622 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18623 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18624 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18625 install_element(BGP_VPNV4_NODE
,
18626 &neighbor_remove_private_as_replace_as_cmd
);
18627 install_element(BGP_VPNV4_NODE
,
18628 &no_neighbor_remove_private_as_replace_as_cmd
);
18629 install_element(BGP_VPNV4_NODE
,
18630 &neighbor_remove_private_as_all_replace_as_cmd
);
18631 install_element(BGP_VPNV4_NODE
,
18632 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18633 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18634 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18635 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18636 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18637 install_element(BGP_VPNV6_NODE
,
18638 &neighbor_remove_private_as_replace_as_cmd
);
18639 install_element(BGP_VPNV6_NODE
,
18640 &no_neighbor_remove_private_as_replace_as_cmd
);
18641 install_element(BGP_VPNV6_NODE
,
18642 &neighbor_remove_private_as_all_replace_as_cmd
);
18643 install_element(BGP_VPNV6_NODE
,
18644 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18646 /* "neighbor send-community" commands.*/
18647 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18648 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18649 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18650 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18651 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18652 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18653 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18654 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18655 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18656 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18657 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18658 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18659 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18660 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18661 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18662 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18663 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18664 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18665 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18666 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18667 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18668 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18669 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18670 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18671 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18672 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18673 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18674 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18675 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18676 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18677 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18678 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18679 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18680 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18681 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18682 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18684 /* "neighbor route-reflector" commands.*/
18685 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18686 install_element(BGP_NODE
,
18687 &no_neighbor_route_reflector_client_hidden_cmd
);
18688 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18689 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18690 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18691 install_element(BGP_IPV4M_NODE
,
18692 &no_neighbor_route_reflector_client_cmd
);
18693 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18694 install_element(BGP_IPV4L_NODE
,
18695 &no_neighbor_route_reflector_client_cmd
);
18696 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18697 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18698 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18699 install_element(BGP_IPV6M_NODE
,
18700 &no_neighbor_route_reflector_client_cmd
);
18701 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18702 install_element(BGP_IPV6L_NODE
,
18703 &no_neighbor_route_reflector_client_cmd
);
18704 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18705 install_element(BGP_VPNV4_NODE
,
18706 &no_neighbor_route_reflector_client_cmd
);
18707 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18708 install_element(BGP_VPNV6_NODE
,
18709 &no_neighbor_route_reflector_client_cmd
);
18710 install_element(BGP_FLOWSPECV4_NODE
,
18711 &neighbor_route_reflector_client_cmd
);
18712 install_element(BGP_FLOWSPECV4_NODE
,
18713 &no_neighbor_route_reflector_client_cmd
);
18714 install_element(BGP_FLOWSPECV6_NODE
,
18715 &neighbor_route_reflector_client_cmd
);
18716 install_element(BGP_FLOWSPECV6_NODE
,
18717 &no_neighbor_route_reflector_client_cmd
);
18718 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18719 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18721 /* "neighbor route-server" commands.*/
18722 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18723 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18724 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18725 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18726 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18727 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18728 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18729 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18730 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18731 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18732 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18733 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18734 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18735 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18736 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18737 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18738 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18739 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18740 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18741 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18742 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18743 install_element(BGP_FLOWSPECV4_NODE
,
18744 &no_neighbor_route_server_client_cmd
);
18745 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18746 install_element(BGP_FLOWSPECV6_NODE
,
18747 &no_neighbor_route_server_client_cmd
);
18749 /* "neighbor disable-addpath-rx" commands. */
18750 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18751 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18752 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18753 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18754 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18755 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18756 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18757 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18758 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18759 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18760 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18761 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18762 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18763 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18764 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18765 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18767 /* "neighbor addpath-tx-all-paths" commands.*/
18768 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18769 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18770 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18771 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18772 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18773 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18774 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18775 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18776 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18777 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18778 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18779 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18780 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18781 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18782 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18783 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18784 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18785 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18787 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18788 install_element(BGP_NODE
,
18789 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18790 install_element(BGP_NODE
,
18791 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18792 install_element(BGP_IPV4_NODE
,
18793 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18794 install_element(BGP_IPV4_NODE
,
18795 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18796 install_element(BGP_IPV4M_NODE
,
18797 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18798 install_element(BGP_IPV4M_NODE
,
18799 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18800 install_element(BGP_IPV4L_NODE
,
18801 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18802 install_element(BGP_IPV4L_NODE
,
18803 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18804 install_element(BGP_IPV6_NODE
,
18805 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18806 install_element(BGP_IPV6_NODE
,
18807 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18808 install_element(BGP_IPV6M_NODE
,
18809 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18810 install_element(BGP_IPV6M_NODE
,
18811 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18812 install_element(BGP_IPV6L_NODE
,
18813 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18814 install_element(BGP_IPV6L_NODE
,
18815 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18816 install_element(BGP_VPNV4_NODE
,
18817 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18818 install_element(BGP_VPNV4_NODE
,
18819 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18820 install_element(BGP_VPNV6_NODE
,
18821 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18822 install_element(BGP_VPNV6_NODE
,
18823 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18825 /* "neighbor sender-as-path-loop-detection" commands. */
18826 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18827 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18829 /* "neighbor passive" commands. */
18830 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18831 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18834 /* "neighbor shutdown" commands. */
18835 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18836 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18837 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18838 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18839 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18840 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18842 /* "neighbor capability extended-nexthop" commands.*/
18843 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18844 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18846 /* "neighbor capability orf prefix-list" commands.*/
18847 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18848 install_element(BGP_NODE
,
18849 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18850 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18851 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18852 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18853 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18854 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18855 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18856 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18857 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18858 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18859 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18860 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18861 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18863 /* "neighbor capability dynamic" commands.*/
18864 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18865 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18867 /* "neighbor dont-capability-negotiate" commands. */
18868 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18869 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18871 /* "neighbor ebgp-multihop" commands. */
18872 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18873 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18874 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18876 /* "neighbor disable-connected-check" commands. */
18877 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18878 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18880 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18881 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18882 install_element(BGP_NODE
,
18883 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18885 /* "neighbor extended-optional-parameters" commands. */
18886 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18887 install_element(BGP_NODE
,
18888 &no_neighbor_extended_optional_parameters_cmd
);
18890 /* "neighbor enforce-first-as" commands. */
18891 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18892 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18894 /* "neighbor description" commands. */
18895 install_element(BGP_NODE
, &neighbor_description_cmd
);
18896 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18897 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18899 /* "neighbor update-source" commands. "*/
18900 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18901 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18903 /* "neighbor default-originate" commands. */
18904 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18905 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18906 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18907 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18908 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18909 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18910 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18911 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18912 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18913 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18914 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18915 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18916 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18917 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18918 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18919 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18920 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18921 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18922 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18923 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18924 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18926 /* "neighbor port" commands. */
18927 install_element(BGP_NODE
, &neighbor_port_cmd
);
18928 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18930 /* "neighbor weight" commands. */
18931 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18932 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18934 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18935 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18936 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18937 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18938 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18939 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18940 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18941 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18942 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18943 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18944 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18945 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18946 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18947 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18948 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18949 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18951 /* "neighbor override-capability" commands. */
18952 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18953 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18955 /* "neighbor strict-capability-match" commands. */
18956 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18957 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18959 /* "neighbor timers" commands. */
18960 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18961 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18963 /* "neighbor timers connect" commands. */
18964 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18965 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18967 /* "neighbor timers delayopen" commands. */
18968 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18969 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18971 /* "neighbor advertisement-interval" commands. */
18972 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18973 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18975 /* "neighbor interface" commands. */
18976 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18977 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18979 /* "neighbor distribute" commands. */
18980 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18981 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18982 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18983 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18984 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18985 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18986 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18987 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18988 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18989 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18990 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18991 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18992 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18993 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18994 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18995 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18996 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18997 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18999 /* "neighbor prefix-list" commands. */
19000 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19001 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19002 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19003 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19004 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19005 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19006 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19007 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19008 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19009 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19010 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19011 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19012 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19013 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19014 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19015 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19016 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19017 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19018 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19019 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19020 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19021 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19023 /* "neighbor filter-list" commands. */
19024 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19025 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19026 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19027 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19028 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19029 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19030 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19031 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19032 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19033 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19034 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19035 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19036 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19037 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19038 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19039 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19040 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19041 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19042 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19043 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19044 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19045 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19047 /* "neighbor route-map" commands. */
19048 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19049 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19050 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19051 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19052 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19053 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19054 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19055 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19056 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19057 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19058 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19059 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19060 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19061 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19062 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19063 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19064 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19065 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19066 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19067 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19068 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19069 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19070 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19071 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19073 /* "neighbor unsuppress-map" commands. */
19074 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19075 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19076 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19077 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19078 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19079 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19080 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19081 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19082 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19083 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19084 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19085 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19086 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19087 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19088 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19089 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19090 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19091 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19093 /* "neighbor advertise-map" commands. */
19094 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19095 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19096 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19097 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19098 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19099 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19100 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19101 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19102 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19103 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19105 /* neighbor maximum-prefix-out commands. */
19106 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19107 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19108 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19109 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19110 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19111 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19112 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19113 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19114 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19115 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19116 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19117 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19118 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19119 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19120 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19121 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19122 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19123 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19125 /* "neighbor maximum-prefix" commands. */
19126 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19127 install_element(BGP_NODE
,
19128 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19129 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19130 install_element(BGP_NODE
,
19131 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19132 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19133 install_element(BGP_NODE
,
19134 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19135 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19136 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19137 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19138 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19139 install_element(BGP_IPV4_NODE
,
19140 &neighbor_maximum_prefix_threshold_warning_cmd
);
19141 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19142 install_element(BGP_IPV4_NODE
,
19143 &neighbor_maximum_prefix_threshold_restart_cmd
);
19144 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19145 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19146 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19147 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19148 install_element(BGP_IPV4M_NODE
,
19149 &neighbor_maximum_prefix_threshold_warning_cmd
);
19150 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19151 install_element(BGP_IPV4M_NODE
,
19152 &neighbor_maximum_prefix_threshold_restart_cmd
);
19153 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19154 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19155 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19156 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19157 install_element(BGP_IPV4L_NODE
,
19158 &neighbor_maximum_prefix_threshold_warning_cmd
);
19159 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19160 install_element(BGP_IPV4L_NODE
,
19161 &neighbor_maximum_prefix_threshold_restart_cmd
);
19162 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19163 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19164 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19165 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19166 install_element(BGP_IPV6_NODE
,
19167 &neighbor_maximum_prefix_threshold_warning_cmd
);
19168 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19169 install_element(BGP_IPV6_NODE
,
19170 &neighbor_maximum_prefix_threshold_restart_cmd
);
19171 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19172 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19173 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19174 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19175 install_element(BGP_IPV6M_NODE
,
19176 &neighbor_maximum_prefix_threshold_warning_cmd
);
19177 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19178 install_element(BGP_IPV6M_NODE
,
19179 &neighbor_maximum_prefix_threshold_restart_cmd
);
19180 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19181 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19182 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19183 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19184 install_element(BGP_IPV6L_NODE
,
19185 &neighbor_maximum_prefix_threshold_warning_cmd
);
19186 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19187 install_element(BGP_IPV6L_NODE
,
19188 &neighbor_maximum_prefix_threshold_restart_cmd
);
19189 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19190 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19191 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19192 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19193 install_element(BGP_VPNV4_NODE
,
19194 &neighbor_maximum_prefix_threshold_warning_cmd
);
19195 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19196 install_element(BGP_VPNV4_NODE
,
19197 &neighbor_maximum_prefix_threshold_restart_cmd
);
19198 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19199 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19200 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19201 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19202 install_element(BGP_VPNV6_NODE
,
19203 &neighbor_maximum_prefix_threshold_warning_cmd
);
19204 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19205 install_element(BGP_VPNV6_NODE
,
19206 &neighbor_maximum_prefix_threshold_restart_cmd
);
19207 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19209 /* "neighbor allowas-in" */
19210 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19211 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19212 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19213 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19214 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19215 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19216 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19217 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19218 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19219 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19220 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19221 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19222 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19223 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19224 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19225 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19226 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19227 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19228 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19229 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19231 /* address-family commands. */
19232 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19233 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19234 #ifdef KEEP_OLD_VPN_COMMANDS
19235 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19236 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19237 #endif /* KEEP_OLD_VPN_COMMANDS */
19239 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19241 /* "exit-address-family" command. */
19242 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19243 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19244 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19245 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19246 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19247 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19248 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19249 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19250 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19251 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19252 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19254 /* "clear ip bgp commands" */
19255 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19257 /* clear ip bgp prefix */
19258 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19259 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19260 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19262 /* "show [ip] bgp summary" commands. */
19263 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19264 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19265 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19266 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19267 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19268 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19269 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19271 /* "show [ip] bgp neighbors" commands. */
19272 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19274 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19276 /* "show [ip] bgp peer-group" commands. */
19277 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19279 /* "show [ip] bgp paths" commands. */
19280 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19282 /* "show [ip] bgp community" commands. */
19283 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19285 /* "show ip bgp large-community" commands. */
19286 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19287 /* "show [ip] bgp attribute-info" commands. */
19288 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19289 /* "show [ip] bgp route-leak" command */
19290 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19292 /* "redistribute" commands. */
19293 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19294 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19295 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19296 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19297 install_element(BGP_NODE
,
19298 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19299 install_element(BGP_NODE
,
19300 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19301 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19302 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19303 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19304 install_element(BGP_NODE
,
19305 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19306 install_element(BGP_NODE
,
19307 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19308 install_element(BGP_NODE
,
19309 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19310 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19311 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19312 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19313 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19314 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19315 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19316 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19317 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19318 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19319 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19320 install_element(BGP_IPV4_NODE
,
19321 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19322 install_element(BGP_IPV4_NODE
,
19323 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19324 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19325 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19326 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19327 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19328 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19329 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19331 /* import|export vpn [route-map RMAP_NAME] */
19332 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19333 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19335 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19336 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19338 /* ttl_security commands */
19339 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19340 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19342 /* "show [ip] bgp memory" commands. */
19343 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19345 /* "show bgp martian next-hop" */
19346 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19348 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19350 /* "show [ip] bgp views" commands. */
19351 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19353 /* "show [ip] bgp vrfs" commands. */
19354 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19356 /* Community-list. */
19357 community_list_vty();
19359 community_alias_vty();
19361 /* vpn-policy commands */
19362 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19363 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19364 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19365 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19366 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19367 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19368 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19369 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19370 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19371 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19372 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19373 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19375 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19376 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19378 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19379 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19380 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19381 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19382 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19383 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19384 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19385 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19386 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19387 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19389 /* tcp-mss command */
19390 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19391 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19393 /* srv6 commands */
19394 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19395 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19396 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19397 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19398 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19399 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19400 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19403 #include "memory.h"
19404 #include "bgp_regex.h"
19405 #include "bgp_clist.h"
19406 #include "bgp_ecommunity.h"
19408 /* VTY functions. */
19410 /* Direction value to string conversion. */
19411 static const char *community_direct_str(int direct
)
19414 case COMMUNITY_DENY
:
19416 case COMMUNITY_PERMIT
:
19423 /* Display error string. */
19424 static void community_list_perror(struct vty
*vty
, int ret
)
19427 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19428 vty_out(vty
, "%% Can't find community-list\n");
19430 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19431 vty_out(vty
, "%% Malformed community-list value\n");
19433 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19435 "%% Community name conflict, previously defined as standard community\n");
19437 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19439 "%% Community name conflict, previously defined as expanded community\n");
19444 /* "community-list" keyword help string. */
19445 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19447 /*community-list standard */
19448 DEFUN (community_list_standard
,
19449 bgp_community_list_standard_cmd
,
19450 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19453 "Community list number (standard)\n"
19454 "Add an standard community-list entry\n"
19455 "Community list name\n"
19456 "Sequence number of an entry\n"
19457 "Sequence number\n"
19458 "Specify community to reject\n"
19459 "Specify community to accept\n"
19462 char *cl_name_or_number
= NULL
;
19465 int style
= COMMUNITY_LIST_STANDARD
;
19468 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19469 seq
= argv
[idx
]->arg
;
19472 argv_find(argv
, argc
, "(1-99)", &idx
);
19473 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19474 cl_name_or_number
= argv
[idx
]->arg
;
19475 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19477 argv_find(argv
, argc
, "AA:NN", &idx
);
19478 char *str
= argv_concat(argv
, argc
, idx
);
19480 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19483 XFREE(MTYPE_TMP
, str
);
19486 /* Display error string. */
19487 community_list_perror(vty
, ret
);
19488 return CMD_WARNING_CONFIG_FAILED
;
19491 return CMD_SUCCESS
;
19494 DEFUN (no_community_list_standard_all
,
19495 no_bgp_community_list_standard_all_cmd
,
19496 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19500 "Community list number (standard)\n"
19501 "Add an standard community-list entry\n"
19502 "Community list name\n"
19503 "Sequence number of an entry\n"
19504 "Sequence number\n"
19505 "Specify community to reject\n"
19506 "Specify community to accept\n"
19509 char *cl_name_or_number
= NULL
;
19512 int style
= COMMUNITY_LIST_STANDARD
;
19516 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19517 seq
= argv
[idx
]->arg
;
19520 argv_find(argv
, argc
, "permit", &idx
);
19521 argv_find(argv
, argc
, "deny", &idx
);
19524 direct
= argv_find(argv
, argc
, "permit", &idx
)
19529 argv_find(argv
, argc
, "AA:NN", &idx
);
19530 str
= argv_concat(argv
, argc
, idx
);
19534 argv_find(argv
, argc
, "(1-99)", &idx
);
19535 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19536 cl_name_or_number
= argv
[idx
]->arg
;
19538 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19541 XFREE(MTYPE_TMP
, str
);
19544 community_list_perror(vty
, ret
);
19545 return CMD_WARNING_CONFIG_FAILED
;
19548 return CMD_SUCCESS
;
19551 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19552 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19553 NO_STR BGP_STR COMMUNITY_LIST_STR
19554 "Community list number (standard)\n"
19555 "Add an standard community-list entry\n"
19556 "Community list name\n")
19558 /*community-list expanded */
19559 DEFUN (community_list_expanded_all
,
19560 bgp_community_list_expanded_all_cmd
,
19561 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19564 "Community list number (expanded)\n"
19565 "Add an expanded community-list entry\n"
19566 "Community list name\n"
19567 "Sequence number of an entry\n"
19568 "Sequence number\n"
19569 "Specify community to reject\n"
19570 "Specify community to accept\n"
19573 char *cl_name_or_number
= NULL
;
19576 int style
= COMMUNITY_LIST_EXPANDED
;
19579 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19580 seq
= argv
[idx
]->arg
;
19584 argv_find(argv
, argc
, "(100-500)", &idx
);
19585 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19586 cl_name_or_number
= argv
[idx
]->arg
;
19587 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19589 argv_find(argv
, argc
, "AA:NN", &idx
);
19590 char *str
= argv_concat(argv
, argc
, idx
);
19592 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19595 XFREE(MTYPE_TMP
, str
);
19598 /* Display error string. */
19599 community_list_perror(vty
, ret
);
19600 return CMD_WARNING_CONFIG_FAILED
;
19603 return CMD_SUCCESS
;
19606 DEFUN (no_community_list_expanded_all
,
19607 no_bgp_community_list_expanded_all_cmd
,
19608 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19612 "Community list number (expanded)\n"
19613 "Add an expanded community-list entry\n"
19614 "Community list name\n"
19615 "Sequence number of an entry\n"
19616 "Sequence number\n"
19617 "Specify community to reject\n"
19618 "Specify community to accept\n"
19621 char *cl_name_or_number
= NULL
;
19625 int style
= COMMUNITY_LIST_EXPANDED
;
19628 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19629 seq
= argv
[idx
]->arg
;
19632 argv_find(argv
, argc
, "permit", &idx
);
19633 argv_find(argv
, argc
, "deny", &idx
);
19636 direct
= argv_find(argv
, argc
, "permit", &idx
)
19641 argv_find(argv
, argc
, "AA:NN", &idx
);
19642 str
= argv_concat(argv
, argc
, idx
);
19646 argv_find(argv
, argc
, "(100-500)", &idx
);
19647 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19648 cl_name_or_number
= argv
[idx
]->arg
;
19650 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19653 XFREE(MTYPE_TMP
, str
);
19656 community_list_perror(vty
, ret
);
19657 return CMD_WARNING_CONFIG_FAILED
;
19660 return CMD_SUCCESS
;
19663 ALIAS(no_community_list_expanded_all
,
19664 no_bgp_community_list_expanded_all_list_cmd
,
19665 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19666 NO_STR BGP_STR COMMUNITY_LIST_STR
19667 "Community list number (expanded)\n"
19668 "Add an expanded community-list entry\n"
19669 "Community list name\n")
19671 /* Return configuration string of community-list entry. */
19672 static const char *community_list_config_str(struct community_entry
*entry
)
19679 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19680 str
= community_str(entry
->u
.com
, false, false);
19681 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19682 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19684 str
= entry
->config
;
19689 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19691 struct community_entry
*entry
;
19693 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19694 if (entry
== list
->head
) {
19695 if (all_digit(list
->name
))
19696 vty_out(vty
, "Community %s list %s\n",
19697 entry
->style
== COMMUNITY_LIST_STANDARD
19699 : "(expanded) access",
19702 vty_out(vty
, "Named Community %s list %s\n",
19703 entry
->style
== COMMUNITY_LIST_STANDARD
19709 vty_out(vty
, " %s\n",
19710 community_direct_str(entry
->direct
));
19712 vty_out(vty
, " %s %s\n",
19713 community_direct_str(entry
->direct
),
19714 community_list_config_str(entry
));
19718 DEFUN (show_community_list
,
19719 show_bgp_community_list_cmd
,
19720 "show bgp community-list",
19723 "List community-list\n")
19725 struct community_list
*list
;
19726 struct community_list_master
*cm
;
19728 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19730 return CMD_SUCCESS
;
19732 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19733 community_list_show(vty
, list
);
19735 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19736 community_list_show(vty
, list
);
19738 return CMD_SUCCESS
;
19741 DEFUN (show_community_list_arg
,
19742 show_bgp_community_list_arg_cmd
,
19743 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19746 "List community-list\n"
19747 "Community-list number\n"
19748 "Community-list name\n"
19749 "Detailed information on community-list\n")
19751 int idx_comm_list
= 3;
19752 struct community_list
*list
;
19754 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19755 COMMUNITY_LIST_MASTER
);
19757 vty_out(vty
, "%% Can't find community-list\n");
19758 return CMD_WARNING
;
19761 community_list_show(vty
, list
);
19763 return CMD_SUCCESS
;
19767 * Large Community code.
19769 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19770 struct cmd_token
**argv
, int style
,
19771 int reject_all_digit_name
)
19780 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19781 seq
= argv
[idx
]->arg
;
19784 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19787 /* All digit name check. */
19789 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19790 argv_find(argv
, argc
, "(1-99)", &idx
);
19791 argv_find(argv
, argc
, "(100-500)", &idx
);
19792 cl_name
= argv
[idx
]->arg
;
19793 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19794 vty_out(vty
, "%% Community name cannot have all digits\n");
19795 return CMD_WARNING_CONFIG_FAILED
;
19799 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19800 argv_find(argv
, argc
, "LINE", &idx
);
19801 /* Concat community string argument. */
19803 str
= argv_concat(argv
, argc
, idx
);
19807 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19809 /* Free temporary community list string allocated by
19811 XFREE(MTYPE_TMP
, str
);
19814 community_list_perror(vty
, ret
);
19815 return CMD_WARNING_CONFIG_FAILED
;
19817 return CMD_SUCCESS
;
19820 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19821 struct cmd_token
**argv
, int style
)
19829 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19830 seq
= argv
[idx
]->arg
;
19833 argv_find(argv
, argc
, "permit", &idx
);
19834 argv_find(argv
, argc
, "deny", &idx
);
19837 /* Check the list direct. */
19838 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19839 direct
= COMMUNITY_PERMIT
;
19841 direct
= COMMUNITY_DENY
;
19844 argv_find(argv
, argc
, "LINE", &idx
);
19845 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19846 /* Concat community string argument. */
19847 str
= argv_concat(argv
, argc
, idx
);
19851 argv_find(argv
, argc
, "(1-99)", &idx
);
19852 argv_find(argv
, argc
, "(100-500)", &idx
);
19853 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19855 /* Unset community list. */
19856 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19859 /* Free temporary community list string allocated by
19861 XFREE(MTYPE_TMP
, str
);
19864 community_list_perror(vty
, ret
);
19865 return CMD_WARNING_CONFIG_FAILED
;
19868 return CMD_SUCCESS
;
19871 /* "large-community-list" keyword help string. */
19872 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19873 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19875 DEFUN (lcommunity_list_standard
,
19876 bgp_lcommunity_list_standard_cmd
,
19877 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19879 LCOMMUNITY_LIST_STR
19880 "Large Community list number (standard)\n"
19881 "Sequence number of an entry\n"
19882 "Sequence number\n"
19883 "Specify large community to reject\n"
19884 "Specify large community to accept\n"
19885 LCOMMUNITY_VAL_STR
)
19887 return lcommunity_list_set_vty(vty
, argc
, argv
,
19888 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19891 DEFUN (lcommunity_list_expanded
,
19892 bgp_lcommunity_list_expanded_cmd
,
19893 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19895 LCOMMUNITY_LIST_STR
19896 "Large Community list number (expanded)\n"
19897 "Sequence number of an entry\n"
19898 "Sequence number\n"
19899 "Specify large community to reject\n"
19900 "Specify large community to accept\n"
19901 "An ordered list as a regular-expression\n")
19903 return lcommunity_list_set_vty(vty
, argc
, argv
,
19904 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19907 DEFUN (lcommunity_list_name_standard
,
19908 bgp_lcommunity_list_name_standard_cmd
,
19909 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19911 LCOMMUNITY_LIST_STR
19912 "Specify standard large-community-list\n"
19913 "Large Community list name\n"
19914 "Sequence number of an entry\n"
19915 "Sequence number\n"
19916 "Specify large community to reject\n"
19917 "Specify large community to accept\n"
19918 LCOMMUNITY_VAL_STR
)
19920 return lcommunity_list_set_vty(vty
, argc
, argv
,
19921 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19924 DEFUN (lcommunity_list_name_expanded
,
19925 bgp_lcommunity_list_name_expanded_cmd
,
19926 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19928 LCOMMUNITY_LIST_STR
19929 "Specify expanded large-community-list\n"
19930 "Large Community list name\n"
19931 "Sequence number of an entry\n"
19932 "Sequence number\n"
19933 "Specify large community to reject\n"
19934 "Specify large community to accept\n"
19935 "An ordered list as a regular-expression\n")
19937 return lcommunity_list_set_vty(vty
, argc
, argv
,
19938 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19941 DEFUN (no_lcommunity_list_all
,
19942 no_bgp_lcommunity_list_all_cmd
,
19943 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19946 LCOMMUNITY_LIST_STR
19947 "Large Community list number (standard)\n"
19948 "Large Community list number (expanded)\n"
19949 "Large Community list name\n")
19951 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19952 LARGE_COMMUNITY_LIST_STANDARD
);
19955 DEFUN (no_lcommunity_list_name_standard_all
,
19956 no_bgp_lcommunity_list_name_standard_all_cmd
,
19957 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19960 LCOMMUNITY_LIST_STR
19961 "Specify standard large-community-list\n"
19962 "Large Community list name\n")
19964 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19965 LARGE_COMMUNITY_LIST_STANDARD
);
19968 DEFUN (no_lcommunity_list_name_expanded_all
,
19969 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19970 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19973 LCOMMUNITY_LIST_STR
19974 "Specify expanded large-community-list\n"
19975 "Large Community list name\n")
19977 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19978 LARGE_COMMUNITY_LIST_EXPANDED
);
19981 DEFUN (no_lcommunity_list_standard
,
19982 no_bgp_lcommunity_list_standard_cmd
,
19983 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19986 LCOMMUNITY_LIST_STR
19987 "Large Community list number (standard)\n"
19988 "Sequence number of an entry\n"
19989 "Sequence number\n"
19990 "Specify large community to reject\n"
19991 "Specify large community to accept\n"
19992 LCOMMUNITY_VAL_STR
)
19994 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19995 LARGE_COMMUNITY_LIST_STANDARD
);
19998 DEFUN (no_lcommunity_list_expanded
,
19999 no_bgp_lcommunity_list_expanded_cmd
,
20000 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20003 LCOMMUNITY_LIST_STR
20004 "Large Community list number (expanded)\n"
20005 "Sequence number of an entry\n"
20006 "Sequence number\n"
20007 "Specify large community to reject\n"
20008 "Specify large community to accept\n"
20009 "An ordered list as a regular-expression\n")
20011 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20012 LARGE_COMMUNITY_LIST_EXPANDED
);
20015 DEFUN (no_lcommunity_list_name_standard
,
20016 no_bgp_lcommunity_list_name_standard_cmd
,
20017 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20020 LCOMMUNITY_LIST_STR
20021 "Specify standard large-community-list\n"
20022 "Large Community list name\n"
20023 "Sequence number of an entry\n"
20024 "Sequence number\n"
20025 "Specify large community to reject\n"
20026 "Specify large community to accept\n"
20027 LCOMMUNITY_VAL_STR
)
20029 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20030 LARGE_COMMUNITY_LIST_STANDARD
);
20033 DEFUN (no_lcommunity_list_name_expanded
,
20034 no_bgp_lcommunity_list_name_expanded_cmd
,
20035 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20038 LCOMMUNITY_LIST_STR
20039 "Specify expanded large-community-list\n"
20040 "Large community list name\n"
20041 "Sequence number of an entry\n"
20042 "Sequence number\n"
20043 "Specify large community to reject\n"
20044 "Specify large community to accept\n"
20045 "An ordered list as a regular-expression\n")
20047 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20048 LARGE_COMMUNITY_LIST_EXPANDED
);
20051 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20053 struct community_entry
*entry
;
20055 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20056 if (entry
== list
->head
) {
20057 if (all_digit(list
->name
))
20058 vty_out(vty
, "Large community %s list %s\n",
20060 LARGE_COMMUNITY_LIST_STANDARD
20062 : "(expanded) access",
20066 "Named large community %s list %s\n",
20068 LARGE_COMMUNITY_LIST_STANDARD
20074 vty_out(vty
, " %s\n",
20075 community_direct_str(entry
->direct
));
20077 vty_out(vty
, " %s %s\n",
20078 community_direct_str(entry
->direct
),
20079 community_list_config_str(entry
));
20083 DEFUN (show_lcommunity_list
,
20084 show_bgp_lcommunity_list_cmd
,
20085 "show bgp large-community-list",
20088 "List large-community list\n")
20090 struct community_list
*list
;
20091 struct community_list_master
*cm
;
20093 cm
= community_list_master_lookup(bgp_clist
,
20094 LARGE_COMMUNITY_LIST_MASTER
);
20096 return CMD_SUCCESS
;
20098 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20099 lcommunity_list_show(vty
, list
);
20101 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20102 lcommunity_list_show(vty
, list
);
20104 return CMD_SUCCESS
;
20107 DEFUN (show_lcommunity_list_arg
,
20108 show_bgp_lcommunity_list_arg_cmd
,
20109 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20112 "List large-community list\n"
20113 "Large-community-list number\n"
20114 "Large-community-list name\n"
20115 "Detailed information on large-community-list\n")
20117 struct community_list
*list
;
20119 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20120 LARGE_COMMUNITY_LIST_MASTER
);
20122 vty_out(vty
, "%% Can't find large-community-list\n");
20123 return CMD_WARNING
;
20126 lcommunity_list_show(vty
, list
);
20128 return CMD_SUCCESS
;
20131 /* "extcommunity-list" keyword help string. */
20132 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20133 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20135 DEFUN (extcommunity_list_standard
,
20136 bgp_extcommunity_list_standard_cmd
,
20137 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20139 EXTCOMMUNITY_LIST_STR
20140 "Extended Community list number (standard)\n"
20141 "Specify standard extcommunity-list\n"
20142 "Community list name\n"
20143 "Sequence number of an entry\n"
20144 "Sequence number\n"
20145 "Specify community to reject\n"
20146 "Specify community to accept\n"
20147 EXTCOMMUNITY_VAL_STR
)
20149 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20151 char *cl_number_or_name
= NULL
;
20156 argv_find(argv
, argc
, "(1-99)", &idx
);
20157 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20158 cl_number_or_name
= argv
[idx
]->arg
;
20160 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20161 seq
= argv
[idx
]->arg
;
20163 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20165 argv_find(argv
, argc
, "AA:NN", &idx
);
20166 char *str
= argv_concat(argv
, argc
, idx
);
20168 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20171 XFREE(MTYPE_TMP
, str
);
20174 community_list_perror(vty
, ret
);
20175 return CMD_WARNING_CONFIG_FAILED
;
20178 return CMD_SUCCESS
;
20181 DEFUN (extcommunity_list_name_expanded
,
20182 bgp_extcommunity_list_name_expanded_cmd
,
20183 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20185 EXTCOMMUNITY_LIST_STR
20186 "Extended Community list number (expanded)\n"
20187 "Specify expanded extcommunity-list\n"
20188 "Extended Community list name\n"
20189 "Sequence number of an entry\n"
20190 "Sequence number\n"
20191 "Specify community to reject\n"
20192 "Specify community to accept\n"
20193 "An ordered list as a regular-expression\n")
20195 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20197 char *cl_number_or_name
= NULL
;
20201 argv_find(argv
, argc
, "(100-500)", &idx
);
20202 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20203 cl_number_or_name
= argv
[idx
]->arg
;
20205 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20206 seq
= argv
[idx
]->arg
;
20208 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20210 argv_find(argv
, argc
, "LINE", &idx
);
20211 char *str
= argv_concat(argv
, argc
, idx
);
20213 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20216 XFREE(MTYPE_TMP
, str
);
20219 community_list_perror(vty
, ret
);
20220 return CMD_WARNING_CONFIG_FAILED
;
20223 return CMD_SUCCESS
;
20226 DEFUN (no_extcommunity_list_standard_all
,
20227 no_bgp_extcommunity_list_standard_all_cmd
,
20228 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20231 EXTCOMMUNITY_LIST_STR
20232 "Extended Community list number (standard)\n"
20233 "Specify standard extcommunity-list\n"
20234 "Community list name\n"
20235 "Sequence number of an entry\n"
20236 "Sequence number\n"
20237 "Specify community to reject\n"
20238 "Specify community to accept\n"
20239 EXTCOMMUNITY_VAL_STR
)
20241 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20243 char *cl_number_or_name
= NULL
;
20248 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20249 seq
= argv
[idx
]->arg
;
20252 argv_find(argv
, argc
, "permit", &idx
);
20253 argv_find(argv
, argc
, "deny", &idx
);
20255 direct
= argv_find(argv
, argc
, "permit", &idx
)
20260 argv_find(argv
, argc
, "AA:NN", &idx
);
20261 str
= argv_concat(argv
, argc
, idx
);
20265 argv_find(argv
, argc
, "(1-99)", &idx
);
20266 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20267 cl_number_or_name
= argv
[idx
]->arg
;
20269 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20270 seq
, direct
, style
);
20272 XFREE(MTYPE_TMP
, str
);
20275 community_list_perror(vty
, ret
);
20276 return CMD_WARNING_CONFIG_FAILED
;
20279 return CMD_SUCCESS
;
20282 ALIAS(no_extcommunity_list_standard_all
,
20283 no_bgp_extcommunity_list_standard_all_list_cmd
,
20284 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20285 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20286 "Extended Community list number (standard)\n"
20287 "Specify standard extcommunity-list\n"
20288 "Community list name\n")
20290 DEFUN (no_extcommunity_list_expanded_all
,
20291 no_bgp_extcommunity_list_expanded_all_cmd
,
20292 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20295 EXTCOMMUNITY_LIST_STR
20296 "Extended Community list number (expanded)\n"
20297 "Specify expanded extcommunity-list\n"
20298 "Extended Community list name\n"
20299 "Sequence number of an entry\n"
20300 "Sequence number\n"
20301 "Specify community to reject\n"
20302 "Specify community to accept\n"
20303 "An ordered list as a regular-expression\n")
20305 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20307 char *cl_number_or_name
= NULL
;
20312 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20313 seq
= argv
[idx
]->arg
;
20316 argv_find(argv
, argc
, "permit", &idx
);
20317 argv_find(argv
, argc
, "deny", &idx
);
20320 direct
= argv_find(argv
, argc
, "permit", &idx
)
20325 argv_find(argv
, argc
, "LINE", &idx
);
20326 str
= argv_concat(argv
, argc
, idx
);
20330 argv_find(argv
, argc
, "(100-500)", &idx
);
20331 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20332 cl_number_or_name
= argv
[idx
]->arg
;
20334 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20335 seq
, direct
, style
);
20337 XFREE(MTYPE_TMP
, str
);
20340 community_list_perror(vty
, ret
);
20341 return CMD_WARNING_CONFIG_FAILED
;
20344 return CMD_SUCCESS
;
20347 ALIAS(no_extcommunity_list_expanded_all
,
20348 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20349 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20350 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20351 "Extended Community list number (expanded)\n"
20352 "Specify expanded extcommunity-list\n"
20353 "Extended Community list name\n")
20355 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20357 struct community_entry
*entry
;
20359 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20360 if (entry
== list
->head
) {
20361 if (all_digit(list
->name
))
20362 vty_out(vty
, "Extended community %s list %s\n",
20363 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20365 : "(expanded) access",
20369 "Named extended community %s list %s\n",
20370 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20376 vty_out(vty
, " %s\n",
20377 community_direct_str(entry
->direct
));
20379 vty_out(vty
, " %s %s\n",
20380 community_direct_str(entry
->direct
),
20381 community_list_config_str(entry
));
20385 DEFUN (show_extcommunity_list
,
20386 show_bgp_extcommunity_list_cmd
,
20387 "show bgp extcommunity-list",
20390 "List extended-community list\n")
20392 struct community_list
*list
;
20393 struct community_list_master
*cm
;
20395 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20397 return CMD_SUCCESS
;
20399 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20400 extcommunity_list_show(vty
, list
);
20402 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20403 extcommunity_list_show(vty
, list
);
20405 return CMD_SUCCESS
;
20408 DEFUN (show_extcommunity_list_arg
,
20409 show_bgp_extcommunity_list_arg_cmd
,
20410 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20413 "List extended-community list\n"
20414 "Extcommunity-list number\n"
20415 "Extcommunity-list name\n"
20416 "Detailed information on extcommunity-list\n")
20418 int idx_comm_list
= 3;
20419 struct community_list
*list
;
20421 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20422 EXTCOMMUNITY_LIST_MASTER
);
20424 vty_out(vty
, "%% Can't find extcommunity-list\n");
20425 return CMD_WARNING
;
20428 extcommunity_list_show(vty
, list
);
20430 return CMD_SUCCESS
;
20433 /* Display community-list and extcommunity-list configuration. */
20434 static int community_list_config_write(struct vty
*vty
)
20436 struct community_list
*list
;
20437 struct community_entry
*entry
;
20438 struct community_list_master
*cm
;
20441 /* Community-list. */
20442 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20444 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20445 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20447 "bgp community-list %s seq %" PRId64
" %s %s\n",
20448 list
->name
, entry
->seq
,
20449 community_direct_str(entry
->direct
),
20450 community_list_config_str(entry
));
20453 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20454 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20456 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20457 entry
->style
== COMMUNITY_LIST_STANDARD
20460 list
->name
, entry
->seq
,
20461 community_direct_str(entry
->direct
),
20462 community_list_config_str(entry
));
20466 /* Extcommunity-list. */
20467 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20469 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20470 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20472 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20473 list
->name
, entry
->seq
,
20474 community_direct_str(entry
->direct
),
20475 community_list_config_str(entry
));
20478 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20479 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20481 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20482 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20485 list
->name
, entry
->seq
,
20486 community_direct_str(entry
->direct
),
20487 community_list_config_str(entry
));
20492 /* lcommunity-list. */
20493 cm
= community_list_master_lookup(bgp_clist
,
20494 LARGE_COMMUNITY_LIST_MASTER
);
20496 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20497 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20499 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20500 list
->name
, entry
->seq
,
20501 community_direct_str(entry
->direct
),
20502 community_list_config_str(entry
));
20505 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20506 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20508 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20510 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20513 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20514 community_list_config_str(entry
));
20521 static int community_list_config_write(struct vty
*vty
);
20522 static struct cmd_node community_list_node
= {
20523 .name
= "community list",
20524 .node
= COMMUNITY_LIST_NODE
,
20526 .config_write
= community_list_config_write
,
20529 static void community_list_vty(void)
20531 install_node(&community_list_node
);
20533 /* Community-list. */
20534 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20535 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20536 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20537 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20538 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20539 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20540 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20541 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20543 /* Extcommunity-list. */
20544 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20545 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20546 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20547 install_element(CONFIG_NODE
,
20548 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20549 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20550 install_element(CONFIG_NODE
,
20551 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20552 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20553 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20555 /* Large Community List */
20556 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20557 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20558 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20559 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20560 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20561 install_element(CONFIG_NODE
,
20562 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20563 install_element(CONFIG_NODE
,
20564 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20565 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20566 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20567 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20568 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20569 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20570 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20572 bgp_community_list_command_completion_setup();
20575 static struct cmd_node community_alias_node
= {
20576 .name
= "community alias",
20577 .node
= COMMUNITY_ALIAS_NODE
,
20579 .config_write
= bgp_community_alias_write
,
20582 void community_alias_vty(void)
20584 install_node(&community_alias_node
);
20586 /* Community-list. */
20587 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20589 bgp_community_alias_command_completion_setup();