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 BGP_AF_MODIFIER_STR
)
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 BGP_AF_MODIFIER_STR
)
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 BGP_AF_MODIFIER_STR
)
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
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
];
10396 uint32_t last_space
= 0;
10399 if (*(desc
+ i
) == 0) {
10400 stripped
[i
] = '\0';
10403 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10405 stripped
[i
] = *(desc
+ i
);
10409 if (last_space
> size
)
10410 stripped
[size
+ 1] = '\0';
10412 stripped
[last_space
] = '\0';
10417 /* Determine whether var peer should be filtered out of the summary. */
10418 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10419 struct peer
*fpeer
, int as_type
,
10423 /* filter neighbor XXXX */
10424 if (fpeer
&& fpeer
!= peer
)
10427 /* filter remote-as (internal|external) */
10428 if (as_type
!= AS_UNSPECIFIED
) {
10429 if (peer
->as_type
== AS_SPECIFIED
) {
10430 if (as_type
== AS_INTERNAL
) {
10431 if (peer
->as
!= peer
->local_as
)
10433 } else if (peer
->as
== peer
->local_as
)
10435 } else if (as_type
!= peer
->as_type
)
10437 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10443 /* Show BGP peer's summary information.
10445 * Peer's description is stripped according to if `wide` option is given
10448 * When adding new columns to `show bgp summary` output, please make
10449 * sure `Desc` is the lastest column to show because it can contain
10450 * whitespaces and the whole output will be tricky.
10452 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10453 struct peer
*fpeer
, int as_type
, as_t as
,
10454 uint16_t show_flags
)
10457 struct listnode
*node
, *nnode
;
10458 unsigned int count
= 0, dn_count
= 0;
10459 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10460 char neighbor_buf
[VTY_BUFSIZ
];
10461 int neighbor_col_default_width
= 16;
10462 int len
, failed_count
= 0;
10463 unsigned int filtered_count
= 0;
10464 int max_neighbor_width
= 0;
10466 json_object
*json
= NULL
;
10467 json_object
*json_peer
= NULL
;
10468 json_object
*json_peers
= NULL
;
10469 struct peer_af
*paf
;
10470 struct bgp_filter
*filter
;
10471 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10472 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10473 bool show_established
=
10474 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10475 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10476 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10478 /* labeled-unicast routes are installed in the unicast table so in order
10480 * display the correct PfxRcd value we must look at SAFI_UNICAST
10483 if (safi
== SAFI_LABELED_UNICAST
)
10484 pfx_rcd_safi
= SAFI_UNICAST
;
10486 pfx_rcd_safi
= safi
;
10489 json
= json_object_new_object();
10490 json_peers
= json_object_new_object();
10491 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10492 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10499 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10502 if (peer
->afc
[afi
][safi
]) {
10503 /* See if we have at least a single failed peer */
10504 if (bgp_has_peer_failed(peer
, afi
, safi
))
10508 if (peer_dynamic_neighbor(peer
))
10513 /* Loop over all neighbors that will be displayed to determine
10515 * characters are needed for the Neighbor column
10517 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10518 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10525 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10528 if (peer
->afc
[afi
][safi
]) {
10529 memset(dn_flag
, '\0', sizeof(dn_flag
));
10530 if (peer_dynamic_neighbor(peer
))
10534 && CHECK_FLAG(bgp
->flags
,
10535 BGP_FLAG_SHOW_HOSTNAME
))
10536 snprintf(neighbor_buf
,
10537 sizeof(neighbor_buf
),
10538 "%s%s(%s) ", dn_flag
,
10539 peer
->hostname
, peer
->host
);
10541 snprintf(neighbor_buf
,
10542 sizeof(neighbor_buf
), "%s%s ",
10543 dn_flag
, peer
->host
);
10545 len
= strlen(neighbor_buf
);
10547 if (len
> max_neighbor_width
)
10548 max_neighbor_width
= len
;
10550 /* See if we have at least a single failed peer */
10551 if (bgp_has_peer_failed(peer
, afi
, safi
))
10557 /* Originally we displayed the Neighbor column as 16
10558 * characters wide so make that the default
10560 if (max_neighbor_width
< neighbor_col_default_width
)
10561 max_neighbor_width
= neighbor_col_default_width
;
10564 if (show_failed
&& !failed_count
) {
10566 json_object_int_add(json
, "failedPeersCount", 0);
10567 json_object_int_add(json
, "dynamicPeers", dn_count
);
10568 json_object_int_add(json
, "totalPeers", count
);
10570 vty_json(vty
, json
);
10572 vty_out(vty
, "%% No failed BGP neighbors found\n");
10574 return CMD_SUCCESS
;
10577 count
= 0; /* Reset the value as its used again */
10578 filtered_count
= 0;
10580 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10581 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10584 if (!peer
->afc
[afi
][safi
])
10588 unsigned long ents
;
10589 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10592 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10594 : (int64_t)bgp
->vrf_id
;
10596 /* Usage summary and header */
10598 json_object_string_addf(json
, "routerId",
10601 json_object_int_add(json
, "as", bgp
->as
);
10602 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10603 json_object_string_add(
10606 == BGP_INSTANCE_TYPE_DEFAULT
)
10611 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10612 &bgp
->router_id
, bgp
->as
,
10613 bgp
->vrf_id
== VRF_UNKNOWN
10615 : (int)bgp
->vrf_id
);
10616 vty_out(vty
, "\n");
10619 if (bgp_update_delay_configured(bgp
)) {
10621 json_object_int_add(
10622 json
, "updateDelayLimit",
10623 bgp
->v_update_delay
);
10625 if (bgp
->v_update_delay
10626 != bgp
->v_establish_wait
)
10627 json_object_int_add(
10629 "updateDelayEstablishWait",
10630 bgp
->v_establish_wait
);
10632 if (bgp_update_delay_active(bgp
)) {
10633 json_object_string_add(
10635 "updateDelayFirstNeighbor",
10636 bgp
->update_delay_begin_time
);
10637 json_object_boolean_true_add(
10639 "updateDelayInProgress");
10641 if (bgp
->update_delay_over
) {
10642 json_object_string_add(
10644 "updateDelayFirstNeighbor",
10645 bgp
->update_delay_begin_time
);
10646 json_object_string_add(
10648 "updateDelayBestpathResumed",
10649 bgp
->update_delay_end_time
);
10650 json_object_string_add(
10652 "updateDelayZebraUpdateResume",
10653 bgp
->update_delay_zebra_resume_time
);
10654 json_object_string_add(
10656 "updateDelayPeerUpdateResume",
10657 bgp
->update_delay_peers_resume_time
);
10662 "Read-only mode update-delay limit: %d seconds\n",
10663 bgp
->v_update_delay
);
10664 if (bgp
->v_update_delay
10665 != bgp
->v_establish_wait
)
10667 " Establish wait: %d seconds\n",
10668 bgp
->v_establish_wait
);
10670 if (bgp_update_delay_active(bgp
)) {
10672 " First neighbor established: %s\n",
10673 bgp
->update_delay_begin_time
);
10675 " Delay in progress\n");
10677 if (bgp
->update_delay_over
) {
10679 " First neighbor established: %s\n",
10680 bgp
->update_delay_begin_time
);
10682 " Best-paths resumed: %s\n",
10683 bgp
->update_delay_end_time
);
10685 " zebra update resumed: %s\n",
10686 bgp
->update_delay_zebra_resume_time
);
10688 " peers update resumed: %s\n",
10689 bgp
->update_delay_peers_resume_time
);
10696 if (bgp_maxmed_onstartup_configured(bgp
)
10697 && bgp
->maxmed_active
)
10698 json_object_boolean_true_add(
10699 json
, "maxMedOnStartup");
10700 if (bgp
->v_maxmed_admin
)
10701 json_object_boolean_true_add(
10702 json
, "maxMedAdministrative");
10704 json_object_int_add(
10705 json
, "tableVersion",
10706 bgp_table_version(bgp
->rib
[afi
][safi
]));
10708 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10709 json_object_int_add(json
, "ribCount", ents
);
10710 json_object_int_add(
10712 ents
* sizeof(struct bgp_dest
));
10714 ents
= bgp
->af_peer_count
[afi
][safi
];
10715 json_object_int_add(json
, "peerCount", ents
);
10716 json_object_int_add(json
, "peerMemory",
10717 ents
* sizeof(struct peer
));
10719 if ((ents
= listcount(bgp
->group
))) {
10720 json_object_int_add(
10721 json
, "peerGroupCount", ents
);
10722 json_object_int_add(
10723 json
, "peerGroupMemory",
10724 ents
* sizeof(struct
10728 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10729 BGP_CONFIG_DAMPENING
))
10730 json_object_boolean_true_add(
10731 json
, "dampeningEnabled");
10734 if (bgp_maxmed_onstartup_configured(bgp
)
10735 && bgp
->maxmed_active
)
10737 "Max-med on-startup active\n");
10738 if (bgp
->v_maxmed_admin
)
10740 "Max-med administrative active\n");
10743 "BGP table version %" PRIu64
10746 bgp
->rib
[afi
][safi
]));
10748 ents
= bgp_table_count(
10749 bgp
->rib
[afi
][safi
]);
10751 "RIB entries %ld, using %s of memory\n",
10761 /* Peer related usage */
10762 ents
= bgp
->af_peer_count
[afi
][safi
];
10764 "Peers %ld, using %s of memory\n",
10774 if ((ents
= listcount(bgp
->group
)))
10776 "Peer groups %ld, using %s of memory\n",
10786 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10787 BGP_CONFIG_DAMPENING
))
10789 "Dampening enabled.\n");
10792 vty_out(vty
, "\n");
10794 /* Subtract 8 here because 'Neighbor' is
10796 vty_out(vty
, "Neighbor");
10797 vty_out(vty
, "%*s",
10798 max_neighbor_width
- 8, " ");
10800 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10805 paf
= peer_af_find(peer
, afi
, safi
);
10806 filter
= &peer
->filter
[afi
][safi
];
10809 /* Works for both failed & successful cases */
10810 if (peer_dynamic_neighbor(peer
))
10815 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10821 bgp_has_peer_failed(peer
, afi
, safi
)) {
10822 json_peer
= json_object_new_object();
10823 bgp_show_failed_summary(vty
, bgp
, peer
,
10824 json_peer
, 0, use_json
);
10825 } else if (!show_failed
) {
10826 if (show_established
10827 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10832 json_peer
= json_object_new_object();
10833 if (peer_dynamic_neighbor(peer
)) {
10834 json_object_boolean_true_add(json_peer
,
10838 if (peer
->hostname
)
10839 json_object_string_add(json_peer
, "hostname",
10842 if (peer
->domainname
)
10843 json_object_string_add(json_peer
, "domainname",
10846 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10847 json_object_int_add(
10848 json_peer
, "localAs",
10849 peer
->change_local_as
10850 ? peer
->change_local_as
10852 json_object_int_add(json_peer
, "version", 4);
10853 json_object_int_add(json_peer
, "msgRcvd",
10854 PEER_TOTAL_RX(peer
));
10855 json_object_int_add(json_peer
, "msgSent",
10856 PEER_TOTAL_TX(peer
));
10858 atomic_size_t outq_count
, inq_count
;
10859 outq_count
= atomic_load_explicit(
10860 &peer
->obuf
->count
,
10861 memory_order_relaxed
);
10862 inq_count
= atomic_load_explicit(
10863 &peer
->ibuf
->count
,
10864 memory_order_relaxed
);
10866 json_object_int_add(json_peer
, "tableVersion",
10867 peer
->version
[afi
][safi
]);
10868 json_object_int_add(json_peer
, "outq",
10870 json_object_int_add(json_peer
, "inq",
10872 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10873 use_json
, json_peer
);
10875 json_object_int_add(json_peer
, "pfxRcd",
10876 peer
->pcount
[afi
][pfx_rcd_safi
]);
10878 if (paf
&& PAF_SUBGRP(paf
))
10879 json_object_int_add(
10880 json_peer
, "pfxSnt",
10881 (PAF_SUBGRP(paf
))->scount
);
10883 json_object_int_add(json_peer
, "pfxSnt",
10886 /* BGP FSM state */
10887 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10888 || CHECK_FLAG(peer
->bgp
->flags
,
10889 BGP_FLAG_SHUTDOWN
))
10890 json_object_string_add(json_peer
,
10893 else if (peer
->afc_recv
[afi
][safi
])
10894 json_object_string_add(
10895 json_peer
, "state",
10896 lookup_msg(bgp_status_msg
,
10897 peer
->status
, NULL
));
10898 else if (CHECK_FLAG(
10900 PEER_STATUS_PREFIX_OVERFLOW
))
10901 json_object_string_add(json_peer
,
10905 json_object_string_add(
10906 json_peer
, "state",
10907 lookup_msg(bgp_status_msg
,
10908 peer
->status
, NULL
));
10910 /* BGP peer state */
10911 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10912 || CHECK_FLAG(peer
->bgp
->flags
,
10913 BGP_FLAG_SHUTDOWN
))
10914 json_object_string_add(json_peer
,
10917 else if (CHECK_FLAG(
10919 PEER_STATUS_PREFIX_OVERFLOW
))
10920 json_object_string_add(json_peer
,
10923 else if (CHECK_FLAG(peer
->flags
,
10924 PEER_FLAG_PASSIVE
))
10925 json_object_string_add(json_peer
,
10928 else if (CHECK_FLAG(peer
->sflags
,
10929 PEER_STATUS_NSF_WAIT
))
10930 json_object_string_add(json_peer
,
10933 else if (CHECK_FLAG(
10935 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10936 && (!bgp_inbound_policy_exists(peer
,
10938 || !bgp_outbound_policy_exists(
10940 json_object_string_add(json_peer
,
10944 json_object_string_add(
10945 json_peer
, "peerState", "OK");
10947 json_object_int_add(json_peer
, "connectionsEstablished",
10948 peer
->established
);
10949 json_object_int_add(json_peer
, "connectionsDropped",
10952 json_object_string_add(
10953 json_peer
, "desc", peer
->desc
);
10955 /* Avoid creating empty peer dicts in JSON */
10956 if (json_peer
== NULL
)
10960 json_object_string_add(json_peer
, "idType",
10962 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10963 json_object_string_add(json_peer
, "idType",
10965 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10966 json_object_string_add(json_peer
, "idType",
10968 json_object_object_add(json_peers
, peer
->host
,
10971 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10977 bgp_has_peer_failed(peer
, afi
, safi
)) {
10978 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10979 max_neighbor_width
,
10981 } else if (!show_failed
) {
10982 if (show_established
10983 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10988 if ((count
- filtered_count
) == 1) {
10989 /* display headline before the first
10991 vty_out(vty
, "\n");
10993 /* Subtract 8 here because 'Neighbor' is
10995 vty_out(vty
, "Neighbor");
10996 vty_out(vty
, "%*s",
10997 max_neighbor_width
- 8, " ");
11000 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11001 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11004 memset(dn_flag
, '\0', sizeof(dn_flag
));
11005 if (peer_dynamic_neighbor(peer
)) {
11010 && CHECK_FLAG(bgp
->flags
,
11011 BGP_FLAG_SHOW_HOSTNAME
))
11012 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11016 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11018 /* pad the neighbor column with spaces */
11019 if (len
< max_neighbor_width
)
11020 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11023 atomic_size_t outq_count
, inq_count
;
11024 outq_count
= atomic_load_explicit(
11025 &peer
->obuf
->count
,
11026 memory_order_relaxed
);
11027 inq_count
= atomic_load_explicit(
11028 &peer
->ibuf
->count
,
11029 memory_order_relaxed
);
11033 "4 %10u %10u %9u %9u %8" PRIu64
11036 peer
->change_local_as
11037 ? peer
->change_local_as
11039 PEER_TOTAL_RX(peer
),
11040 PEER_TOTAL_TX(peer
),
11041 peer
->version
[afi
][safi
],
11042 inq_count
, outq_count
,
11043 peer_uptime(peer
->uptime
,
11048 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11050 peer
->as
, PEER_TOTAL_RX(peer
),
11051 PEER_TOTAL_TX(peer
),
11052 peer
->version
[afi
][safi
],
11053 inq_count
, outq_count
,
11054 peer_uptime(peer
->uptime
,
11059 if (peer_established(peer
)) {
11060 if (peer
->afc_recv
[afi
][safi
]) {
11063 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11064 && !bgp_inbound_policy_exists(
11066 vty_out(vty
, " %12s",
11075 vty_out(vty
, " NoNeg");
11078 if (paf
&& PAF_SUBGRP(paf
)) {
11081 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11082 && !bgp_outbound_policy_exists(
11084 vty_out(vty
, " %8s",
11093 vty_out(vty
, " NoNeg");
11096 if (CHECK_FLAG(peer
->flags
,
11097 PEER_FLAG_SHUTDOWN
)
11098 || CHECK_FLAG(peer
->bgp
->flags
,
11099 BGP_FLAG_SHUTDOWN
))
11100 vty_out(vty
, " Idle (Admin)");
11101 else if (CHECK_FLAG(
11103 PEER_STATUS_PREFIX_OVERFLOW
))
11104 vty_out(vty
, " Idle (PfxCt)");
11106 vty_out(vty
, " %12s",
11107 lookup_msg(bgp_status_msg
,
11108 peer
->status
, NULL
));
11110 vty_out(vty
, " %8u", 0);
11112 /* Make sure `Desc` column is the lastest in
11116 vty_out(vty
, " %s",
11117 bgp_peer_description_stripped(
11119 show_wide
? 64 : 20));
11121 vty_out(vty
, " N/A");
11122 vty_out(vty
, "\n");
11129 json_object_object_add(json
, "peers", json_peers
);
11130 json_object_int_add(json
, "failedPeers", failed_count
);
11131 json_object_int_add(json
, "displayedPeers",
11132 count
- filtered_count
);
11133 json_object_int_add(json
, "totalPeers", count
);
11134 json_object_int_add(json
, "dynamicPeers", dn_count
);
11137 bgp_show_bestpath_json(bgp
, json
);
11139 vty_json(vty
, json
);
11142 if (filtered_count
== count
)
11143 vty_out(vty
, "\n%% No matching neighbor\n");
11146 vty_out(vty
, "\nDisplayed neighbors %d",
11148 else if (as_type
!= AS_UNSPECIFIED
|| as
11149 || fpeer
|| show_established
)
11150 vty_out(vty
, "\nDisplayed neighbors %d",
11151 count
- filtered_count
);
11153 vty_out(vty
, "\nTotal number of neighbors %d\n",
11157 vty_out(vty
, "No %s neighbor is configured\n",
11158 get_afi_safi_str(afi
, safi
, false));
11162 vty_out(vty
, "* - dynamic neighbor\n");
11163 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11164 dn_count
, bgp
->dynamic_neighbors_limit
);
11168 return CMD_SUCCESS
;
11171 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11172 int safi
, struct peer
*fpeer
, int as_type
,
11173 as_t as
, uint16_t show_flags
)
11176 int afi_wildcard
= (afi
== AFI_MAX
);
11177 int safi_wildcard
= (safi
== SAFI_MAX
);
11178 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11179 bool nbr_output
= false;
11180 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11182 if (use_json
&& is_wildcard
)
11183 vty_out(vty
, "{\n");
11185 afi
= 1; /* AFI_IP */
11186 while (afi
< AFI_MAX
) {
11188 safi
= 1; /* SAFI_UNICAST */
11189 while (safi
< SAFI_MAX
) {
11190 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11195 * So limit output to those afi/safi
11197 * actualy have something interesting in
11202 vty_out(vty
, ",\n");
11206 vty_out(vty
, "\"%s\":",
11207 get_afi_safi_str(afi
,
11212 "\n%s Summary (%s):\n",
11213 get_afi_safi_str(afi
,
11219 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11220 as_type
, as
, show_flags
);
11223 if (!safi_wildcard
)
11231 if (use_json
&& is_wildcard
)
11232 vty_out(vty
, "}\n");
11233 else if (!nbr_output
) {
11235 vty_out(vty
, "{}\n");
11237 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11242 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11244 const char *neighbor
,
11245 int as_type
, as_t as
,
11246 uint16_t show_flags
)
11248 struct listnode
*node
, *nnode
;
11250 struct peer
*fpeer
= NULL
;
11252 bool nbr_output
= false;
11253 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11256 vty_out(vty
, "{\n");
11258 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11262 vty_out(vty
, ",\n");
11266 vty_out(vty
, "\"%s\":",
11267 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11272 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11277 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11282 vty_out(vty
, "}\n");
11283 else if (!nbr_output
)
11284 vty_out(vty
, "%% BGP instance not found\n");
11287 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11288 safi_t safi
, const char *neighbor
, int as_type
,
11289 as_t as
, uint16_t show_flags
)
11292 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11293 struct peer
*fpeer
= NULL
;
11296 if (strmatch(name
, "all")) {
11297 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11300 return CMD_SUCCESS
;
11302 bgp
= bgp_lookup_by_name(name
);
11306 vty_out(vty
, "{}\n");
11309 "%% BGP instance not found\n");
11310 return CMD_WARNING
;
11314 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11317 return CMD_WARNING
;
11319 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11320 as_type
, as
, show_flags
);
11321 return CMD_SUCCESS
;
11325 bgp
= bgp_get_default();
11329 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11332 return CMD_WARNING
;
11334 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11338 vty_out(vty
, "{}\n");
11340 vty_out(vty
, "%% BGP instance not found\n");
11341 return CMD_WARNING
;
11344 return CMD_SUCCESS
;
11347 /* `show [ip] bgp summary' commands. */
11348 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11349 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11350 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11351 "]] [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]",
11352 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11353 BGP_SAFI_WITH_LABEL_HELP_STR
11354 "Display the entries for all address families\n"
11355 "Summary of BGP neighbor status\n"
11356 "Show only sessions in Established state\n"
11357 "Show only sessions not in Established state\n"
11358 "Show only the specified neighbor session\n"
11359 "Neighbor to display information about\n"
11360 "Neighbor to display information about\n"
11361 "Neighbor on BGP configured interface\n"
11362 "Show only the specified remote AS sessions\n"
11364 "Internal (iBGP) AS sessions\n"
11365 "External (eBGP) AS sessions\n"
11366 "Shorten the information on BGP instances\n"
11367 "Increase table width for longer output\n" JSON_STR
)
11370 afi_t afi
= AFI_MAX
;
11371 safi_t safi
= SAFI_MAX
;
11372 as_t as
= 0; /* 0 means AS filter not set */
11373 int as_type
= AS_UNSPECIFIED
;
11374 uint16_t show_flags
= 0;
11378 /* show [ip] bgp */
11379 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11381 /* [<vrf> VIEWVRFNAME] */
11382 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11383 vrf
= argv
[idx
+ 1]->arg
;
11384 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11386 } else if (argv_find(argv
, argc
, "view", &idx
))
11387 /* [<view> VIEWVRFNAME] */
11388 vrf
= argv
[idx
+ 1]->arg
;
11389 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11390 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11391 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11394 if (argv_find(argv
, argc
, "failed", &idx
))
11395 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11397 if (argv_find(argv
, argc
, "established", &idx
))
11398 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11400 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11401 if (argv
[idx
+ 1]->arg
[0] == 'i')
11402 as_type
= AS_INTERNAL
;
11403 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11404 as_type
= AS_EXTERNAL
;
11406 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11409 if (argv_find(argv
, argc
, "terse", &idx
))
11410 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11412 if (argv_find(argv
, argc
, "wide", &idx
))
11413 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11415 if (argv_find(argv
, argc
, "json", &idx
))
11416 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11418 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11422 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11425 return get_afi_safi_json_str(afi
, safi
);
11427 return get_afi_safi_vty_str(afi
, safi
);
11431 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11432 afi_t afi
, safi_t safi
,
11433 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11434 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11435 bool use_json
, json_object
*json_pref
)
11438 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11439 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11441 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11442 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11443 json_object_string_add(json_pref
, "sendMode",
11444 "advertisedAndReceived");
11445 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11446 json_object_string_add(json_pref
, "sendMode",
11448 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11449 json_object_string_add(json_pref
, "sendMode",
11452 vty_out(vty
, " Send-mode: ");
11453 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11454 vty_out(vty
, "advertised");
11455 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11456 vty_out(vty
, "%sreceived",
11457 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11461 vty_out(vty
, "\n");
11466 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11467 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11469 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11470 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11471 json_object_string_add(json_pref
, "recvMode",
11472 "advertisedAndReceived");
11473 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11474 json_object_string_add(json_pref
, "recvMode",
11476 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11477 json_object_string_add(json_pref
, "recvMode",
11480 vty_out(vty
, " Receive-mode: ");
11481 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11482 vty_out(vty
, "advertised");
11483 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11484 vty_out(vty
, "%sreceived",
11485 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11489 vty_out(vty
, "\n");
11494 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11502 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11503 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11504 && (peer_established(p
))) {
11505 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11506 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11510 json_object_boolean_add(json
, "rBit", rbit
);
11511 json_object_boolean_add(json
, "nBit", nbit
);
11513 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11514 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11518 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11523 const char *mode
= "NotApplicable";
11526 vty_out(vty
, "\n Remote GR Mode: ");
11528 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11529 && (peer_established(peer
))) {
11531 if ((peer
->nsf_af_count
== 0)
11532 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11536 } else if (peer
->nsf_af_count
== 0
11537 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11541 } else if (peer
->nsf_af_count
!= 0
11542 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11549 json_object_string_add(json
, "remoteGrMode", mode
);
11551 vty_out(vty
, mode
, "\n");
11554 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11559 const char *mode
= "Invalid";
11562 vty_out(vty
, " Local GR Mode: ");
11564 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11566 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11568 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11570 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11571 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11573 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11575 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11582 json_object_string_add(json
, "localGrMode", mode
);
11584 vty_out(vty
, mode
, "\n");
11588 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11589 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11593 json_object
*json_afi_safi
= NULL
;
11594 json_object
*json_timer
= NULL
;
11595 json_object
*json_endofrib_status
= NULL
;
11596 bool eor_flag
= false;
11598 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11599 if (!peer
->afc
[afi
][safi
])
11602 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11603 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11607 json_afi_safi
= json_object_new_object();
11608 json_endofrib_status
= json_object_new_object();
11609 json_timer
= json_object_new_object();
11612 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11618 vty_out(vty
, " %s:\n",
11619 get_afi_safi_str(afi
, safi
, false));
11621 vty_out(vty
, " F bit: ");
11624 if (peer
->nsf
[afi
][safi
] &&
11625 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11626 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11629 json_object_boolean_true_add(json_afi_safi
,
11632 vty_out(vty
, "True\n");
11635 json_object_boolean_false_add(json_afi_safi
,
11638 vty_out(vty
, "False\n");
11642 vty_out(vty
, " End-of-RIB sent: ");
11644 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11645 PEER_STATUS_EOR_SEND
)) {
11647 json_object_boolean_true_add(
11648 json_endofrib_status
, "endOfRibSend");
11650 PRINT_EOR_JSON(eor_flag
);
11652 vty_out(vty
, "Yes\n");
11654 " End-of-RIB sent after update: ");
11656 PRINT_EOR(eor_flag
);
11660 json_object_boolean_false_add(
11661 json_endofrib_status
, "endOfRibSend");
11662 json_object_boolean_false_add(
11663 json_endofrib_status
,
11664 "endOfRibSentAfterUpdate");
11666 vty_out(vty
, "No\n");
11668 " End-of-RIB sent after update: ");
11669 vty_out(vty
, "No\n");
11674 vty_out(vty
, " End-of-RIB received: ");
11676 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11677 PEER_STATUS_EOR_RECEIVED
)) {
11679 json_object_boolean_true_add(
11680 json_endofrib_status
, "endOfRibRecv");
11682 vty_out(vty
, "Yes\n");
11685 json_object_boolean_false_add(
11686 json_endofrib_status
, "endOfRibRecv");
11688 vty_out(vty
, "No\n");
11692 json_object_int_add(json_timer
, "stalePathTimer",
11693 peer
->bgp
->stalepath_time
);
11695 if (peer
->t_gr_stale
!= NULL
) {
11696 json_object_int_add(json_timer
,
11697 "stalePathTimerRemaining",
11698 thread_timer_remain_second(
11699 peer
->t_gr_stale
));
11702 /* Display Configured Selection
11703 * Deferral only when when
11704 * Gr mode is enabled.
11706 if (CHECK_FLAG(peer
->flags
,
11707 PEER_FLAG_GRACEFUL_RESTART
)) {
11708 json_object_int_add(json_timer
,
11709 "selectionDeferralTimer",
11710 peer
->bgp
->stalepath_time
);
11713 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11716 json_object_int_add(
11718 "selectionDeferralTimerRemaining",
11719 thread_timer_remain_second(
11720 peer
->bgp
->gr_info
[afi
][safi
]
11721 .t_select_deferral
));
11724 vty_out(vty
, " Timers:\n");
11726 " Configured Stale Path Time(sec): %u\n",
11727 peer
->bgp
->stalepath_time
);
11729 if (peer
->t_gr_stale
!= NULL
)
11731 " Stale Path Remaining(sec): %ld\n",
11732 thread_timer_remain_second(
11733 peer
->t_gr_stale
));
11734 /* Display Configured Selection
11735 * Deferral only when when
11736 * Gr mode is enabled.
11738 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11740 " Configured Selection Deferral Time(sec): %u\n",
11741 peer
->bgp
->select_defer_time
);
11743 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11746 " Selection Deferral Time Remaining(sec): %ld\n",
11747 thread_timer_remain_second(
11748 peer
->bgp
->gr_info
[afi
][safi
]
11749 .t_select_deferral
));
11752 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11753 json_endofrib_status
);
11754 json_object_object_add(json_afi_safi
, "timers",
11756 json_object_object_add(
11757 json
, get_afi_safi_str(afi
, safi
, true),
11763 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11769 json_object
*json_timer
= NULL
;
11771 json_timer
= json_object_new_object();
11773 json_object_int_add(json_timer
, "configuredRestartTimer",
11774 p
->bgp
->restart_time
);
11776 json_object_int_add(json_timer
, "receivedRestartTimer",
11779 if (p
->t_gr_restart
!= NULL
)
11780 json_object_int_add(
11781 json_timer
, "restartTimerRemaining",
11782 thread_timer_remain_second(p
->t_gr_restart
));
11784 json_object_object_add(json
, "timers", json_timer
);
11787 vty_out(vty
, " Timers:\n");
11788 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11789 p
->bgp
->restart_time
);
11791 vty_out(vty
, " Received Restart Time(sec): %u\n",
11793 if (p
->t_gr_restart
!= NULL
)
11794 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11795 thread_timer_remain_second(p
->t_gr_restart
));
11796 if (p
->t_gr_restart
!= NULL
) {
11797 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11798 thread_timer_remain_second(p
->t_gr_restart
));
11803 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11804 bool use_json
, json_object
*json
)
11806 char dn_flag
[2] = {0};
11807 /* '*' + v6 address of neighbor */
11808 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11810 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11815 json_object_string_addf(json
, "neighborAddr", "%pSU",
11818 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11821 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11825 json_object_string_add(json
, "neighborAddr",
11828 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11831 /* more gr info in new format */
11832 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11835 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11836 safi_t safi
, bool use_json
,
11837 json_object
*json_neigh
)
11839 struct bgp_filter
*filter
;
11840 struct peer_af
*paf
;
11841 char orf_pfx_name
[BUFSIZ
];
11843 json_object
*json_af
= NULL
;
11844 json_object
*json_prefA
= NULL
;
11845 json_object
*json_prefB
= NULL
;
11846 json_object
*json_addr
= NULL
;
11847 json_object
*json_advmap
= NULL
;
11850 json_addr
= json_object_new_object();
11851 json_af
= json_object_new_object();
11852 filter
= &p
->filter
[afi
][safi
];
11854 if (peer_group_active(p
))
11855 json_object_string_add(json_addr
, "peerGroupMember",
11858 paf
= peer_af_find(p
, afi
, safi
);
11859 if (paf
&& PAF_SUBGRP(paf
)) {
11860 json_object_int_add(json_addr
, "updateGroupId",
11861 PAF_UPDGRP(paf
)->id
);
11862 json_object_int_add(json_addr
, "subGroupId",
11863 PAF_SUBGRP(paf
)->id
);
11864 json_object_int_add(json_addr
, "packetQueueLength",
11865 bpacket_queue_virtual_length(paf
));
11868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11870 PEER_CAP_ORF_PREFIX_SM_RCV
)
11871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11872 PEER_CAP_ORF_PREFIX_RM_ADV
)
11873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11874 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11875 json_object_int_add(json_af
, "orfType",
11877 json_prefA
= json_object_new_object();
11878 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11879 PEER_CAP_ORF_PREFIX_SM_ADV
,
11880 PEER_CAP_ORF_PREFIX_RM_ADV
,
11881 PEER_CAP_ORF_PREFIX_SM_RCV
,
11882 PEER_CAP_ORF_PREFIX_RM_RCV
,
11883 use_json
, json_prefA
);
11884 json_object_object_add(json_af
, "orfPrefixList",
11888 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11890 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11891 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11892 PEER_CAP_ORF_PREFIX_RM_ADV
)
11893 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11894 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11895 json_object_int_add(json_af
, "orfOldType",
11896 ORF_TYPE_PREFIX_OLD
);
11897 json_prefB
= json_object_new_object();
11898 bgp_show_peer_afi_orf_cap(
11899 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11900 PEER_CAP_ORF_PREFIX_RM_ADV
,
11901 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11902 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11904 json_object_object_add(json_af
, "orfOldPrefixList",
11908 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11909 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11910 PEER_CAP_ORF_PREFIX_SM_RCV
)
11911 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11912 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11913 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11914 PEER_CAP_ORF_PREFIX_RM_ADV
)
11915 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11916 PEER_CAP_ORF_PREFIX_RM_RCV
)
11917 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11918 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11919 json_object_object_add(json_addr
, "afDependentCap",
11922 json_object_free(json_af
);
11924 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11925 p
->host
, afi
, safi
);
11926 orf_pfx_count
= prefix_bgp_show_prefix_list(
11927 NULL
, afi
, orf_pfx_name
, use_json
);
11929 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11930 PEER_STATUS_ORF_PREFIX_SEND
)
11931 || orf_pfx_count
) {
11932 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11933 PEER_STATUS_ORF_PREFIX_SEND
))
11934 json_object_boolean_true_add(json_neigh
,
11937 json_object_int_add(json_addr
, "orfRecvCounter",
11940 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11941 PEER_STATUS_ORF_WAIT_REFRESH
))
11942 json_object_string_add(
11943 json_addr
, "orfFirstUpdate",
11944 "deferredUntilORFOrRouteRefreshRecvd");
11946 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11947 PEER_FLAG_REFLECTOR_CLIENT
))
11948 json_object_boolean_true_add(json_addr
,
11949 "routeReflectorClient");
11950 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11951 PEER_FLAG_RSERVER_CLIENT
))
11952 json_object_boolean_true_add(json_addr
,
11953 "routeServerClient");
11954 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11955 json_object_boolean_true_add(json_addr
,
11956 "inboundSoftConfigPermit");
11958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11959 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11960 json_object_boolean_true_add(
11962 "privateAsNumsAllReplacedInUpdatesToNbr");
11963 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11964 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11965 json_object_boolean_true_add(
11967 "privateAsNumsReplacedInUpdatesToNbr");
11968 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11969 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11970 json_object_boolean_true_add(
11972 "privateAsNumsAllRemovedInUpdatesToNbr");
11973 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11974 PEER_FLAG_REMOVE_PRIVATE_AS
))
11975 json_object_boolean_true_add(
11977 "privateAsNumsRemovedInUpdatesToNbr");
11979 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11980 json_object_boolean_true_add(
11982 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11985 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11986 json_object_string_add(json_addr
,
11987 "overrideASNsInOutboundUpdates",
11988 "ifAspathEqualRemoteAs");
11990 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11991 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11992 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11993 json_object_boolean_true_add(json_addr
,
11994 "routerAlwaysNextHop");
11995 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11996 PEER_FLAG_AS_PATH_UNCHANGED
))
11997 json_object_boolean_true_add(
11998 json_addr
, "unchangedAsPathPropogatedToNbr");
11999 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12000 PEER_FLAG_NEXTHOP_UNCHANGED
))
12001 json_object_boolean_true_add(
12002 json_addr
, "unchangedNextHopPropogatedToNbr");
12003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12004 json_object_boolean_true_add(
12005 json_addr
, "unchangedMedPropogatedToNbr");
12006 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12007 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12008 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12010 PEER_FLAG_SEND_COMMUNITY
)
12011 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12012 PEER_FLAG_SEND_EXT_COMMUNITY
))
12013 json_object_string_add(json_addr
,
12014 "commAttriSentToNbr",
12015 "extendedAndStandard");
12016 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12017 PEER_FLAG_SEND_EXT_COMMUNITY
))
12018 json_object_string_add(json_addr
,
12019 "commAttriSentToNbr",
12022 json_object_string_add(json_addr
,
12023 "commAttriSentToNbr",
12026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12027 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12028 if (p
->default_rmap
[afi
][safi
].name
)
12029 json_object_string_add(
12030 json_addr
, "defaultRouteMap",
12031 p
->default_rmap
[afi
][safi
].name
);
12033 if (paf
&& PAF_SUBGRP(paf
)
12034 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12035 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12036 json_object_boolean_true_add(json_addr
,
12039 json_object_boolean_true_add(json_addr
,
12043 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12044 if (is_evpn_enabled())
12045 json_object_boolean_true_add(
12046 json_addr
, "advertiseAllVnis");
12049 if (filter
->plist
[FILTER_IN
].name
12050 || filter
->dlist
[FILTER_IN
].name
12051 || filter
->aslist
[FILTER_IN
].name
12052 || filter
->map
[RMAP_IN
].name
)
12053 json_object_boolean_true_add(json_addr
,
12054 "inboundPathPolicyConfig");
12055 if (filter
->plist
[FILTER_OUT
].name
12056 || filter
->dlist
[FILTER_OUT
].name
12057 || filter
->aslist
[FILTER_OUT
].name
12058 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12059 json_object_boolean_true_add(
12060 json_addr
, "outboundPathPolicyConfig");
12063 if (filter
->plist
[FILTER_IN
].name
)
12064 json_object_string_add(json_addr
,
12065 "incomingUpdatePrefixFilterList",
12066 filter
->plist
[FILTER_IN
].name
);
12067 if (filter
->plist
[FILTER_OUT
].name
)
12068 json_object_string_add(json_addr
,
12069 "outgoingUpdatePrefixFilterList",
12070 filter
->plist
[FILTER_OUT
].name
);
12072 /* distribute-list */
12073 if (filter
->dlist
[FILTER_IN
].name
)
12074 json_object_string_add(
12075 json_addr
, "incomingUpdateNetworkFilterList",
12076 filter
->dlist
[FILTER_IN
].name
);
12077 if (filter
->dlist
[FILTER_OUT
].name
)
12078 json_object_string_add(
12079 json_addr
, "outgoingUpdateNetworkFilterList",
12080 filter
->dlist
[FILTER_OUT
].name
);
12083 if (filter
->aslist
[FILTER_IN
].name
)
12084 json_object_string_add(json_addr
,
12085 "incomingUpdateAsPathFilterList",
12086 filter
->aslist
[FILTER_IN
].name
);
12087 if (filter
->aslist
[FILTER_OUT
].name
)
12088 json_object_string_add(json_addr
,
12089 "outgoingUpdateAsPathFilterList",
12090 filter
->aslist
[FILTER_OUT
].name
);
12093 if (filter
->map
[RMAP_IN
].name
)
12094 json_object_string_add(
12095 json_addr
, "routeMapForIncomingAdvertisements",
12096 filter
->map
[RMAP_IN
].name
);
12097 if (filter
->map
[RMAP_OUT
].name
)
12098 json_object_string_add(
12099 json_addr
, "routeMapForOutgoingAdvertisements",
12100 filter
->map
[RMAP_OUT
].name
);
12102 /* ebgp-requires-policy (inbound) */
12103 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12104 && !bgp_inbound_policy_exists(p
, filter
))
12105 json_object_string_add(
12106 json_addr
, "inboundEbgpRequiresPolicy",
12107 "Inbound updates discarded due to missing policy");
12109 /* ebgp-requires-policy (outbound) */
12110 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12111 && (!bgp_outbound_policy_exists(p
, filter
)))
12112 json_object_string_add(
12113 json_addr
, "outboundEbgpRequiresPolicy",
12114 "Outbound updates discarded due to missing policy");
12116 /* unsuppress-map */
12117 if (filter
->usmap
.name
)
12118 json_object_string_add(json_addr
,
12119 "selectiveUnsuppressRouteMap",
12120 filter
->usmap
.name
);
12122 /* advertise-map */
12123 if (filter
->advmap
.aname
) {
12124 json_advmap
= json_object_new_object();
12125 json_object_string_add(json_advmap
, "condition",
12126 filter
->advmap
.condition
12129 json_object_string_add(json_advmap
, "conditionMap",
12130 filter
->advmap
.cname
);
12131 json_object_string_add(json_advmap
, "advertiseMap",
12132 filter
->advmap
.aname
);
12133 json_object_string_add(
12134 json_advmap
, "advertiseStatus",
12135 filter
->advmap
.update_type
==
12136 UPDATE_TYPE_ADVERTISE
12139 json_object_object_add(json_addr
, "advertiseMap",
12143 /* Receive prefix count */
12144 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12145 p
->pcount
[afi
][safi
]);
12146 if (paf
&& PAF_SUBGRP(paf
))
12147 json_object_int_add(json_addr
, "sentPrefixCounter",
12148 (PAF_SUBGRP(paf
))->scount
);
12150 /* Maximum prefix */
12151 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12152 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12153 p
->pmax_out
[afi
][safi
]);
12155 /* Maximum prefix */
12156 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12157 json_object_int_add(json_addr
, "prefixAllowedMax",
12158 p
->pmax
[afi
][safi
]);
12159 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12160 PEER_FLAG_MAX_PREFIX_WARNING
))
12161 json_object_boolean_true_add(
12162 json_addr
, "prefixAllowedMaxWarning");
12163 json_object_int_add(json_addr
,
12164 "prefixAllowedWarningThresh",
12165 p
->pmax_threshold
[afi
][safi
]);
12166 if (p
->pmax_restart
[afi
][safi
])
12167 json_object_int_add(
12169 "prefixAllowedRestartIntervalMsecs",
12170 p
->pmax_restart
[afi
][safi
] * 60000);
12172 json_object_object_add(json_neigh
,
12173 get_afi_safi_str(afi
, safi
, true),
12177 filter
= &p
->filter
[afi
][safi
];
12179 vty_out(vty
, " For address family: %s\n",
12180 get_afi_safi_str(afi
, safi
, false));
12182 if (peer_group_active(p
))
12183 vty_out(vty
, " %s peer-group member\n",
12186 paf
= peer_af_find(p
, afi
, safi
);
12187 if (paf
&& PAF_SUBGRP(paf
)) {
12188 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12189 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12190 vty_out(vty
, " Packet Queue length %d\n",
12191 bpacket_queue_virtual_length(paf
));
12193 vty_out(vty
, " Not part of any update group\n");
12195 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12196 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12197 PEER_CAP_ORF_PREFIX_SM_RCV
)
12198 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12199 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12200 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12201 PEER_CAP_ORF_PREFIX_RM_ADV
)
12202 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12203 PEER_CAP_ORF_PREFIX_RM_RCV
)
12204 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12205 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12206 vty_out(vty
, " AF-dependant capabilities:\n");
12208 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12209 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12210 PEER_CAP_ORF_PREFIX_SM_RCV
)
12211 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12212 PEER_CAP_ORF_PREFIX_RM_ADV
)
12213 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12214 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12216 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12218 bgp_show_peer_afi_orf_cap(
12219 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12220 PEER_CAP_ORF_PREFIX_RM_ADV
,
12221 PEER_CAP_ORF_PREFIX_SM_RCV
,
12222 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12224 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12225 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12226 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12227 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12228 PEER_CAP_ORF_PREFIX_RM_ADV
)
12229 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12230 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12232 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12233 ORF_TYPE_PREFIX_OLD
);
12234 bgp_show_peer_afi_orf_cap(
12235 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12236 PEER_CAP_ORF_PREFIX_RM_ADV
,
12237 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12238 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12241 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12242 p
->host
, afi
, safi
);
12243 orf_pfx_count
= prefix_bgp_show_prefix_list(
12244 NULL
, afi
, orf_pfx_name
, use_json
);
12246 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12247 PEER_STATUS_ORF_PREFIX_SEND
)
12248 || orf_pfx_count
) {
12249 vty_out(vty
, " Outbound Route Filter (ORF):");
12250 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12251 PEER_STATUS_ORF_PREFIX_SEND
))
12252 vty_out(vty
, " sent;");
12254 vty_out(vty
, " received (%d entries)",
12256 vty_out(vty
, "\n");
12258 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12259 PEER_STATUS_ORF_WAIT_REFRESH
))
12261 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12263 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12264 PEER_FLAG_REFLECTOR_CLIENT
))
12265 vty_out(vty
, " Route-Reflector Client\n");
12266 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12267 PEER_FLAG_RSERVER_CLIENT
))
12268 vty_out(vty
, " Route-Server Client\n");
12269 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12271 " Inbound soft reconfiguration allowed\n");
12273 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12274 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12276 " Private AS numbers (all) replaced in updates to this neighbor\n");
12277 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12278 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12280 " Private AS numbers replaced in updates to this neighbor\n");
12281 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12282 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12284 " Private AS numbers (all) removed in updates to this neighbor\n");
12285 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12286 PEER_FLAG_REMOVE_PRIVATE_AS
))
12288 " Private AS numbers removed in updates to this neighbor\n");
12290 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12291 vty_out(vty
, " %s\n",
12292 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12293 ->human_description
);
12295 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12297 " Override ASNs in outbound updates if aspath equals remote-as\n");
12299 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12300 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12301 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12302 vty_out(vty
, " NEXT_HOP is always this router\n");
12303 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12304 PEER_FLAG_AS_PATH_UNCHANGED
))
12306 " AS_PATH is propagated unchanged to this neighbor\n");
12307 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12308 PEER_FLAG_NEXTHOP_UNCHANGED
))
12310 " NEXT_HOP is propagated unchanged to this neighbor\n");
12311 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12313 " MED is propagated unchanged to this neighbor\n");
12314 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12315 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12316 PEER_FLAG_SEND_EXT_COMMUNITY
)
12317 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12318 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12320 " Community attribute sent to this neighbor");
12321 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12322 PEER_FLAG_SEND_COMMUNITY
)
12323 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12324 PEER_FLAG_SEND_EXT_COMMUNITY
)
12325 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12326 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12327 vty_out(vty
, "(all)\n");
12328 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12329 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12330 vty_out(vty
, "(large)\n");
12331 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12332 PEER_FLAG_SEND_EXT_COMMUNITY
))
12333 vty_out(vty
, "(extended)\n");
12335 vty_out(vty
, "(standard)\n");
12337 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12338 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12339 vty_out(vty
, " Default information originate,");
12341 if (p
->default_rmap
[afi
][safi
].name
)
12342 vty_out(vty
, " default route-map %s%s,",
12343 p
->default_rmap
[afi
][safi
].map
? "*"
12345 p
->default_rmap
[afi
][safi
].name
);
12346 if (paf
&& PAF_SUBGRP(paf
)
12347 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12348 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12349 vty_out(vty
, " default sent\n");
12351 vty_out(vty
, " default not sent\n");
12354 /* advertise-vni-all */
12355 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12356 if (is_evpn_enabled())
12357 vty_out(vty
, " advertise-all-vni\n");
12360 if (filter
->plist
[FILTER_IN
].name
12361 || filter
->dlist
[FILTER_IN
].name
12362 || filter
->aslist
[FILTER_IN
].name
12363 || filter
->map
[RMAP_IN
].name
)
12364 vty_out(vty
, " Inbound path policy configured\n");
12365 if (filter
->plist
[FILTER_OUT
].name
12366 || filter
->dlist
[FILTER_OUT
].name
12367 || filter
->aslist
[FILTER_OUT
].name
12368 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12369 vty_out(vty
, " Outbound path policy configured\n");
12372 if (filter
->plist
[FILTER_IN
].name
)
12374 " Incoming update prefix filter list is %s%s\n",
12375 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12376 filter
->plist
[FILTER_IN
].name
);
12377 if (filter
->plist
[FILTER_OUT
].name
)
12379 " Outgoing update prefix filter list is %s%s\n",
12380 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12381 filter
->plist
[FILTER_OUT
].name
);
12383 /* distribute-list */
12384 if (filter
->dlist
[FILTER_IN
].name
)
12386 " Incoming update network filter list is %s%s\n",
12387 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12388 filter
->dlist
[FILTER_IN
].name
);
12389 if (filter
->dlist
[FILTER_OUT
].name
)
12391 " Outgoing update network filter list is %s%s\n",
12392 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12393 filter
->dlist
[FILTER_OUT
].name
);
12396 if (filter
->aslist
[FILTER_IN
].name
)
12398 " Incoming update AS path filter list is %s%s\n",
12399 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12400 filter
->aslist
[FILTER_IN
].name
);
12401 if (filter
->aslist
[FILTER_OUT
].name
)
12403 " Outgoing update AS path filter list is %s%s\n",
12404 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12405 filter
->aslist
[FILTER_OUT
].name
);
12408 if (filter
->map
[RMAP_IN
].name
)
12410 " Route map for incoming advertisements is %s%s\n",
12411 filter
->map
[RMAP_IN
].map
? "*" : "",
12412 filter
->map
[RMAP_IN
].name
);
12413 if (filter
->map
[RMAP_OUT
].name
)
12415 " Route map for outgoing advertisements is %s%s\n",
12416 filter
->map
[RMAP_OUT
].map
? "*" : "",
12417 filter
->map
[RMAP_OUT
].name
);
12419 /* ebgp-requires-policy (inbound) */
12420 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12421 && !bgp_inbound_policy_exists(p
, filter
))
12423 " Inbound updates discarded due to missing policy\n");
12425 /* ebgp-requires-policy (outbound) */
12426 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12427 && !bgp_outbound_policy_exists(p
, filter
))
12429 " Outbound updates discarded due to missing policy\n");
12431 /* unsuppress-map */
12432 if (filter
->usmap
.name
)
12434 " Route map for selective unsuppress is %s%s\n",
12435 filter
->usmap
.map
? "*" : "",
12436 filter
->usmap
.name
);
12438 /* advertise-map */
12439 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12441 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12442 filter
->advmap
.condition
? "EXIST"
12444 filter
->advmap
.cmap
? "*" : "",
12445 filter
->advmap
.cname
,
12446 filter
->advmap
.amap
? "*" : "",
12447 filter
->advmap
.aname
,
12448 filter
->advmap
.update_type
==
12449 UPDATE_TYPE_ADVERTISE
12453 /* Receive prefix count */
12454 vty_out(vty
, " %u accepted prefixes\n",
12455 p
->pcount
[afi
][safi
]);
12457 /* maximum-prefix-out */
12458 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12459 PEER_FLAG_MAX_PREFIX_OUT
))
12461 " Maximum allowed prefixes sent %u\n",
12462 p
->pmax_out
[afi
][safi
]);
12464 /* Maximum prefix */
12465 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12467 " Maximum prefixes allowed %u%s\n",
12468 p
->pmax
[afi
][safi
],
12469 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12470 PEER_FLAG_MAX_PREFIX_WARNING
)
12471 ? " (warning-only)"
12473 vty_out(vty
, " Threshold for warning message %d%%",
12474 p
->pmax_threshold
[afi
][safi
]);
12475 if (p
->pmax_restart
[afi
][safi
])
12476 vty_out(vty
, ", restart interval %d min",
12477 p
->pmax_restart
[afi
][safi
]);
12478 vty_out(vty
, "\n");
12481 vty_out(vty
, "\n");
12485 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12489 char buf1
[PREFIX2STR_BUFFER
];
12490 char timebuf
[BGP_UPTIME_LEN
];
12496 json_object
*json_neigh
= NULL
;
12498 uint32_t sync_tcp_mss
;
12503 json_neigh
= json_object_new_object();
12505 memset(dn_flag
, '\0', sizeof(dn_flag
));
12506 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12510 if (p
->conf_if
) /* Configured interface name. */
12511 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12513 else /* Configured IP address. */
12514 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12519 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12520 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12522 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12523 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12526 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12528 if (p
->change_local_as
)
12529 json_object_int_add(json_neigh
, "localAs",
12530 p
->change_local_as
);
12532 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12534 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12535 json_object_boolean_true_add(json_neigh
,
12536 "localAsNoPrepend");
12538 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12539 json_object_boolean_true_add(json_neigh
,
12540 "localAsReplaceAs");
12542 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12543 || (p
->as_type
== AS_INTERNAL
))
12544 vty_out(vty
, "remote AS %u, ", p
->as
);
12546 vty_out(vty
, "remote AS Unspecified, ");
12547 vty_out(vty
, "local AS %u%s%s, ",
12548 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12549 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12552 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12556 /* peer type internal or confed-internal */
12557 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12559 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12560 json_object_boolean_true_add(
12561 json_neigh
, "nbrConfedInternalLink");
12563 json_object_boolean_true_add(json_neigh
,
12564 "nbrInternalLink");
12566 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12567 vty_out(vty
, "confed-internal link\n");
12569 vty_out(vty
, "internal link\n");
12571 /* peer type external or confed-external */
12572 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12574 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12575 json_object_boolean_true_add(
12576 json_neigh
, "nbrConfedExternalLink");
12578 json_object_boolean_true_add(json_neigh
,
12579 "nbrExternalLink");
12581 if (bgp_confederation_peers_check(bgp
, p
->as
))
12582 vty_out(vty
, "confed-external link\n");
12584 vty_out(vty
, "external link\n");
12588 json_object_boolean_true_add(json_neigh
,
12589 "nbrUnspecifiedLink");
12591 vty_out(vty
, "unspecified link\n");
12596 json_object_string_add(json_neigh
, "localRole",
12597 bgp_get_name_by_role(p
->local_role
));
12598 json_object_string_add(json_neigh
, "remoteRole",
12599 bgp_get_name_by_role(p
->remote_role
));
12601 vty_out(vty
, " Local Role: %s\n",
12602 bgp_get_name_by_role(p
->local_role
));
12603 vty_out(vty
, " Remote Role: %s\n",
12604 bgp_get_name_by_role(p
->remote_role
));
12611 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12613 vty_out(vty
, " Description: %s\n", p
->desc
);
12619 json_object_string_add(json_neigh
, "hostname",
12623 json_object_string_add(json_neigh
, "domainname",
12626 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12627 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12630 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12637 json_object_string_add(json_neigh
, "peerGroup",
12641 struct prefix prefix
, *range
= NULL
;
12643 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12644 range
= peer_group_lookup_dynamic_neighbor_range(
12645 p
->group
, &prefix
);
12648 json_object_string_addf(
12650 "peerSubnetRangeGroup", "%pFX",
12656 " Member of peer-group %s for session parameters\n",
12660 struct prefix prefix
, *range
= NULL
;
12662 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12663 range
= peer_group_lookup_dynamic_neighbor_range(
12664 p
->group
, &prefix
);
12668 " Belongs to the subnet range group: %pFX\n",
12676 /* Administrative shutdown. */
12677 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12678 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12679 json_object_boolean_true_add(json_neigh
,
12683 json_object_int_add(json_neigh
, "bgpVersion", 4);
12684 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12686 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12689 /* Confederation */
12690 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12691 && bgp_confederation_peers_check(bgp
, p
->as
))
12692 json_object_boolean_true_add(json_neigh
,
12696 json_object_string_add(
12697 json_neigh
, "bgpState",
12698 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12700 if (peer_established(p
)) {
12703 uptime
= bgp_clock();
12704 uptime
-= p
->uptime
;
12705 epoch_tbuf
= time(NULL
) - uptime
;
12707 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12709 json_object_string_add(json_neigh
, "bgpTimerUpString",
12710 peer_uptime(p
->uptime
, timebuf
,
12713 json_object_int_add(json_neigh
,
12714 "bgpTimerUpEstablishedEpoch",
12718 else if (p
->status
== Active
) {
12719 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12720 json_object_string_add(json_neigh
, "bgpStateIs",
12722 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12723 json_object_string_add(json_neigh
, "bgpStateIs",
12731 uptime
= bgp_clock();
12732 uptime
-= p
->readtime
;
12733 gmtime_r(&uptime
, &tm
);
12735 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12736 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12737 + (tm
.tm_hour
* 3600000));
12739 uptime
= bgp_clock();
12740 uptime
-= p
->last_write
;
12741 gmtime_r(&uptime
, &tm
);
12743 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12744 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12745 + (tm
.tm_hour
* 3600000));
12747 uptime
= bgp_clock();
12748 uptime
-= p
->update_time
;
12749 gmtime_r(&uptime
, &tm
);
12751 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12752 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12753 + (tm
.tm_hour
* 3600000));
12755 /* Configured timer values. */
12756 json_object_int_add(json_neigh
,
12757 "bgpTimerConfiguredHoldTimeMsecs",
12758 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12759 ? p
->holdtime
* 1000
12760 : bgp
->default_holdtime
* 1000);
12761 json_object_int_add(json_neigh
,
12762 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12763 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12764 ? p
->keepalive
* 1000
12765 : bgp
->default_keepalive
* 1000);
12766 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12767 p
->v_holdtime
* 1000);
12768 json_object_int_add(json_neigh
,
12769 "bgpTimerKeepAliveIntervalMsecs",
12770 p
->v_keepalive
* 1000);
12771 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12772 json_object_int_add(json_neigh
,
12773 "bgpTimerDelayOpenTimeMsecs",
12774 p
->v_delayopen
* 1000);
12777 /* Configured and Synced tcp-mss value for peer */
12778 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12779 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12780 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12782 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12786 /* Extended Optional Parameters Length for BGP OPEN Message */
12787 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12788 json_object_boolean_true_add(
12789 json_neigh
, "extendedOptionalParametersLength");
12791 json_object_boolean_false_add(
12792 json_neigh
, "extendedOptionalParametersLength");
12794 /* Conditional advertisements */
12795 json_object_int_add(
12797 "bgpTimerConfiguredConditionalAdvertisementsSec",
12798 bgp
->condition_check_period
);
12799 if (thread_is_scheduled(bgp
->t_condition_check
))
12800 json_object_int_add(
12802 "bgpTimerUntilConditionalAdvertisementsSec",
12803 thread_timer_remain_second(
12804 bgp
->t_condition_check
));
12806 /* Administrative shutdown. */
12807 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12808 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12809 vty_out(vty
, " Administratively shut down\n");
12812 vty_out(vty
, " BGP version 4");
12813 vty_out(vty
, ", remote router ID %s",
12814 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12815 vty_out(vty
, ", local router ID %s\n",
12816 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12819 /* Confederation */
12820 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12821 && bgp_confederation_peers_check(bgp
, p
->as
))
12823 " Neighbor under common administration\n");
12826 vty_out(vty
, " BGP state = %s",
12827 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12829 if (peer_established(p
))
12830 vty_out(vty
, ", up for %8s",
12831 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12834 else if (p
->status
== Active
) {
12835 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12836 vty_out(vty
, " (passive)");
12837 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12838 vty_out(vty
, " (NSF passive)");
12840 vty_out(vty
, "\n");
12843 vty_out(vty
, " Last read %s",
12844 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12846 vty_out(vty
, ", Last write %s\n",
12847 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12850 /* Configured timer values. */
12852 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12853 p
->v_holdtime
, p
->v_keepalive
);
12854 vty_out(vty
, " Configured hold time is %d seconds",
12855 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12857 : bgp
->default_holdtime
);
12858 vty_out(vty
, ", keepalive interval is %d seconds\n",
12859 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12861 : bgp
->default_keepalive
);
12862 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12864 " Configured DelayOpenTime is %d seconds\n",
12867 /* Configured and synced tcp-mss value for peer */
12868 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12869 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12870 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12871 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12874 /* Extended Optional Parameters Length for BGP OPEN Message */
12875 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12877 " Extended Optional Parameters Length is enabled\n");
12879 /* Conditional advertisements */
12881 " Configured conditional advertisements interval is %d seconds\n",
12882 bgp
->condition_check_period
);
12883 if (thread_is_scheduled(bgp
->t_condition_check
))
12885 " Time until conditional advertisements begin is %lu seconds\n",
12886 thread_timer_remain_second(
12887 bgp
->t_condition_check
));
12890 if (peer_established(p
) &&
12891 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12893 json_object
*json_cap
= NULL
;
12895 json_cap
= json_object_new_object();
12898 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12899 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12900 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12901 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12902 json_object_string_add(
12903 json_cap
, "4byteAs",
12904 "advertisedAndReceived");
12905 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12906 json_object_string_add(json_cap
,
12909 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12910 json_object_string_add(json_cap
,
12915 /* Extended Message Support */
12916 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12917 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12918 json_object_string_add(json_cap
,
12920 "advertisedAndReceived");
12921 else if (CHECK_FLAG(p
->cap
,
12922 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12923 json_object_string_add(json_cap
,
12926 else if (CHECK_FLAG(p
->cap
,
12927 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12928 json_object_string_add(json_cap
,
12933 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12934 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12935 json_object
*json_add
= NULL
;
12936 const char *print_store
;
12938 json_add
= json_object_new_object();
12940 FOREACH_AFI_SAFI (afi
, safi
) {
12941 json_object
*json_sub
= NULL
;
12942 json_sub
= json_object_new_object();
12943 print_store
= get_afi_safi_str(
12947 p
->af_cap
[afi
][safi
],
12948 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12950 p
->af_cap
[afi
][safi
],
12951 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12955 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12959 PEER_CAP_ADDPATH_AF_TX_RCV
))
12960 json_object_boolean_true_add(
12962 "txAdvertisedAndReceived");
12967 PEER_CAP_ADDPATH_AF_TX_ADV
))
12968 json_object_boolean_true_add(
12975 PEER_CAP_ADDPATH_AF_TX_RCV
))
12976 json_object_boolean_true_add(
12982 p
->af_cap
[afi
][safi
],
12983 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12985 p
->af_cap
[afi
][safi
],
12986 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12990 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12994 PEER_CAP_ADDPATH_AF_RX_RCV
))
12995 json_object_boolean_true_add(
12997 "rxAdvertisedAndReceived");
13002 PEER_CAP_ADDPATH_AF_RX_ADV
))
13003 json_object_boolean_true_add(
13010 PEER_CAP_ADDPATH_AF_RX_RCV
))
13011 json_object_boolean_true_add(
13017 p
->af_cap
[afi
][safi
],
13018 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13020 p
->af_cap
[afi
][safi
],
13021 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13023 p
->af_cap
[afi
][safi
],
13024 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13026 p
->af_cap
[afi
][safi
],
13027 PEER_CAP_ADDPATH_AF_RX_RCV
))
13028 json_object_object_add(
13029 json_add
, print_store
,
13032 json_object_free(json_sub
);
13035 json_object_object_add(json_cap
, "addPath",
13040 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13041 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13042 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13043 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13044 json_object_string_add(
13045 json_cap
, "dynamic",
13046 "advertisedAndReceived");
13047 else if (CHECK_FLAG(p
->cap
,
13048 PEER_CAP_DYNAMIC_ADV
))
13049 json_object_string_add(json_cap
,
13052 else if (CHECK_FLAG(p
->cap
,
13053 PEER_CAP_DYNAMIC_RCV
))
13054 json_object_string_add(json_cap
,
13060 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13061 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13062 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13063 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13064 json_object_string_add(
13066 "advertisedAndReceived");
13067 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13068 json_object_string_add(json_cap
, "role",
13070 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13071 json_object_string_add(json_cap
, "role",
13075 /* Extended nexthop */
13076 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13077 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13078 json_object
*json_nxt
= NULL
;
13079 const char *print_store
;
13082 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13083 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13084 json_object_string_add(
13085 json_cap
, "extendedNexthop",
13086 "advertisedAndReceived");
13087 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13088 json_object_string_add(
13089 json_cap
, "extendedNexthop",
13091 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13092 json_object_string_add(
13093 json_cap
, "extendedNexthop",
13096 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13097 json_nxt
= json_object_new_object();
13099 for (safi
= SAFI_UNICAST
;
13100 safi
< SAFI_MAX
; safi
++) {
13104 PEER_CAP_ENHE_AF_RCV
)) {
13110 json_object_string_add(
13113 "recieved"); /* misspelled for compatibility */
13116 json_object_object_add(
13118 "extendedNexthopFamililesByPeer",
13123 /* Long-lived Graceful Restart */
13124 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13125 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13126 json_object
*json_llgr
= NULL
;
13127 const char *afi_safi_str
;
13129 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13130 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13131 json_object_string_add(
13133 "longLivedGracefulRestart",
13134 "advertisedAndReceived");
13135 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13136 json_object_string_add(
13138 "longLivedGracefulRestart",
13140 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13141 json_object_string_add(
13143 "longLivedGracefulRestart",
13146 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13147 json_llgr
= json_object_new_object();
13149 FOREACH_AFI_SAFI (afi
, safi
) {
13153 PEER_CAP_ENHE_AF_RCV
)) {
13159 json_object_string_add(
13165 json_object_object_add(
13167 "longLivedGracefulRestartByPeer",
13172 /* Route Refresh */
13173 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13174 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13175 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13176 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13177 (CHECK_FLAG(p
->cap
,
13178 PEER_CAP_REFRESH_NEW_RCV
) ||
13180 PEER_CAP_REFRESH_OLD_RCV
))) {
13183 PEER_CAP_REFRESH_OLD_RCV
) &&
13186 PEER_CAP_REFRESH_NEW_RCV
))
13187 json_object_string_add(
13190 "advertisedAndReceivedOldNew");
13194 PEER_CAP_REFRESH_OLD_RCV
))
13195 json_object_string_add(
13198 "advertisedAndReceivedOld");
13200 json_object_string_add(
13203 "advertisedAndReceivedNew");
13205 } else if (CHECK_FLAG(p
->cap
,
13206 PEER_CAP_REFRESH_ADV
))
13207 json_object_string_add(json_cap
,
13210 else if (CHECK_FLAG(p
->cap
,
13211 PEER_CAP_REFRESH_NEW_RCV
) ||
13213 PEER_CAP_REFRESH_OLD_RCV
))
13214 json_object_string_add(json_cap
,
13219 /* Enhanced Route Refresh */
13220 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13221 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13222 if (CHECK_FLAG(p
->cap
,
13223 PEER_CAP_ENHANCED_RR_ADV
) &&
13225 PEER_CAP_ENHANCED_RR_RCV
))
13226 json_object_string_add(
13228 "enhancedRouteRefresh",
13229 "advertisedAndReceived");
13230 else if (CHECK_FLAG(p
->cap
,
13231 PEER_CAP_ENHANCED_RR_ADV
))
13232 json_object_string_add(
13234 "enhancedRouteRefresh",
13236 else if (CHECK_FLAG(p
->cap
,
13237 PEER_CAP_ENHANCED_RR_RCV
))
13238 json_object_string_add(
13240 "enhancedRouteRefresh",
13244 /* Multiprotocol Extensions */
13245 json_object
*json_multi
= NULL
;
13247 json_multi
= json_object_new_object();
13249 FOREACH_AFI_SAFI (afi
, safi
) {
13250 if (p
->afc_adv
[afi
][safi
] ||
13251 p
->afc_recv
[afi
][safi
]) {
13252 json_object
*json_exten
= NULL
;
13253 json_exten
= json_object_new_object();
13255 if (p
->afc_adv
[afi
][safi
] &&
13256 p
->afc_recv
[afi
][safi
])
13257 json_object_boolean_true_add(
13259 "advertisedAndReceived");
13260 else if (p
->afc_adv
[afi
][safi
])
13261 json_object_boolean_true_add(
13264 else if (p
->afc_recv
[afi
][safi
])
13265 json_object_boolean_true_add(
13266 json_exten
, "received");
13268 json_object_object_add(
13270 get_afi_safi_str(afi
, safi
,
13275 json_object_object_add(json_cap
,
13276 "multiprotocolExtensions",
13279 /* Hostname capabilities */
13280 json_object
*json_hname
= NULL
;
13282 json_hname
= json_object_new_object();
13284 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13285 json_object_string_add(
13286 json_hname
, "advHostName",
13287 bgp
->peer_self
->hostname
13288 ? bgp
->peer_self
->hostname
13290 json_object_string_add(
13291 json_hname
, "advDomainName",
13292 bgp
->peer_self
->domainname
13293 ? bgp
->peer_self
->domainname
13298 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13299 json_object_string_add(
13300 json_hname
, "rcvHostName",
13301 p
->hostname
? p
->hostname
: "n/a");
13302 json_object_string_add(
13303 json_hname
, "rcvDomainName",
13304 p
->domainname
? p
->domainname
: "n/a");
13307 json_object_object_add(json_cap
, "hostName",
13310 /* Graceful Restart */
13311 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13312 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13313 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13314 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13315 json_object_string_add(
13316 json_cap
, "gracefulRestart",
13317 "advertisedAndReceived");
13318 else if (CHECK_FLAG(p
->cap
,
13319 PEER_CAP_RESTART_ADV
))
13320 json_object_string_add(
13322 "gracefulRestartCapability",
13324 else if (CHECK_FLAG(p
->cap
,
13325 PEER_CAP_RESTART_RCV
))
13326 json_object_string_add(
13328 "gracefulRestartCapability",
13331 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13332 int restart_af_count
= 0;
13333 json_object
*json_restart
= NULL
;
13334 json_restart
= json_object_new_object();
13336 json_object_int_add(
13338 "gracefulRestartRemoteTimerMsecs",
13339 p
->v_gr_restart
* 1000);
13341 FOREACH_AFI_SAFI (afi
, safi
) {
13345 PEER_CAP_RESTART_AF_RCV
)) {
13346 json_object
*json_sub
=
13349 json_object_new_object();
13355 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13356 json_object_boolean_true_add(
13359 restart_af_count
++;
13360 json_object_object_add(
13369 if (!restart_af_count
) {
13370 json_object_string_add(
13372 "addressFamiliesByPeer",
13374 json_object_free(json_restart
);
13376 json_object_object_add(
13378 "addressFamiliesByPeer",
13382 json_object_object_add(
13383 json_neigh
, "neighborCapabilities", json_cap
);
13385 vty_out(vty
, " Neighbor capabilities:\n");
13388 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13389 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13390 vty_out(vty
, " 4 Byte AS:");
13391 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13392 vty_out(vty
, " advertised");
13393 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13394 vty_out(vty
, " %sreceived",
13399 vty_out(vty
, "\n");
13402 /* Extended Message Support */
13403 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13404 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13405 vty_out(vty
, " Extended Message:");
13406 if (CHECK_FLAG(p
->cap
,
13407 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13408 vty_out(vty
, " advertised");
13409 if (CHECK_FLAG(p
->cap
,
13410 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13411 vty_out(vty
, " %sreceived",
13414 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13417 vty_out(vty
, "\n");
13421 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13422 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13423 vty_out(vty
, " AddPath:\n");
13425 FOREACH_AFI_SAFI (afi
, safi
) {
13427 p
->af_cap
[afi
][safi
],
13428 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13430 p
->af_cap
[afi
][safi
],
13431 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13432 vty_out(vty
, " %s: TX ",
13440 PEER_CAP_ADDPATH_AF_TX_ADV
))
13447 PEER_CAP_ADDPATH_AF_TX_RCV
))
13454 PEER_CAP_ADDPATH_AF_TX_ADV
)
13458 vty_out(vty
, "\n");
13462 p
->af_cap
[afi
][safi
],
13463 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13465 p
->af_cap
[afi
][safi
],
13466 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13467 vty_out(vty
, " %s: RX ",
13475 PEER_CAP_ADDPATH_AF_RX_ADV
))
13482 PEER_CAP_ADDPATH_AF_RX_RCV
))
13489 PEER_CAP_ADDPATH_AF_RX_ADV
)
13493 vty_out(vty
, "\n");
13499 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13500 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13501 vty_out(vty
, " Dynamic:");
13502 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13503 vty_out(vty
, " advertised");
13504 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13505 vty_out(vty
, " %sreceived",
13507 PEER_CAP_DYNAMIC_ADV
)
13510 vty_out(vty
, "\n");
13514 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13515 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13516 vty_out(vty
, " Role:");
13517 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13518 vty_out(vty
, " advertised");
13519 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13520 vty_out(vty
, " %sreceived",
13525 vty_out(vty
, "\n");
13528 /* Extended nexthop */
13529 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13530 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13531 vty_out(vty
, " Extended nexthop:");
13532 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13533 vty_out(vty
, " advertised");
13534 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13535 vty_out(vty
, " %sreceived",
13540 vty_out(vty
, "\n");
13542 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13544 " Address families by peer:\n ");
13545 for (safi
= SAFI_UNICAST
;
13546 safi
< SAFI_MAX
; safi
++)
13550 PEER_CAP_ENHE_AF_RCV
))
13560 /* Long-lived Graceful Restart */
13561 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13562 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13564 " Long-lived Graceful Restart:");
13565 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13566 vty_out(vty
, " advertised");
13567 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13568 vty_out(vty
, " %sreceived",
13573 vty_out(vty
, "\n");
13575 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13577 " Address families by peer:\n");
13578 FOREACH_AFI_SAFI (afi
, safi
)
13582 PEER_CAP_LLGR_AF_RCV
))
13592 /* Route Refresh */
13593 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13594 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13595 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13596 vty_out(vty
, " Route refresh:");
13597 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13598 vty_out(vty
, " advertised");
13599 if (CHECK_FLAG(p
->cap
,
13600 PEER_CAP_REFRESH_NEW_RCV
) ||
13602 PEER_CAP_REFRESH_OLD_RCV
))
13603 vty_out(vty
, " %sreceived(%s)",
13605 PEER_CAP_REFRESH_ADV
)
13610 PEER_CAP_REFRESH_OLD_RCV
) &&
13613 PEER_CAP_REFRESH_NEW_RCV
))
13617 PEER_CAP_REFRESH_OLD_RCV
)
13621 vty_out(vty
, "\n");
13624 /* Enhanced Route Refresh */
13625 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13626 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13627 vty_out(vty
, " Enhanced Route Refresh:");
13628 if (CHECK_FLAG(p
->cap
,
13629 PEER_CAP_ENHANCED_RR_ADV
))
13630 vty_out(vty
, " advertised");
13631 if (CHECK_FLAG(p
->cap
,
13632 PEER_CAP_ENHANCED_RR_RCV
))
13633 vty_out(vty
, " %sreceived",
13635 PEER_CAP_REFRESH_ADV
)
13638 vty_out(vty
, "\n");
13641 /* Multiprotocol Extensions */
13642 FOREACH_AFI_SAFI (afi
, safi
)
13643 if (p
->afc_adv
[afi
][safi
] ||
13644 p
->afc_recv
[afi
][safi
]) {
13645 vty_out(vty
, " Address Family %s:",
13646 get_afi_safi_str(afi
, safi
,
13648 if (p
->afc_adv
[afi
][safi
])
13649 vty_out(vty
, " advertised");
13650 if (p
->afc_recv
[afi
][safi
])
13651 vty_out(vty
, " %sreceived",
13652 p
->afc_adv
[afi
][safi
]
13655 vty_out(vty
, "\n");
13658 /* Hostname capability */
13659 vty_out(vty
, " Hostname Capability:");
13661 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13663 " advertised (name: %s,domain name: %s)",
13664 bgp
->peer_self
->hostname
13665 ? bgp
->peer_self
->hostname
13667 bgp
->peer_self
->domainname
13668 ? bgp
->peer_self
->domainname
13671 vty_out(vty
, " not advertised");
13674 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13676 " received (name: %s,domain name: %s)",
13677 p
->hostname
? p
->hostname
: "n/a",
13678 p
->domainname
? p
->domainname
: "n/a");
13680 vty_out(vty
, " not received");
13683 vty_out(vty
, "\n");
13685 /* Graceful Restart */
13686 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13687 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13689 " Graceful Restart Capability:");
13690 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13691 vty_out(vty
, " advertised");
13692 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13693 vty_out(vty
, " %sreceived",
13695 PEER_CAP_RESTART_ADV
)
13698 vty_out(vty
, "\n");
13700 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13701 int restart_af_count
= 0;
13704 " Remote Restart timer is %d seconds\n",
13707 " Address families by peer:\n ");
13709 FOREACH_AFI_SAFI (afi
, safi
)
13713 PEER_CAP_RESTART_AF_RCV
)) {
13714 vty_out(vty
, "%s%s(%s)",
13726 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13728 : "not preserved");
13729 restart_af_count
++;
13731 if (!restart_af_count
)
13732 vty_out(vty
, "none");
13733 vty_out(vty
, "\n");
13735 } /* Graceful Restart */
13739 /* graceful restart information */
13740 json_object
*json_grace
= NULL
;
13741 json_object
*json_grace_send
= NULL
;
13742 json_object
*json_grace_recv
= NULL
;
13743 int eor_send_af_count
= 0;
13744 int eor_receive_af_count
= 0;
13747 json_grace
= json_object_new_object();
13748 json_grace_send
= json_object_new_object();
13749 json_grace_recv
= json_object_new_object();
13751 if ((peer_established(p
)) &&
13752 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13753 FOREACH_AFI_SAFI (afi
, safi
) {
13754 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13755 PEER_STATUS_EOR_SEND
)) {
13756 json_object_boolean_true_add(
13758 get_afi_safi_str(afi
, safi
,
13760 eor_send_af_count
++;
13763 FOREACH_AFI_SAFI (afi
, safi
) {
13764 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13765 PEER_STATUS_EOR_RECEIVED
)) {
13766 json_object_boolean_true_add(
13768 get_afi_safi_str(afi
, safi
,
13770 eor_receive_af_count
++;
13774 json_object_object_add(json_grace
, "endOfRibSend",
13776 json_object_object_add(json_grace
, "endOfRibRecv",
13780 if (p
->t_gr_restart
)
13781 json_object_int_add(
13782 json_grace
, "gracefulRestartTimerMsecs",
13783 thread_timer_remain_second(p
->t_gr_restart
) *
13787 json_object_int_add(
13788 json_grace
, "gracefulStalepathTimerMsecs",
13789 thread_timer_remain_second(p
->t_gr_stale
) *
13791 /* more gr info in new format */
13792 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13793 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13796 vty_out(vty
, " Graceful restart information:\n");
13797 if ((peer_established(p
)) &&
13798 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13800 vty_out(vty
, " End-of-RIB send: ");
13801 FOREACH_AFI_SAFI (afi
, safi
) {
13802 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13803 PEER_STATUS_EOR_SEND
)) {
13804 vty_out(vty
, "%s%s",
13805 eor_send_af_count
? ", " : "",
13806 get_afi_safi_str(afi
, safi
,
13808 eor_send_af_count
++;
13811 vty_out(vty
, "\n");
13812 vty_out(vty
, " End-of-RIB received: ");
13813 FOREACH_AFI_SAFI (afi
, safi
) {
13814 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13815 PEER_STATUS_EOR_RECEIVED
)) {
13816 vty_out(vty
, "%s%s",
13817 eor_receive_af_count
? ", "
13819 get_afi_safi_str(afi
, safi
,
13821 eor_receive_af_count
++;
13824 vty_out(vty
, "\n");
13827 if (p
->t_gr_restart
)
13829 " The remaining time of restart timer is %ld\n",
13830 thread_timer_remain_second(p
->t_gr_restart
));
13834 " The remaining time of stalepath timer is %ld\n",
13835 thread_timer_remain_second(p
->t_gr_stale
));
13837 /* more gr info in new format */
13838 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13842 json_object
*json_stat
= NULL
;
13843 json_stat
= json_object_new_object();
13844 /* Packet counts. */
13846 atomic_size_t outq_count
, inq_count
;
13847 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13848 memory_order_relaxed
);
13849 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13850 memory_order_relaxed
);
13852 json_object_int_add(json_stat
, "depthInq",
13853 (unsigned long)inq_count
);
13854 json_object_int_add(json_stat
, "depthOutq",
13855 (unsigned long)outq_count
);
13856 json_object_int_add(json_stat
, "opensSent",
13857 atomic_load_explicit(&p
->open_out
,
13858 memory_order_relaxed
));
13859 json_object_int_add(json_stat
, "opensRecv",
13860 atomic_load_explicit(&p
->open_in
,
13861 memory_order_relaxed
));
13862 json_object_int_add(json_stat
, "notificationsSent",
13863 atomic_load_explicit(&p
->notify_out
,
13864 memory_order_relaxed
));
13865 json_object_int_add(json_stat
, "notificationsRecv",
13866 atomic_load_explicit(&p
->notify_in
,
13867 memory_order_relaxed
));
13868 json_object_int_add(json_stat
, "updatesSent",
13869 atomic_load_explicit(&p
->update_out
,
13870 memory_order_relaxed
));
13871 json_object_int_add(json_stat
, "updatesRecv",
13872 atomic_load_explicit(&p
->update_in
,
13873 memory_order_relaxed
));
13874 json_object_int_add(json_stat
, "keepalivesSent",
13875 atomic_load_explicit(&p
->keepalive_out
,
13876 memory_order_relaxed
));
13877 json_object_int_add(json_stat
, "keepalivesRecv",
13878 atomic_load_explicit(&p
->keepalive_in
,
13879 memory_order_relaxed
));
13880 json_object_int_add(json_stat
, "routeRefreshSent",
13881 atomic_load_explicit(&p
->refresh_out
,
13882 memory_order_relaxed
));
13883 json_object_int_add(json_stat
, "routeRefreshRecv",
13884 atomic_load_explicit(&p
->refresh_in
,
13885 memory_order_relaxed
));
13886 json_object_int_add(json_stat
, "capabilitySent",
13887 atomic_load_explicit(&p
->dynamic_cap_out
,
13888 memory_order_relaxed
));
13889 json_object_int_add(json_stat
, "capabilityRecv",
13890 atomic_load_explicit(&p
->dynamic_cap_in
,
13891 memory_order_relaxed
));
13892 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13893 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13894 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13896 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13897 notify_out
, notify_in
, update_out
, update_in
,
13898 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13899 dynamic_cap_out
, dynamic_cap_in
;
13900 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13901 memory_order_relaxed
);
13902 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13903 memory_order_relaxed
);
13904 open_out
= atomic_load_explicit(&p
->open_out
,
13905 memory_order_relaxed
);
13907 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13908 notify_out
= atomic_load_explicit(&p
->notify_out
,
13909 memory_order_relaxed
);
13910 notify_in
= atomic_load_explicit(&p
->notify_in
,
13911 memory_order_relaxed
);
13912 update_out
= atomic_load_explicit(&p
->update_out
,
13913 memory_order_relaxed
);
13914 update_in
= atomic_load_explicit(&p
->update_in
,
13915 memory_order_relaxed
);
13916 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13917 memory_order_relaxed
);
13918 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13919 memory_order_relaxed
);
13920 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13921 memory_order_relaxed
);
13922 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13923 memory_order_relaxed
);
13924 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13925 memory_order_relaxed
);
13926 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13927 memory_order_relaxed
);
13929 /* Packet counts. */
13930 vty_out(vty
, " Message statistics:\n");
13931 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13932 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13933 vty_out(vty
, " Sent Rcvd\n");
13934 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13936 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13938 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13940 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13942 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13944 vty_out(vty
, " Capability: %10zu %10zu\n",
13945 dynamic_cap_out
, dynamic_cap_in
);
13946 vty_out(vty
, " Total: %10u %10u\n",
13947 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13951 /* advertisement-interval */
13952 json_object_int_add(json_neigh
,
13953 "minBtwnAdvertisementRunsTimerMsecs",
13954 p
->v_routeadv
* 1000);
13956 /* Update-source. */
13957 if (p
->update_if
|| p
->update_source
) {
13959 json_object_string_add(json_neigh
,
13962 else if (p
->update_source
)
13963 json_object_string_addf(json_neigh
,
13964 "updateSource", "%pSU",
13968 /* advertisement-interval */
13970 " Minimum time between advertisement runs is %d seconds\n",
13973 /* Update-source. */
13974 if (p
->update_if
|| p
->update_source
) {
13975 vty_out(vty
, " Update source is ");
13977 vty_out(vty
, "%s", p
->update_if
);
13978 else if (p
->update_source
)
13979 vty_out(vty
, "%pSU", p
->update_source
);
13980 vty_out(vty
, "\n");
13983 vty_out(vty
, "\n");
13986 /* Address Family Information */
13987 json_object
*json_hold
= NULL
;
13990 json_hold
= json_object_new_object();
13992 FOREACH_AFI_SAFI (afi
, safi
)
13993 if (p
->afc
[afi
][safi
])
13994 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13998 json_object_object_add(json_neigh
, "addressFamilyInfo",
14000 json_object_int_add(json_neigh
, "connectionsEstablished",
14002 json_object_int_add(json_neigh
, "connectionsDropped",
14005 vty_out(vty
, " Connections established %d; dropped %d\n",
14006 p
->established
, p
->dropped
);
14008 if (!p
->last_reset
) {
14010 json_object_string_add(json_neigh
, "lastReset",
14013 vty_out(vty
, " Last reset never\n");
14019 uptime
= bgp_clock();
14020 uptime
-= p
->resettime
;
14021 gmtime_r(&uptime
, &tm
);
14023 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14025 + (tm
.tm_min
* 60000)
14026 + (tm
.tm_hour
* 3600000));
14027 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14029 vty_out(vty
, " Last reset %s, ",
14030 peer_uptime(p
->resettime
, timebuf
,
14031 BGP_UPTIME_LEN
, 0, NULL
));
14033 bgp_show_peer_reset(vty
, p
, NULL
, false);
14034 if (p
->last_reset_cause_size
) {
14035 msg
= p
->last_reset_cause
;
14037 " Message received that caused BGP to send a NOTIFICATION:\n ");
14038 for (i
= 1; i
<= p
->last_reset_cause_size
;
14040 vty_out(vty
, "%02X", *msg
++);
14042 if (i
!= p
->last_reset_cause_size
) {
14044 vty_out(vty
, "\n ");
14045 } else if (i
% 4 == 0) {
14050 vty_out(vty
, "\n");
14055 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14057 json_object_boolean_true_add(json_neigh
,
14058 "prefixesConfigExceedMax");
14061 " Peer had exceeded the max. no. of prefixes configured.\n");
14063 if (p
->t_pmax_restart
) {
14065 json_object_boolean_true_add(
14066 json_neigh
, "reducePrefixNumFrom");
14067 json_object_int_add(json_neigh
,
14068 "restartInTimerMsec",
14069 thread_timer_remain_second(
14074 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14075 p
->host
, thread_timer_remain_second(
14076 p
->t_pmax_restart
));
14079 json_object_boolean_true_add(
14081 "reducePrefixNumAndClearIpBgp");
14084 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14089 /* EBGP Multihop and GTSM */
14090 if (p
->sort
!= BGP_PEER_IBGP
) {
14092 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14093 json_object_int_add(json_neigh
,
14094 "externalBgpNbrMaxHopsAway",
14097 json_object_int_add(json_neigh
,
14098 "externalBgpNbrMaxHopsAway",
14101 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14103 " External BGP neighbor may be up to %d hops away.\n",
14107 " External BGP neighbor may be up to %d hops away.\n",
14112 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14113 json_object_int_add(json_neigh
,
14114 "internalBgpNbrMaxHopsAway",
14117 json_object_int_add(json_neigh
,
14118 "internalBgpNbrMaxHopsAway",
14121 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14123 " Internal BGP neighbor may be up to %d hops away.\n",
14127 " Internal BGP neighbor may be up to %d hops away.\n",
14132 /* Local address. */
14135 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14137 json_object_int_add(json_neigh
, "portLocal",
14138 ntohs(p
->su_local
->sin
.sin_port
));
14140 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14141 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14144 json_object_string_add(json_neigh
, "hostLocal",
14146 json_object_int_add(json_neigh
, "portLocal", -1);
14150 /* Remote address. */
14151 if (p
->su_remote
) {
14153 json_object_string_addf(json_neigh
, "hostForeign",
14154 "%pSU", p
->su_remote
);
14155 json_object_int_add(json_neigh
, "portForeign",
14156 ntohs(p
->su_remote
->sin
.sin_port
));
14158 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14160 ntohs(p
->su_remote
->sin
.sin_port
));
14163 json_object_string_add(json_neigh
, "hostForeign",
14165 json_object_int_add(json_neigh
, "portForeign", -1);
14169 /* Nexthop display. */
14172 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14174 json_object_string_addf(json_neigh
, "nexthopGlobal",
14175 "%pI6", &p
->nexthop
.v6_global
);
14176 json_object_string_addf(json_neigh
, "nexthopLocal",
14177 "%pI6", &p
->nexthop
.v6_local
);
14178 if (p
->shared_network
)
14179 json_object_string_add(json_neigh
,
14183 json_object_string_add(json_neigh
,
14185 "nonSharedNetwork");
14187 vty_out(vty
, "Nexthop: %s\n",
14188 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14190 vty_out(vty
, "Nexthop global: %s\n",
14191 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14193 vty_out(vty
, "Nexthop local: %s\n",
14194 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14196 vty_out(vty
, "BGP connection: %s\n",
14197 p
->shared_network
? "shared network"
14198 : "non shared network");
14202 /* Timer information. */
14204 json_object_int_add(json_neigh
, "connectRetryTimer",
14206 if (peer_established(p
) && p
->rtt
)
14207 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14210 json_object_int_add(
14211 json_neigh
, "nextStartTimerDueInMsecs",
14212 thread_timer_remain_second(p
->t_start
) * 1000);
14214 json_object_int_add(
14215 json_neigh
, "nextConnectTimerDueInMsecs",
14216 thread_timer_remain_second(p
->t_connect
)
14218 if (p
->t_routeadv
) {
14219 json_object_int_add(json_neigh
, "mraiInterval",
14221 json_object_int_add(
14222 json_neigh
, "mraiTimerExpireInMsecs",
14223 thread_timer_remain_second(p
->t_routeadv
)
14227 json_object_int_add(json_neigh
, "authenticationEnabled",
14231 json_object_string_add(json_neigh
, "readThread", "on");
14233 json_object_string_add(json_neigh
, "readThread", "off");
14235 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14236 json_object_string_add(json_neigh
, "writeThread", "on");
14238 json_object_string_add(json_neigh
, "writeThread",
14241 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14243 if (peer_established(p
) && p
->rtt
)
14244 vty_out(vty
, "Estimated round trip time: %d ms\n",
14247 vty_out(vty
, "Next start timer due in %ld seconds\n",
14248 thread_timer_remain_second(p
->t_start
));
14250 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14251 thread_timer_remain_second(p
->t_connect
));
14254 "MRAI (interval %u) timer expires in %ld seconds\n",
14256 thread_timer_remain_second(p
->t_routeadv
));
14258 vty_out(vty
, "Peer Authentication Enabled\n");
14260 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14261 p
->t_read
? "on" : "off",
14262 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14267 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14268 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14269 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14272 vty_out(vty
, "\n");
14274 /* BFD information. */
14276 bgp_bfd_show_info(vty
, p
, json_neigh
);
14279 if (p
->conf_if
) /* Configured interface name. */
14280 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14281 else /* Configured IP address. */
14282 json_object_object_add(json
, p
->host
, json_neigh
);
14286 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14287 enum show_type type
,
14288 union sockunion
*su
,
14289 const char *conf_if
, afi_t afi
,
14292 struct listnode
*node
, *nnode
;
14295 safi_t safi
= SAFI_UNICAST
;
14296 json_object
*json
= NULL
;
14297 json_object
*json_neighbor
= NULL
;
14300 json
= json_object_new_object();
14301 json_neighbor
= json_object_new_object();
14304 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14306 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14309 if ((peer
->afc
[afi
][safi
]) == 0)
14312 if (type
== show_all
) {
14313 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14317 json_object_object_add(json
, peer
->host
,
14319 json_neighbor
= NULL
;
14322 } else if (type
== show_peer
) {
14325 && !strcmp(peer
->conf_if
, conf_if
))
14327 && !strcmp(peer
->hostname
, conf_if
))) {
14329 bgp_show_peer_gr_status(vty
, peer
,
14334 if (sockunion_same(&peer
->su
, su
)) {
14336 bgp_show_peer_gr_status(vty
, peer
,
14341 if (use_json
&& find
)
14342 json_object_object_add(json
, peer
->host
,
14347 json_neighbor
= NULL
;
14352 if (type
== show_peer
&& !find
) {
14354 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14356 vty_out(vty
, "%% No such neighbor\n");
14360 json_object_free(json_neighbor
);
14361 vty_json(vty
, json
);
14363 vty_out(vty
, "\n");
14366 return CMD_SUCCESS
;
14369 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14370 enum show_type type
, union sockunion
*su
,
14371 const char *conf_if
, bool use_json
,
14374 struct listnode
*node
, *nnode
;
14377 bool nbr_output
= false;
14378 afi_t afi
= AFI_MAX
;
14379 safi_t safi
= SAFI_MAX
;
14381 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14383 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14387 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14388 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14393 bgp_show_peer(vty
, peer
, use_json
, json
);
14399 && !strcmp(peer
->conf_if
, conf_if
))
14401 && !strcmp(peer
->hostname
, conf_if
))) {
14403 bgp_show_peer(vty
, peer
, use_json
,
14407 if (sockunion_same(&peer
->su
, su
)) {
14409 bgp_show_peer(vty
, peer
, use_json
,
14414 case show_ipv4_peer
:
14415 case show_ipv6_peer
:
14416 FOREACH_SAFI (safi
) {
14417 if (peer
->afc
[afi
][safi
]) {
14420 && !strcmp(peer
->conf_if
, conf_if
))
14422 && !strcmp(peer
->hostname
, conf_if
))) {
14424 bgp_show_peer(vty
, peer
, use_json
,
14429 if (sockunion_same(&peer
->su
, su
)) {
14431 bgp_show_peer(vty
, peer
, use_json
,
14439 case show_ipv4_all
:
14440 case show_ipv6_all
:
14441 FOREACH_SAFI (safi
) {
14442 if (peer
->afc
[afi
][safi
]) {
14443 bgp_show_peer(vty
, peer
, use_json
, json
);
14452 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14453 type
== show_ipv6_peer
) && !find
) {
14455 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14457 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14460 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14461 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14462 vty_out(vty
, "%% No BGP neighbors found\n");
14465 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14466 json
, JSON_C_TO_STRING_PRETTY
));
14468 vty_out(vty
, "\n");
14471 return CMD_SUCCESS
;
14474 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14475 enum show_type type
,
14476 const char *ip_str
,
14477 afi_t afi
, bool use_json
)
14482 union sockunion su
;
14484 bgp
= bgp_get_default();
14490 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14494 ret
= str2sockunion(ip_str
, &su
);
14496 bgp_show_neighbor_graceful_restart(
14497 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14499 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14500 NULL
, afi
, use_json
);
14502 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14506 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14507 enum show_type type
,
14508 const char *ip_str
,
14511 struct listnode
*node
, *nnode
;
14513 union sockunion su
;
14514 json_object
*json
= NULL
;
14515 int ret
, is_first
= 1;
14516 bool nbr_output
= false;
14519 vty_out(vty
, "{\n");
14521 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14524 if (!(json
= json_object_new_object())) {
14526 EC_BGP_JSON_MEM_ERROR
,
14527 "Unable to allocate memory for JSON object");
14529 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14533 json_object_int_add(json
, "vrfId",
14534 (bgp
->vrf_id
== VRF_UNKNOWN
)
14536 : (int64_t)bgp
->vrf_id
);
14537 json_object_string_add(
14539 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14544 vty_out(vty
, ",\n");
14548 vty_out(vty
, "\"%s\":",
14549 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14553 vty_out(vty
, "\nInstance %s:\n",
14554 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14559 if (type
== show_peer
|| type
== show_ipv4_peer
||
14560 type
== show_ipv6_peer
) {
14561 ret
= str2sockunion(ip_str
, &su
);
14563 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14566 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14569 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14572 json_object_free(json
);
14577 vty_out(vty
, "}\n");
14578 else if (!nbr_output
)
14579 vty_out(vty
, "%% BGP instance not found\n");
14582 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14583 enum show_type type
, const char *ip_str
,
14588 union sockunion su
;
14589 json_object
*json
= NULL
;
14592 if (strmatch(name
, "all")) {
14593 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14595 return CMD_SUCCESS
;
14597 bgp
= bgp_lookup_by_name(name
);
14600 json
= json_object_new_object();
14601 vty_json(vty
, json
);
14604 "%% BGP instance not found\n");
14606 return CMD_WARNING
;
14610 bgp
= bgp_get_default();
14614 json
= json_object_new_object();
14616 ret
= str2sockunion(ip_str
, &su
);
14618 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14621 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14624 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14627 json_object_free(json
);
14630 vty_out(vty
, "{}\n");
14632 vty_out(vty
, "%% BGP instance not found\n");
14635 return CMD_SUCCESS
;
14640 /* "show [ip] bgp neighbors graceful-restart" commands. */
14641 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14642 show_ip_bgp_neighbors_graceful_restart_cmd
,
14643 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14649 "Neighbor to display information about\n"
14650 "Neighbor to display information about\n"
14651 "Neighbor on BGP configured interface\n"
14655 char *sh_arg
= NULL
;
14656 enum show_type sh_type
;
14658 afi_t afi
= AFI_MAX
;
14659 bool uj
= use_json(argc
, argv
);
14661 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14666 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14667 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14668 || argv_find(argv
, argc
, "WORD", &idx
)) {
14669 sh_type
= show_peer
;
14670 sh_arg
= argv
[idx
]->arg
;
14672 sh_type
= show_all
;
14674 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14675 return CMD_SUCCESS
;
14678 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14682 /* "show [ip] bgp neighbors" commands. */
14683 DEFUN (show_ip_bgp_neighbors
,
14684 show_ip_bgp_neighbors_cmd
,
14685 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14689 BGP_INSTANCE_HELP_STR
14692 "Detailed information on TCP and BGP neighbor connections\n"
14693 "Neighbor to display information about\n"
14694 "Neighbor to display information about\n"
14695 "Neighbor on BGP configured interface\n"
14699 char *sh_arg
= NULL
;
14700 enum show_type sh_type
;
14701 afi_t afi
= AFI_MAX
;
14703 bool uj
= use_json(argc
, argv
);
14707 /* [<vrf> VIEWVRFNAME] */
14708 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14709 vrf
= argv
[idx
+ 1]->arg
;
14710 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14712 } else if (argv_find(argv
, argc
, "view", &idx
))
14713 /* [<view> VIEWVRFNAME] */
14714 vrf
= argv
[idx
+ 1]->arg
;
14718 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14719 sh_type
= show_ipv4_all
;
14721 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14722 sh_type
= show_ipv6_all
;
14725 sh_type
= show_all
;
14728 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14729 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14730 || argv_find(argv
, argc
, "WORD", &idx
)) {
14731 sh_type
= show_peer
;
14732 sh_arg
= argv
[idx
]->arg
;
14735 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14736 sh_type
= show_ipv4_peer
;
14737 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14738 sh_type
= show_ipv6_peer
;
14741 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14744 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14745 paths' and `show ip mbgp paths'. Those functions results are the
14747 DEFUN (show_ip_bgp_paths
,
14748 show_ip_bgp_paths_cmd
,
14749 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14754 "Path information\n")
14756 vty_out(vty
, "Address Refcnt Path\n");
14757 aspath_print_all_vty(vty
);
14758 return CMD_SUCCESS
;
14763 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14766 struct community
*com
;
14768 com
= (struct community
*)bucket
->data
;
14769 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14770 community_str(com
, false, false));
14773 /* Show BGP's community internal data. */
14774 DEFUN (show_ip_bgp_community_info
,
14775 show_ip_bgp_community_info_cmd
,
14776 "show [ip] bgp community-info",
14780 "List all bgp community information\n")
14782 vty_out(vty
, "Address Refcnt Community\n");
14784 hash_iterate(community_hash(),
14785 (void (*)(struct hash_bucket
*,
14786 void *))community_show_all_iterator
,
14789 return CMD_SUCCESS
;
14792 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14795 struct lcommunity
*lcom
;
14797 lcom
= (struct lcommunity
*)bucket
->data
;
14798 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14799 lcommunity_str(lcom
, false, false));
14802 /* Show BGP's community internal data. */
14803 DEFUN (show_ip_bgp_lcommunity_info
,
14804 show_ip_bgp_lcommunity_info_cmd
,
14805 "show ip bgp large-community-info",
14809 "List all bgp large-community information\n")
14811 vty_out(vty
, "Address Refcnt Large-community\n");
14813 hash_iterate(lcommunity_hash(),
14814 (void (*)(struct hash_bucket
*,
14815 void *))lcommunity_show_all_iterator
,
14818 return CMD_SUCCESS
;
14820 /* Graceful Restart */
14822 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14829 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14831 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14833 switch (bgp_global_gr_mode
) {
14835 case GLOBAL_HELPER
:
14836 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14840 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14843 case GLOBAL_DISABLE
:
14844 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14847 case GLOBAL_INVALID
:
14849 "Global BGP GR Mode Invalid\n");
14852 vty_out(vty
, "\n");
14855 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14856 enum show_type type
,
14857 const char *ip_str
,
14858 afi_t afi
, bool use_json
)
14860 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14863 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14865 bgp_show_neighbor_graceful_restart_vty(
14866 vty
, type
, ip_str
, afi
, use_json
);
14869 } else if (afi
!= AFI_MAX
) {
14870 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14873 return CMD_ERR_INCOMPLETE
;
14876 return CMD_SUCCESS
;
14878 /* Graceful Restart */
14880 DEFUN (show_ip_bgp_attr_info
,
14881 show_ip_bgp_attr_info_cmd
,
14882 "show [ip] bgp attribute-info",
14886 "List all bgp attribute information\n")
14888 attr_show_all(vty
);
14889 return CMD_SUCCESS
;
14892 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14893 afi_t afi
, safi_t safi
,
14894 bool use_json
, json_object
*json
)
14897 struct listnode
*node
;
14899 char buf1
[INET6_ADDRSTRLEN
];
14901 enum vpn_policy_direction dir
;
14904 json_object
*json_import_vrfs
= NULL
;
14905 json_object
*json_export_vrfs
= NULL
;
14907 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14910 vty_json(vty
, json
);
14912 return CMD_WARNING
;
14915 /* Provide context for the block */
14916 json_object_string_add(json
, "vrf", name
? name
: "default");
14917 json_object_string_add(json
, "afiSafi",
14918 get_afi_safi_str(afi
, safi
, true));
14920 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14921 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14922 json_object_string_add(json
, "importFromVrfs", "none");
14923 json_object_string_add(json
, "importRts", "none");
14925 json_import_vrfs
= json_object_new_array();
14927 for (ALL_LIST_ELEMENTS_RO(
14928 bgp
->vpn_policy
[afi
].import_vrf
,
14930 json_object_array_add(json_import_vrfs
,
14931 json_object_new_string(vname
));
14933 json_object_object_add(json
, "importFromVrfs",
14935 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14936 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14937 ecom_str
= ecommunity_ecom2str(
14938 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14939 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14940 json_object_string_add(json
, "importRts",
14942 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14944 json_object_string_add(json
, "importRts",
14948 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14949 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14950 json_object_string_add(json
, "exportToVrfs", "none");
14951 json_object_string_add(json
, "routeDistinguisher",
14953 json_object_string_add(json
, "exportRts", "none");
14955 json_export_vrfs
= json_object_new_array();
14957 for (ALL_LIST_ELEMENTS_RO(
14958 bgp
->vpn_policy
[afi
].export_vrf
,
14960 json_object_array_add(json_export_vrfs
,
14961 json_object_new_string(vname
));
14962 json_object_object_add(json
, "exportToVrfs",
14964 json_object_string_add(json
, "routeDistinguisher",
14965 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14966 buf1
, RD_ADDRSTRLEN
));
14968 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14969 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14970 ecom_str
= ecommunity_ecom2str(
14971 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14972 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14973 json_object_string_add(json
, "exportRts",
14975 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14977 json_object_string_add(json
, "exportRts",
14982 vty_json(vty
, json
);
14985 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14988 vty_out(vty
, "%% No such BGP instance exist\n");
14989 return CMD_WARNING
;
14992 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14993 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14995 "This VRF is not importing %s routes from any other VRF\n",
14996 get_afi_safi_str(afi
, safi
, false));
14999 "This VRF is importing %s routes from the following VRFs:\n",
15000 get_afi_safi_str(afi
, safi
, false));
15002 for (ALL_LIST_ELEMENTS_RO(
15003 bgp
->vpn_policy
[afi
].import_vrf
,
15005 vty_out(vty
, " %s\n", vname
);
15007 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15009 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15010 ecom_str
= ecommunity_ecom2str(
15011 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15012 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15013 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15015 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15017 vty_out(vty
, "Import RT(s):\n");
15020 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15021 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15023 "This VRF is not exporting %s routes to any other VRF\n",
15024 get_afi_safi_str(afi
, safi
, false));
15027 "This VRF is exporting %s routes to the following VRFs:\n",
15028 get_afi_safi_str(afi
, safi
, false));
15030 for (ALL_LIST_ELEMENTS_RO(
15031 bgp
->vpn_policy
[afi
].export_vrf
,
15033 vty_out(vty
, " %s\n", vname
);
15035 vty_out(vty
, "RD: %s\n",
15036 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15037 buf1
, RD_ADDRSTRLEN
));
15039 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15040 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15041 ecom_str
= ecommunity_ecom2str(
15042 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15043 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15044 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15045 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15047 vty_out(vty
, "Import RT(s):\n");
15051 return CMD_SUCCESS
;
15054 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15055 safi_t safi
, bool use_json
)
15057 struct listnode
*node
, *nnode
;
15059 char *vrf_name
= NULL
;
15060 json_object
*json
= NULL
;
15061 json_object
*json_vrf
= NULL
;
15062 json_object
*json_vrfs
= NULL
;
15065 json
= json_object_new_object();
15066 json_vrfs
= json_object_new_object();
15069 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15071 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15072 vrf_name
= bgp
->name
;
15075 json_vrf
= json_object_new_object();
15077 vty_out(vty
, "\nInstance %s:\n",
15078 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15079 ? VRF_DEFAULT_NAME
: bgp
->name
);
15081 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15083 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15084 json_object_object_add(json_vrfs
,
15085 VRF_DEFAULT_NAME
, json_vrf
);
15087 json_object_object_add(json_vrfs
, vrf_name
,
15093 json_object_object_add(json
, "vrfs", json_vrfs
);
15094 vty_json(vty
, json
);
15097 return CMD_SUCCESS
;
15100 /* "show [ip] bgp route-leak" command. */
15101 DEFUN (show_ip_bgp_route_leak
,
15102 show_ip_bgp_route_leak_cmd
,
15103 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15107 BGP_INSTANCE_HELP_STR
15110 "Route leaking information\n"
15114 afi_t afi
= AFI_MAX
;
15115 safi_t safi
= SAFI_MAX
;
15117 bool uj
= use_json(argc
, argv
);
15119 json_object
*json
= NULL
;
15121 /* show [ip] bgp */
15122 if (argv_find(argv
, argc
, "ip", &idx
)) {
15124 safi
= SAFI_UNICAST
;
15126 /* [vrf VIEWVRFNAME] */
15127 if (argv_find(argv
, argc
, "view", &idx
)) {
15129 "%% This command is not applicable to BGP views\n");
15130 return CMD_WARNING
;
15133 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15134 vrf
= argv
[idx
+ 1]->arg
;
15135 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15138 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15139 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15140 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15142 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15144 "%% This command is applicable only for unicast ipv4|ipv6\n");
15145 return CMD_WARNING
;
15148 if (vrf
&& strmatch(vrf
, "all"))
15149 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15152 json
= json_object_new_object();
15154 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15157 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15160 struct listnode
*node
, *nnode
;
15163 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15164 vty_out(vty
, "\nInstance %s:\n",
15165 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15168 update_group_show(bgp
, afi
, safi
, vty
, 0);
15172 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15173 int safi
, uint64_t subgrp_id
)
15178 if (strmatch(name
, "all")) {
15179 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15180 return CMD_SUCCESS
;
15182 bgp
= bgp_lookup_by_name(name
);
15185 bgp
= bgp_get_default();
15189 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15190 return CMD_SUCCESS
;
15193 DEFUN (show_ip_bgp_updgrps
,
15194 show_ip_bgp_updgrps_cmd
,
15195 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15199 BGP_INSTANCE_HELP_STR
15201 BGP_SAFI_WITH_LABEL_HELP_STR
15202 "Detailed info about dynamic update groups\n"
15203 "Specific subgroup to display detailed info for\n")
15206 afi_t afi
= AFI_IP6
;
15207 safi_t safi
= SAFI_UNICAST
;
15208 uint64_t subgrp_id
= 0;
15212 /* show [ip] bgp */
15213 if (argv_find(argv
, argc
, "ip", &idx
))
15215 /* [<vrf> VIEWVRFNAME] */
15216 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15217 vrf
= argv
[idx
+ 1]->arg
;
15218 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15220 } else if (argv_find(argv
, argc
, "view", &idx
))
15221 /* [<view> VIEWVRFNAME] */
15222 vrf
= argv
[idx
+ 1]->arg
;
15223 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15224 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15225 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15228 /* get subgroup id, if provided */
15230 if (argv
[idx
]->type
== VARIABLE_TKN
)
15231 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15233 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15236 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15237 show_bgp_instance_all_ipv6_updgrps_cmd
,
15238 "show [ip] bgp <view|vrf> all update-groups",
15242 BGP_INSTANCE_ALL_HELP_STR
15243 "Detailed info about dynamic update groups\n")
15245 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15246 return CMD_SUCCESS
;
15249 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15250 show_bgp_l2vpn_evpn_updgrps_cmd
,
15251 "show [ip] bgp l2vpn evpn update-groups",
15255 "l2vpn address family\n"
15256 "evpn sub-address family\n"
15257 "Detailed info about dynamic update groups\n")
15260 uint64_t subgrp_id
= 0;
15262 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15263 return CMD_SUCCESS
;
15266 DEFUN (show_bgp_updgrps_stats
,
15267 show_bgp_updgrps_stats_cmd
,
15268 "show [ip] bgp update-groups statistics",
15272 "Detailed info about dynamic update groups\n"
15277 bgp
= bgp_get_default();
15279 update_group_show_stats(bgp
, vty
);
15281 return CMD_SUCCESS
;
15284 DEFUN (show_bgp_instance_updgrps_stats
,
15285 show_bgp_instance_updgrps_stats_cmd
,
15286 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15290 BGP_INSTANCE_HELP_STR
15291 "Detailed info about dynamic update groups\n"
15297 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15299 update_group_show_stats(bgp
, vty
);
15301 return CMD_SUCCESS
;
15304 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15305 afi_t afi
, safi_t safi
,
15306 const char *what
, uint64_t subgrp_id
)
15311 bgp
= bgp_lookup_by_name(name
);
15313 bgp
= bgp_get_default();
15316 if (!strcmp(what
, "advertise-queue"))
15317 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15319 else if (!strcmp(what
, "advertised-routes"))
15320 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15322 else if (!strcmp(what
, "packet-queue"))
15323 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15328 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15329 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15330 "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",
15331 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15333 "Detailed info about dynamic update groups\n"
15334 "Specific subgroup to display info for\n"
15335 "Advertisement queue\n"
15336 "Announced routes\n"
15339 uint64_t subgrp_id
= 0;
15343 subgrp_id
= strtoull(sgid
, NULL
, 10);
15348 afiz
= bgp_vty_afi_from_str(afi
);
15352 afiz
= bgp_vty_afi_from_str(afi
);
15353 if (afiz
!= AFI_IP
)
15355 "%% Cannot specify both 'ip' and 'ipv6'\n");
15356 return CMD_WARNING
;
15359 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15361 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15362 return CMD_SUCCESS
;
15365 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15368 struct listnode
*node
, *nnode
;
15369 struct prefix
*range
;
15374 const char *peer_status
;
15378 json_object
*json_peer_group
= NULL
;
15379 json_object
*json_peer_group_afc
= NULL
;
15380 json_object
*json_peer_group_members
= NULL
;
15381 json_object
*json_peer_group_dynamic
= NULL
;
15382 json_object
*json_peer_group_dynamic_af
= NULL
;
15383 json_object
*json_peer_group_ranges
= NULL
;
15385 conf
= group
->conf
;
15388 json_peer_group
= json_object_new_object();
15389 json_peer_group_afc
= json_object_new_array();
15392 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15394 json_object_int_add(json_peer_group
, "remoteAs",
15397 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15398 group
->name
, conf
->as
);
15399 } else if (conf
->as_type
== AS_INTERNAL
) {
15401 json_object_int_add(json_peer_group
, "remoteAs",
15404 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15405 group
->name
, group
->bgp
->as
);
15408 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15411 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15413 json_object_string_add(json_peer_group
, "type",
15416 vty_out(vty
, " Peer-group type is internal\n");
15419 json_object_string_add(json_peer_group
, "type",
15422 vty_out(vty
, " Peer-group type is external\n");
15425 /* Display AFs configured. */
15427 vty_out(vty
, " Configured address-families:");
15429 FOREACH_AFI_SAFI (afi
, safi
) {
15430 if (conf
->afc
[afi
][safi
]) {
15433 json_object_array_add(
15434 json_peer_group_afc
,
15435 json_object_new_string(get_afi_safi_str(
15436 afi
, safi
, false)));
15438 vty_out(vty
, " %s;",
15439 get_afi_safi_str(afi
, safi
, false));
15444 json_object_object_add(json_peer_group
,
15445 "addressFamiliesConfigured",
15446 json_peer_group_afc
);
15449 vty_out(vty
, " none\n");
15451 vty_out(vty
, "\n");
15454 /* Display listen ranges (for dynamic neighbors), if any */
15455 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15456 lr_count
= listcount(group
->listen_range
[afi
]);
15459 if (!json_peer_group_dynamic
)
15460 json_peer_group_dynamic
=
15461 json_object_new_object();
15463 json_peer_group_dynamic_af
=
15464 json_object_new_object();
15465 json_peer_group_ranges
=
15466 json_object_new_array();
15467 json_object_int_add(json_peer_group_dynamic_af
,
15468 "count", lr_count
);
15470 vty_out(vty
, " %d %s listen range(s)\n",
15471 lr_count
, afi2str(afi
));
15474 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15479 snprintfrr(buf
, sizeof(buf
), "%pFX",
15482 json_object_array_add(
15483 json_peer_group_ranges
,
15484 json_object_new_string(buf
));
15486 vty_out(vty
, " %pFX\n", range
);
15491 json_object_object_add(
15492 json_peer_group_dynamic_af
, "ranges",
15493 json_peer_group_ranges
);
15495 json_object_object_add(
15496 json_peer_group_dynamic
, afi2str(afi
),
15497 json_peer_group_dynamic_af
);
15502 if (json_peer_group_dynamic
)
15503 json_object_object_add(json_peer_group
, "dynamicRanges",
15504 json_peer_group_dynamic
);
15506 /* Display group members and their status */
15507 if (listcount(group
->peer
)) {
15509 json_peer_group_members
= json_object_new_object();
15511 vty_out(vty
, " Peer-group members:\n");
15512 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15513 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15514 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15515 peer_status
= "Idle (Admin)";
15516 else if (CHECK_FLAG(peer
->sflags
,
15517 PEER_STATUS_PREFIX_OVERFLOW
))
15518 peer_status
= "Idle (PfxCt)";
15520 peer_status
= lookup_msg(bgp_status_msg
,
15521 peer
->status
, NULL
);
15523 dynamic
= peer_dynamic_neighbor(peer
);
15526 json_object
*json_peer_group_member
=
15527 json_object_new_object();
15529 json_object_string_add(json_peer_group_member
,
15530 "status", peer_status
);
15533 json_object_boolean_true_add(
15534 json_peer_group_member
,
15537 json_object_object_add(json_peer_group_members
,
15539 json_peer_group_member
);
15541 vty_out(vty
, " %s %s %s \n", peer
->host
,
15542 dynamic
? "(dynamic)" : "",
15547 json_object_object_add(json_peer_group
, "members",
15548 json_peer_group_members
);
15552 json_object_object_add(json
, group
->name
, json_peer_group
);
15554 return CMD_SUCCESS
;
15557 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15558 const char *group_name
, bool uj
)
15561 struct listnode
*node
, *nnode
;
15562 struct peer_group
*group
;
15563 bool found
= false;
15564 json_object
*json
= NULL
;
15567 json
= json_object_new_object();
15569 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15573 vty_json(vty
, json
);
15575 vty_out(vty
, "%% BGP instance not found\n");
15577 return CMD_WARNING
;
15580 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15582 if (strmatch(group
->name
, group_name
)) {
15583 bgp_show_one_peer_group(vty
, group
, json
);
15588 bgp_show_one_peer_group(vty
, group
, json
);
15592 if (group_name
&& !found
&& !uj
)
15593 vty_out(vty
, "%% No such peer-group\n");
15596 vty_json(vty
, json
);
15598 return CMD_SUCCESS
;
15601 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15602 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15603 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15604 "Detailed information on BGP peer groups\n"
15605 "Peer group name\n" JSON_STR
)
15609 bool uj
= use_json(argc
, argv
);
15611 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15613 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15615 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15619 /* Redistribute VTY commands. */
15621 DEFUN (bgp_redistribute_ipv4
,
15622 bgp_redistribute_ipv4_cmd
,
15623 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15624 "Redistribute information from another routing protocol\n"
15625 FRR_IP_REDIST_HELP_STR_BGPD
)
15627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15628 int idx_protocol
= 1;
15631 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15633 vty_out(vty
, "%% Invalid route type\n");
15634 return CMD_WARNING_CONFIG_FAILED
;
15637 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15638 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15642 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15643 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15644 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15646 DEFUN (bgp_redistribute_ipv4_rmap
,
15647 bgp_redistribute_ipv4_rmap_cmd
,
15648 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15649 "Redistribute information from another routing protocol\n"
15650 FRR_IP_REDIST_HELP_STR_BGPD
15651 "Route map reference\n"
15652 "Pointer to route-map entries\n")
15654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15655 int idx_protocol
= 1;
15658 struct bgp_redist
*red
;
15660 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15661 vty
, argv
[idx_word
]->arg
);
15663 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15665 vty_out(vty
, "%% Invalid route type\n");
15666 return CMD_WARNING_CONFIG_FAILED
;
15669 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15671 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15672 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15676 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15677 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15678 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15679 "Route map reference\n"
15680 "Pointer to route-map entries\n")
15682 DEFUN (bgp_redistribute_ipv4_metric
,
15683 bgp_redistribute_ipv4_metric_cmd
,
15684 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15685 "Redistribute information from another routing protocol\n"
15686 FRR_IP_REDIST_HELP_STR_BGPD
15687 "Metric for redistributed routes\n"
15688 "Default metric\n")
15690 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15691 int idx_protocol
= 1;
15692 int idx_number
= 3;
15695 struct bgp_redist
*red
;
15698 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15700 vty_out(vty
, "%% Invalid route type\n");
15701 return CMD_WARNING_CONFIG_FAILED
;
15703 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15705 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15706 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15707 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15711 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15712 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15713 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15714 "Metric for redistributed routes\n"
15715 "Default metric\n")
15717 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15718 bgp_redistribute_ipv4_rmap_metric_cmd
,
15719 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15720 "Redistribute information from another routing protocol\n"
15721 FRR_IP_REDIST_HELP_STR_BGPD
15722 "Route map reference\n"
15723 "Pointer to route-map entries\n"
15724 "Metric for redistributed routes\n"
15725 "Default metric\n")
15727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15728 int idx_protocol
= 1;
15730 int idx_number
= 5;
15733 struct bgp_redist
*red
;
15735 struct route_map
*route_map
=
15736 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15738 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15740 vty_out(vty
, "%% Invalid route type\n");
15741 return CMD_WARNING_CONFIG_FAILED
;
15743 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15745 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15747 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15748 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15749 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15753 bgp_redistribute_ipv4_rmap_metric
,
15754 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15755 "redistribute " FRR_IP_REDIST_STR_BGPD
15756 " route-map RMAP_NAME metric (0-4294967295)",
15757 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15758 "Route map reference\n"
15759 "Pointer to route-map entries\n"
15760 "Metric for redistributed routes\n"
15761 "Default metric\n")
15763 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15764 bgp_redistribute_ipv4_metric_rmap_cmd
,
15765 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15766 "Redistribute information from another routing protocol\n"
15767 FRR_IP_REDIST_HELP_STR_BGPD
15768 "Metric for redistributed routes\n"
15770 "Route map reference\n"
15771 "Pointer to route-map entries\n")
15773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15774 int idx_protocol
= 1;
15775 int idx_number
= 3;
15779 struct bgp_redist
*red
;
15781 struct route_map
*route_map
=
15782 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15784 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15786 vty_out(vty
, "%% Invalid route type\n");
15787 return CMD_WARNING_CONFIG_FAILED
;
15789 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15791 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15792 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15794 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15795 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15799 bgp_redistribute_ipv4_metric_rmap
,
15800 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15801 "redistribute " FRR_IP_REDIST_STR_BGPD
15802 " metric (0-4294967295) route-map RMAP_NAME",
15803 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15804 "Metric for redistributed routes\n"
15806 "Route map reference\n"
15807 "Pointer to route-map entries\n")
15809 DEFUN (bgp_redistribute_ipv4_ospf
,
15810 bgp_redistribute_ipv4_ospf_cmd
,
15811 "redistribute <ospf|table> (1-65535)",
15812 "Redistribute information from another routing protocol\n"
15813 "Open Shortest Path First (OSPFv2)\n"
15814 "Non-main Kernel Routing Table\n"
15815 "Instance ID/Table ID\n")
15817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15818 int idx_ospf_table
= 1;
15819 int idx_number
= 2;
15820 unsigned short instance
;
15821 unsigned short protocol
;
15823 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15825 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15826 protocol
= ZEBRA_ROUTE_OSPF
;
15828 protocol
= ZEBRA_ROUTE_TABLE
;
15830 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15831 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15834 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15835 "redistribute <ospf|table> (1-65535)",
15836 "Redistribute information from another routing protocol\n"
15837 "Open Shortest Path First (OSPFv2)\n"
15838 "Non-main Kernel Routing Table\n"
15839 "Instance ID/Table ID\n")
15841 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15842 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15843 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15844 "Redistribute information from another routing protocol\n"
15845 "Open Shortest Path First (OSPFv2)\n"
15846 "Non-main Kernel Routing Table\n"
15847 "Instance ID/Table ID\n"
15848 "Route map reference\n"
15849 "Pointer to route-map entries\n")
15851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15852 int idx_ospf_table
= 1;
15853 int idx_number
= 2;
15855 struct bgp_redist
*red
;
15856 unsigned short instance
;
15859 struct route_map
*route_map
=
15860 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15862 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15863 protocol
= ZEBRA_ROUTE_OSPF
;
15865 protocol
= ZEBRA_ROUTE_TABLE
;
15867 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15868 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15870 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15871 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15874 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15875 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15876 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15877 "Redistribute information from another routing protocol\n"
15878 "Open Shortest Path First (OSPFv2)\n"
15879 "Non-main Kernel Routing Table\n"
15880 "Instance ID/Table ID\n"
15881 "Route map reference\n"
15882 "Pointer to route-map entries\n")
15884 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15885 bgp_redistribute_ipv4_ospf_metric_cmd
,
15886 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15887 "Redistribute information from another routing protocol\n"
15888 "Open Shortest Path First (OSPFv2)\n"
15889 "Non-main Kernel Routing Table\n"
15890 "Instance ID/Table ID\n"
15891 "Metric for redistributed routes\n"
15892 "Default metric\n")
15894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15895 int idx_ospf_table
= 1;
15896 int idx_number
= 2;
15897 int idx_number_2
= 4;
15899 struct bgp_redist
*red
;
15900 unsigned short instance
;
15904 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15905 protocol
= ZEBRA_ROUTE_OSPF
;
15907 protocol
= ZEBRA_ROUTE_TABLE
;
15909 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15910 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15912 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15913 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15915 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15918 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15919 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15920 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15921 "Redistribute information from another routing protocol\n"
15922 "Open Shortest Path First (OSPFv2)\n"
15923 "Non-main Kernel Routing Table\n"
15924 "Instance ID/Table ID\n"
15925 "Metric for redistributed routes\n"
15926 "Default metric\n")
15928 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15929 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15930 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15931 "Redistribute information from another routing protocol\n"
15932 "Open Shortest Path First (OSPFv2)\n"
15933 "Non-main Kernel Routing Table\n"
15934 "Instance ID/Table ID\n"
15935 "Route map reference\n"
15936 "Pointer to route-map entries\n"
15937 "Metric for redistributed routes\n"
15938 "Default metric\n")
15940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15941 int idx_ospf_table
= 1;
15942 int idx_number
= 2;
15944 int idx_number_2
= 6;
15946 struct bgp_redist
*red
;
15947 unsigned short instance
;
15950 struct route_map
*route_map
=
15951 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15953 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15954 protocol
= ZEBRA_ROUTE_OSPF
;
15956 protocol
= ZEBRA_ROUTE_TABLE
;
15958 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15959 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15961 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15963 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15964 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15966 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15970 bgp_redistribute_ipv4_ospf_rmap_metric
,
15971 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15972 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15973 "Redistribute information from another routing protocol\n"
15974 "Open Shortest Path First (OSPFv2)\n"
15975 "Non-main Kernel Routing Table\n"
15976 "Instance ID/Table ID\n"
15977 "Route map reference\n"
15978 "Pointer to route-map entries\n"
15979 "Metric for redistributed routes\n"
15980 "Default metric\n")
15982 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15983 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15984 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
15985 "Redistribute information from another routing protocol\n"
15986 "Open Shortest Path First (OSPFv2)\n"
15987 "Non-main Kernel Routing Table\n"
15988 "Instance ID/Table ID\n"
15989 "Metric for redistributed routes\n"
15991 "Route map reference\n"
15992 "Pointer to route-map entries\n")
15994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15995 int idx_ospf_table
= 1;
15996 int idx_number
= 2;
15997 int idx_number_2
= 4;
16000 struct bgp_redist
*red
;
16001 unsigned short instance
;
16004 struct route_map
*route_map
=
16005 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16007 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16008 protocol
= ZEBRA_ROUTE_OSPF
;
16010 protocol
= ZEBRA_ROUTE_TABLE
;
16012 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16013 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16015 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16016 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16019 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16020 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16024 bgp_redistribute_ipv4_ospf_metric_rmap
,
16025 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16026 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16027 "Redistribute information from another routing protocol\n"
16028 "Open Shortest Path First (OSPFv2)\n"
16029 "Non-main Kernel Routing Table\n"
16030 "Instance ID/Table ID\n"
16031 "Metric for redistributed routes\n"
16033 "Route map reference\n"
16034 "Pointer to route-map entries\n")
16036 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16037 no_bgp_redistribute_ipv4_ospf_cmd
,
16038 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16040 "Redistribute information from another routing protocol\n"
16041 "Open Shortest Path First (OSPFv2)\n"
16042 "Non-main Kernel Routing Table\n"
16043 "Instance ID/Table ID\n"
16044 "Metric for redistributed routes\n"
16046 "Route map reference\n"
16047 "Pointer to route-map entries\n")
16049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16050 int idx_ospf_table
= 2;
16051 int idx_number
= 3;
16052 unsigned short instance
;
16055 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16056 protocol
= ZEBRA_ROUTE_OSPF
;
16058 protocol
= ZEBRA_ROUTE_TABLE
;
16060 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16061 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16065 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16066 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16068 "Redistribute information from another routing protocol\n"
16069 "Open Shortest Path First (OSPFv2)\n"
16070 "Non-main Kernel Routing Table\n"
16071 "Instance ID/Table ID\n"
16072 "Metric for redistributed routes\n"
16074 "Route map reference\n"
16075 "Pointer to route-map entries\n")
16077 DEFUN (no_bgp_redistribute_ipv4
,
16078 no_bgp_redistribute_ipv4_cmd
,
16079 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16081 "Redistribute information from another routing protocol\n"
16082 FRR_IP_REDIST_HELP_STR_BGPD
16083 "Metric for redistributed routes\n"
16085 "Route map reference\n"
16086 "Pointer to route-map entries\n")
16088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16089 int idx_protocol
= 2;
16092 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16094 vty_out(vty
, "%% Invalid route type\n");
16095 return CMD_WARNING_CONFIG_FAILED
;
16097 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16101 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16102 "no redistribute " FRR_IP_REDIST_STR_BGPD
16103 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16105 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16106 "Metric for redistributed routes\n"
16108 "Route map reference\n"
16109 "Pointer to route-map entries\n")
16111 DEFUN (bgp_redistribute_ipv6
,
16112 bgp_redistribute_ipv6_cmd
,
16113 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16114 "Redistribute information from another routing protocol\n"
16115 FRR_IP6_REDIST_HELP_STR_BGPD
)
16117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16118 int idx_protocol
= 1;
16121 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16123 vty_out(vty
, "%% Invalid route type\n");
16124 return CMD_WARNING_CONFIG_FAILED
;
16127 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16128 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16131 DEFUN (bgp_redistribute_ipv6_rmap
,
16132 bgp_redistribute_ipv6_rmap_cmd
,
16133 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16134 "Redistribute information from another routing protocol\n"
16135 FRR_IP6_REDIST_HELP_STR_BGPD
16136 "Route map reference\n"
16137 "Pointer to route-map entries\n")
16139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16140 int idx_protocol
= 1;
16143 struct bgp_redist
*red
;
16145 struct route_map
*route_map
=
16146 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16148 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16150 vty_out(vty
, "%% Invalid route type\n");
16151 return CMD_WARNING_CONFIG_FAILED
;
16154 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16156 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16157 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16160 DEFUN (bgp_redistribute_ipv6_metric
,
16161 bgp_redistribute_ipv6_metric_cmd
,
16162 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16163 "Redistribute information from another routing protocol\n"
16164 FRR_IP6_REDIST_HELP_STR_BGPD
16165 "Metric for redistributed routes\n"
16166 "Default metric\n")
16168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16169 int idx_protocol
= 1;
16170 int idx_number
= 3;
16173 struct bgp_redist
*red
;
16176 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16178 vty_out(vty
, "%% Invalid route type\n");
16179 return CMD_WARNING_CONFIG_FAILED
;
16181 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16183 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16184 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16185 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16188 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16189 bgp_redistribute_ipv6_rmap_metric_cmd
,
16190 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16191 "Redistribute information from another routing protocol\n"
16192 FRR_IP6_REDIST_HELP_STR_BGPD
16193 "Route map reference\n"
16194 "Pointer to route-map entries\n"
16195 "Metric for redistributed routes\n"
16196 "Default metric\n")
16198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16199 int idx_protocol
= 1;
16201 int idx_number
= 5;
16204 struct bgp_redist
*red
;
16206 struct route_map
*route_map
=
16207 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16209 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16211 vty_out(vty
, "%% Invalid route type\n");
16212 return CMD_WARNING_CONFIG_FAILED
;
16214 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16216 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16218 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16219 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16221 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16224 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16225 bgp_redistribute_ipv6_metric_rmap_cmd
,
16226 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16227 "Redistribute information from another routing protocol\n"
16228 FRR_IP6_REDIST_HELP_STR_BGPD
16229 "Metric for redistributed routes\n"
16231 "Route map reference\n"
16232 "Pointer to route-map entries\n")
16234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16235 int idx_protocol
= 1;
16236 int idx_number
= 3;
16240 struct bgp_redist
*red
;
16242 struct route_map
*route_map
=
16243 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16245 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16247 vty_out(vty
, "%% Invalid route type\n");
16248 return CMD_WARNING_CONFIG_FAILED
;
16250 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16252 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16253 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16256 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16257 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16260 DEFUN (no_bgp_redistribute_ipv6
,
16261 no_bgp_redistribute_ipv6_cmd
,
16262 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16264 "Redistribute information from another routing protocol\n"
16265 FRR_IP6_REDIST_HELP_STR_BGPD
16266 "Metric for redistributed routes\n"
16268 "Route map reference\n"
16269 "Pointer to route-map entries\n")
16271 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16272 int idx_protocol
= 2;
16275 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16277 vty_out(vty
, "%% Invalid route type\n");
16278 return CMD_WARNING_CONFIG_FAILED
;
16281 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16284 /* Neighbor update tcp-mss. */
16285 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16286 const char *tcp_mss_str
)
16289 uint32_t tcp_mss_val
= 0;
16291 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16293 return CMD_WARNING_CONFIG_FAILED
;
16296 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16297 peer_tcp_mss_set(peer
, tcp_mss_val
);
16299 peer_tcp_mss_unset(peer
);
16302 return CMD_SUCCESS
;
16305 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16306 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16308 "TCP max segment size\n"
16311 int peer_index
= 1;
16315 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16316 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16317 argv
[mss_index
]->arg
);
16320 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16321 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16322 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16323 "TCP max segment size\n"
16326 int peer_index
= 2;
16329 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16330 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16333 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16334 afi_t afi
, safi_t safi
)
16338 /* Unicast redistribution only. */
16339 if (safi
!= SAFI_UNICAST
)
16342 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16343 /* Redistribute BGP does not make sense. */
16344 if (i
!= ZEBRA_ROUTE_BGP
) {
16345 struct list
*red_list
;
16346 struct listnode
*node
;
16347 struct bgp_redist
*red
;
16349 red_list
= bgp
->redist
[afi
][i
];
16353 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16354 /* "redistribute" configuration. */
16355 vty_out(vty
, " redistribute %s",
16356 zebra_route_string(i
));
16358 vty_out(vty
, " %d", red
->instance
);
16359 if (red
->redist_metric_flag
)
16360 vty_out(vty
, " metric %u",
16361 red
->redist_metric
);
16362 if (red
->rmap
.name
)
16363 vty_out(vty
, " route-map %s",
16365 vty_out(vty
, "\n");
16371 /* peer-group helpers for config-write */
16373 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16375 if (!peer_group_active(peer
)) {
16376 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16377 return !CHECK_FLAG(peer
->flags
, flag
);
16379 return !!CHECK_FLAG(peer
->flags
, flag
);
16382 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16385 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16388 if (!peer_group_active(peer
)) {
16389 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16390 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16392 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16395 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16398 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16399 uint8_t type
, int direct
)
16401 struct bgp_filter
*filter
;
16403 if (peer_group_active(peer
))
16404 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16407 filter
= &peer
->filter
[afi
][safi
];
16409 case PEER_FT_DISTRIBUTE_LIST
:
16410 return !!(filter
->dlist
[direct
].name
);
16411 case PEER_FT_FILTER_LIST
:
16412 return !!(filter
->aslist
[direct
].name
);
16413 case PEER_FT_PREFIX_LIST
:
16414 return !!(filter
->plist
[direct
].name
);
16415 case PEER_FT_ROUTE_MAP
:
16416 return !!(filter
->map
[direct
].name
);
16417 case PEER_FT_UNSUPPRESS_MAP
:
16418 return !!(filter
->usmap
.name
);
16419 case PEER_FT_ADVERTISE_MAP
:
16420 return !!(filter
->advmap
.aname
16421 && ((filter
->advmap
.condition
== direct
)
16422 && filter
->advmap
.cname
));
16428 /* Return true if the addpath type is set for peer and different from
16431 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16434 enum bgp_addpath_strat type
, g_type
;
16436 type
= peer
->addpath_type
[afi
][safi
];
16438 if (type
!= BGP_ADDPATH_NONE
) {
16439 if (peer_group_active(peer
)) {
16440 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16442 if (type
!= g_type
)
16454 /* This is part of the address-family block (unicast only) */
16455 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16459 uint32_t tovpn_sid_index
= 0;
16461 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16462 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16463 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16464 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16465 bgp
->vpn_policy
[afi
]
16466 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16468 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16469 bgp
->vpn_policy
[afi
]
16470 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16472 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16473 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16474 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16475 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16478 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16479 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16481 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16484 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16485 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16486 bgp
->vpn_policy
[afi
].tovpn_label
);
16490 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16491 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16492 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16493 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16494 } else if (tovpn_sid_index
!= 0) {
16495 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16499 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16500 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16501 char buf
[RD_ADDRSTRLEN
];
16502 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16503 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16506 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16507 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16509 char buf
[PREFIX_STRLEN
];
16510 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16511 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16514 vty_out(vty
, "%*snexthop vpn export %s\n",
16518 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16519 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16521 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16522 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16524 char *b
= ecommunity_ecom2str(
16525 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16526 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16527 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16528 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16530 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16531 char *b
= ecommunity_ecom2str(
16532 bgp
->vpn_policy
[afi
]
16533 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16534 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16535 ECOMMUNITY_ROUTE_TARGET
);
16536 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16537 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16539 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16540 char *b
= ecommunity_ecom2str(
16541 bgp
->vpn_policy
[afi
]
16542 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16543 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16544 ECOMMUNITY_ROUTE_TARGET
);
16545 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16546 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16550 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16551 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16552 bgp
->vpn_policy
[afi
]
16553 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16555 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16556 char *b
= ecommunity_ecom2str(
16557 bgp
->vpn_policy
[afi
]
16558 .import_redirect_rtlist
,
16559 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16560 ECOMMUNITY_ROUTE_TARGET
);
16562 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16563 != ECOMMUNITY_SIZE
)
16564 vty_out(vty
, "%*srt6 redirect import %s\n",
16567 vty_out(vty
, "%*srt redirect import %s\n",
16569 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16573 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16574 afi_t afi
, safi_t safi
)
16576 struct bgp_filter
*filter
;
16580 filter
= &peer
->filter
[afi
][safi
];
16582 /* distribute-list. */
16583 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16585 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16586 filter
->dlist
[FILTER_IN
].name
);
16588 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16590 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16591 filter
->dlist
[FILTER_OUT
].name
);
16594 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16596 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16597 filter
->plist
[FILTER_IN
].name
);
16599 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16601 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16602 filter
->plist
[FILTER_OUT
].name
);
16605 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16606 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16607 filter
->map
[RMAP_IN
].name
);
16609 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16611 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16612 filter
->map
[RMAP_OUT
].name
);
16614 /* unsuppress-map */
16615 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16616 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16617 filter
->usmap
.name
);
16619 /* advertise-map : always applied in OUT direction*/
16620 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16621 CONDITION_NON_EXIST
))
16623 " neighbor %s advertise-map %s non-exist-map %s\n",
16624 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16626 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16628 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16629 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16632 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16634 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16635 filter
->aslist
[FILTER_IN
].name
);
16637 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16639 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16640 filter
->aslist
[FILTER_OUT
].name
);
16643 /* BGP peer configuration display function. */
16644 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16647 struct peer
*g_peer
= NULL
;
16649 int if_pg_printed
= false;
16650 int if_ras_printed
= false;
16652 /* Skip dynamic neighbors. */
16653 if (peer_dynamic_neighbor(peer
))
16657 addr
= peer
->conf_if
;
16661 /************************************
16662 ****** Global to the neighbor ******
16663 ************************************/
16664 if (peer
->conf_if
) {
16665 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16666 vty_out(vty
, " neighbor %s interface v6only", addr
);
16668 vty_out(vty
, " neighbor %s interface", addr
);
16670 if (peer_group_active(peer
)) {
16671 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16672 if_pg_printed
= true;
16673 } else if (peer
->as_type
== AS_SPECIFIED
) {
16674 vty_out(vty
, " remote-as %u", peer
->as
);
16675 if_ras_printed
= true;
16676 } else if (peer
->as_type
== AS_INTERNAL
) {
16677 vty_out(vty
, " remote-as internal");
16678 if_ras_printed
= true;
16679 } else if (peer
->as_type
== AS_EXTERNAL
) {
16680 vty_out(vty
, " remote-as external");
16681 if_ras_printed
= true;
16684 vty_out(vty
, "\n");
16687 /* remote-as and peer-group */
16688 /* peer is a member of a peer-group */
16689 if (peer_group_active(peer
)) {
16690 g_peer
= peer
->group
->conf
;
16692 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16693 if (peer
->as_type
== AS_SPECIFIED
) {
16694 vty_out(vty
, " neighbor %s remote-as %u\n",
16696 } else if (peer
->as_type
== AS_INTERNAL
) {
16698 " neighbor %s remote-as internal\n",
16700 } else if (peer
->as_type
== AS_EXTERNAL
) {
16702 " neighbor %s remote-as external\n",
16707 /* For swpX peers we displayed the peer-group
16708 * via 'neighbor swpX interface peer-group PGNAME' */
16709 if (!if_pg_printed
)
16710 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16711 peer
->group
->name
);
16714 /* peer is NOT a member of a peer-group */
16716 /* peer is a peer-group, declare the peer-group */
16717 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16718 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16721 if (!if_ras_printed
) {
16722 if (peer
->as_type
== AS_SPECIFIED
) {
16723 vty_out(vty
, " neighbor %s remote-as %u\n",
16725 } else if (peer
->as_type
== AS_INTERNAL
) {
16727 " neighbor %s remote-as internal\n",
16729 } else if (peer
->as_type
== AS_EXTERNAL
) {
16731 " neighbor %s remote-as external\n",
16738 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16739 vty_out(vty
, " neighbor %s local-as %u", addr
,
16740 peer
->change_local_as
);
16741 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16742 vty_out(vty
, " no-prepend");
16743 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16744 vty_out(vty
, " replace-as");
16745 vty_out(vty
, "\n");
16750 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16754 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16755 if (peer
->tx_shutdown_message
)
16756 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16757 peer
->tx_shutdown_message
);
16759 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16762 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16763 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16764 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16767 if (peer
->bfd_config
)
16768 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16771 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16772 vty_out(vty
, " neighbor %s password %s\n", addr
,
16775 /* neighbor solo */
16776 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16777 if (!peer_group_active(peer
)) {
16778 vty_out(vty
, " neighbor %s solo\n", addr
);
16783 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16784 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16787 /* Local interface name */
16788 if (peer
->ifname
) {
16789 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16792 /* TCP max segment size */
16793 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16794 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16797 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16798 vty_out(vty
, " neighbor %s passive\n", addr
);
16800 /* ebgp-multihop */
16801 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16802 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16803 && peer
->ttl
== MAXTTL
)) {
16804 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16805 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16811 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16812 peer
->local_role
!= ROLE_UNDEFINED
)
16813 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16814 bgp_get_name_by_role(peer
->local_role
),
16815 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16819 /* ttl-security hops */
16820 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16821 if (!peer_group_active(peer
)
16822 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16823 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16824 addr
, peer
->gtsm_hops
);
16828 /* disable-connected-check */
16829 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16830 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16832 /* link-bw-encoding-ieee */
16833 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16834 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16837 /* extended-optional-parameters */
16838 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16839 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16842 /* enforce-first-as */
16843 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16844 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16846 /* update-source */
16847 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16848 if (peer
->update_source
)
16849 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16850 peer
->update_source
);
16851 else if (peer
->update_if
)
16852 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16856 /* advertisement-interval */
16857 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16858 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16862 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16863 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16864 peer
->keepalive
, peer
->holdtime
);
16866 /* timers connect */
16867 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16868 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16870 /* need special-case handling for changed default values due to
16871 * config profile / version (because there is no "timers bgp connect"
16872 * command, we need to save this per-peer :/)
16874 else if (!peer_group_active(peer
) && !peer
->connect
&&
16875 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16876 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16877 peer
->bgp
->default_connect_retry
);
16879 /* timers delayopen */
16880 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16881 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16883 /* Save config even though flag is not set if default values have been
16886 else if (!peer_group_active(peer
) && !peer
->delayopen
16887 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16888 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16889 peer
->bgp
->default_delayopen
);
16891 /* capability dynamic */
16892 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16893 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16895 /* capability extended-nexthop */
16896 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16897 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
16900 " no neighbor %s capability extended-nexthop\n",
16902 else if (!peer
->conf_if
)
16904 " neighbor %s capability extended-nexthop\n",
16908 /* dont-capability-negotiation */
16909 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16910 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16912 /* override-capability */
16913 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16914 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16916 /* strict-capability-match */
16917 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16918 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16920 /* Sender side AS path loop detection. */
16921 if (peer
->as_path_loop_detection
)
16922 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16925 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16926 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16928 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16929 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16931 " neighbor %s graceful-restart-helper\n", addr
);
16932 } else if (CHECK_FLAG(
16933 peer
->peer_gr_new_status_flag
,
16934 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16936 " neighbor %s graceful-restart\n", addr
);
16938 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16939 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16941 peer
->peer_gr_new_status_flag
,
16942 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16943 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16949 /* BGP peer configuration display function. */
16950 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16951 struct peer
*peer
, afi_t afi
, safi_t safi
)
16953 struct peer
*g_peer
= NULL
;
16955 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16957 /* Skip dynamic neighbors. */
16958 if (peer_dynamic_neighbor(peer
))
16962 addr
= peer
->conf_if
;
16966 /************************************
16967 ****** Per AF to the neighbor ******
16968 ************************************/
16969 if (peer_group_active(peer
)) {
16970 g_peer
= peer
->group
->conf
;
16972 /* If the peer-group is active but peer is not, print a 'no
16974 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16975 vty_out(vty
, " no neighbor %s activate\n", addr
);
16978 /* If the peer-group is not active but peer is, print an
16980 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16981 vty_out(vty
, " neighbor %s activate\n", addr
);
16984 if (peer
->afc
[afi
][safi
]) {
16985 if (safi
== SAFI_ENCAP
)
16986 vty_out(vty
, " neighbor %s activate\n", addr
);
16987 else if (!bgp
->default_af
[afi
][safi
])
16988 vty_out(vty
, " neighbor %s activate\n", addr
);
16990 if (bgp
->default_af
[afi
][safi
])
16991 vty_out(vty
, " no neighbor %s activate\n",
16996 /* addpath TX knobs */
16997 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16998 switch (peer
->addpath_type
[afi
][safi
]) {
16999 case BGP_ADDPATH_ALL
:
17000 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17003 case BGP_ADDPATH_BEST_PER_AS
:
17005 " neighbor %s addpath-tx-bestpath-per-AS\n",
17008 case BGP_ADDPATH_MAX
:
17009 case BGP_ADDPATH_NONE
:
17014 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17015 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17017 /* ORF capability. */
17018 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17019 || peergroup_af_flag_check(peer
, afi
, safi
,
17020 PEER_FLAG_ORF_PREFIX_RM
)) {
17021 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17023 if (peergroup_af_flag_check(peer
, afi
, safi
,
17024 PEER_FLAG_ORF_PREFIX_SM
)
17025 && peergroup_af_flag_check(peer
, afi
, safi
,
17026 PEER_FLAG_ORF_PREFIX_RM
))
17027 vty_out(vty
, " both");
17028 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17029 PEER_FLAG_ORF_PREFIX_SM
))
17030 vty_out(vty
, " send");
17032 vty_out(vty
, " receive");
17033 vty_out(vty
, "\n");
17036 /* Route reflector client. */
17037 if (peergroup_af_flag_check(peer
, afi
, safi
,
17038 PEER_FLAG_REFLECTOR_CLIENT
)) {
17039 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17042 /* next-hop-self force */
17043 if (peergroup_af_flag_check(peer
, afi
, safi
,
17044 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17045 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17048 /* next-hop-self */
17049 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17050 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17053 /* remove-private-AS */
17054 if (peergroup_af_flag_check(peer
, afi
, safi
,
17055 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17056 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17060 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17061 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17062 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17066 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17067 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17068 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17071 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17072 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17073 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17077 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17078 vty_out(vty
, " neighbor %s as-override\n", addr
);
17081 /* send-community print. */
17082 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17083 PEER_FLAG_SEND_COMMUNITY
);
17084 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17085 PEER_FLAG_SEND_EXT_COMMUNITY
);
17086 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17087 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17089 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17090 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17093 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17096 " no neighbor %s send-community extended\n",
17100 vty_out(vty
, " no neighbor %s send-community large\n",
17104 /* Default information */
17105 if (peergroup_af_flag_check(peer
, afi
, safi
,
17106 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17107 vty_out(vty
, " neighbor %s default-originate", addr
);
17109 if (peer
->default_rmap
[afi
][safi
].name
)
17110 vty_out(vty
, " route-map %s",
17111 peer
->default_rmap
[afi
][safi
].name
);
17113 vty_out(vty
, "\n");
17116 /* Soft reconfiguration inbound. */
17117 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17118 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17122 /* maximum-prefix. */
17123 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17124 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17125 peer
->pmax
[afi
][safi
]);
17127 if (peer
->pmax_threshold
[afi
][safi
]
17128 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17129 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17130 if (peer_af_flag_check(peer
, afi
, safi
,
17131 PEER_FLAG_MAX_PREFIX_WARNING
))
17132 vty_out(vty
, " warning-only");
17133 if (peer
->pmax_restart
[afi
][safi
])
17134 vty_out(vty
, " restart %u",
17135 peer
->pmax_restart
[afi
][safi
]);
17136 if (peer_af_flag_check(peer
, afi
, safi
,
17137 PEER_FLAG_MAX_PREFIX_FORCE
))
17138 vty_out(vty
, " force");
17140 vty_out(vty
, "\n");
17143 /* maximum-prefix-out */
17144 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17145 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17146 addr
, peer
->pmax_out
[afi
][safi
]);
17148 /* Route server client. */
17149 if (peergroup_af_flag_check(peer
, afi
, safi
,
17150 PEER_FLAG_RSERVER_CLIENT
)) {
17151 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17154 /* Nexthop-local unchanged. */
17155 if (peergroup_af_flag_check(peer
, afi
, safi
,
17156 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17157 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17160 /* allowas-in <1-10> */
17161 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17162 if (peer_af_flag_check(peer
, afi
, safi
,
17163 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17164 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17165 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17166 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17168 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17169 peer
->allowas_in
[afi
][safi
]);
17174 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17175 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17176 peer
->weight
[afi
][safi
]);
17179 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17181 /* atribute-unchanged. */
17182 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17183 || (safi
!= SAFI_EVPN
17184 && peer_af_flag_check(peer
, afi
, safi
,
17185 PEER_FLAG_NEXTHOP_UNCHANGED
))
17186 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17188 if (!peer_group_active(peer
)
17189 || peergroup_af_flag_check(peer
, afi
, safi
,
17190 PEER_FLAG_AS_PATH_UNCHANGED
)
17191 || peergroup_af_flag_check(peer
, afi
, safi
,
17192 PEER_FLAG_NEXTHOP_UNCHANGED
)
17193 || peergroup_af_flag_check(peer
, afi
, safi
,
17194 PEER_FLAG_MED_UNCHANGED
)) {
17197 " neighbor %s attribute-unchanged%s%s%s\n",
17199 peer_af_flag_check(peer
, afi
, safi
,
17200 PEER_FLAG_AS_PATH_UNCHANGED
)
17203 peer_af_flag_check(peer
, afi
, safi
,
17204 PEER_FLAG_NEXTHOP_UNCHANGED
)
17207 peer_af_flag_check(peer
, afi
, safi
,
17208 PEER_FLAG_MED_UNCHANGED
)
17215 /* Address family based peer configuration display. */
17216 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17220 struct peer_group
*group
;
17221 struct listnode
*node
, *nnode
;
17224 vty_frame(vty
, " !\n address-family ");
17225 if (afi
== AFI_IP
) {
17226 if (safi
== SAFI_UNICAST
)
17227 vty_frame(vty
, "ipv4 unicast");
17228 else if (safi
== SAFI_LABELED_UNICAST
)
17229 vty_frame(vty
, "ipv4 labeled-unicast");
17230 else if (safi
== SAFI_MULTICAST
)
17231 vty_frame(vty
, "ipv4 multicast");
17232 else if (safi
== SAFI_MPLS_VPN
)
17233 vty_frame(vty
, "ipv4 vpn");
17234 else if (safi
== SAFI_ENCAP
)
17235 vty_frame(vty
, "ipv4 encap");
17236 else if (safi
== SAFI_FLOWSPEC
)
17237 vty_frame(vty
, "ipv4 flowspec");
17238 } else if (afi
== AFI_IP6
) {
17239 if (safi
== SAFI_UNICAST
)
17240 vty_frame(vty
, "ipv6 unicast");
17241 else if (safi
== SAFI_LABELED_UNICAST
)
17242 vty_frame(vty
, "ipv6 labeled-unicast");
17243 else if (safi
== SAFI_MULTICAST
)
17244 vty_frame(vty
, "ipv6 multicast");
17245 else if (safi
== SAFI_MPLS_VPN
)
17246 vty_frame(vty
, "ipv6 vpn");
17247 else if (safi
== SAFI_ENCAP
)
17248 vty_frame(vty
, "ipv6 encap");
17249 else if (safi
== SAFI_FLOWSPEC
)
17250 vty_frame(vty
, "ipv6 flowspec");
17251 } else if (afi
== AFI_L2VPN
) {
17252 if (safi
== SAFI_EVPN
)
17253 vty_frame(vty
, "l2vpn evpn");
17255 vty_frame(vty
, "\n");
17257 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17259 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17261 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17263 /* BGP flag dampening. */
17264 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17265 bgp_config_write_damp(vty
, afi
, safi
);
17267 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17268 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17270 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17271 /* Do not display doppelganger peers */
17272 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17273 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17276 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17277 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17279 if (safi
== SAFI_EVPN
)
17280 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17282 if (safi
== SAFI_FLOWSPEC
)
17283 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17285 if (safi
== SAFI_UNICAST
) {
17286 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17287 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17288 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17290 vty_out(vty
, " export vpn\n");
17292 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17293 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17295 vty_out(vty
, " import vpn\n");
17297 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17298 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17301 for (ALL_LIST_ELEMENTS_RO(
17302 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17304 vty_out(vty
, " import vrf %s\n", name
);
17308 vty_endframe(vty
, " exit-address-family\n");
17311 int bgp_config_write(struct vty
*vty
)
17314 struct peer_group
*group
;
17316 struct listnode
*node
, *nnode
;
17317 struct listnode
*mnode
, *mnnode
;
17321 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17322 vty_out(vty
, "bgp route-map delay-timer %u\n",
17323 bm
->rmap_update_timer
);
17325 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17326 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17327 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17328 vty_out(vty
, " %d", bm
->v_establish_wait
);
17329 vty_out(vty
, "\n");
17332 if (bm
->wait_for_fib
)
17333 vty_out(vty
, "bgp suppress-fib-pending\n");
17335 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17336 vty_out(vty
, "bgp graceful-shutdown\n");
17338 /* No-RIB (Zebra) option flag configuration */
17339 if (bgp_option_check(BGP_OPT_NO_FIB
))
17340 vty_out(vty
, "bgp no-rib\n");
17342 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17343 vty_out(vty
, "bgp send-extra-data zebra\n");
17345 /* BGP session DSCP value */
17346 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17347 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17349 /* BGP configuration. */
17350 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17352 /* skip all auto created vrf as they dont have user config */
17353 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17356 /* Router bgp ASN */
17357 vty_out(vty
, "router bgp %u", bgp
->as
);
17360 vty_out(vty
, " %s %s",
17361 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17362 ? "view" : "vrf", bgp
->name
);
17363 vty_out(vty
, "\n");
17365 /* BGP fast-external-failover. */
17366 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17367 vty_out(vty
, " no bgp fast-external-failover\n");
17369 /* BGP router ID. */
17370 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17371 vty_out(vty
, " bgp router-id %pI4\n",
17372 &bgp
->router_id_static
);
17374 /* Suppress fib pending */
17375 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17376 vty_out(vty
, " bgp suppress-fib-pending\n");
17378 /* BGP log-neighbor-changes. */
17379 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17380 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17381 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17382 CHECK_FLAG(bgp
->flags
,
17383 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17387 /* BGP configuration. */
17388 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17389 vty_out(vty
, " bgp always-compare-med\n");
17391 /* RFC8212 default eBGP policy. */
17392 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17393 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17394 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17395 CHECK_FLAG(bgp
->flags
,
17396 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17400 /* draft-ietf-idr-deprecate-as-set-confed-set */
17401 if (bgp
->reject_as_sets
)
17402 vty_out(vty
, " bgp reject-as-sets\n");
17404 /* Suppress duplicate updates if the route actually not changed
17406 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17407 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17408 vty_out(vty
, " %sbgp suppress-duplicates\n",
17409 CHECK_FLAG(bgp
->flags
,
17410 BGP_FLAG_SUPPRESS_DUPLICATES
)
17414 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17416 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17417 SAVE_BGP_HARD_ADMIN_RESET
)
17418 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17419 CHECK_FLAG(bgp
->flags
,
17420 BGP_FLAG_HARD_ADMIN_RESET
)
17424 /* BGP default <afi>-<safi> */
17425 FOREACH_AFI_SAFI (afi
, safi
) {
17426 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17427 if (!bgp
->default_af
[afi
][safi
])
17428 vty_out(vty
, " no bgp default %s\n",
17429 get_bgp_default_af_flag(afi
,
17431 } else if (bgp
->default_af
[afi
][safi
])
17432 vty_out(vty
, " bgp default %s\n",
17433 get_bgp_default_af_flag(afi
, safi
));
17436 /* BGP default local-preference. */
17437 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17438 vty_out(vty
, " bgp default local-preference %u\n",
17439 bgp
->default_local_pref
);
17441 /* BGP default show-hostname */
17442 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17443 != SAVE_BGP_SHOW_HOSTNAME
)
17444 vty_out(vty
, " %sbgp default show-hostname\n",
17445 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17449 /* BGP default show-nexthop-hostname */
17450 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17451 != SAVE_BGP_SHOW_HOSTNAME
)
17452 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17453 CHECK_FLAG(bgp
->flags
,
17454 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17458 /* BGP default subgroup-pkt-queue-max. */
17459 if (bgp
->default_subgroup_pkt_queue_max
17460 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17461 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17462 bgp
->default_subgroup_pkt_queue_max
);
17464 /* BGP client-to-client reflection. */
17465 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17466 vty_out(vty
, " no bgp client-to-client reflection\n");
17468 /* BGP cluster ID. */
17469 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17470 vty_out(vty
, " bgp cluster-id %pI4\n",
17473 /* Disable ebgp connected nexthop check */
17474 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17476 " bgp disable-ebgp-connected-route-check\n");
17478 /* Confederation identifier*/
17479 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17480 vty_out(vty
, " bgp confederation identifier %u\n",
17483 /* Confederation peer */
17484 if (bgp
->confed_peers_cnt
> 0) {
17487 vty_out(vty
, " bgp confederation peers");
17489 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17490 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17492 vty_out(vty
, "\n");
17495 /* BGP deterministic-med. */
17496 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17497 != SAVE_BGP_DETERMINISTIC_MED
)
17498 vty_out(vty
, " %sbgp deterministic-med\n",
17499 CHECK_FLAG(bgp
->flags
,
17500 BGP_FLAG_DETERMINISTIC_MED
)
17504 /* BGP update-delay. */
17505 bgp_config_write_update_delay(vty
, bgp
);
17507 if (bgp
->v_maxmed_onstartup
17508 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17509 vty_out(vty
, " bgp max-med on-startup %u",
17510 bgp
->v_maxmed_onstartup
);
17511 if (bgp
->maxmed_onstartup_value
17512 != BGP_MAXMED_VALUE_DEFAULT
)
17513 vty_out(vty
, " %u",
17514 bgp
->maxmed_onstartup_value
);
17515 vty_out(vty
, "\n");
17517 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17518 vty_out(vty
, " bgp max-med administrative");
17519 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17520 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17521 vty_out(vty
, "\n");
17525 bgp_config_write_wpkt_quanta(vty
, bgp
);
17527 bgp_config_write_rpkt_quanta(vty
, bgp
);
17529 /* coalesce time */
17530 bgp_config_write_coalesce_time(vty
, bgp
);
17532 /* BGP per-instance graceful-shutdown */
17533 /* BGP-wide settings and per-instance settings are mutually
17536 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17537 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17538 vty_out(vty
, " bgp graceful-shutdown\n");
17540 /* Long-lived Graceful Restart */
17541 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17543 " bgp long-lived-graceful-restart stale-time %u\n",
17544 bgp
->llgr_stale_time
);
17546 /* BGP graceful-restart. */
17547 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17549 " bgp graceful-restart stalepath-time %u\n",
17550 bgp
->stalepath_time
);
17552 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17553 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17554 bgp
->restart_time
);
17556 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17557 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17558 vty_out(vty
, " %sbgp graceful-restart notification\n",
17559 CHECK_FLAG(bgp
->flags
,
17560 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17564 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17566 " bgp graceful-restart select-defer-time %u\n",
17567 bgp
->select_defer_time
);
17569 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17570 vty_out(vty
, " bgp graceful-restart\n");
17572 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17573 vty_out(vty
, " bgp graceful-restart-disable\n");
17575 /* BGP graceful-restart Preserve State F bit. */
17576 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17578 " bgp graceful-restart preserve-fw-state\n");
17580 /* Stale timer for RIB */
17581 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17583 " bgp graceful-restart rib-stale-time %u\n",
17584 bgp
->rib_stale_time
);
17586 /* BGP bestpath method. */
17587 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17588 vty_out(vty
, " bgp bestpath as-path ignore\n");
17589 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17590 vty_out(vty
, " bgp bestpath as-path confed\n");
17592 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17593 if (CHECK_FLAG(bgp
->flags
,
17594 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17596 " bgp bestpath as-path multipath-relax as-set\n");
17599 " bgp bestpath as-path multipath-relax\n");
17603 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17605 " bgp route-reflector allow-outbound-policy\n");
17607 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17608 vty_out(vty
, " bgp bestpath compare-routerid\n");
17609 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17610 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17611 vty_out(vty
, " bgp bestpath med");
17612 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17613 vty_out(vty
, " confed");
17614 if (CHECK_FLAG(bgp
->flags
,
17615 BGP_FLAG_MED_MISSING_AS_WORST
))
17616 vty_out(vty
, " missing-as-worst");
17617 vty_out(vty
, "\n");
17620 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17622 " bgp bestpath peer-type multipath-relax\n");
17624 /* Link bandwidth handling. */
17625 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17626 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17627 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17628 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17629 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17630 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17632 /* BGP network import check. */
17633 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17634 != SAVE_BGP_IMPORT_CHECK
)
17635 vty_out(vty
, " %sbgp network import-check\n",
17636 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17640 /* BGP timers configuration. */
17641 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17642 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17643 vty_out(vty
, " timers bgp %u %u\n",
17644 bgp
->default_keepalive
, bgp
->default_holdtime
);
17646 /* BGP minimum holdtime configuration. */
17647 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17648 && bgp
->default_min_holdtime
!= 0)
17649 vty_out(vty
, " bgp minimum-holdtime %u\n",
17650 bgp
->default_min_holdtime
);
17652 /* Conditional advertisement timer configuration */
17653 if (bgp
->condition_check_period
17654 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17656 " bgp conditional-advertisement timer %u\n",
17657 bgp
->condition_check_period
);
17660 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17661 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17664 /* Normal neighbor configuration. */
17665 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17666 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17667 bgp_config_write_peer_global(vty
, bgp
, peer
);
17670 /* listen range and limit for dynamic BGP neighbors */
17671 bgp_config_write_listen(vty
, bgp
);
17674 * BGP default autoshutdown neighbors
17676 * This must be placed after any peer and peer-group
17677 * configuration, to avoid setting all peers to shutdown after
17678 * a daemon restart, which is undesired behavior. (see #2286)
17680 if (bgp
->autoshutdown
)
17681 vty_out(vty
, " bgp default shutdown\n");
17683 /* BGP instance administrative shutdown */
17684 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17685 vty_out(vty
, " bgp shutdown\n");
17687 if (bgp
->allow_martian
)
17688 vty_out(vty
, " bgp allow-martian-nexthop\n");
17690 if (bgp
->fast_convergence
)
17691 vty_out(vty
, " bgp fast-convergence\n");
17693 if (bgp
->srv6_enabled
) {
17694 vty_frame(vty
, " !\n segment-routing srv6\n");
17695 if (strlen(bgp
->srv6_locator_name
))
17696 vty_out(vty
, " locator %s\n",
17697 bgp
->srv6_locator_name
);
17698 vty_endframe(vty
, " exit\n");
17702 /* IPv4 unicast configuration. */
17703 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17705 /* IPv4 multicast configuration. */
17706 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17708 /* IPv4 labeled-unicast configuration. */
17709 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17711 /* IPv4 VPN configuration. */
17712 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17714 /* ENCAPv4 configuration. */
17715 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17717 /* FLOWSPEC v4 configuration. */
17718 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17720 /* IPv6 unicast configuration. */
17721 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17723 /* IPv6 multicast configuration. */
17724 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17726 /* IPv6 labeled-unicast configuration. */
17727 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17728 SAFI_LABELED_UNICAST
);
17730 /* IPv6 VPN configuration. */
17731 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17733 /* ENCAPv6 configuration. */
17734 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17736 /* FLOWSPEC v6 configuration. */
17737 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17739 /* EVPN configuration. */
17740 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17742 hook_call(bgp_inst_config_write
, bgp
, vty
);
17744 #ifdef ENABLE_BGP_VNC
17745 bgp_rfapi_cfg_write(vty
, bgp
);
17748 vty_out(vty
, "exit\n");
17749 vty_out(vty
, "!\n");
17755 /* BGP node structure. */
17756 static struct cmd_node bgp_node
= {
17759 .parent_node
= CONFIG_NODE
,
17760 .prompt
= "%s(config-router)# ",
17761 .config_write
= bgp_config_write
,
17764 static struct cmd_node bgp_ipv4_unicast_node
= {
17765 .name
= "bgp ipv4 unicast",
17766 .node
= BGP_IPV4_NODE
,
17767 .parent_node
= BGP_NODE
,
17768 .prompt
= "%s(config-router-af)# ",
17772 static struct cmd_node bgp_ipv4_multicast_node
= {
17773 .name
= "bgp ipv4 multicast",
17774 .node
= BGP_IPV4M_NODE
,
17775 .parent_node
= BGP_NODE
,
17776 .prompt
= "%s(config-router-af)# ",
17780 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17781 .name
= "bgp ipv4 labeled unicast",
17782 .node
= BGP_IPV4L_NODE
,
17783 .parent_node
= BGP_NODE
,
17784 .prompt
= "%s(config-router-af)# ",
17788 static struct cmd_node bgp_ipv6_unicast_node
= {
17789 .name
= "bgp ipv6 unicast",
17790 .node
= BGP_IPV6_NODE
,
17791 .parent_node
= BGP_NODE
,
17792 .prompt
= "%s(config-router-af)# ",
17796 static struct cmd_node bgp_ipv6_multicast_node
= {
17797 .name
= "bgp ipv6 multicast",
17798 .node
= BGP_IPV6M_NODE
,
17799 .parent_node
= BGP_NODE
,
17800 .prompt
= "%s(config-router-af)# ",
17804 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17805 .name
= "bgp ipv6 labeled unicast",
17806 .node
= BGP_IPV6L_NODE
,
17807 .parent_node
= BGP_NODE
,
17808 .prompt
= "%s(config-router-af)# ",
17812 static struct cmd_node bgp_vpnv4_node
= {
17813 .name
= "bgp vpnv4",
17814 .node
= BGP_VPNV4_NODE
,
17815 .parent_node
= BGP_NODE
,
17816 .prompt
= "%s(config-router-af)# ",
17820 static struct cmd_node bgp_vpnv6_node
= {
17821 .name
= "bgp vpnv6",
17822 .node
= BGP_VPNV6_NODE
,
17823 .parent_node
= BGP_NODE
,
17824 .prompt
= "%s(config-router-af-vpnv6)# ",
17828 static struct cmd_node bgp_evpn_node
= {
17829 .name
= "bgp evpn",
17830 .node
= BGP_EVPN_NODE
,
17831 .parent_node
= BGP_NODE
,
17832 .prompt
= "%s(config-router-evpn)# ",
17836 static struct cmd_node bgp_evpn_vni_node
= {
17837 .name
= "bgp evpn vni",
17838 .node
= BGP_EVPN_VNI_NODE
,
17839 .parent_node
= BGP_EVPN_NODE
,
17840 .prompt
= "%s(config-router-af-vni)# ",
17843 static struct cmd_node bgp_flowspecv4_node
= {
17844 .name
= "bgp ipv4 flowspec",
17845 .node
= BGP_FLOWSPECV4_NODE
,
17846 .parent_node
= BGP_NODE
,
17847 .prompt
= "%s(config-router-af)# ",
17851 static struct cmd_node bgp_flowspecv6_node
= {
17852 .name
= "bgp ipv6 flowspec",
17853 .node
= BGP_FLOWSPECV6_NODE
,
17854 .parent_node
= BGP_NODE
,
17855 .prompt
= "%s(config-router-af-vpnv6)# ",
17859 static struct cmd_node bgp_srv6_node
= {
17860 .name
= "bgp srv6",
17861 .node
= BGP_SRV6_NODE
,
17862 .parent_node
= BGP_NODE
,
17863 .prompt
= "%s(config-router-srv6)# ",
17866 static void community_list_vty(void);
17868 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17871 struct peer_group
*group
;
17872 struct listnode
*lnbgp
, *lnpeer
;
17874 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17875 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17877 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17881 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17885 struct listnode
*lnbgp
, *lnpeer
;
17887 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17888 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17889 /* only provide suggestions on the appropriate input
17891 * they'll otherwise show up multiple times */
17892 enum cmd_token_type match_type
;
17893 char *name
= peer
->host
;
17895 if (peer
->conf_if
) {
17896 match_type
= VARIABLE_TKN
;
17897 name
= peer
->conf_if
;
17898 } else if (strchr(peer
->host
, ':'))
17899 match_type
= IPV6_TKN
;
17901 match_type
= IPV4_TKN
;
17903 if (token
->type
!= match_type
)
17906 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17911 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17913 bgp_ac_peer(comps
, token
);
17915 if (token
->type
== VARIABLE_TKN
)
17916 bgp_ac_peergroup(comps
, token
);
17919 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17920 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17921 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17922 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17923 {.completions
= NULL
}};
17925 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17926 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17927 {.completions
= NULL
} };
17929 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
17931 static struct thread
*t_bgp_cfg
;
17933 bool bgp_config_inprocess(void)
17935 return thread_is_scheduled(t_bgp_cfg
);
17938 static void bgp_config_finish(struct thread
*t
)
17940 struct listnode
*node
;
17943 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
17944 hook_call(bgp_config_end
, bgp
);
17947 static void bgp_config_start(void)
17949 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
17950 THREAD_OFF(t_bgp_cfg
);
17951 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17952 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
17955 /* When we receive a hook the configuration is read,
17956 * we start a timer to make sure we postpone sending
17957 * EoR before route-maps are processed.
17958 * This is especially valid if using `bgp route-map delay-timer`.
17960 static void bgp_config_end(void)
17962 #define BGP_POST_CONFIG_DELAY_SECONDS 1
17963 uint32_t bgp_post_config_delay
=
17964 thread_is_scheduled(bm
->t_rmap_update
)
17965 ? thread_timer_remain_second(bm
->t_rmap_update
)
17966 : BGP_POST_CONFIG_DELAY_SECONDS
;
17968 /* If BGP config processing thread isn't running, then
17969 * we can return and rely it's properly handled.
17971 if (!bgp_config_inprocess())
17974 THREAD_OFF(t_bgp_cfg
);
17976 /* Start a new timer to make sure we don't send EoR
17977 * before route-maps are processed.
17979 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17980 bgp_post_config_delay
, &t_bgp_cfg
);
17983 void bgp_vty_init(void)
17985 cmd_variable_handler_register(bgp_var_neighbor
);
17986 cmd_variable_handler_register(bgp_var_peergroup
);
17988 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
17990 /* Install bgp top node. */
17991 install_node(&bgp_node
);
17992 install_node(&bgp_ipv4_unicast_node
);
17993 install_node(&bgp_ipv4_multicast_node
);
17994 install_node(&bgp_ipv4_labeled_unicast_node
);
17995 install_node(&bgp_ipv6_unicast_node
);
17996 install_node(&bgp_ipv6_multicast_node
);
17997 install_node(&bgp_ipv6_labeled_unicast_node
);
17998 install_node(&bgp_vpnv4_node
);
17999 install_node(&bgp_vpnv6_node
);
18000 install_node(&bgp_evpn_node
);
18001 install_node(&bgp_evpn_vni_node
);
18002 install_node(&bgp_flowspecv4_node
);
18003 install_node(&bgp_flowspecv6_node
);
18004 install_node(&bgp_srv6_node
);
18006 /* Install default VTY commands to new nodes. */
18007 install_default(BGP_NODE
);
18008 install_default(BGP_IPV4_NODE
);
18009 install_default(BGP_IPV4M_NODE
);
18010 install_default(BGP_IPV4L_NODE
);
18011 install_default(BGP_IPV6_NODE
);
18012 install_default(BGP_IPV6M_NODE
);
18013 install_default(BGP_IPV6L_NODE
);
18014 install_default(BGP_VPNV4_NODE
);
18015 install_default(BGP_VPNV6_NODE
);
18016 install_default(BGP_FLOWSPECV4_NODE
);
18017 install_default(BGP_FLOWSPECV6_NODE
);
18018 install_default(BGP_EVPN_NODE
);
18019 install_default(BGP_EVPN_VNI_NODE
);
18020 install_default(BGP_SRV6_NODE
);
18022 /* "bgp local-mac" hidden commands. */
18023 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18024 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18026 /* "bgp suppress-fib-pending" global */
18027 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18029 /* bgp route-map delay-timer commands. */
18030 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18031 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18033 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18035 /* bgp fast-convergence command */
18036 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18037 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18039 /* global bgp update-delay command */
18040 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18041 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18043 /* global bgp graceful-shutdown command */
18044 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18045 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18047 /* Dummy commands (Currently not supported) */
18048 install_element(BGP_NODE
, &no_synchronization_cmd
);
18049 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18051 /* "router bgp" commands. */
18052 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18054 /* "no router bgp" commands. */
18055 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18057 /* "bgp session-dscp command */
18058 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18059 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18061 /* "bgp router-id" commands. */
18062 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18063 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18065 /* "bgp suppress-fib-pending" command */
18066 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18068 /* "bgp cluster-id" commands. */
18069 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18070 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18072 /* "bgp no-rib" commands. */
18073 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18074 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18076 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18078 /* "bgp confederation" commands. */
18079 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18080 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18082 /* "bgp confederation peers" commands. */
18083 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18084 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18086 /* bgp max-med command */
18087 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18088 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18089 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18090 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18091 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18093 /* "neighbor role" commands. */
18094 install_element(BGP_NODE
, &neighbor_role_cmd
);
18095 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18096 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18098 /* bgp disable-ebgp-connected-nh-check */
18099 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18100 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18102 /* bgp update-delay command */
18103 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18104 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18106 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18107 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18109 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18110 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18112 /* "maximum-paths" commands. */
18113 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18114 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18115 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18116 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18117 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18118 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18119 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18120 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18121 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18122 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18123 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18124 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18125 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18126 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18127 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18129 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18130 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18131 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18132 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18133 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18134 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18135 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18136 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18137 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18138 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18140 /* "timers bgp" commands. */
18141 install_element(BGP_NODE
, &bgp_timers_cmd
);
18142 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18144 /* "minimum-holdtime" commands. */
18145 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18146 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18148 /* route-map delay-timer commands - per instance for backwards compat.
18150 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18151 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18153 /* "bgp client-to-client reflection" commands */
18154 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18155 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18157 /* "bgp always-compare-med" commands */
18158 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18159 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18161 /* bgp ebgp-requires-policy */
18162 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18163 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18165 /* bgp suppress-duplicates */
18166 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18167 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18169 /* bgp reject-as-sets */
18170 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18171 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18173 /* "bgp deterministic-med" commands */
18174 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18175 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18177 /* "bgp graceful-restart" command */
18178 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18179 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18181 /* "bgp graceful-restart-disable" command */
18182 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18183 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18185 /* "neighbor a:b:c:d graceful-restart" command */
18186 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18187 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18189 /* "neighbor a:b:c:d graceful-restart-disable" command */
18190 install_element(BGP_NODE
,
18191 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18192 install_element(BGP_NODE
,
18193 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18195 /* "neighbor a:b:c:d graceful-restart-helper" command */
18196 install_element(BGP_NODE
,
18197 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18198 install_element(BGP_NODE
,
18199 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18201 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18202 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18203 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18204 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18205 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18206 install_element(BGP_NODE
,
18207 &no_bgp_graceful_restart_select_defer_time_cmd
);
18208 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18209 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18210 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18212 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18213 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18214 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18215 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18217 /* "bgp graceful-shutdown" commands */
18218 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18219 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18221 /* "bgp hard-administrative-reset" commands */
18222 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18224 /* "bgp long-lived-graceful-restart" commands */
18225 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18226 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18228 /* "bgp fast-external-failover" commands */
18229 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18230 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18232 /* "bgp bestpath compare-routerid" commands */
18233 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18234 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18236 /* "bgp bestpath as-path ignore" commands */
18237 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18238 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18240 /* "bgp bestpath as-path confed" commands */
18241 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18242 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18244 /* "bgp bestpath as-path multipath-relax" commands */
18245 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18246 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18248 /* "bgp bestpath peer-type multipath-relax" commands */
18249 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18250 install_element(BGP_NODE
,
18251 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18253 /* "bgp log-neighbor-changes" commands */
18254 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18255 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18257 /* "bgp bestpath med" commands */
18258 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18259 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18261 /* "bgp bestpath bandwidth" commands */
18262 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18263 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18265 /* "no bgp default <afi>-<safi>" commands. */
18266 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18268 /* "bgp network import-check" commands. */
18269 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18270 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18271 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18273 /* "bgp default local-preference" commands. */
18274 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18275 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18277 /* bgp default show-hostname */
18278 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18279 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18281 /* bgp default show-nexthop-hostname */
18282 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18283 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18285 /* "bgp default subgroup-pkt-queue-max" commands. */
18286 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18287 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18289 /* bgp ibgp-allow-policy-mods command */
18290 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18291 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18293 /* "bgp listen limit" commands. */
18294 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18295 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18297 /* "bgp listen range" commands. */
18298 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18299 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18301 /* "bgp default shutdown" command */
18302 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18304 /* "bgp shutdown" commands */
18305 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18306 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18307 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18308 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18310 /* "neighbor remote-as" commands. */
18311 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18312 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18313 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18314 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18315 install_element(BGP_NODE
,
18316 &neighbor_interface_v6only_config_remote_as_cmd
);
18317 install_element(BGP_NODE
, &no_neighbor_cmd
);
18318 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18320 /* "neighbor peer-group" commands. */
18321 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18322 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18323 install_element(BGP_NODE
,
18324 &no_neighbor_interface_peer_group_remote_as_cmd
);
18326 /* "neighbor local-as" commands. */
18327 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18328 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18329 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18330 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18332 /* "neighbor solo" commands. */
18333 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18334 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18336 /* "neighbor password" commands. */
18337 install_element(BGP_NODE
, &neighbor_password_cmd
);
18338 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18340 /* "neighbor activate" commands. */
18341 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18342 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18343 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18344 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18345 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18346 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18347 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18348 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18349 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18350 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18351 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18352 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18354 /* "no neighbor activate" commands. */
18355 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18356 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18357 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18358 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18359 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18360 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18361 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18362 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18363 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18364 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18365 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18366 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18368 /* "neighbor peer-group" set commands. */
18369 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18370 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18371 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18372 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18373 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18374 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18375 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18376 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18377 install_element(BGP_FLOWSPECV4_NODE
,
18378 &neighbor_set_peer_group_hidden_cmd
);
18379 install_element(BGP_FLOWSPECV6_NODE
,
18380 &neighbor_set_peer_group_hidden_cmd
);
18382 /* "no neighbor peer-group unset" commands. */
18383 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18384 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18385 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18386 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18387 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18388 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18389 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18390 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18391 install_element(BGP_FLOWSPECV4_NODE
,
18392 &no_neighbor_set_peer_group_hidden_cmd
);
18393 install_element(BGP_FLOWSPECV6_NODE
,
18394 &no_neighbor_set_peer_group_hidden_cmd
);
18396 /* "neighbor softreconfiguration inbound" commands.*/
18397 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18398 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18399 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18400 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18401 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18402 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18403 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18404 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18405 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18406 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18407 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18408 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18409 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18410 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18411 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18412 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18413 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18414 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18415 install_element(BGP_FLOWSPECV4_NODE
,
18416 &neighbor_soft_reconfiguration_cmd
);
18417 install_element(BGP_FLOWSPECV4_NODE
,
18418 &no_neighbor_soft_reconfiguration_cmd
);
18419 install_element(BGP_FLOWSPECV6_NODE
,
18420 &neighbor_soft_reconfiguration_cmd
);
18421 install_element(BGP_FLOWSPECV6_NODE
,
18422 &no_neighbor_soft_reconfiguration_cmd
);
18423 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18424 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18426 /* "neighbor attribute-unchanged" commands. */
18427 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18428 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18429 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18430 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18431 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18432 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18433 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18434 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18435 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18436 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18437 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18438 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18439 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18440 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18441 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18442 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18443 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18444 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18446 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18447 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18449 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18450 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18451 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18452 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18454 /* "nexthop-local unchanged" commands */
18455 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18456 install_element(BGP_IPV6_NODE
,
18457 &no_neighbor_nexthop_local_unchanged_cmd
);
18459 /* "neighbor next-hop-self" commands. */
18460 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18461 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18462 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18463 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18464 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18465 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18466 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18467 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18468 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18469 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18470 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18471 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18472 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18473 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18474 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18475 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18476 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18477 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18478 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18479 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18481 /* "neighbor next-hop-self force" commands. */
18482 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18483 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18484 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18485 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18486 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18487 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18488 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18489 install_element(BGP_IPV4_NODE
,
18490 &no_neighbor_nexthop_self_all_hidden_cmd
);
18491 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18492 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18493 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18494 install_element(BGP_IPV4M_NODE
,
18495 &no_neighbor_nexthop_self_all_hidden_cmd
);
18496 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18497 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18498 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18499 install_element(BGP_IPV4L_NODE
,
18500 &no_neighbor_nexthop_self_all_hidden_cmd
);
18501 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18502 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18503 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18504 install_element(BGP_IPV6_NODE
,
18505 &no_neighbor_nexthop_self_all_hidden_cmd
);
18506 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18507 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18508 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18509 install_element(BGP_IPV6M_NODE
,
18510 &no_neighbor_nexthop_self_all_hidden_cmd
);
18511 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18512 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18513 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18514 install_element(BGP_IPV6L_NODE
,
18515 &no_neighbor_nexthop_self_all_hidden_cmd
);
18516 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18517 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18518 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18519 install_element(BGP_VPNV4_NODE
,
18520 &no_neighbor_nexthop_self_all_hidden_cmd
);
18521 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18522 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18523 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18524 install_element(BGP_VPNV6_NODE
,
18525 &no_neighbor_nexthop_self_all_hidden_cmd
);
18526 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18527 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18529 /* "neighbor as-override" commands. */
18530 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18531 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18532 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18533 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18534 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18535 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18536 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18537 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18538 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18539 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18540 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18541 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18542 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18543 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18544 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18545 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18546 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18547 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18549 /* "neighbor remove-private-AS" commands. */
18550 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18551 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18552 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18553 install_element(BGP_NODE
,
18554 &no_neighbor_remove_private_as_all_hidden_cmd
);
18555 install_element(BGP_NODE
,
18556 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18557 install_element(BGP_NODE
,
18558 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18559 install_element(BGP_NODE
,
18560 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18563 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18564 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18565 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18566 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18567 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18568 install_element(BGP_IPV4_NODE
,
18569 &neighbor_remove_private_as_replace_as_cmd
);
18570 install_element(BGP_IPV4_NODE
,
18571 &no_neighbor_remove_private_as_replace_as_cmd
);
18572 install_element(BGP_IPV4_NODE
,
18573 &neighbor_remove_private_as_all_replace_as_cmd
);
18574 install_element(BGP_IPV4_NODE
,
18575 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18576 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18577 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18578 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18579 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18580 install_element(BGP_IPV4M_NODE
,
18581 &neighbor_remove_private_as_replace_as_cmd
);
18582 install_element(BGP_IPV4M_NODE
,
18583 &no_neighbor_remove_private_as_replace_as_cmd
);
18584 install_element(BGP_IPV4M_NODE
,
18585 &neighbor_remove_private_as_all_replace_as_cmd
);
18586 install_element(BGP_IPV4M_NODE
,
18587 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18588 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18589 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18590 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18591 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18592 install_element(BGP_IPV4L_NODE
,
18593 &neighbor_remove_private_as_replace_as_cmd
);
18594 install_element(BGP_IPV4L_NODE
,
18595 &no_neighbor_remove_private_as_replace_as_cmd
);
18596 install_element(BGP_IPV4L_NODE
,
18597 &neighbor_remove_private_as_all_replace_as_cmd
);
18598 install_element(BGP_IPV4L_NODE
,
18599 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18600 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18601 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18602 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18603 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18604 install_element(BGP_IPV6_NODE
,
18605 &neighbor_remove_private_as_replace_as_cmd
);
18606 install_element(BGP_IPV6_NODE
,
18607 &no_neighbor_remove_private_as_replace_as_cmd
);
18608 install_element(BGP_IPV6_NODE
,
18609 &neighbor_remove_private_as_all_replace_as_cmd
);
18610 install_element(BGP_IPV6_NODE
,
18611 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18612 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18613 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18614 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18615 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18616 install_element(BGP_IPV6M_NODE
,
18617 &neighbor_remove_private_as_replace_as_cmd
);
18618 install_element(BGP_IPV6M_NODE
,
18619 &no_neighbor_remove_private_as_replace_as_cmd
);
18620 install_element(BGP_IPV6M_NODE
,
18621 &neighbor_remove_private_as_all_replace_as_cmd
);
18622 install_element(BGP_IPV6M_NODE
,
18623 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18624 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18625 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18626 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18627 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18628 install_element(BGP_IPV6L_NODE
,
18629 &neighbor_remove_private_as_replace_as_cmd
);
18630 install_element(BGP_IPV6L_NODE
,
18631 &no_neighbor_remove_private_as_replace_as_cmd
);
18632 install_element(BGP_IPV6L_NODE
,
18633 &neighbor_remove_private_as_all_replace_as_cmd
);
18634 install_element(BGP_IPV6L_NODE
,
18635 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18636 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18637 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18638 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18639 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18640 install_element(BGP_VPNV4_NODE
,
18641 &neighbor_remove_private_as_replace_as_cmd
);
18642 install_element(BGP_VPNV4_NODE
,
18643 &no_neighbor_remove_private_as_replace_as_cmd
);
18644 install_element(BGP_VPNV4_NODE
,
18645 &neighbor_remove_private_as_all_replace_as_cmd
);
18646 install_element(BGP_VPNV4_NODE
,
18647 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18648 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18649 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18650 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18651 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18652 install_element(BGP_VPNV6_NODE
,
18653 &neighbor_remove_private_as_replace_as_cmd
);
18654 install_element(BGP_VPNV6_NODE
,
18655 &no_neighbor_remove_private_as_replace_as_cmd
);
18656 install_element(BGP_VPNV6_NODE
,
18657 &neighbor_remove_private_as_all_replace_as_cmd
);
18658 install_element(BGP_VPNV6_NODE
,
18659 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18661 /* "neighbor send-community" commands.*/
18662 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18663 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18664 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18665 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18666 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18667 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18668 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18669 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18670 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18671 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18672 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18673 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18674 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18675 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18676 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18677 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18678 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18679 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18680 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18681 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18682 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18683 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18684 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18685 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18686 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18687 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18688 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18689 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18690 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18691 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18692 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18693 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18694 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18695 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18696 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18697 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18699 /* "neighbor route-reflector" commands.*/
18700 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18701 install_element(BGP_NODE
,
18702 &no_neighbor_route_reflector_client_hidden_cmd
);
18703 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18704 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18705 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18706 install_element(BGP_IPV4M_NODE
,
18707 &no_neighbor_route_reflector_client_cmd
);
18708 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18709 install_element(BGP_IPV4L_NODE
,
18710 &no_neighbor_route_reflector_client_cmd
);
18711 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18712 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18713 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18714 install_element(BGP_IPV6M_NODE
,
18715 &no_neighbor_route_reflector_client_cmd
);
18716 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18717 install_element(BGP_IPV6L_NODE
,
18718 &no_neighbor_route_reflector_client_cmd
);
18719 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18720 install_element(BGP_VPNV4_NODE
,
18721 &no_neighbor_route_reflector_client_cmd
);
18722 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18723 install_element(BGP_VPNV6_NODE
,
18724 &no_neighbor_route_reflector_client_cmd
);
18725 install_element(BGP_FLOWSPECV4_NODE
,
18726 &neighbor_route_reflector_client_cmd
);
18727 install_element(BGP_FLOWSPECV4_NODE
,
18728 &no_neighbor_route_reflector_client_cmd
);
18729 install_element(BGP_FLOWSPECV6_NODE
,
18730 &neighbor_route_reflector_client_cmd
);
18731 install_element(BGP_FLOWSPECV6_NODE
,
18732 &no_neighbor_route_reflector_client_cmd
);
18733 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18734 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18736 /* "neighbor route-server" commands.*/
18737 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18738 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18739 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18740 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18741 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18742 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18743 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18744 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18745 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18746 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18747 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18748 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18749 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18750 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18751 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18752 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18753 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18754 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18755 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18756 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18757 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18758 install_element(BGP_FLOWSPECV4_NODE
,
18759 &no_neighbor_route_server_client_cmd
);
18760 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18761 install_element(BGP_FLOWSPECV6_NODE
,
18762 &no_neighbor_route_server_client_cmd
);
18764 /* "neighbor disable-addpath-rx" commands. */
18765 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18766 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18767 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18768 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18769 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18770 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18771 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18772 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18773 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18774 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18775 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18776 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18777 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18778 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18779 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18780 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18782 /* "neighbor addpath-tx-all-paths" commands.*/
18783 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18784 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18785 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18786 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18787 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18788 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18789 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18790 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18791 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18792 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18793 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18794 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18795 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18796 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18797 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18798 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18799 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18800 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18802 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18803 install_element(BGP_NODE
,
18804 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18805 install_element(BGP_NODE
,
18806 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18807 install_element(BGP_IPV4_NODE
,
18808 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18809 install_element(BGP_IPV4_NODE
,
18810 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18811 install_element(BGP_IPV4M_NODE
,
18812 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18813 install_element(BGP_IPV4M_NODE
,
18814 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18815 install_element(BGP_IPV4L_NODE
,
18816 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18817 install_element(BGP_IPV4L_NODE
,
18818 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18819 install_element(BGP_IPV6_NODE
,
18820 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18821 install_element(BGP_IPV6_NODE
,
18822 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18823 install_element(BGP_IPV6M_NODE
,
18824 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18825 install_element(BGP_IPV6M_NODE
,
18826 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18827 install_element(BGP_IPV6L_NODE
,
18828 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18829 install_element(BGP_IPV6L_NODE
,
18830 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18831 install_element(BGP_VPNV4_NODE
,
18832 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18833 install_element(BGP_VPNV4_NODE
,
18834 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18835 install_element(BGP_VPNV6_NODE
,
18836 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18837 install_element(BGP_VPNV6_NODE
,
18838 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18840 /* "neighbor sender-as-path-loop-detection" commands. */
18841 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18842 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18844 /* "neighbor passive" commands. */
18845 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18846 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18849 /* "neighbor shutdown" commands. */
18850 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18851 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18852 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18853 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18854 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18855 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18857 /* "neighbor capability extended-nexthop" commands.*/
18858 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18859 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18861 /* "neighbor capability orf prefix-list" commands.*/
18862 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18863 install_element(BGP_NODE
,
18864 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18865 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18866 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18867 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18868 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18869 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18870 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18871 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18872 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18873 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18874 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18875 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18876 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18878 /* "neighbor capability dynamic" commands.*/
18879 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18880 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18882 /* "neighbor dont-capability-negotiate" commands. */
18883 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18884 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18886 /* "neighbor ebgp-multihop" commands. */
18887 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18888 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18889 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18891 /* "neighbor disable-connected-check" commands. */
18892 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18893 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18895 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18896 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18897 install_element(BGP_NODE
,
18898 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18900 /* "neighbor extended-optional-parameters" commands. */
18901 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18902 install_element(BGP_NODE
,
18903 &no_neighbor_extended_optional_parameters_cmd
);
18905 /* "neighbor enforce-first-as" commands. */
18906 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18907 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18909 /* "neighbor description" commands. */
18910 install_element(BGP_NODE
, &neighbor_description_cmd
);
18911 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18912 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18914 /* "neighbor update-source" commands. "*/
18915 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18916 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18918 /* "neighbor default-originate" commands. */
18919 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18920 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18921 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18922 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18923 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18924 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18925 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18926 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18927 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18928 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18929 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18930 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18931 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18932 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18933 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18934 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18935 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18936 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18937 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18938 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18939 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18941 /* "neighbor port" commands. */
18942 install_element(BGP_NODE
, &neighbor_port_cmd
);
18943 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18945 /* "neighbor weight" commands. */
18946 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18947 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18949 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18950 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18951 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18952 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18953 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18954 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18955 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18956 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18957 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18958 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18959 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18960 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18961 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18962 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18963 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18964 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18966 /* "neighbor override-capability" commands. */
18967 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18968 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18970 /* "neighbor strict-capability-match" commands. */
18971 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18972 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18974 /* "neighbor timers" commands. */
18975 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18976 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18978 /* "neighbor timers connect" commands. */
18979 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18980 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18982 /* "neighbor timers delayopen" commands. */
18983 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18984 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18986 /* "neighbor advertisement-interval" commands. */
18987 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18988 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18990 /* "neighbor interface" commands. */
18991 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18992 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18994 /* "neighbor distribute" commands. */
18995 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18996 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18997 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18998 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18999 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19000 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19001 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19002 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19003 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19004 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19005 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19006 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19007 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19008 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19009 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19010 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19011 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19012 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19014 /* "neighbor prefix-list" commands. */
19015 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19016 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19017 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19018 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19019 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19020 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19021 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19022 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19023 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19024 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19025 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19026 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19027 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19028 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19029 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19030 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19031 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19032 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19033 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19034 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19035 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19036 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19038 /* "neighbor filter-list" commands. */
19039 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19040 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19041 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19042 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19043 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19044 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19045 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19046 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19047 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19048 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19049 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19050 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19051 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19052 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19053 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19054 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19055 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19056 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19057 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19058 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19059 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19060 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19062 /* "neighbor route-map" commands. */
19063 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19064 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19065 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19066 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19067 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19068 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19069 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19070 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19071 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19072 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19073 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19074 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19075 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19076 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19077 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19078 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19079 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19080 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19081 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19082 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19083 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19084 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19085 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19086 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19088 /* "neighbor unsuppress-map" commands. */
19089 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19090 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19091 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19092 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19093 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19094 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19095 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19096 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19097 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19098 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19099 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19100 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19101 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19102 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19103 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19104 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19105 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19106 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19108 /* "neighbor advertise-map" commands. */
19109 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19110 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19111 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19112 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19113 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19114 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19115 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19116 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19117 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19118 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19120 /* neighbor maximum-prefix-out commands. */
19121 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19122 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19123 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19124 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19125 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19126 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19127 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19128 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19129 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19130 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19131 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19132 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19133 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19134 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19135 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19136 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19137 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19138 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19140 /* "neighbor maximum-prefix" commands. */
19141 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19142 install_element(BGP_NODE
,
19143 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19144 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19145 install_element(BGP_NODE
,
19146 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19147 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19148 install_element(BGP_NODE
,
19149 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19150 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19151 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19152 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19153 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19154 install_element(BGP_IPV4_NODE
,
19155 &neighbor_maximum_prefix_threshold_warning_cmd
);
19156 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19157 install_element(BGP_IPV4_NODE
,
19158 &neighbor_maximum_prefix_threshold_restart_cmd
);
19159 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19160 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19161 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19162 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19163 install_element(BGP_IPV4M_NODE
,
19164 &neighbor_maximum_prefix_threshold_warning_cmd
);
19165 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19166 install_element(BGP_IPV4M_NODE
,
19167 &neighbor_maximum_prefix_threshold_restart_cmd
);
19168 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19169 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19170 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19171 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19172 install_element(BGP_IPV4L_NODE
,
19173 &neighbor_maximum_prefix_threshold_warning_cmd
);
19174 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19175 install_element(BGP_IPV4L_NODE
,
19176 &neighbor_maximum_prefix_threshold_restart_cmd
);
19177 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19178 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19179 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19180 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19181 install_element(BGP_IPV6_NODE
,
19182 &neighbor_maximum_prefix_threshold_warning_cmd
);
19183 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19184 install_element(BGP_IPV6_NODE
,
19185 &neighbor_maximum_prefix_threshold_restart_cmd
);
19186 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19187 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19188 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19189 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19190 install_element(BGP_IPV6M_NODE
,
19191 &neighbor_maximum_prefix_threshold_warning_cmd
);
19192 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19193 install_element(BGP_IPV6M_NODE
,
19194 &neighbor_maximum_prefix_threshold_restart_cmd
);
19195 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19196 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19197 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19198 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19199 install_element(BGP_IPV6L_NODE
,
19200 &neighbor_maximum_prefix_threshold_warning_cmd
);
19201 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19202 install_element(BGP_IPV6L_NODE
,
19203 &neighbor_maximum_prefix_threshold_restart_cmd
);
19204 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19205 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19206 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19207 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19208 install_element(BGP_VPNV4_NODE
,
19209 &neighbor_maximum_prefix_threshold_warning_cmd
);
19210 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19211 install_element(BGP_VPNV4_NODE
,
19212 &neighbor_maximum_prefix_threshold_restart_cmd
);
19213 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19214 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19215 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19216 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19217 install_element(BGP_VPNV6_NODE
,
19218 &neighbor_maximum_prefix_threshold_warning_cmd
);
19219 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19220 install_element(BGP_VPNV6_NODE
,
19221 &neighbor_maximum_prefix_threshold_restart_cmd
);
19222 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19224 /* "neighbor allowas-in" */
19225 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19226 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19227 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19228 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19229 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19230 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19231 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19232 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19233 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19234 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19235 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19236 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19237 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19238 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19239 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19240 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19241 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19242 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19243 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19244 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19246 /* address-family commands. */
19247 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19248 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19249 #ifdef KEEP_OLD_VPN_COMMANDS
19250 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19251 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19252 #endif /* KEEP_OLD_VPN_COMMANDS */
19254 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19256 /* "exit-address-family" command. */
19257 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19258 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19259 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19260 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19261 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19262 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19263 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19264 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19265 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19266 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19267 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19269 /* "clear ip bgp commands" */
19270 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19272 /* clear ip bgp prefix */
19273 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19274 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19275 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19277 /* "show [ip] bgp summary" commands. */
19278 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19279 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19280 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19281 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19282 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19283 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19284 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19286 /* "show [ip] bgp neighbors" commands. */
19287 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19289 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19291 /* "show [ip] bgp peer-group" commands. */
19292 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19294 /* "show [ip] bgp paths" commands. */
19295 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19297 /* "show [ip] bgp community" commands. */
19298 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19300 /* "show ip bgp large-community" commands. */
19301 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19302 /* "show [ip] bgp attribute-info" commands. */
19303 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19304 /* "show [ip] bgp route-leak" command */
19305 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19307 /* "redistribute" commands. */
19308 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19309 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19310 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19311 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19312 install_element(BGP_NODE
,
19313 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19314 install_element(BGP_NODE
,
19315 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19316 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19317 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19318 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19319 install_element(BGP_NODE
,
19320 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19321 install_element(BGP_NODE
,
19322 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19323 install_element(BGP_NODE
,
19324 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19325 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19326 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19327 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19328 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19329 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19330 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19331 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19332 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19333 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19334 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19335 install_element(BGP_IPV4_NODE
,
19336 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19337 install_element(BGP_IPV4_NODE
,
19338 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19339 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19340 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19341 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19342 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19343 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19344 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19346 /* import|export vpn [route-map RMAP_NAME] */
19347 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19348 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19350 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19351 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19353 /* ttl_security commands */
19354 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19355 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19357 /* "show [ip] bgp memory" commands. */
19358 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19360 /* "show bgp martian next-hop" */
19361 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19363 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19365 /* "show [ip] bgp views" commands. */
19366 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19368 /* "show [ip] bgp vrfs" commands. */
19369 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19371 /* Community-list. */
19372 community_list_vty();
19374 community_alias_vty();
19376 /* vpn-policy commands */
19377 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19378 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19379 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19380 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19381 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19382 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19383 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19384 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19385 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19386 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19387 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19388 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19390 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19391 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19393 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19394 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19395 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19396 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19397 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19398 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19399 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19400 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19401 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19402 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19404 /* tcp-mss command */
19405 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19406 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19408 /* srv6 commands */
19409 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19410 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19411 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19412 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19413 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19414 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19415 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19418 #include "memory.h"
19419 #include "bgp_regex.h"
19420 #include "bgp_clist.h"
19421 #include "bgp_ecommunity.h"
19423 /* VTY functions. */
19425 /* Direction value to string conversion. */
19426 static const char *community_direct_str(int direct
)
19429 case COMMUNITY_DENY
:
19431 case COMMUNITY_PERMIT
:
19438 /* Display error string. */
19439 static void community_list_perror(struct vty
*vty
, int ret
)
19442 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19443 vty_out(vty
, "%% Can't find community-list\n");
19445 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19446 vty_out(vty
, "%% Malformed community-list value\n");
19448 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19450 "%% Community name conflict, previously defined as standard community\n");
19452 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19454 "%% Community name conflict, previously defined as expanded community\n");
19459 /* "community-list" keyword help string. */
19460 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19462 /*community-list standard */
19463 DEFUN (community_list_standard
,
19464 bgp_community_list_standard_cmd
,
19465 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19468 "Community list number (standard)\n"
19469 "Add an standard community-list entry\n"
19470 "Community list name\n"
19471 "Sequence number of an entry\n"
19472 "Sequence number\n"
19473 "Specify community to reject\n"
19474 "Specify community to accept\n"
19477 char *cl_name_or_number
= NULL
;
19480 int style
= COMMUNITY_LIST_STANDARD
;
19483 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19484 seq
= argv
[idx
]->arg
;
19487 argv_find(argv
, argc
, "(1-99)", &idx
);
19488 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19489 cl_name_or_number
= argv
[idx
]->arg
;
19490 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19492 argv_find(argv
, argc
, "AA:NN", &idx
);
19493 char *str
= argv_concat(argv
, argc
, idx
);
19495 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19498 XFREE(MTYPE_TMP
, str
);
19501 /* Display error string. */
19502 community_list_perror(vty
, ret
);
19503 return CMD_WARNING_CONFIG_FAILED
;
19506 return CMD_SUCCESS
;
19509 DEFUN (no_community_list_standard_all
,
19510 no_bgp_community_list_standard_all_cmd
,
19511 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19515 "Community list number (standard)\n"
19516 "Add an standard community-list entry\n"
19517 "Community list name\n"
19518 "Sequence number of an entry\n"
19519 "Sequence number\n"
19520 "Specify community to reject\n"
19521 "Specify community to accept\n"
19524 char *cl_name_or_number
= NULL
;
19527 int style
= COMMUNITY_LIST_STANDARD
;
19531 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19532 seq
= argv
[idx
]->arg
;
19535 argv_find(argv
, argc
, "permit", &idx
);
19536 argv_find(argv
, argc
, "deny", &idx
);
19539 direct
= argv_find(argv
, argc
, "permit", &idx
)
19544 argv_find(argv
, argc
, "AA:NN", &idx
);
19545 str
= argv_concat(argv
, argc
, idx
);
19549 argv_find(argv
, argc
, "(1-99)", &idx
);
19550 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19551 cl_name_or_number
= argv
[idx
]->arg
;
19553 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19556 XFREE(MTYPE_TMP
, str
);
19559 community_list_perror(vty
, ret
);
19560 return CMD_WARNING_CONFIG_FAILED
;
19563 return CMD_SUCCESS
;
19566 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19567 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19568 NO_STR BGP_STR COMMUNITY_LIST_STR
19569 "Community list number (standard)\n"
19570 "Add an standard community-list entry\n"
19571 "Community list name\n")
19573 /*community-list expanded */
19574 DEFUN (community_list_expanded_all
,
19575 bgp_community_list_expanded_all_cmd
,
19576 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19579 "Community list number (expanded)\n"
19580 "Add an expanded community-list entry\n"
19581 "Community list name\n"
19582 "Sequence number of an entry\n"
19583 "Sequence number\n"
19584 "Specify community to reject\n"
19585 "Specify community to accept\n"
19588 char *cl_name_or_number
= NULL
;
19591 int style
= COMMUNITY_LIST_EXPANDED
;
19594 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19595 seq
= argv
[idx
]->arg
;
19599 argv_find(argv
, argc
, "(100-500)", &idx
);
19600 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19601 cl_name_or_number
= argv
[idx
]->arg
;
19602 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19604 argv_find(argv
, argc
, "AA:NN", &idx
);
19605 char *str
= argv_concat(argv
, argc
, idx
);
19607 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19610 XFREE(MTYPE_TMP
, str
);
19613 /* Display error string. */
19614 community_list_perror(vty
, ret
);
19615 return CMD_WARNING_CONFIG_FAILED
;
19618 return CMD_SUCCESS
;
19621 DEFUN (no_community_list_expanded_all
,
19622 no_bgp_community_list_expanded_all_cmd
,
19623 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19627 "Community list number (expanded)\n"
19628 "Add an expanded community-list entry\n"
19629 "Community list name\n"
19630 "Sequence number of an entry\n"
19631 "Sequence number\n"
19632 "Specify community to reject\n"
19633 "Specify community to accept\n"
19636 char *cl_name_or_number
= NULL
;
19640 int style
= COMMUNITY_LIST_EXPANDED
;
19643 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19644 seq
= argv
[idx
]->arg
;
19647 argv_find(argv
, argc
, "permit", &idx
);
19648 argv_find(argv
, argc
, "deny", &idx
);
19651 direct
= argv_find(argv
, argc
, "permit", &idx
)
19656 argv_find(argv
, argc
, "AA:NN", &idx
);
19657 str
= argv_concat(argv
, argc
, idx
);
19661 argv_find(argv
, argc
, "(100-500)", &idx
);
19662 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19663 cl_name_or_number
= argv
[idx
]->arg
;
19665 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19668 XFREE(MTYPE_TMP
, str
);
19671 community_list_perror(vty
, ret
);
19672 return CMD_WARNING_CONFIG_FAILED
;
19675 return CMD_SUCCESS
;
19678 ALIAS(no_community_list_expanded_all
,
19679 no_bgp_community_list_expanded_all_list_cmd
,
19680 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19681 NO_STR BGP_STR COMMUNITY_LIST_STR
19682 "Community list number (expanded)\n"
19683 "Add an expanded community-list entry\n"
19684 "Community list name\n")
19686 /* Return configuration string of community-list entry. */
19687 static const char *community_list_config_str(struct community_entry
*entry
)
19694 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19695 str
= community_str(entry
->u
.com
, false, false);
19696 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19697 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19699 str
= entry
->config
;
19704 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19706 struct community_entry
*entry
;
19708 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19709 if (entry
== list
->head
) {
19710 if (all_digit(list
->name
))
19711 vty_out(vty
, "Community %s list %s\n",
19712 entry
->style
== COMMUNITY_LIST_STANDARD
19714 : "(expanded) access",
19717 vty_out(vty
, "Named Community %s list %s\n",
19718 entry
->style
== COMMUNITY_LIST_STANDARD
19724 vty_out(vty
, " %s\n",
19725 community_direct_str(entry
->direct
));
19727 vty_out(vty
, " %s %s\n",
19728 community_direct_str(entry
->direct
),
19729 community_list_config_str(entry
));
19733 DEFUN (show_community_list
,
19734 show_bgp_community_list_cmd
,
19735 "show bgp community-list",
19738 "List community-list\n")
19740 struct community_list
*list
;
19741 struct community_list_master
*cm
;
19743 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19745 return CMD_SUCCESS
;
19747 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19748 community_list_show(vty
, list
);
19750 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19751 community_list_show(vty
, list
);
19753 return CMD_SUCCESS
;
19756 DEFUN (show_community_list_arg
,
19757 show_bgp_community_list_arg_cmd
,
19758 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19761 "List community-list\n"
19762 "Community-list number\n"
19763 "Community-list name\n"
19764 "Detailed information on community-list\n")
19766 int idx_comm_list
= 3;
19767 struct community_list
*list
;
19769 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19770 COMMUNITY_LIST_MASTER
);
19772 vty_out(vty
, "%% Can't find community-list\n");
19773 return CMD_WARNING
;
19776 community_list_show(vty
, list
);
19778 return CMD_SUCCESS
;
19782 * Large Community code.
19784 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19785 struct cmd_token
**argv
, int style
,
19786 int reject_all_digit_name
)
19795 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19796 seq
= argv
[idx
]->arg
;
19799 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19802 /* All digit name check. */
19804 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19805 argv_find(argv
, argc
, "(1-99)", &idx
);
19806 argv_find(argv
, argc
, "(100-500)", &idx
);
19807 cl_name
= argv
[idx
]->arg
;
19808 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19809 vty_out(vty
, "%% Community name cannot have all digits\n");
19810 return CMD_WARNING_CONFIG_FAILED
;
19814 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19815 argv_find(argv
, argc
, "LINE", &idx
);
19816 /* Concat community string argument. */
19818 str
= argv_concat(argv
, argc
, idx
);
19822 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19824 /* Free temporary community list string allocated by
19826 XFREE(MTYPE_TMP
, str
);
19829 community_list_perror(vty
, ret
);
19830 return CMD_WARNING_CONFIG_FAILED
;
19832 return CMD_SUCCESS
;
19835 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19836 struct cmd_token
**argv
, int style
)
19844 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19845 seq
= argv
[idx
]->arg
;
19848 argv_find(argv
, argc
, "permit", &idx
);
19849 argv_find(argv
, argc
, "deny", &idx
);
19852 /* Check the list direct. */
19853 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19854 direct
= COMMUNITY_PERMIT
;
19856 direct
= COMMUNITY_DENY
;
19859 argv_find(argv
, argc
, "LINE", &idx
);
19860 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19861 /* Concat community string argument. */
19862 str
= argv_concat(argv
, argc
, idx
);
19866 argv_find(argv
, argc
, "(1-99)", &idx
);
19867 argv_find(argv
, argc
, "(100-500)", &idx
);
19868 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19870 /* Unset community list. */
19871 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19874 /* Free temporary community list string allocated by
19876 XFREE(MTYPE_TMP
, str
);
19879 community_list_perror(vty
, ret
);
19880 return CMD_WARNING_CONFIG_FAILED
;
19883 return CMD_SUCCESS
;
19886 /* "large-community-list" keyword help string. */
19887 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19888 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19890 DEFUN (lcommunity_list_standard
,
19891 bgp_lcommunity_list_standard_cmd
,
19892 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19894 LCOMMUNITY_LIST_STR
19895 "Large Community list number (standard)\n"
19896 "Sequence number of an entry\n"
19897 "Sequence number\n"
19898 "Specify large community to reject\n"
19899 "Specify large community to accept\n"
19900 LCOMMUNITY_VAL_STR
)
19902 return lcommunity_list_set_vty(vty
, argc
, argv
,
19903 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19906 DEFUN (lcommunity_list_expanded
,
19907 bgp_lcommunity_list_expanded_cmd
,
19908 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19910 LCOMMUNITY_LIST_STR
19911 "Large Community list number (expanded)\n"
19912 "Sequence number of an entry\n"
19913 "Sequence number\n"
19914 "Specify large community to reject\n"
19915 "Specify large community to accept\n"
19916 "An ordered list as a regular-expression\n")
19918 return lcommunity_list_set_vty(vty
, argc
, argv
,
19919 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19922 DEFUN (lcommunity_list_name_standard
,
19923 bgp_lcommunity_list_name_standard_cmd
,
19924 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19926 LCOMMUNITY_LIST_STR
19927 "Specify standard large-community-list\n"
19928 "Large Community list name\n"
19929 "Sequence number of an entry\n"
19930 "Sequence number\n"
19931 "Specify large community to reject\n"
19932 "Specify large community to accept\n"
19933 LCOMMUNITY_VAL_STR
)
19935 return lcommunity_list_set_vty(vty
, argc
, argv
,
19936 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19939 DEFUN (lcommunity_list_name_expanded
,
19940 bgp_lcommunity_list_name_expanded_cmd
,
19941 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19943 LCOMMUNITY_LIST_STR
19944 "Specify expanded large-community-list\n"
19945 "Large Community list name\n"
19946 "Sequence number of an entry\n"
19947 "Sequence number\n"
19948 "Specify large community to reject\n"
19949 "Specify large community to accept\n"
19950 "An ordered list as a regular-expression\n")
19952 return lcommunity_list_set_vty(vty
, argc
, argv
,
19953 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19956 DEFUN (no_lcommunity_list_all
,
19957 no_bgp_lcommunity_list_all_cmd
,
19958 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19961 LCOMMUNITY_LIST_STR
19962 "Large Community list number (standard)\n"
19963 "Large Community list number (expanded)\n"
19964 "Large Community list name\n")
19966 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19967 LARGE_COMMUNITY_LIST_STANDARD
);
19970 DEFUN (no_lcommunity_list_name_standard_all
,
19971 no_bgp_lcommunity_list_name_standard_all_cmd
,
19972 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19975 LCOMMUNITY_LIST_STR
19976 "Specify standard large-community-list\n"
19977 "Large Community list name\n")
19979 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19980 LARGE_COMMUNITY_LIST_STANDARD
);
19983 DEFUN (no_lcommunity_list_name_expanded_all
,
19984 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19985 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19988 LCOMMUNITY_LIST_STR
19989 "Specify expanded large-community-list\n"
19990 "Large Community list name\n")
19992 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19993 LARGE_COMMUNITY_LIST_EXPANDED
);
19996 DEFUN (no_lcommunity_list_standard
,
19997 no_bgp_lcommunity_list_standard_cmd
,
19998 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20001 LCOMMUNITY_LIST_STR
20002 "Large Community list number (standard)\n"
20003 "Sequence number of an entry\n"
20004 "Sequence number\n"
20005 "Specify large community to reject\n"
20006 "Specify large community to accept\n"
20007 LCOMMUNITY_VAL_STR
)
20009 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20010 LARGE_COMMUNITY_LIST_STANDARD
);
20013 DEFUN (no_lcommunity_list_expanded
,
20014 no_bgp_lcommunity_list_expanded_cmd
,
20015 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20018 LCOMMUNITY_LIST_STR
20019 "Large Community list number (expanded)\n"
20020 "Sequence number of an entry\n"
20021 "Sequence number\n"
20022 "Specify large community to reject\n"
20023 "Specify large community to accept\n"
20024 "An ordered list as a regular-expression\n")
20026 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20027 LARGE_COMMUNITY_LIST_EXPANDED
);
20030 DEFUN (no_lcommunity_list_name_standard
,
20031 no_bgp_lcommunity_list_name_standard_cmd
,
20032 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20035 LCOMMUNITY_LIST_STR
20036 "Specify standard large-community-list\n"
20037 "Large Community list name\n"
20038 "Sequence number of an entry\n"
20039 "Sequence number\n"
20040 "Specify large community to reject\n"
20041 "Specify large community to accept\n"
20042 LCOMMUNITY_VAL_STR
)
20044 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20045 LARGE_COMMUNITY_LIST_STANDARD
);
20048 DEFUN (no_lcommunity_list_name_expanded
,
20049 no_bgp_lcommunity_list_name_expanded_cmd
,
20050 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20053 LCOMMUNITY_LIST_STR
20054 "Specify expanded large-community-list\n"
20055 "Large community list name\n"
20056 "Sequence number of an entry\n"
20057 "Sequence number\n"
20058 "Specify large community to reject\n"
20059 "Specify large community to accept\n"
20060 "An ordered list as a regular-expression\n")
20062 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20063 LARGE_COMMUNITY_LIST_EXPANDED
);
20066 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20068 struct community_entry
*entry
;
20070 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20071 if (entry
== list
->head
) {
20072 if (all_digit(list
->name
))
20073 vty_out(vty
, "Large community %s list %s\n",
20075 LARGE_COMMUNITY_LIST_STANDARD
20077 : "(expanded) access",
20081 "Named large community %s list %s\n",
20083 LARGE_COMMUNITY_LIST_STANDARD
20089 vty_out(vty
, " %s\n",
20090 community_direct_str(entry
->direct
));
20092 vty_out(vty
, " %s %s\n",
20093 community_direct_str(entry
->direct
),
20094 community_list_config_str(entry
));
20098 DEFUN (show_lcommunity_list
,
20099 show_bgp_lcommunity_list_cmd
,
20100 "show bgp large-community-list",
20103 "List large-community list\n")
20105 struct community_list
*list
;
20106 struct community_list_master
*cm
;
20108 cm
= community_list_master_lookup(bgp_clist
,
20109 LARGE_COMMUNITY_LIST_MASTER
);
20111 return CMD_SUCCESS
;
20113 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20114 lcommunity_list_show(vty
, list
);
20116 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20117 lcommunity_list_show(vty
, list
);
20119 return CMD_SUCCESS
;
20122 DEFUN (show_lcommunity_list_arg
,
20123 show_bgp_lcommunity_list_arg_cmd
,
20124 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20127 "List large-community list\n"
20128 "Large-community-list number\n"
20129 "Large-community-list name\n"
20130 "Detailed information on large-community-list\n")
20132 struct community_list
*list
;
20134 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20135 LARGE_COMMUNITY_LIST_MASTER
);
20137 vty_out(vty
, "%% Can't find large-community-list\n");
20138 return CMD_WARNING
;
20141 lcommunity_list_show(vty
, list
);
20143 return CMD_SUCCESS
;
20146 /* "extcommunity-list" keyword help string. */
20147 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20148 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20150 DEFUN (extcommunity_list_standard
,
20151 bgp_extcommunity_list_standard_cmd
,
20152 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20154 EXTCOMMUNITY_LIST_STR
20155 "Extended Community list number (standard)\n"
20156 "Specify standard extcommunity-list\n"
20157 "Community list name\n"
20158 "Sequence number of an entry\n"
20159 "Sequence number\n"
20160 "Specify community to reject\n"
20161 "Specify community to accept\n"
20162 EXTCOMMUNITY_VAL_STR
)
20164 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20166 char *cl_number_or_name
= NULL
;
20171 argv_find(argv
, argc
, "(1-99)", &idx
);
20172 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20173 cl_number_or_name
= argv
[idx
]->arg
;
20175 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20176 seq
= argv
[idx
]->arg
;
20178 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20180 argv_find(argv
, argc
, "AA:NN", &idx
);
20181 char *str
= argv_concat(argv
, argc
, idx
);
20183 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20186 XFREE(MTYPE_TMP
, str
);
20189 community_list_perror(vty
, ret
);
20190 return CMD_WARNING_CONFIG_FAILED
;
20193 return CMD_SUCCESS
;
20196 DEFUN (extcommunity_list_name_expanded
,
20197 bgp_extcommunity_list_name_expanded_cmd
,
20198 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20200 EXTCOMMUNITY_LIST_STR
20201 "Extended Community list number (expanded)\n"
20202 "Specify expanded extcommunity-list\n"
20203 "Extended Community list name\n"
20204 "Sequence number of an entry\n"
20205 "Sequence number\n"
20206 "Specify community to reject\n"
20207 "Specify community to accept\n"
20208 "An ordered list as a regular-expression\n")
20210 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20212 char *cl_number_or_name
= NULL
;
20216 argv_find(argv
, argc
, "(100-500)", &idx
);
20217 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20218 cl_number_or_name
= argv
[idx
]->arg
;
20220 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20221 seq
= argv
[idx
]->arg
;
20223 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20225 argv_find(argv
, argc
, "LINE", &idx
);
20226 char *str
= argv_concat(argv
, argc
, idx
);
20228 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20231 XFREE(MTYPE_TMP
, str
);
20234 community_list_perror(vty
, ret
);
20235 return CMD_WARNING_CONFIG_FAILED
;
20238 return CMD_SUCCESS
;
20241 DEFUN (no_extcommunity_list_standard_all
,
20242 no_bgp_extcommunity_list_standard_all_cmd
,
20243 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20246 EXTCOMMUNITY_LIST_STR
20247 "Extended Community list number (standard)\n"
20248 "Specify standard extcommunity-list\n"
20249 "Community list name\n"
20250 "Sequence number of an entry\n"
20251 "Sequence number\n"
20252 "Specify community to reject\n"
20253 "Specify community to accept\n"
20254 EXTCOMMUNITY_VAL_STR
)
20256 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20258 char *cl_number_or_name
= NULL
;
20263 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20264 seq
= argv
[idx
]->arg
;
20267 argv_find(argv
, argc
, "permit", &idx
);
20268 argv_find(argv
, argc
, "deny", &idx
);
20270 direct
= argv_find(argv
, argc
, "permit", &idx
)
20275 argv_find(argv
, argc
, "AA:NN", &idx
);
20276 str
= argv_concat(argv
, argc
, idx
);
20280 argv_find(argv
, argc
, "(1-99)", &idx
);
20281 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20282 cl_number_or_name
= argv
[idx
]->arg
;
20284 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20285 seq
, direct
, style
);
20287 XFREE(MTYPE_TMP
, str
);
20290 community_list_perror(vty
, ret
);
20291 return CMD_WARNING_CONFIG_FAILED
;
20294 return CMD_SUCCESS
;
20297 ALIAS(no_extcommunity_list_standard_all
,
20298 no_bgp_extcommunity_list_standard_all_list_cmd
,
20299 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20300 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20301 "Extended Community list number (standard)\n"
20302 "Specify standard extcommunity-list\n"
20303 "Community list name\n")
20305 DEFUN (no_extcommunity_list_expanded_all
,
20306 no_bgp_extcommunity_list_expanded_all_cmd
,
20307 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20310 EXTCOMMUNITY_LIST_STR
20311 "Extended Community list number (expanded)\n"
20312 "Specify expanded extcommunity-list\n"
20313 "Extended Community list name\n"
20314 "Sequence number of an entry\n"
20315 "Sequence number\n"
20316 "Specify community to reject\n"
20317 "Specify community to accept\n"
20318 "An ordered list as a regular-expression\n")
20320 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20322 char *cl_number_or_name
= NULL
;
20327 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20328 seq
= argv
[idx
]->arg
;
20331 argv_find(argv
, argc
, "permit", &idx
);
20332 argv_find(argv
, argc
, "deny", &idx
);
20335 direct
= argv_find(argv
, argc
, "permit", &idx
)
20340 argv_find(argv
, argc
, "LINE", &idx
);
20341 str
= argv_concat(argv
, argc
, idx
);
20345 argv_find(argv
, argc
, "(100-500)", &idx
);
20346 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20347 cl_number_or_name
= argv
[idx
]->arg
;
20349 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20350 seq
, direct
, style
);
20352 XFREE(MTYPE_TMP
, str
);
20355 community_list_perror(vty
, ret
);
20356 return CMD_WARNING_CONFIG_FAILED
;
20359 return CMD_SUCCESS
;
20362 ALIAS(no_extcommunity_list_expanded_all
,
20363 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20364 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20365 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20366 "Extended Community list number (expanded)\n"
20367 "Specify expanded extcommunity-list\n"
20368 "Extended Community list name\n")
20370 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20372 struct community_entry
*entry
;
20374 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20375 if (entry
== list
->head
) {
20376 if (all_digit(list
->name
))
20377 vty_out(vty
, "Extended community %s list %s\n",
20378 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20380 : "(expanded) access",
20384 "Named extended community %s list %s\n",
20385 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20391 vty_out(vty
, " %s\n",
20392 community_direct_str(entry
->direct
));
20394 vty_out(vty
, " %s %s\n",
20395 community_direct_str(entry
->direct
),
20396 community_list_config_str(entry
));
20400 DEFUN (show_extcommunity_list
,
20401 show_bgp_extcommunity_list_cmd
,
20402 "show bgp extcommunity-list",
20405 "List extended-community list\n")
20407 struct community_list
*list
;
20408 struct community_list_master
*cm
;
20410 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20412 return CMD_SUCCESS
;
20414 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20415 extcommunity_list_show(vty
, list
);
20417 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20418 extcommunity_list_show(vty
, list
);
20420 return CMD_SUCCESS
;
20423 DEFUN (show_extcommunity_list_arg
,
20424 show_bgp_extcommunity_list_arg_cmd
,
20425 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20428 "List extended-community list\n"
20429 "Extcommunity-list number\n"
20430 "Extcommunity-list name\n"
20431 "Detailed information on extcommunity-list\n")
20433 int idx_comm_list
= 3;
20434 struct community_list
*list
;
20436 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20437 EXTCOMMUNITY_LIST_MASTER
);
20439 vty_out(vty
, "%% Can't find extcommunity-list\n");
20440 return CMD_WARNING
;
20443 extcommunity_list_show(vty
, list
);
20445 return CMD_SUCCESS
;
20448 /* Display community-list and extcommunity-list configuration. */
20449 static int community_list_config_write(struct vty
*vty
)
20451 struct community_list
*list
;
20452 struct community_entry
*entry
;
20453 struct community_list_master
*cm
;
20456 /* Community-list. */
20457 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20459 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20460 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20462 "bgp community-list %s seq %" PRId64
" %s %s\n",
20463 list
->name
, entry
->seq
,
20464 community_direct_str(entry
->direct
),
20465 community_list_config_str(entry
));
20468 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20469 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20471 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20472 entry
->style
== COMMUNITY_LIST_STANDARD
20475 list
->name
, entry
->seq
,
20476 community_direct_str(entry
->direct
),
20477 community_list_config_str(entry
));
20481 /* Extcommunity-list. */
20482 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20484 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20485 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20487 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20488 list
->name
, entry
->seq
,
20489 community_direct_str(entry
->direct
),
20490 community_list_config_str(entry
));
20493 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20494 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20496 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20497 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20500 list
->name
, entry
->seq
,
20501 community_direct_str(entry
->direct
),
20502 community_list_config_str(entry
));
20507 /* lcommunity-list. */
20508 cm
= community_list_master_lookup(bgp_clist
,
20509 LARGE_COMMUNITY_LIST_MASTER
);
20511 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20512 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20514 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20515 list
->name
, entry
->seq
,
20516 community_direct_str(entry
->direct
),
20517 community_list_config_str(entry
));
20520 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20521 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20523 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20525 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20528 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20529 community_list_config_str(entry
));
20536 static int community_list_config_write(struct vty
*vty
);
20537 static struct cmd_node community_list_node
= {
20538 .name
= "community list",
20539 .node
= COMMUNITY_LIST_NODE
,
20541 .config_write
= community_list_config_write
,
20544 static void community_list_vty(void)
20546 install_node(&community_list_node
);
20548 /* Community-list. */
20549 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20550 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20551 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20552 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20553 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20554 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20555 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20556 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20558 /* Extcommunity-list. */
20559 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20560 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20561 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20562 install_element(CONFIG_NODE
,
20563 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20564 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20565 install_element(CONFIG_NODE
,
20566 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20567 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20568 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20570 /* Large Community List */
20571 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20572 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20573 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20574 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20575 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20576 install_element(CONFIG_NODE
,
20577 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20578 install_element(CONFIG_NODE
,
20579 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20580 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20581 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20582 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20583 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20584 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20585 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20587 bgp_community_list_command_completion_setup();
20590 static struct cmd_node community_alias_node
= {
20591 .name
= "community alias",
20592 .node
= COMMUNITY_ALIAS_NODE
,
20594 .config_write
= bgp_community_alias_write
,
20597 void community_alias_vty(void)
20599 install_node(&community_alias_node
);
20601 /* Community-list. */
20602 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20604 bgp_community_alias_command_completion_setup();