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
:
956 "%% BGP: Enable %s address family for the neighbor %s\n",
957 get_afi_safi_str(afi
, safi
, false), peer
->host
);
960 "%% BGP: Enable %s address family for the neighbor %s",
961 get_afi_safi_str(afi
, safi
, false), peer
->host
);
963 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
966 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
970 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
978 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
979 struct listnode
**nnode
, enum bgp_clear_type stype
)
984 /* if afi/.safi not specified, spin thru all of them */
985 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
988 enum bgp_af_index index
;
990 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
991 paf
= peer
->peer_af_array
[index
];
995 if (paf
&& paf
->subgroup
)
996 SET_FLAG(paf
->subgroup
->sflags
,
997 SUBGRP_STATUS_FORCE_UPDATES
);
1000 tmp_safi
= paf
->safi
;
1001 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1004 if (stype
== BGP_CLEAR_SOFT_NONE
)
1005 ret
= peer_clear(peer
, nnode
);
1007 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1010 /* if afi specified and safi not, spin thru safis on this afi */
1011 } else if (safi
== SAFI_UNSPEC
) {
1014 for (tmp_safi
= SAFI_UNICAST
;
1015 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1016 if (!peer
->afc
[afi
][tmp_safi
])
1019 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1020 if (paf
&& paf
->subgroup
)
1021 SET_FLAG(paf
->subgroup
->sflags
,
1022 SUBGRP_STATUS_FORCE_UPDATES
);
1024 if (stype
== BGP_CLEAR_SOFT_NONE
)
1025 ret
= peer_clear(peer
, nnode
);
1027 ret
= peer_clear_soft(peer
, afi
,
1030 /* both afi/safi specified, let the caller know if not defined */
1032 if (!peer
->afc
[afi
][safi
])
1035 paf
= peer_af_find(peer
, afi
, safi
);
1036 if (paf
&& paf
->subgroup
)
1037 SET_FLAG(paf
->subgroup
->sflags
,
1038 SUBGRP_STATUS_FORCE_UPDATES
);
1040 if (stype
== BGP_CLEAR_SOFT_NONE
)
1041 ret
= peer_clear(peer
, nnode
);
1043 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1049 /* `clear ip bgp' functions. */
1050 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1051 enum clear_sort sort
, enum bgp_clear_type stype
,
1058 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1060 /* Clear all neighbors. */
1062 * Pass along pointer to next node to peer_clear() when walking all
1063 * nodes on the BGP instance as that may get freed if it is a
1066 if (sort
== clear_all
) {
1067 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1069 bgp_peer_gr_flags_update(peer
);
1071 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1072 gr_router_detected
= true;
1074 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1078 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1081 if (gr_router_detected
1082 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1083 bgp_zebra_send_capabilities(bgp
, false);
1084 } else if (!gr_router_detected
1085 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1086 bgp_zebra_send_capabilities(bgp
, true);
1089 /* This is to apply read-only mode on this clear. */
1090 if (stype
== BGP_CLEAR_SOFT_NONE
)
1091 bgp
->update_delay_over
= 0;
1096 /* Clear specified neighbor. */
1097 if (sort
== clear_peer
) {
1100 /* Make sockunion for lookup. */
1101 ret
= str2sockunion(arg
, &su
);
1103 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1105 peer
= peer_lookup_by_hostname(bgp
, arg
);
1108 "Malformed address or name: %s\n",
1114 peer
= peer_lookup(bgp
, &su
);
1117 "%% BGP: Unknown neighbor - \"%s\"\n",
1123 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1124 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1126 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1128 /* if afi/safi not defined for this peer, let caller know */
1130 ret
= BGP_ERR_AF_UNCONFIGURED
;
1133 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1138 /* Clear all neighbors belonging to a specific peer-group. */
1139 if (sort
== clear_group
) {
1140 struct peer_group
*group
;
1142 group
= peer_group_lookup(bgp
, arg
);
1144 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1148 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1149 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1152 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1159 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1160 get_afi_safi_str(afi
, safi
, false), arg
);
1165 /* Clear all external (eBGP) neighbors. */
1166 if (sort
== clear_external
) {
1167 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1168 if (peer
->sort
== BGP_PEER_IBGP
)
1171 bgp_peer_gr_flags_update(peer
);
1173 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1174 gr_router_detected
= true;
1176 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1179 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1184 if (gr_router_detected
1185 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1186 bgp_zebra_send_capabilities(bgp
, false);
1187 } else if (!gr_router_detected
1188 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1189 bgp_zebra_send_capabilities(bgp
, true);
1194 "%% BGP: No external %s peer is configured\n",
1195 get_afi_safi_str(afi
, safi
, false));
1200 /* Clear all neighbors belonging to a specific AS. */
1201 if (sort
== clear_as
) {
1202 as_t as
= strtoul(arg
, NULL
, 10);
1204 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1208 bgp_peer_gr_flags_update(peer
);
1210 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1211 gr_router_detected
= true;
1213 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1216 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1221 if (gr_router_detected
1222 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1223 bgp_zebra_send_capabilities(bgp
, false);
1224 } else if (!gr_router_detected
1225 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1226 bgp_zebra_send_capabilities(bgp
, true);
1231 "%% BGP: No %s peer is configured with AS %s\n",
1232 get_afi_safi_str(afi
, safi
, false), arg
);
1240 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1241 safi_t safi
, enum clear_sort sort
,
1242 enum bgp_clear_type stype
, const char *arg
)
1246 /* BGP structure lookup. */
1248 bgp
= bgp_lookup_by_name(name
);
1250 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1254 bgp
= bgp_get_default();
1256 vty_out(vty
, "No BGP process is configured\n");
1261 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1264 /* clear soft inbound */
1265 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1270 FOREACH_AFI_SAFI (afi
, safi
)
1271 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1272 BGP_CLEAR_SOFT_IN
, NULL
);
1275 /* clear soft outbound */
1276 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1281 FOREACH_AFI_SAFI (afi
, safi
)
1282 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1283 BGP_CLEAR_SOFT_OUT
, NULL
);
1287 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1289 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1292 #ifndef VTYSH_EXTRACT_PL
1293 #include "bgpd/bgp_vty_clippy.c"
1296 DEFUN_HIDDEN (bgp_local_mac
,
1298 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1300 "Local MAC config\n"
1301 "VxLAN Network Identifier\n"
1305 "mac-mobility sequence\n"
1315 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1316 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1317 vty_out(vty
, "%% Malformed MAC address\n");
1320 memset(&ip
, 0, sizeof(ip
));
1321 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1323 bgp
= bgp_get_default();
1325 vty_out(vty
, "Default BGP instance is not there\n");
1329 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1332 vty_out(vty
, "Internal error\n");
1339 DEFUN_HIDDEN (no_bgp_local_mac
,
1340 no_bgp_local_mac_cmd
,
1341 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1344 "Local MAC config\n"
1345 "VxLAN Network Identifier\n"
1356 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1357 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1358 vty_out(vty
, "%% Malformed MAC address\n");
1361 memset(&ip
, 0, sizeof(ip
));
1363 bgp
= bgp_get_default();
1365 vty_out(vty
, "Default BGP instance is not there\n");
1369 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1371 vty_out(vty
, "Internal error\n");
1378 DEFUN (no_synchronization
,
1379 no_synchronization_cmd
,
1380 "no synchronization",
1382 "Perform IGP synchronization\n")
1387 DEFUN (no_auto_summary
,
1388 no_auto_summary_cmd
,
1391 "Enable automatic network number summarization\n")
1396 /* "router bgp" commands. */
1397 DEFUN_NOSH (router_bgp
,
1399 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1403 BGP_INSTANCE_HELP_STR
)
1406 int idx_view_vrf
= 3;
1412 const char *name
= NULL
;
1413 enum bgp_instance_type inst_type
;
1415 // "router bgp" without an ASN
1417 // Pending: Make VRF option available for ASN less config
1418 bgp
= bgp_get_default();
1421 vty_out(vty
, "%% No BGP process is configured\n");
1422 return CMD_WARNING_CONFIG_FAILED
;
1425 if (listcount(bm
->bgp
) > 1) {
1426 vty_out(vty
, "%% Please specify ASN and VRF\n");
1427 return CMD_WARNING_CONFIG_FAILED
;
1433 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1435 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1436 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1437 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1439 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1441 name
= argv
[idx_vrf
]->arg
;
1443 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1444 if (strmatch(name
, VRF_DEFAULT_NAME
))
1447 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1448 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1449 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1452 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1453 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1455 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1457 case BGP_ERR_AS_MISMATCH
:
1458 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1459 return CMD_WARNING_CONFIG_FAILED
;
1460 case BGP_ERR_INSTANCE_MISMATCH
:
1462 "BGP instance name and AS number mismatch\n");
1464 "BGP instance is already running; AS is %u\n",
1466 return CMD_WARNING_CONFIG_FAILED
;
1470 * If we just instantiated the default instance, complete
1471 * any pending VRF-VPN leaking that was configured via
1472 * earlier "router bgp X vrf FOO" blocks.
1474 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1475 vpn_leak_postchange_all();
1477 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1478 bgp_vpn_leak_export(bgp
);
1479 /* Pending: handle when user tries to change a view to vrf n vv.
1483 /* unset the auto created flag as the user config is now present */
1484 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1485 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1490 /* "no router bgp" commands. */
1491 DEFUN (no_router_bgp
,
1493 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1498 BGP_INSTANCE_HELP_STR
)
1504 const char *name
= NULL
;
1506 // "no router bgp" without an ASN
1508 // Pending: Make VRF option available for ASN less config
1509 bgp
= bgp_get_default();
1512 vty_out(vty
, "%% No BGP process is configured\n");
1513 return CMD_WARNING_CONFIG_FAILED
;
1516 if (listcount(bm
->bgp
) > 1) {
1517 vty_out(vty
, "%% Please specify ASN and VRF\n");
1518 return CMD_WARNING_CONFIG_FAILED
;
1522 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1524 return CMD_WARNING_CONFIG_FAILED
;
1527 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1530 name
= argv
[idx_vrf
]->arg
;
1531 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1532 && strmatch(name
, VRF_DEFAULT_NAME
))
1536 /* Lookup bgp structure. */
1537 bgp
= bgp_lookup(as
, name
);
1539 vty_out(vty
, "%% Can't find BGP instance\n");
1540 return CMD_WARNING_CONFIG_FAILED
;
1544 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1546 return CMD_WARNING_CONFIG_FAILED
;
1549 /* Cannot delete default instance if vrf instances exist */
1550 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1551 struct listnode
*node
;
1552 struct bgp
*tmp_bgp
;
1554 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1555 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1557 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1558 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1559 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1560 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1561 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1562 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1563 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1564 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1565 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1566 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1567 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1568 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1569 (bgp
== bgp_get_evpn() &&
1570 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1571 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1572 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1573 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1574 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1575 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1576 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1577 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1578 (hashcount(tmp_bgp
->vnihash
))) {
1580 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1581 return CMD_WARNING_CONFIG_FAILED
;
1592 /* bgp session-dscp */
1594 DEFPY (bgp_session_dscp
,
1595 bgp_session_dscp_cmd
,
1596 "bgp session-dscp (0-63)$dscp",
1598 "Override default (C6) bgp TCP session DSCP value\n"
1599 "Manually configured dscp parameter\n")
1601 bm
->tcp_dscp
= dscp
<< 2;
1606 DEFPY (no_bgp_session_dscp
,
1607 no_bgp_session_dscp_cmd
,
1608 "no bgp session-dscp [(0-63)]",
1611 "Override default (C6) bgp TCP session DSCP value\n"
1612 "Manually configured dscp parameter\n")
1614 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1619 /* BGP router-id. */
1621 DEFPY (bgp_router_id
,
1623 "bgp router-id A.B.C.D",
1625 "Override configured router identifier\n"
1626 "Manually configured router identifier\n")
1628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1629 bgp_router_id_static_set(bgp
, router_id
);
1633 DEFPY (no_bgp_router_id
,
1634 no_bgp_router_id_cmd
,
1635 "no bgp router-id [A.B.C.D]",
1638 "Override configured router identifier\n"
1639 "Manually configured router identifier\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1643 if (router_id_str
) {
1644 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1645 vty_out(vty
, "%% BGP router-id doesn't match\n");
1646 return CMD_WARNING_CONFIG_FAILED
;
1650 router_id
.s_addr
= 0;
1651 bgp_router_id_static_set(bgp
, router_id
);
1656 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1657 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1659 "Add community specific parameters\n"
1660 "Create an alias for a community\n"
1661 "Community (AA:BB or AA:BB:CC)\n"
1664 struct community_alias ca
= {};
1665 struct community_alias
*lookup_community
;
1666 struct community_alias
*lookup_alias
;
1667 struct community
*comm
;
1668 struct lcommunity
*lcomm
;
1669 uint8_t invalid
= 0;
1671 comm
= community_str2com(community
);
1674 community_free(&comm
);
1676 lcomm
= lcommunity_str2com(community
);
1679 lcommunity_free(&lcomm
);
1682 vty_out(vty
, "Invalid community format\n");
1686 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1687 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1689 lookup_community
= bgp_ca_community_lookup(&ca
);
1690 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1693 bgp_ca_alias_delete(&ca
);
1694 bgp_ca_community_delete(&ca
);
1697 /* Lookup if community hash table has an item
1698 * with the same alias name.
1700 strlcpy(ca
.community
, lookup_alias
->community
,
1701 sizeof(ca
.community
));
1702 if (bgp_ca_community_lookup(&ca
)) {
1704 "community (%s) already has this alias (%s)\n",
1705 lookup_alias
->community
,
1706 lookup_alias
->alias
);
1709 bgp_ca_alias_delete(&ca
);
1712 if (lookup_community
) {
1713 /* Lookup if alias hash table has an item
1714 * with the same community.
1716 strlcpy(ca
.alias
, lookup_community
->alias
,
1718 if (bgp_ca_alias_lookup(&ca
)) {
1720 "alias (%s) already has this community (%s)\n",
1721 lookup_community
->alias
,
1722 lookup_community
->community
);
1725 bgp_ca_community_delete(&ca
);
1728 bgp_ca_alias_insert(&ca
);
1729 bgp_ca_community_insert(&ca
);
1735 DEFPY (bgp_global_suppress_fib_pending
,
1736 bgp_global_suppress_fib_pending_cmd
,
1737 "[no] bgp suppress-fib-pending",
1740 "Advertise only routes that are programmed in kernel to peers globally\n")
1742 bm_wait_for_fib_set(!no
);
1747 DEFPY (bgp_suppress_fib_pending
,
1748 bgp_suppress_fib_pending_cmd
,
1749 "[no] bgp suppress-fib-pending",
1752 "Advertise only routes that are programmed in kernel to peers\n")
1754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1756 bgp_suppress_fib_pending_set(bgp
, !no
);
1761 /* BGP Cluster ID. */
1762 DEFUN (bgp_cluster_id
,
1764 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1766 "Configure Route-Reflector Cluster-id\n"
1767 "Route-Reflector Cluster-id in IP address format\n"
1768 "Route-Reflector Cluster-id as 32 bit quantity\n")
1770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1773 struct in_addr cluster
;
1775 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1777 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1778 return CMD_WARNING_CONFIG_FAILED
;
1781 bgp_cluster_id_set(bgp
, &cluster
);
1782 bgp_clear_star_soft_out(vty
, bgp
->name
);
1787 DEFUN (no_bgp_cluster_id
,
1788 no_bgp_cluster_id_cmd
,
1789 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1792 "Configure Route-Reflector Cluster-id\n"
1793 "Route-Reflector Cluster-id in IP address format\n"
1794 "Route-Reflector Cluster-id as 32 bit quantity\n")
1796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1797 bgp_cluster_id_unset(bgp
);
1798 bgp_clear_star_soft_out(vty
, bgp
->name
);
1807 "Disable BGP route installation to RIB (Zebra)\n")
1809 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1811 "%% No-RIB option is already set, nothing to do here.\n");
1815 bgp_option_norib_set_runtime();
1820 DEFPY (no_bgp_norib
,
1825 "Disable BGP route installation to RIB (Zebra)\n")
1827 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1829 "%% No-RIB option is not set, nothing to do here.\n");
1833 bgp_option_norib_unset_runtime();
1838 DEFPY (no_bgp_send_extra_data
,
1839 no_bgp_send_extra_data_cmd
,
1840 "[no] bgp send-extra-data zebra",
1843 "Extra data to Zebra for display/use\n"
1847 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1849 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1854 DEFUN (bgp_confederation_identifier
,
1855 bgp_confederation_identifier_cmd
,
1856 "bgp confederation identifier (1-4294967295)",
1858 "AS confederation parameters\n"
1860 "Set routing domain confederation AS\n")
1862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1866 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1868 bgp_confederation_id_set(bgp
, as
);
1873 DEFUN (no_bgp_confederation_identifier
,
1874 no_bgp_confederation_identifier_cmd
,
1875 "no bgp confederation identifier [(1-4294967295)]",
1878 "AS confederation parameters\n"
1880 "Set routing domain confederation AS\n")
1882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1883 bgp_confederation_id_unset(bgp
);
1888 DEFUN (bgp_confederation_peers
,
1889 bgp_confederation_peers_cmd
,
1890 "bgp confederation peers (1-4294967295)...",
1892 "AS confederation parameters\n"
1893 "Peer ASs in BGP confederation\n"
1896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1901 for (i
= idx_asn
; i
< argc
; i
++) {
1902 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1904 if (bgp
->as
== as
) {
1906 "%% Local member-AS not allowed in confed peer list\n");
1910 bgp_confederation_peers_add(bgp
, as
);
1915 DEFUN (no_bgp_confederation_peers
,
1916 no_bgp_confederation_peers_cmd
,
1917 "no bgp confederation peers (1-4294967295)...",
1920 "AS confederation parameters\n"
1921 "Peer ASs in BGP confederation\n"
1924 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1929 for (i
= idx_asn
; i
< argc
; i
++) {
1930 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1932 bgp_confederation_peers_remove(bgp
, as
);
1938 * Central routine for maximum-paths configuration.
1939 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1940 * @set: 1 for setting values, 0 for removing the max-paths config.
1942 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1943 const char *mpaths
, uint16_t options
,
1946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1947 uint16_t maxpaths
= 0;
1952 afi
= bgp_node_afi(vty
);
1953 safi
= bgp_node_safi(vty
);
1956 maxpaths
= strtol(mpaths
, NULL
, 10);
1957 if (maxpaths
> multipath_num
) {
1959 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1960 maxpaths
, multipath_num
);
1961 return CMD_WARNING_CONFIG_FAILED
;
1963 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1966 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1970 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1971 (set
== 1) ? "" : "un",
1972 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1973 maxpaths
, afi
, safi
);
1974 return CMD_WARNING_CONFIG_FAILED
;
1977 bgp_recalculate_all_bestpaths(bgp
);
1982 DEFUN (bgp_maxmed_admin
,
1983 bgp_maxmed_admin_cmd
,
1984 "bgp max-med administrative ",
1986 "Advertise routes with max-med\n"
1987 "Administratively applied, for an indefinite period\n")
1989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1991 bgp
->v_maxmed_admin
= 1;
1992 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1994 bgp_maxmed_update(bgp
);
1999 DEFUN (bgp_maxmed_admin_medv
,
2000 bgp_maxmed_admin_medv_cmd
,
2001 "bgp max-med administrative (0-4294967295)",
2003 "Advertise routes with max-med\n"
2004 "Administratively applied, for an indefinite period\n"
2005 "Max MED value to be used\n")
2007 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2010 bgp
->v_maxmed_admin
= 1;
2011 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2013 bgp_maxmed_update(bgp
);
2018 DEFUN (no_bgp_maxmed_admin
,
2019 no_bgp_maxmed_admin_cmd
,
2020 "no bgp max-med administrative [(0-4294967295)]",
2023 "Advertise routes with max-med\n"
2024 "Administratively applied, for an indefinite period\n"
2025 "Max MED value to be used\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2028 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2029 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2030 bgp_maxmed_update(bgp
);
2035 DEFUN (bgp_maxmed_onstartup
,
2036 bgp_maxmed_onstartup_cmd
,
2037 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2039 "Advertise routes with max-med\n"
2040 "Effective on a startup\n"
2041 "Time (seconds) period for max-med\n"
2042 "Max MED value to be used\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2047 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2048 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2049 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2050 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2052 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2054 bgp_maxmed_update(bgp
);
2059 DEFUN (no_bgp_maxmed_onstartup
,
2060 no_bgp_maxmed_onstartup_cmd
,
2061 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2064 "Advertise routes with max-med\n"
2065 "Effective on a startup\n"
2066 "Time (seconds) period for max-med\n"
2067 "Max MED value to be used\n")
2069 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2071 /* Cancel max-med onstartup if its on */
2072 if (bgp
->t_maxmed_onstartup
) {
2073 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2074 bgp
->maxmed_onstartup_over
= 1;
2077 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2078 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2080 bgp_maxmed_update(bgp
);
2085 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2086 uint16_t update_delay
,
2087 uint16_t establish_wait
)
2089 struct listnode
*node
, *nnode
;
2091 bool vrf_cfg
= false;
2094 * See if update-delay is set per-vrf and warn user to delete it
2095 * Note that we only need to check this if this is the first time
2096 * setting the global config.
2098 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2099 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2100 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2102 "%% update-delay configuration found in vrf %s\n",
2103 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2113 "%%Failed: global update-delay config not permitted\n");
2117 if (!establish_wait
) { /* update-delay <delay> */
2118 bm
->v_update_delay
= update_delay
;
2119 bm
->v_establish_wait
= bm
->v_update_delay
;
2121 /* update-delay <delay> <establish-wait> */
2122 if (update_delay
< establish_wait
) {
2124 "%%Failed: update-delay less than the establish-wait!\n");
2125 return CMD_WARNING_CONFIG_FAILED
;
2128 bm
->v_update_delay
= update_delay
;
2129 bm
->v_establish_wait
= establish_wait
;
2132 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2133 bgp
->v_update_delay
= bm
->v_update_delay
;
2134 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2140 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2142 struct listnode
*node
, *nnode
;
2145 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2146 bm
->v_establish_wait
= bm
->v_update_delay
;
2148 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2149 bgp
->v_update_delay
= bm
->v_update_delay
;
2150 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2156 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2157 uint16_t establish_wait
)
2159 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2161 /* if configured globally, per-instance config is not allowed */
2162 if (bm
->v_update_delay
) {
2164 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2165 return CMD_WARNING_CONFIG_FAILED
;
2169 if (!establish_wait
) /* update-delay <delay> */
2171 bgp
->v_update_delay
= update_delay
;
2172 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2176 /* update-delay <delay> <establish-wait> */
2177 if (update_delay
< establish_wait
) {
2179 "%%Failed: update-delay less than the establish-wait!\n");
2180 return CMD_WARNING_CONFIG_FAILED
;
2183 bgp
->v_update_delay
= update_delay
;
2184 bgp
->v_establish_wait
= establish_wait
;
2189 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2193 /* If configured globally, cannot remove from one bgp instance */
2194 if (bm
->v_update_delay
) {
2196 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2197 return CMD_WARNING_CONFIG_FAILED
;
2199 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2200 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2205 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2207 /* If configured globally, no need to display per-instance value */
2208 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2209 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2210 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2211 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2216 /* Global update-delay configuration */
2217 DEFPY (bgp_global_update_delay
,
2218 bgp_global_update_delay_cmd
,
2219 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2221 "Force initial delay for best-path and updates for all bgp instances\n"
2222 "Max delay in seconds\n"
2223 "Establish wait in seconds\n")
2225 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2228 /* Global update-delay deconfiguration */
2229 DEFPY (no_bgp_global_update_delay
,
2230 no_bgp_global_update_delay_cmd
,
2231 "no bgp update-delay [(0-3600) [(1-3600)]]",
2234 "Force initial delay for best-path and updates\n"
2235 "Max delay in seconds\n"
2236 "Establish wait in seconds\n")
2238 return bgp_global_update_delay_deconfig_vty(vty
);
2241 /* Update-delay configuration */
2243 DEFPY (bgp_update_delay
,
2244 bgp_update_delay_cmd
,
2245 "update-delay (0-3600)$delay [(1-3600)$wait]",
2246 "Force initial delay for best-path and updates\n"
2247 "Max delay in seconds\n"
2248 "Establish wait in seconds\n")
2250 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2253 /* Update-delay deconfiguration */
2254 DEFPY (no_bgp_update_delay
,
2255 no_bgp_update_delay_cmd
,
2256 "no update-delay [(0-3600) [(1-3600)]]",
2258 "Force initial delay for best-path and updates\n"
2259 "Max delay in seconds\n"
2260 "Establish wait in seconds\n")
2262 return bgp_update_delay_deconfig_vty(vty
);
2266 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2269 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2271 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2272 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2277 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2282 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2283 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2288 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2291 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2292 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2293 vty_out(vty
, " write-quanta %d\n", quanta
);
2296 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2299 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2300 if (quanta
!= BGP_READ_PACKET_MAX
)
2301 vty_out(vty
, " read-quanta %d\n", quanta
);
2304 /* Packet quanta configuration
2306 * XXX: The value set here controls the size of a stack buffer in the IO
2307 * thread. When changing these limits be careful to prevent stack overflow.
2309 * Furthermore, the maximums used here should correspond to
2310 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2312 DEFPY (bgp_wpkt_quanta
,
2313 bgp_wpkt_quanta_cmd
,
2314 "[no] write-quanta (1-64)$quanta",
2316 "How many packets to write to peer socket per run\n"
2317 "Number of packets\n")
2319 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2322 DEFPY (bgp_rpkt_quanta
,
2323 bgp_rpkt_quanta_cmd
,
2324 "[no] read-quanta (1-10)$quanta",
2326 "How many packets to read from peer socket per I/O cycle\n"
2327 "Number of packets\n")
2329 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2332 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2334 if (!bgp
->heuristic_coalesce
)
2335 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2339 DEFUN (bgp_coalesce_time
,
2340 bgp_coalesce_time_cmd
,
2341 "coalesce-time (0-4294967295)",
2342 "Subgroup coalesce timer\n"
2343 "Subgroup coalesce timer value (in ms)\n")
2345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2349 bgp
->heuristic_coalesce
= false;
2351 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2352 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2357 DEFUN (no_bgp_coalesce_time
,
2358 no_bgp_coalesce_time_cmd
,
2359 "no coalesce-time (0-4294967295)",
2361 "Subgroup coalesce timer\n"
2362 "Subgroup coalesce timer value (in ms)\n")
2364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2366 bgp
->heuristic_coalesce
= true;
2367 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2371 /* Maximum-paths configuration */
2372 DEFUN (bgp_maxpaths
,
2374 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2375 "Forward packets over multiple paths\n"
2376 "Number of paths\n")
2379 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2380 argv
[idx_number
]->arg
, 0, 1);
2383 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2384 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2385 "Forward packets over multiple paths\n"
2386 "Number of paths\n")
2388 DEFUN (bgp_maxpaths_ibgp
,
2389 bgp_maxpaths_ibgp_cmd
,
2390 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2391 "Forward packets over multiple paths\n"
2393 "Number of paths\n")
2396 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2397 argv
[idx_number
]->arg
, 0, 1);
2400 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2401 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2402 "Forward packets over multiple paths\n"
2404 "Number of paths\n")
2406 DEFUN (bgp_maxpaths_ibgp_cluster
,
2407 bgp_maxpaths_ibgp_cluster_cmd
,
2408 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2409 "Forward packets over multiple paths\n"
2412 "Match the cluster length\n")
2415 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2416 argv
[idx_number
]->arg
, true, 1);
2419 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2420 "maximum-paths ibgp " CMD_RANGE_STR(
2421 1, MULTIPATH_NUM
) " equal-cluster-length",
2422 "Forward packets over multiple paths\n"
2425 "Match the cluster length\n")
2427 DEFUN (no_bgp_maxpaths
,
2428 no_bgp_maxpaths_cmd
,
2429 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2431 "Forward packets over multiple paths\n"
2432 "Number of paths\n")
2434 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2437 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2438 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2439 "Forward packets over multiple paths\n"
2440 "Number of paths\n")
2442 DEFUN (no_bgp_maxpaths_ibgp
,
2443 no_bgp_maxpaths_ibgp_cmd
,
2444 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2446 "Forward packets over multiple paths\n"
2449 "Match the cluster length\n")
2451 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2454 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2455 "no maximum-paths ibgp [" CMD_RANGE_STR(
2456 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2458 "Forward packets over multiple paths\n"
2461 "Match the cluster length\n")
2463 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2464 afi_t afi
, safi_t safi
)
2466 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2467 vty_out(vty
, " maximum-paths %d\n",
2468 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2471 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2472 vty_out(vty
, " maximum-paths ibgp %d",
2473 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2474 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2475 vty_out(vty
, " equal-cluster-length");
2484 "timers bgp (0-65535) (0-65535)",
2485 "Adjust routing timers\n"
2487 "Keepalive interval\n"
2490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2492 int idx_number_2
= 3;
2493 unsigned long keepalive
= 0;
2494 unsigned long holdtime
= 0;
2496 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2497 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2499 /* Holdtime value check. */
2500 if (holdtime
< 3 && holdtime
!= 0) {
2502 "%% hold time value must be either 0 or greater than 3\n");
2503 return CMD_WARNING_CONFIG_FAILED
;
2506 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2507 BGP_DEFAULT_DELAYOPEN
);
2512 DEFUN (no_bgp_timers
,
2514 "no timers bgp [(0-65535) (0-65535)]",
2516 "Adjust routing timers\n"
2518 "Keepalive interval\n"
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2522 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2523 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2528 /* BGP minimum holdtime. */
2530 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2531 "bgp minimum-holdtime (1-65535)",
2532 "BGP specific commands\n"
2533 "BGP minimum holdtime\n"
2536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2538 unsigned long min_holdtime
;
2540 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2542 bgp
->default_min_holdtime
= min_holdtime
;
2547 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2548 "no bgp minimum-holdtime [(1-65535)]",
2550 "BGP specific commands\n"
2551 "BGP minimum holdtime\n"
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 bgp
->default_min_holdtime
= 0;
2561 DEFUN (bgp_client_to_client_reflection
,
2562 bgp_client_to_client_reflection_cmd
,
2563 "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 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2570 bgp_clear_star_soft_out(vty
, bgp
->name
);
2575 DEFUN (no_bgp_client_to_client_reflection
,
2576 no_bgp_client_to_client_reflection_cmd
,
2577 "no bgp client-to-client reflection",
2580 "Configure client to client route reflection\n"
2581 "reflection of routes allowed\n")
2583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2584 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2585 bgp_clear_star_soft_out(vty
, bgp
->name
);
2590 /* "bgp always-compare-med" configuration. */
2591 DEFUN (bgp_always_compare_med
,
2592 bgp_always_compare_med_cmd
,
2593 "bgp always-compare-med",
2595 "Allow comparing MED from different neighbors\n")
2597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2598 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2599 bgp_recalculate_all_bestpaths(bgp
);
2604 DEFUN (no_bgp_always_compare_med
,
2605 no_bgp_always_compare_med_cmd
,
2606 "no bgp always-compare-med",
2609 "Allow comparing MED from different neighbors\n")
2611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2612 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2613 bgp_recalculate_all_bestpaths(bgp
);
2619 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2620 "bgp ebgp-requires-policy",
2622 "Require in and out policy for eBGP peers (RFC8212)\n")
2624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2625 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2629 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2630 "no bgp ebgp-requires-policy",
2633 "Require in and out policy for eBGP peers (RFC8212)\n")
2635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2636 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2640 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2641 "bgp suppress-duplicates",
2643 "Suppress duplicate updates if the route actually not changed\n")
2645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2646 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2650 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2651 "no bgp suppress-duplicates",
2654 "Suppress duplicate updates if the route actually not changed\n")
2656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2657 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2661 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2662 "bgp reject-as-sets",
2664 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2667 struct listnode
*node
, *nnode
;
2670 bgp
->reject_as_sets
= true;
2672 /* Reset existing BGP sessions to reject routes
2673 * with aspath containing AS_SET or AS_CONFED_SET.
2675 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2676 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2677 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2678 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2679 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2686 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2687 "no bgp reject-as-sets",
2690 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 struct listnode
*node
, *nnode
;
2696 bgp
->reject_as_sets
= false;
2698 /* Reset existing BGP sessions to reject routes
2699 * with aspath containing AS_SET or AS_CONFED_SET.
2701 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2702 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2703 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2704 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2705 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2712 /* "bgp deterministic-med" configuration. */
2713 DEFUN (bgp_deterministic_med
,
2714 bgp_deterministic_med_cmd
,
2715 "bgp deterministic-med",
2717 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2722 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2723 bgp_recalculate_all_bestpaths(bgp
);
2729 DEFUN (no_bgp_deterministic_med
,
2730 no_bgp_deterministic_med_cmd
,
2731 "no bgp deterministic-med",
2734 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2736 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2737 int bestpath_per_as_used
;
2741 struct listnode
*node
, *nnode
;
2743 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2744 bestpath_per_as_used
= 0;
2746 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2747 FOREACH_AFI_SAFI (afi
, safi
)
2748 if (bgp_addpath_dmed_required(
2749 peer
->addpath_type
[afi
][safi
])) {
2750 bestpath_per_as_used
= 1;
2754 if (bestpath_per_as_used
)
2758 if (bestpath_per_as_used
) {
2760 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2761 return CMD_WARNING_CONFIG_FAILED
;
2763 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2764 bgp_recalculate_all_bestpaths(bgp
);
2771 /* "bgp graceful-restart mode" configuration. */
2772 DEFUN (bgp_graceful_restart
,
2773 bgp_graceful_restart_cmd
,
2774 "bgp graceful-restart",
2779 int ret
= BGP_GR_FAILURE
;
2781 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2782 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2786 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2788 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2791 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2792 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2794 "Graceful restart configuration changed, reset all peers to take effect\n");
2795 return bgp_vty_return(vty
, ret
);
2798 DEFUN (no_bgp_graceful_restart
,
2799 no_bgp_graceful_restart_cmd
,
2800 "no bgp graceful-restart",
2806 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2808 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2809 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2811 int ret
= BGP_GR_FAILURE
;
2813 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2815 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2818 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2819 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2821 "Graceful restart configuration changed, reset all peers to take effect\n");
2823 return bgp_vty_return(vty
, ret
);
2826 DEFUN (bgp_graceful_restart_stalepath_time
,
2827 bgp_graceful_restart_stalepath_time_cmd
,
2828 "bgp graceful-restart stalepath-time (1-4095)",
2830 "Graceful restart capability parameters\n"
2831 "Set the max time to hold onto restarting peer's stale paths\n"
2832 "Delay value (seconds)\n")
2834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2838 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2839 bgp
->stalepath_time
= stalepath
;
2843 DEFUN (bgp_graceful_restart_restart_time
,
2844 bgp_graceful_restart_restart_time_cmd
,
2845 "bgp graceful-restart restart-time (0-4095)",
2847 "Graceful restart capability parameters\n"
2848 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2849 "Delay value (seconds)\n")
2851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2855 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2856 bgp
->restart_time
= restart
;
2860 DEFUN (bgp_graceful_restart_select_defer_time
,
2861 bgp_graceful_restart_select_defer_time_cmd
,
2862 "bgp graceful-restart select-defer-time (0-3600)",
2864 "Graceful restart capability parameters\n"
2865 "Set the time to defer the BGP route selection after restart\n"
2866 "Delay value (seconds, 0 - disable)\n")
2868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2870 uint32_t defer_time
;
2872 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2873 bgp
->select_defer_time
= defer_time
;
2874 if (defer_time
== 0)
2875 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2877 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2882 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2883 no_bgp_graceful_restart_stalepath_time_cmd
,
2884 "no bgp graceful-restart stalepath-time [(1-4095)]",
2887 "Graceful restart capability parameters\n"
2888 "Set the max time to hold onto restarting peer's stale paths\n"
2889 "Delay value (seconds)\n")
2891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2893 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2897 DEFUN (no_bgp_graceful_restart_restart_time
,
2898 no_bgp_graceful_restart_restart_time_cmd
,
2899 "no bgp graceful-restart restart-time [(0-4095)]",
2902 "Graceful restart capability parameters\n"
2903 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2904 "Delay value (seconds)\n")
2906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2908 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2912 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2913 no_bgp_graceful_restart_select_defer_time_cmd
,
2914 "no bgp graceful-restart select-defer-time [(0-3600)]",
2917 "Graceful restart capability parameters\n"
2918 "Set the time to defer the BGP route selection after restart\n"
2919 "Delay value (seconds)\n")
2921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2923 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2924 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2929 DEFUN (bgp_graceful_restart_preserve_fw
,
2930 bgp_graceful_restart_preserve_fw_cmd
,
2931 "bgp graceful-restart preserve-fw-state",
2933 "Graceful restart capability parameters\n"
2934 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2937 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2941 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2942 no_bgp_graceful_restart_preserve_fw_cmd
,
2943 "no bgp graceful-restart preserve-fw-state",
2946 "Graceful restart capability parameters\n"
2947 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2954 DEFPY (bgp_graceful_restart_notification
,
2955 bgp_graceful_restart_notification_cmd
,
2956 "[no$no] bgp graceful-restart notification",
2959 "Graceful restart capability parameters\n"
2960 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
2962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2965 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2967 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2972 DEFPY (bgp_administrative_reset
,
2973 bgp_administrative_reset_cmd
,
2974 "[no$no] bgp hard-administrative-reset",
2977 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
2979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2982 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2984 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
2989 DEFUN (bgp_graceful_restart_disable
,
2990 bgp_graceful_restart_disable_cmd
,
2991 "bgp graceful-restart-disable",
2995 int ret
= BGP_GR_FAILURE
;
2997 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2999 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3003 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3005 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3008 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3010 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3012 "Graceful restart configuration changed, reset all peers to take effect\n");
3014 return bgp_vty_return(vty
, ret
);
3017 DEFUN (no_bgp_graceful_restart_disable
,
3018 no_bgp_graceful_restart_disable_cmd
,
3019 "no bgp graceful-restart-disable",
3025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3027 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3029 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3031 int ret
= BGP_GR_FAILURE
;
3033 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3035 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3038 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3040 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3042 "Graceful restart configuration changed, reset all peers to take effect\n");
3044 return bgp_vty_return(vty
, ret
);
3047 DEFUN (bgp_neighbor_graceful_restart_set
,
3048 bgp_neighbor_graceful_restart_set_cmd
,
3049 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3057 int ret
= BGP_GR_FAILURE
;
3059 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3061 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3063 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3065 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3067 return CMD_WARNING_CONFIG_FAILED
;
3069 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3071 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3072 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3074 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3076 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3078 "Graceful restart configuration changed, reset this peer to take effect\n");
3080 return bgp_vty_return(vty
, ret
);
3083 DEFUN (no_bgp_neighbor_graceful_restart
,
3084 no_bgp_neighbor_graceful_restart_set_cmd
,
3085 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3093 int ret
= BGP_GR_FAILURE
;
3096 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3098 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3100 return CMD_WARNING_CONFIG_FAILED
;
3102 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3104 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3106 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3108 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3109 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3111 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3113 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3115 "Graceful restart configuration changed, reset this peer to take effect\n");
3117 return bgp_vty_return(vty
, ret
);
3120 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3121 bgp_neighbor_graceful_restart_helper_set_cmd
,
3122 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3125 GR_NEIGHBOR_HELPER_CMD
3130 int ret
= BGP_GR_FAILURE
;
3132 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3134 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3136 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3138 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3141 return CMD_WARNING_CONFIG_FAILED
;
3144 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3146 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3147 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3149 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3151 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3153 "Graceful restart configuration changed, reset this peer to take effect\n");
3155 return bgp_vty_return(vty
, ret
);
3158 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3159 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3160 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3164 NO_GR_NEIGHBOR_HELPER_CMD
3168 int ret
= BGP_GR_FAILURE
;
3171 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3173 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3175 return CMD_WARNING_CONFIG_FAILED
;
3177 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3179 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3181 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3183 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3184 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3186 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3188 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3190 "Graceful restart configuration changed, reset this peer to take effect\n");
3192 return bgp_vty_return(vty
, ret
);
3195 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3196 bgp_neighbor_graceful_restart_disable_set_cmd
,
3197 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3200 GR_NEIGHBOR_DISABLE_CMD
3205 int ret
= BGP_GR_FAILURE
;
3207 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3209 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3211 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3213 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3215 return CMD_WARNING_CONFIG_FAILED
;
3217 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3219 if (peer
->bgp
->t_startup
)
3220 bgp_peer_gr_flags_update(peer
);
3222 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3223 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3225 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3227 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3229 "Graceful restart configuration changed, reset this peer to take effect\n");
3231 return bgp_vty_return(vty
, ret
);
3234 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3235 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3236 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3240 NO_GR_NEIGHBOR_DISABLE_CMD
3244 int ret
= BGP_GR_FAILURE
;
3247 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3251 return CMD_WARNING_CONFIG_FAILED
;
3253 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3255 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3257 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3259 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3260 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3262 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3264 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3266 "Graceful restart configuration changed, reset this peer to take effect\n");
3268 return bgp_vty_return(vty
, ret
);
3271 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3272 bgp_graceful_restart_disable_eor_cmd
,
3273 "bgp graceful-restart disable-eor",
3275 "Graceful restart configuration parameters\n"
3276 "Disable EOR Check\n")
3278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3279 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3284 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3285 no_bgp_graceful_restart_disable_eor_cmd
,
3286 "no bgp graceful-restart disable-eor",
3289 "Graceful restart configuration parameters\n"
3290 "Disable EOR Check\n")
3292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3293 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3298 DEFUN (bgp_graceful_restart_rib_stale_time
,
3299 bgp_graceful_restart_rib_stale_time_cmd
,
3300 "bgp graceful-restart rib-stale-time (1-3600)",
3302 "Graceful restart configuration parameters\n"
3303 "Specify the stale route removal timer in rib\n"
3304 "Delay value (seconds)\n")
3306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3308 uint32_t stale_time
;
3310 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3311 bgp
->rib_stale_time
= stale_time
;
3312 /* Send the stale timer update message to RIB */
3313 if (bgp_zebra_stale_timer_update(bgp
))
3319 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3320 no_bgp_graceful_restart_rib_stale_time_cmd
,
3321 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3324 "Graceful restart configuration parameters\n"
3325 "Specify the stale route removal timer in rib\n"
3326 "Delay value (seconds)\n")
3328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3330 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3331 /* Send the stale timer update message to RIB */
3332 if (bgp_zebra_stale_timer_update(bgp
))
3338 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3339 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3341 "Enable Long-lived Graceful Restart\n"
3342 "Specifies maximum time to wait before purging long-lived stale routes\n"
3343 "Stale time value (seconds)\n")
3345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3347 uint32_t llgr_stale_time
;
3349 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3350 bgp
->llgr_stale_time
= llgr_stale_time
;
3355 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3356 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3358 "Enable Long-lived Graceful Restart\n"
3359 "Specifies maximum time to wait before purging long-lived stale routes\n"
3360 "Stale time value (seconds)\n")
3362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3364 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3369 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3372 bgp_static_redo_import_check(bgp
);
3373 bgp_redistribute_redo(bgp
);
3374 bgp_clear_star_soft_out(vty
, bgp
->name
);
3375 bgp_clear_star_soft_in(vty
, bgp
->name
);
3378 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3380 struct listnode
*node
, *nnode
;
3382 bool vrf_cfg
= false;
3384 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3387 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3388 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3389 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3391 "%% graceful-shutdown configuration found in vrf %s\n",
3392 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3393 VRF_DEFAULT_NAME
: bgp
->name
);
3400 "%%Failed: global graceful-shutdown not permitted\n");
3404 /* Set flag globally */
3405 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3407 /* Initiate processing for all BGP instances. */
3408 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3409 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3414 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3416 struct listnode
*node
, *nnode
;
3419 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3422 /* Unset flag globally */
3423 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3425 /* Initiate processing for all BGP instances. */
3426 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3427 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3432 /* "bgp graceful-shutdown" configuration */
3433 DEFUN (bgp_graceful_shutdown
,
3434 bgp_graceful_shutdown_cmd
,
3435 "bgp graceful-shutdown",
3437 "Graceful shutdown parameters\n")
3439 if (vty
->node
== CONFIG_NODE
)
3440 return bgp_global_graceful_shutdown_config_vty(vty
);
3442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3444 /* if configured globally, per-instance config is not allowed */
3445 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3447 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3448 return CMD_WARNING_CONFIG_FAILED
;
3451 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3452 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3453 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3459 DEFUN (no_bgp_graceful_shutdown
,
3460 no_bgp_graceful_shutdown_cmd
,
3461 "no bgp graceful-shutdown",
3464 "Graceful shutdown parameters\n")
3466 if (vty
->node
== CONFIG_NODE
)
3467 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3469 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3471 /* If configured globally, cannot remove from one bgp instance */
3472 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3474 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3475 return CMD_WARNING_CONFIG_FAILED
;
3478 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3479 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3480 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3486 /* "bgp fast-external-failover" configuration. */
3487 DEFUN (bgp_fast_external_failover
,
3488 bgp_fast_external_failover_cmd
,
3489 "bgp fast-external-failover",
3491 "Immediately reset session if a link to a directly connected external peer goes down\n")
3493 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3494 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3498 DEFUN (no_bgp_fast_external_failover
,
3499 no_bgp_fast_external_failover_cmd
,
3500 "no bgp fast-external-failover",
3503 "Immediately reset session if a link to a directly connected external peer goes down\n")
3505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3506 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3510 /* "bgp bestpath compare-routerid" configuration. */
3511 DEFUN (bgp_bestpath_compare_router_id
,
3512 bgp_bestpath_compare_router_id_cmd
,
3513 "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 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3520 bgp_recalculate_all_bestpaths(bgp
);
3525 DEFUN (no_bgp_bestpath_compare_router_id
,
3526 no_bgp_bestpath_compare_router_id_cmd
,
3527 "no bgp bestpath compare-routerid",
3530 "Change the default bestpath selection\n"
3531 "Compare router-id for identical EBGP paths\n")
3533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3534 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3535 bgp_recalculate_all_bestpaths(bgp
);
3540 /* "bgp bestpath as-path ignore" configuration. */
3541 DEFUN (bgp_bestpath_aspath_ignore
,
3542 bgp_bestpath_aspath_ignore_cmd
,
3543 "bgp bestpath as-path ignore",
3545 "Change the default bestpath selection\n"
3546 "AS-path attribute\n"
3547 "Ignore as-path length in selecting a route\n")
3549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3550 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3551 bgp_recalculate_all_bestpaths(bgp
);
3556 DEFUN (no_bgp_bestpath_aspath_ignore
,
3557 no_bgp_bestpath_aspath_ignore_cmd
,
3558 "no bgp bestpath as-path ignore",
3561 "Change the default bestpath selection\n"
3562 "AS-path attribute\n"
3563 "Ignore as-path length in selecting a route\n")
3565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3566 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3567 bgp_recalculate_all_bestpaths(bgp
);
3572 /* "bgp bestpath as-path confed" configuration. */
3573 DEFUN (bgp_bestpath_aspath_confed
,
3574 bgp_bestpath_aspath_confed_cmd
,
3575 "bgp bestpath as-path confed",
3577 "Change the default bestpath selection\n"
3578 "AS-path attribute\n"
3579 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3582 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3583 bgp_recalculate_all_bestpaths(bgp
);
3588 DEFUN (no_bgp_bestpath_aspath_confed
,
3589 no_bgp_bestpath_aspath_confed_cmd
,
3590 "no bgp bestpath as-path confed",
3593 "Change the default bestpath selection\n"
3594 "AS-path attribute\n"
3595 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3598 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3599 bgp_recalculate_all_bestpaths(bgp
);
3604 /* "bgp bestpath as-path multipath-relax" configuration. */
3605 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3606 bgp_bestpath_aspath_multipath_relax_cmd
,
3607 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3609 "Change the default bestpath selection\n"
3610 "AS-path attribute\n"
3611 "Allow load sharing across routes that have different AS paths (but same length)\n"
3612 "Generate an AS_SET\n"
3613 "Do not generate an AS_SET\n")
3615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3617 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3619 /* no-as-set is now the default behavior so we can silently
3621 if (argv_find(argv
, argc
, "as-set", &idx
))
3622 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3624 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3626 bgp_recalculate_all_bestpaths(bgp
);
3631 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3632 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3633 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3636 "Change the default bestpath selection\n"
3637 "AS-path attribute\n"
3638 "Allow load sharing across routes that have different AS paths (but same length)\n"
3639 "Generate an AS_SET\n"
3640 "Do not generate an AS_SET\n")
3642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3643 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3644 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3645 bgp_recalculate_all_bestpaths(bgp
);
3650 /* "bgp bestpath peer-type multipath-relax" configuration. */
3651 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3652 bgp_bestpath_peer_type_multipath_relax_cmd
,
3653 "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 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3661 bgp_recalculate_all_bestpaths(bgp
);
3666 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3667 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3668 "no bgp bestpath peer-type multipath-relax",
3670 "Change the default bestpath selection\n"
3672 "Allow load sharing across routes learned from different peer types\n")
3674 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3675 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3676 bgp_recalculate_all_bestpaths(bgp
);
3681 /* "bgp log-neighbor-changes" configuration. */
3682 DEFUN (bgp_log_neighbor_changes
,
3683 bgp_log_neighbor_changes_cmd
,
3684 "bgp log-neighbor-changes",
3686 "Log neighbor up/down and reset reason\n")
3688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3689 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3693 DEFUN (no_bgp_log_neighbor_changes
,
3694 no_bgp_log_neighbor_changes_cmd
,
3695 "no bgp log-neighbor-changes",
3698 "Log neighbor up/down and reset reason\n")
3700 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3701 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3705 /* "bgp bestpath med" configuration. */
3706 DEFUN (bgp_bestpath_med
,
3707 bgp_bestpath_med_cmd
,
3708 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3710 "Change the default bestpath selection\n"
3712 "Compare MED among confederation paths\n"
3713 "Treat missing MED as the least preferred one\n"
3714 "Treat missing MED as the least preferred one\n"
3715 "Compare MED among confederation paths\n")
3717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 if (argv_find(argv
, argc
, "confed", &idx
))
3721 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3723 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3724 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3726 bgp_recalculate_all_bestpaths(bgp
);
3731 DEFUN (no_bgp_bestpath_med
,
3732 no_bgp_bestpath_med_cmd
,
3733 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3736 "Change the default bestpath selection\n"
3738 "Compare MED among confederation paths\n"
3739 "Treat missing MED as the least preferred one\n"
3740 "Treat missing MED as the least preferred one\n"
3741 "Compare MED among confederation paths\n")
3743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3746 if (argv_find(argv
, argc
, "confed", &idx
))
3747 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3749 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3750 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3752 bgp_recalculate_all_bestpaths(bgp
);
3757 /* "bgp bestpath bandwidth" configuration. */
3758 DEFPY (bgp_bestpath_bw
,
3759 bgp_bestpath_bw_cmd
,
3760 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3762 "Change the default bestpath selection\n"
3763 "Link Bandwidth attribute\n"
3764 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3765 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3766 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3773 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3774 return CMD_ERR_INCOMPLETE
;
3776 if (!strcmp(bw_cfg
, "ignore"))
3777 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3778 else if (!strcmp(bw_cfg
, "skip-missing"))
3779 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3780 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3781 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3783 return CMD_ERR_NO_MATCH
;
3785 /* This config is used in route install, so redo that. */
3786 FOREACH_AFI_SAFI (afi
, safi
) {
3787 if (!bgp_fibupd_safi(safi
))
3789 bgp_zebra_announce_table(bgp
, afi
, safi
);
3795 DEFPY (no_bgp_bestpath_bw
,
3796 no_bgp_bestpath_bw_cmd
,
3797 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3800 "Change the default bestpath selection\n"
3801 "Link Bandwidth attribute\n"
3802 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3803 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3804 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3806 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3810 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3812 /* This config is used in route install, so redo that. */
3813 FOREACH_AFI_SAFI (afi
, safi
) {
3814 if (!bgp_fibupd_safi(safi
))
3816 bgp_zebra_announce_table(bgp
, afi
, safi
);
3821 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3822 "[no] bgp default <ipv4-unicast|"
3825 "ipv4-labeled-unicast|"
3830 "ipv6-labeled-unicast|"
3832 "l2vpn-evpn>$afi_safi",
3835 "Configure BGP defaults\n"
3836 "Activate ipv4-unicast for a peer by default\n"
3837 "Activate ipv4-multicast for a peer by default\n"
3838 "Activate ipv4-vpn for a peer by default\n"
3839 "Activate ipv4-labeled-unicast for a peer by default\n"
3840 "Activate ipv4-flowspec for a peer by default\n"
3841 "Activate ipv6-unicast for a peer by default\n"
3842 "Activate ipv6-multicast for a peer by default\n"
3843 "Activate ipv6-vpn for a peer by default\n"
3844 "Activate ipv6-labeled-unicast for a peer by default\n"
3845 "Activate ipv6-flowspec for a peer by default\n"
3846 "Activate l2vpn-evpn for a peer by default\n")
3848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3849 char afi_safi_str
[strlen(afi_safi
) + 1];
3850 char *afi_safi_str_tok
;
3852 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3853 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3854 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3855 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3859 * Impossible situation but making coverity happy
3861 assert(afi
!= AFI_MAX
);
3863 if (strmatch(safi_str
, "labeled"))
3864 safi
= bgp_vty_safi_from_str("labeled-unicast");
3866 safi
= bgp_vty_safi_from_str(safi_str
);
3868 assert(safi
!= SAFI_MAX
);
3870 bgp
->default_af
[afi
][safi
] = false;
3872 if ((safi
== SAFI_LABELED_UNICAST
3873 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3874 || (safi
== SAFI_UNICAST
3875 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3876 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3878 bgp
->default_af
[afi
][safi
] = true;
3884 /* Display hostname in certain command outputs */
3885 DEFUN (bgp_default_show_hostname
,
3886 bgp_default_show_hostname_cmd
,
3887 "bgp default show-hostname",
3889 "Configure BGP defaults\n"
3890 "Show hostname in certain command outputs\n")
3892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3893 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3897 DEFUN (no_bgp_default_show_hostname
,
3898 no_bgp_default_show_hostname_cmd
,
3899 "no bgp default show-hostname",
3902 "Configure BGP defaults\n"
3903 "Show hostname in certain command outputs\n")
3905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3906 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3910 /* Display hostname in certain command outputs */
3911 DEFUN (bgp_default_show_nexthop_hostname
,
3912 bgp_default_show_nexthop_hostname_cmd
,
3913 "bgp default show-nexthop-hostname",
3915 "Configure BGP defaults\n"
3916 "Show hostname for nexthop in certain command outputs\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3919 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3923 DEFUN (no_bgp_default_show_nexthop_hostname
,
3924 no_bgp_default_show_nexthop_hostname_cmd
,
3925 "no bgp default show-nexthop-hostname",
3928 "Configure BGP defaults\n"
3929 "Show hostname for nexthop in certain command outputs\n")
3931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3932 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3936 /* "bgp network import-check" configuration. */
3937 DEFUN (bgp_network_import_check
,
3938 bgp_network_import_check_cmd
,
3939 "bgp network import-check",
3941 "BGP network command\n"
3942 "Check BGP network route exists in IGP\n")
3944 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3945 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3946 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3947 bgp_static_redo_import_check(bgp
);
3953 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3954 "bgp network import-check exact",
3956 "BGP network command\n"
3957 "Check BGP network route exists in IGP\n"
3958 "Match route precisely\n")
3960 DEFUN (no_bgp_network_import_check
,
3961 no_bgp_network_import_check_cmd
,
3962 "no bgp network import-check",
3965 "BGP network command\n"
3966 "Check BGP network route exists in IGP\n")
3968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3969 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3970 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3971 bgp_static_redo_import_check(bgp
);
3977 DEFUN (bgp_default_local_preference
,
3978 bgp_default_local_preference_cmd
,
3979 "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
);
3987 uint32_t local_pref
;
3989 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3991 bgp_default_local_preference_set(bgp
, local_pref
);
3992 bgp_clear_star_soft_in(vty
, bgp
->name
);
3997 DEFUN (no_bgp_default_local_preference
,
3998 no_bgp_default_local_preference_cmd
,
3999 "no bgp default local-preference [(0-4294967295)]",
4002 "Configure BGP defaults\n"
4003 "local preference (higher=more preferred)\n"
4004 "Configure default local preference value\n")
4006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4007 bgp_default_local_preference_unset(bgp
);
4008 bgp_clear_star_soft_in(vty
, bgp
->name
);
4014 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4015 bgp_default_subgroup_pkt_queue_max_cmd
,
4016 "bgp default subgroup-pkt-queue-max (20-100)",
4018 "Configure BGP defaults\n"
4019 "subgroup-pkt-queue-max\n"
4020 "Configure subgroup packet queue max\n")
4022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4026 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4028 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4033 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4034 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4035 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4038 "Configure BGP defaults\n"
4039 "subgroup-pkt-queue-max\n"
4040 "Configure subgroup packet queue max\n")
4042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4043 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4048 DEFUN (bgp_rr_allow_outbound_policy
,
4049 bgp_rr_allow_outbound_policy_cmd
,
4050 "bgp route-reflector allow-outbound-policy",
4052 "Allow modifications made by out route-map\n"
4053 "on ibgp neighbors\n")
4055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4057 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4058 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4059 update_group_announce_rrclients(bgp
);
4060 bgp_clear_star_soft_out(vty
, bgp
->name
);
4066 DEFUN (no_bgp_rr_allow_outbound_policy
,
4067 no_bgp_rr_allow_outbound_policy_cmd
,
4068 "no bgp route-reflector allow-outbound-policy",
4071 "Allow modifications made by out route-map\n"
4072 "on ibgp neighbors\n")
4074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4076 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4077 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4078 update_group_announce_rrclients(bgp
);
4079 bgp_clear_star_soft_out(vty
, bgp
->name
);
4085 DEFUN (bgp_listen_limit
,
4086 bgp_listen_limit_cmd
,
4087 "bgp listen limit (1-65535)",
4089 "BGP Dynamic Neighbors listen commands\n"
4090 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4091 "Configure Dynamic Neighbors listen limit value\n")
4093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4097 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4099 bgp_listen_limit_set(bgp
, listen_limit
);
4104 DEFUN (no_bgp_listen_limit
,
4105 no_bgp_listen_limit_cmd
,
4106 "no bgp listen limit [(1-65535)]",
4109 "BGP Dynamic Neighbors listen commands\n"
4110 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4111 "Configure Dynamic Neighbors listen limit value\n")
4113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4114 bgp_listen_limit_unset(bgp
);
4120 * Check if this listen range is already configured. Check for exact
4121 * match or overlap based on input.
4123 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4124 struct prefix
*range
, int exact
)
4126 struct listnode
*node
, *nnode
;
4127 struct listnode
*node1
, *nnode1
;
4128 struct peer_group
*group
;
4133 afi
= family2afi(range
->family
);
4134 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4135 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4138 match
= prefix_same(range
, lr
);
4140 match
= (prefix_match(range
, lr
)
4141 || prefix_match(lr
, range
));
4150 DEFUN (bgp_listen_range
,
4151 bgp_listen_range_cmd
,
4152 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4154 "Configure BGP dynamic neighbors listen range\n"
4155 "Configure BGP dynamic neighbors listen range\n"
4157 "Member of the peer-group\n"
4158 "Peer-group name\n")
4160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4161 struct prefix range
;
4162 struct peer_group
*group
, *existing_group
;
4167 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4168 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4169 char *prefix
= argv
[idx
]->arg
;
4170 argv_find(argv
, argc
, "PGNAME", &idx
);
4171 char *peergroup
= argv
[idx
]->arg
;
4173 /* Convert IP prefix string to struct prefix. */
4174 ret
= str2prefix(prefix
, &range
);
4176 vty_out(vty
, "%% Malformed listen range\n");
4177 return CMD_WARNING_CONFIG_FAILED
;
4180 afi
= family2afi(range
.family
);
4182 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4184 "%% Malformed listen range (link-local address)\n");
4185 return CMD_WARNING_CONFIG_FAILED
;
4190 /* Check if same listen range is already configured. */
4191 existing_group
= listen_range_exists(bgp
, &range
, 1);
4192 if (existing_group
) {
4193 if (strcmp(existing_group
->name
, peergroup
) == 0)
4197 "%% Same listen range is attached to peer-group %s\n",
4198 existing_group
->name
);
4199 return CMD_WARNING_CONFIG_FAILED
;
4203 /* Check if an overlapping listen range exists. */
4204 if (listen_range_exists(bgp
, &range
, 0)) {
4206 "%% Listen range overlaps with existing listen range\n");
4207 return CMD_WARNING_CONFIG_FAILED
;
4210 group
= peer_group_lookup(bgp
, peergroup
);
4212 vty_out(vty
, "%% Configure the peer-group first\n");
4213 return CMD_WARNING_CONFIG_FAILED
;
4216 ret
= peer_group_listen_range_add(group
, &range
);
4217 return bgp_vty_return(vty
, ret
);
4220 DEFUN (no_bgp_listen_range
,
4221 no_bgp_listen_range_cmd
,
4222 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4225 "Unconfigure BGP dynamic neighbors listen range\n"
4226 "Unconfigure BGP dynamic neighbors listen range\n"
4228 "Member of the peer-group\n"
4229 "Peer-group name\n")
4231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4232 struct prefix range
;
4233 struct peer_group
*group
;
4238 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4239 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4240 char *prefix
= argv
[idx
]->arg
;
4241 argv_find(argv
, argc
, "PGNAME", &idx
);
4242 char *peergroup
= argv
[idx
]->arg
;
4244 /* Convert IP prefix string to struct prefix. */
4245 ret
= str2prefix(prefix
, &range
);
4247 vty_out(vty
, "%% Malformed listen range\n");
4248 return CMD_WARNING_CONFIG_FAILED
;
4251 afi
= family2afi(range
.family
);
4253 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4255 "%% Malformed listen range (link-local address)\n");
4256 return CMD_WARNING_CONFIG_FAILED
;
4261 group
= peer_group_lookup(bgp
, peergroup
);
4263 vty_out(vty
, "%% Peer-group does not exist\n");
4264 return CMD_WARNING_CONFIG_FAILED
;
4267 ret
= peer_group_listen_range_del(group
, &range
);
4268 return bgp_vty_return(vty
, ret
);
4271 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4273 struct peer_group
*group
;
4274 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4275 struct prefix
*range
;
4278 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4279 vty_out(vty
, " bgp listen limit %d\n",
4280 bgp
->dynamic_neighbors_limit
);
4282 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4283 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4284 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4287 " bgp listen range %pFX peer-group %s\n",
4288 range
, group
->name
);
4295 DEFUN (bgp_disable_connected_route_check
,
4296 bgp_disable_connected_route_check_cmd
,
4297 "bgp disable-ebgp-connected-route-check",
4299 "Disable checking if nexthop is connected on ebgp sessions\n")
4301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4302 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4303 bgp_clear_star_soft_in(vty
, bgp
->name
);
4308 DEFUN (no_bgp_disable_connected_route_check
,
4309 no_bgp_disable_connected_route_check_cmd
,
4310 "no bgp disable-ebgp-connected-route-check",
4313 "Disable checking if nexthop is connected on ebgp sessions\n")
4315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4316 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4317 bgp_clear_star_soft_in(vty
, bgp
->name
);
4323 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4329 int as_type
= AS_SPECIFIED
;
4332 if (as_str
[0] == 'i') {
4334 as_type
= AS_INTERNAL
;
4335 } else if (as_str
[0] == 'e') {
4337 as_type
= AS_EXTERNAL
;
4339 /* Get AS number. */
4340 as
= strtoul(as_str
, NULL
, 10);
4343 /* If peer is peer group or interface peer, call proper function. */
4344 ret
= str2sockunion(peer_str
, &su
);
4348 /* Check if existing interface peer */
4349 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4351 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4353 /* if not interface peer, check peer-group settings */
4354 if (ret
< 0 && !peer
) {
4355 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4358 "%% Create the peer-group or interface first\n");
4359 return CMD_WARNING_CONFIG_FAILED
;
4364 if (peer_address_self_check(bgp
, &su
)) {
4366 "%% Can not configure the local system as neighbor\n");
4367 return CMD_WARNING_CONFIG_FAILED
;
4369 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4372 return bgp_vty_return(vty
, ret
);
4375 DEFUN (bgp_default_shutdown
,
4376 bgp_default_shutdown_cmd
,
4377 "[no] bgp default shutdown",
4380 "Configure BGP defaults\n"
4381 "Apply administrative shutdown to newly configured peers\n")
4383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4384 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4388 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4390 "Administrative shutdown of the BGP instance\n"
4391 "Add a shutdown message (RFC 8203)\n"
4392 "Shutdown message\n")
4394 char *msgstr
= NULL
;
4396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4399 msgstr
= argv_concat(argv
, argc
, 3);
4401 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4402 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4403 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4404 return CMD_WARNING_CONFIG_FAILED
;
4407 bgp_shutdown_enable(bgp
, msgstr
);
4408 XFREE(MTYPE_TMP
, msgstr
);
4413 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4414 BGP_STR
"Administrative shutdown of the BGP instance\n")
4416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4418 bgp_shutdown_enable(bgp
, NULL
);
4423 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4424 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4428 bgp_shutdown_disable(bgp
);
4433 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4434 "no bgp shutdown message MSG...", NO_STR BGP_STR
4435 "Administrative shutdown of the BGP instance\n"
4436 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4438 DEFUN (neighbor_remote_as
,
4439 neighbor_remote_as_cmd
,
4440 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4443 "Specify a BGP neighbor\n"
4445 "Internal BGP peer\n"
4446 "External BGP peer\n")
4449 int idx_remote_as
= 3;
4450 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4451 argv
[idx_remote_as
]->arg
);
4454 DEFPY (bgp_allow_martian
,
4455 bgp_allow_martian_cmd
,
4456 "[no]$no bgp allow-martian-nexthop",
4459 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4464 bgp
->allow_martian
= false;
4466 bgp
->allow_martian
= true;
4471 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4472 * sessions do not wait for hold timer expiry to bring down the sessions
4473 * when nexthop becomes unreachable
4475 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4476 BGP_STR
"Fast convergence for bgp sessions\n")
4478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4479 bgp
->fast_convergence
= true;
4484 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4485 "no bgp fast-convergence",
4486 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4489 bgp
->fast_convergence
= false;
4494 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4496 const char *peer_group_name
,
4499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4501 int as_type
= AS_UNSPECIFIED
;
4503 struct peer_group
*group
;
4506 group
= peer_group_lookup(bgp
, conf_if
);
4509 vty_out(vty
, "%% Name conflict with peer-group \n");
4510 return CMD_WARNING_CONFIG_FAILED
;
4514 if (as_str
[0] == 'i') {
4515 as_type
= AS_INTERNAL
;
4516 } else if (as_str
[0] == 'e') {
4517 as_type
= AS_EXTERNAL
;
4519 /* Get AS number. */
4520 as
= strtoul(as_str
, NULL
, 10);
4521 as_type
= AS_SPECIFIED
;
4525 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4528 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4530 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4534 vty_out(vty
, "%% BGP failed to create peer\n");
4535 return CMD_WARNING_CONFIG_FAILED
;
4539 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4541 /* Request zebra to initiate IPv6 RAs on this interface. We do
4543 * any unnumbered peer in order to not worry about run-time
4545 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4547 * gets deleted later etc.)
4550 bgp_zebra_initiate_radv(bgp
, peer
);
4553 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4554 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4556 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4558 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4560 /* v6only flag changed. Reset bgp seesion */
4561 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4562 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4563 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4564 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4566 bgp_session_reset(peer
);
4569 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4570 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4571 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4572 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4575 if (peer_group_name
) {
4576 group
= peer_group_lookup(bgp
, peer_group_name
);
4578 vty_out(vty
, "%% Configure the peer-group first\n");
4579 return CMD_WARNING_CONFIG_FAILED
;
4582 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4585 return bgp_vty_return(vty
, ret
);
4588 DEFUN (neighbor_interface_config
,
4589 neighbor_interface_config_cmd
,
4590 "neighbor WORD interface [peer-group PGNAME]",
4592 "Interface name or neighbor tag\n"
4593 "Enable BGP on interface\n"
4594 "Member of the peer-group\n"
4595 "Peer-group name\n")
4598 int idx_peer_group_word
= 4;
4600 if (argc
> idx_peer_group_word
)
4601 return peer_conf_interface_get(
4602 vty
, argv
[idx_word
]->arg
, 0,
4603 argv
[idx_peer_group_word
]->arg
, NULL
);
4605 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4609 DEFUN (neighbor_interface_config_v6only
,
4610 neighbor_interface_config_v6only_cmd
,
4611 "neighbor WORD interface v6only [peer-group PGNAME]",
4613 "Interface name or neighbor tag\n"
4614 "Enable BGP on interface\n"
4615 "Enable BGP with v6 link-local only\n"
4616 "Member of the peer-group\n"
4617 "Peer-group name\n")
4620 int idx_peer_group_word
= 5;
4622 if (argc
> idx_peer_group_word
)
4623 return peer_conf_interface_get(
4624 vty
, argv
[idx_word
]->arg
, 1,
4625 argv
[idx_peer_group_word
]->arg
, NULL
);
4627 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4631 DEFUN (neighbor_interface_config_remote_as
,
4632 neighbor_interface_config_remote_as_cmd
,
4633 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4635 "Interface name or neighbor tag\n"
4636 "Enable BGP on interface\n"
4637 "Specify a BGP neighbor\n"
4639 "Internal BGP peer\n"
4640 "External BGP peer\n")
4643 int idx_remote_as
= 4;
4644 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4645 argv
[idx_remote_as
]->arg
);
4648 DEFUN (neighbor_interface_v6only_config_remote_as
,
4649 neighbor_interface_v6only_config_remote_as_cmd
,
4650 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4652 "Interface name or neighbor tag\n"
4653 "Enable BGP with v6 link-local only\n"
4654 "Enable BGP on interface\n"
4655 "Specify a BGP neighbor\n"
4657 "Internal BGP peer\n"
4658 "External BGP peer\n")
4661 int idx_remote_as
= 5;
4662 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4663 argv
[idx_remote_as
]->arg
);
4666 DEFUN (neighbor_peer_group
,
4667 neighbor_peer_group_cmd
,
4668 "neighbor WORD peer-group",
4670 "Interface name or neighbor tag\n"
4671 "Configure peer-group\n")
4673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4676 struct peer_group
*group
;
4678 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4680 vty_out(vty
, "%% Name conflict with interface: \n");
4681 return CMD_WARNING_CONFIG_FAILED
;
4684 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4686 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4687 return CMD_WARNING_CONFIG_FAILED
;
4695 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4699 "Specify a BGP neighbor\n"
4701 "Internal BGP peer\n"
4702 "External BGP peer\n")
4704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4708 struct peer_group
*group
;
4712 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4714 /* look up for neighbor by interface name config. */
4715 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4717 /* Request zebra to terminate IPv6 RAs on this
4720 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4721 peer_notify_unconfig(peer
);
4726 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4728 peer_group_notify_unconfig(group
);
4729 peer_group_delete(group
);
4731 vty_out(vty
, "%% Create the peer-group first\n");
4732 return CMD_WARNING_CONFIG_FAILED
;
4735 peer
= peer_lookup(bgp
, &su
);
4737 if (peer_dynamic_neighbor(peer
)) {
4739 "%% Operation not allowed on a dynamic neighbor\n");
4740 return CMD_WARNING_CONFIG_FAILED
;
4743 other
= peer
->doppelganger
;
4745 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4746 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4748 peer_notify_unconfig(peer
);
4750 if (other
&& other
->status
!= Deleted
) {
4751 peer_notify_unconfig(other
);
4760 DEFUN (no_neighbor_interface_config
,
4761 no_neighbor_interface_config_cmd
,
4762 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4766 "Configure BGP on interface\n"
4767 "Enable BGP with v6 link-local only\n"
4768 "Member of the peer-group\n"
4770 "Specify a BGP neighbor\n"
4772 "Internal BGP peer\n"
4773 "External BGP peer\n")
4775 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4779 /* look up for neighbor by interface name config. */
4780 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4782 /* Request zebra to terminate IPv6 RAs on this interface. */
4784 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4785 peer_notify_unconfig(peer
);
4788 vty_out(vty
, "%% Create the bgp interface first\n");
4789 return CMD_WARNING_CONFIG_FAILED
;
4794 DEFUN (no_neighbor_peer_group
,
4795 no_neighbor_peer_group_cmd
,
4796 "no neighbor WORD peer-group",
4800 "Configure peer-group\n")
4802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4804 struct peer_group
*group
;
4806 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4808 peer_group_notify_unconfig(group
);
4809 peer_group_delete(group
);
4811 vty_out(vty
, "%% Create the peer-group first\n");
4812 return CMD_WARNING_CONFIG_FAILED
;
4817 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4818 no_neighbor_interface_peer_group_remote_as_cmd
,
4819 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4822 "Interface name or neighbor tag\n"
4823 "Specify a BGP neighbor\n"
4825 "Internal BGP peer\n"
4826 "External BGP peer\n")
4828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4830 struct peer_group
*group
;
4833 /* look up for neighbor by interface name config. */
4834 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4836 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4840 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4842 peer_group_remote_as_delete(group
);
4844 vty_out(vty
, "%% Create the peer-group or interface first\n");
4845 return CMD_WARNING_CONFIG_FAILED
;
4850 DEFUN (neighbor_local_as
,
4851 neighbor_local_as_cmd
,
4852 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4855 "Specify a local-as number\n"
4856 "AS number used as local AS\n")
4864 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4866 return CMD_WARNING_CONFIG_FAILED
;
4868 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4869 ret
= peer_local_as_set(peer
, as
, 0, 0);
4870 return bgp_vty_return(vty
, ret
);
4873 DEFUN (neighbor_local_as_no_prepend
,
4874 neighbor_local_as_no_prepend_cmd
,
4875 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4878 "Specify a local-as number\n"
4879 "AS number used as local AS\n"
4880 "Do not prepend local-as to updates from ebgp peers\n")
4888 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4890 return CMD_WARNING_CONFIG_FAILED
;
4892 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4893 ret
= peer_local_as_set(peer
, as
, 1, 0);
4894 return bgp_vty_return(vty
, ret
);
4897 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4898 neighbor_local_as_no_prepend_replace_as_cmd
,
4899 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4902 "Specify a local-as number\n"
4903 "AS number used as local AS\n"
4904 "Do not prepend local-as to updates from ebgp peers\n"
4905 "Do not prepend local-as to updates from ibgp peers\n")
4913 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4915 return CMD_WARNING_CONFIG_FAILED
;
4917 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4918 ret
= peer_local_as_set(peer
, as
, 1, 1);
4919 return bgp_vty_return(vty
, ret
);
4922 DEFUN (no_neighbor_local_as
,
4923 no_neighbor_local_as_cmd
,
4924 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4928 "Specify a local-as number\n"
4929 "AS number used as local AS\n"
4930 "Do not prepend local-as to updates from ebgp peers\n"
4931 "Do not prepend local-as to updates from ibgp peers\n")
4937 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4939 return CMD_WARNING_CONFIG_FAILED
;
4941 ret
= peer_local_as_unset(peer
);
4942 return bgp_vty_return(vty
, ret
);
4946 DEFUN (neighbor_solo
,
4948 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4951 "Solo peer - part of its own update group\n")
4957 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4959 return CMD_WARNING_CONFIG_FAILED
;
4961 ret
= update_group_adjust_soloness(peer
, 1);
4962 return bgp_vty_return(vty
, ret
);
4965 DEFUN (no_neighbor_solo
,
4966 no_neighbor_solo_cmd
,
4967 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4971 "Solo peer - part of its own update group\n")
4977 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4979 return CMD_WARNING_CONFIG_FAILED
;
4981 ret
= update_group_adjust_soloness(peer
, 0);
4982 return bgp_vty_return(vty
, ret
);
4985 DEFUN (neighbor_password
,
4986 neighbor_password_cmd
,
4987 "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_set(peer
, argv
[idx_line
]->arg
);
5003 return bgp_vty_return(vty
, ret
);
5006 DEFUN (no_neighbor_password
,
5007 no_neighbor_password_cmd
,
5008 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5019 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5021 return CMD_WARNING_CONFIG_FAILED
;
5023 ret
= peer_password_unset(peer
);
5024 return bgp_vty_return(vty
, ret
);
5027 DEFUN (neighbor_activate
,
5028 neighbor_activate_cmd
,
5029 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5032 "Enable the Address Family for this Neighbor\n")
5038 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5040 return CMD_WARNING_CONFIG_FAILED
;
5042 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5043 return bgp_vty_return(vty
, ret
);
5046 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5048 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5049 "Enable the Address Family for this Neighbor\n")
5051 DEFUN (no_neighbor_activate
,
5052 no_neighbor_activate_cmd
,
5053 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5057 "Enable the Address Family for this Neighbor\n")
5064 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5066 return CMD_WARNING_CONFIG_FAILED
;
5068 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5069 return bgp_vty_return(vty
, ret
);
5072 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5073 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5074 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5075 "Enable the Address Family for this Neighbor\n")
5077 DEFUN (neighbor_set_peer_group
,
5078 neighbor_set_peer_group_cmd
,
5079 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5082 "Member of the peer-group\n"
5083 "Peer-group name\n")
5085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5092 struct peer_group
*group
;
5094 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5096 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5098 vty_out(vty
, "%% Malformed address or name: %s\n",
5099 argv
[idx_peer
]->arg
);
5100 return CMD_WARNING_CONFIG_FAILED
;
5103 if (peer_address_self_check(bgp
, &su
)) {
5105 "%% Can not configure the local system as neighbor\n");
5106 return CMD_WARNING_CONFIG_FAILED
;
5109 /* Disallow for dynamic neighbor. */
5110 peer
= peer_lookup(bgp
, &su
);
5111 if (peer
&& peer_dynamic_neighbor(peer
)) {
5113 "%% Operation not allowed on a dynamic neighbor\n");
5114 return CMD_WARNING_CONFIG_FAILED
;
5118 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5120 vty_out(vty
, "%% Configure the peer-group first\n");
5121 return CMD_WARNING_CONFIG_FAILED
;
5124 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5126 return bgp_vty_return(vty
, ret
);
5129 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5130 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5131 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5132 "Member of the peer-group\n"
5133 "Peer-group name\n")
5135 DEFUN (no_neighbor_set_peer_group
,
5136 no_neighbor_set_peer_group_cmd
,
5137 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5141 "Member of the peer-group\n"
5142 "Peer-group name\n")
5144 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5149 struct peer_group
*group
;
5151 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5153 return CMD_WARNING_CONFIG_FAILED
;
5155 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5157 vty_out(vty
, "%% Configure the peer-group first\n");
5158 return CMD_WARNING_CONFIG_FAILED
;
5161 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5162 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5164 peer_notify_unconfig(peer
);
5165 ret
= peer_delete(peer
);
5167 return bgp_vty_return(vty
, ret
);
5170 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5171 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5172 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5173 "Member of the peer-group\n"
5174 "Peer-group name\n")
5176 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5177 uint64_t flag
, int set
)
5182 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5184 return CMD_WARNING_CONFIG_FAILED
;
5187 * If 'neighbor <interface>', then this is for directly connected peers,
5188 * we should not accept disable-connected-check.
5190 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5192 "%s is directly connected peer, cannot accept disable-connected-check\n",
5194 return CMD_WARNING_CONFIG_FAILED
;
5197 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5198 peer_tx_shutdown_message_unset(peer
);
5201 ret
= peer_flag_set(peer
, flag
);
5203 ret
= peer_flag_unset(peer
, flag
);
5205 return bgp_vty_return(vty
, ret
);
5208 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5210 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5213 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5216 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5219 /* neighbor passive. */
5220 DEFUN (neighbor_passive
,
5221 neighbor_passive_cmd
,
5222 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5225 "Don't send open messages to this neighbor\n")
5228 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5231 DEFUN (no_neighbor_passive
,
5232 no_neighbor_passive_cmd
,
5233 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5237 "Don't send open messages to this neighbor\n")
5240 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5243 /* neighbor shutdown. */
5244 DEFUN (neighbor_shutdown_msg
,
5245 neighbor_shutdown_msg_cmd
,
5246 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5249 "Administratively shut down this neighbor\n"
5250 "Add a shutdown message (RFC 8203)\n"
5251 "Shutdown message\n")
5257 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5261 return CMD_WARNING_CONFIG_FAILED
;
5262 message
= argv_concat(argv
, argc
, 4);
5263 peer_tx_shutdown_message_set(peer
, message
);
5264 XFREE(MTYPE_TMP
, message
);
5267 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5270 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5271 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5272 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5273 "Administratively shut down this neighbor\n")
5275 DEFUN (no_neighbor_shutdown_msg
,
5276 no_neighbor_shutdown_msg_cmd
,
5277 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5281 "Administratively shut down this neighbor\n"
5282 "Remove a shutdown message (RFC 8203)\n"
5283 "Shutdown message\n")
5287 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5288 PEER_FLAG_SHUTDOWN
);
5291 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5292 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5293 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5294 "Administratively shut down this neighbor\n")
5296 DEFUN(neighbor_shutdown_rtt
,
5297 neighbor_shutdown_rtt_cmd
,
5298 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5301 "Administratively shut down this neighbor\n"
5302 "Shutdown if round-trip-time is higher than expected\n"
5303 "Round-trip-time in milliseconds\n"
5304 "Specify the number of keepalives before shutdown\n"
5305 "The number of keepalives with higher RTT to shutdown\n")
5312 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5315 return CMD_WARNING_CONFIG_FAILED
;
5317 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5319 if (argv_find(argv
, argc
, "count", &idx_count
))
5320 peer
->rtt_keepalive_conf
=
5321 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5323 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5324 PEER_FLAG_RTT_SHUTDOWN
);
5327 DEFUN(no_neighbor_shutdown_rtt
,
5328 no_neighbor_shutdown_rtt_cmd
,
5329 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5333 "Administratively shut down this neighbor\n"
5334 "Shutdown if round-trip-time is higher than expected\n"
5335 "Round-trip-time in milliseconds\n"
5336 "Specify the number of keepalives before shutdown\n"
5337 "The number of keepalives with higher RTT to shutdown\n")
5342 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5345 return CMD_WARNING_CONFIG_FAILED
;
5347 peer
->rtt_expected
= 0;
5348 peer
->rtt_keepalive_conf
= 1;
5350 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5351 PEER_FLAG_RTT_SHUTDOWN
);
5354 /* neighbor capability dynamic. */
5355 DEFUN (neighbor_capability_dynamic
,
5356 neighbor_capability_dynamic_cmd
,
5357 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5360 "Advertise capability to the peer\n"
5361 "Advertise dynamic capability to this neighbor\n")
5364 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5365 PEER_FLAG_DYNAMIC_CAPABILITY
);
5368 DEFUN (no_neighbor_capability_dynamic
,
5369 no_neighbor_capability_dynamic_cmd
,
5370 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5374 "Advertise capability to the peer\n"
5375 "Advertise dynamic capability to this neighbor\n")
5378 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5379 PEER_FLAG_DYNAMIC_CAPABILITY
);
5382 /* neighbor dont-capability-negotiate */
5383 DEFUN (neighbor_dont_capability_negotiate
,
5384 neighbor_dont_capability_negotiate_cmd
,
5385 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5388 "Do not perform capability negotiation\n")
5391 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5392 PEER_FLAG_DONT_CAPABILITY
);
5395 DEFUN (no_neighbor_dont_capability_negotiate
,
5396 no_neighbor_dont_capability_negotiate_cmd
,
5397 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5401 "Do not perform capability negotiation\n")
5404 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5405 PEER_FLAG_DONT_CAPABILITY
);
5408 /* neighbor capability extended next hop encoding */
5409 DEFUN (neighbor_capability_enhe
,
5410 neighbor_capability_enhe_cmd
,
5411 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5414 "Advertise capability to the peer\n"
5415 "Advertise extended next-hop capability to the peer\n")
5420 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5421 if (peer
&& peer
->conf_if
)
5424 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5425 PEER_FLAG_CAPABILITY_ENHE
);
5428 DEFUN (no_neighbor_capability_enhe
,
5429 no_neighbor_capability_enhe_cmd
,
5430 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5434 "Advertise capability to the peer\n"
5435 "Advertise extended next-hop capability to the peer\n")
5440 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5441 if (peer
&& peer
->conf_if
) {
5443 "Peer %s cannot have capability extended-nexthop turned off\n",
5444 argv
[idx_peer
]->arg
);
5445 return CMD_WARNING_CONFIG_FAILED
;
5448 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5449 PEER_FLAG_CAPABILITY_ENHE
);
5452 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5453 afi_t afi
, safi_t safi
, uint32_t flag
,
5459 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5461 return CMD_WARNING_CONFIG_FAILED
;
5464 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5466 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5468 return bgp_vty_return(vty
, ret
);
5471 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5472 afi_t afi
, safi_t safi
, uint32_t flag
)
5474 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5477 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5478 afi_t afi
, safi_t safi
, uint32_t flag
)
5480 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5483 /* neighbor capability orf prefix-list. */
5484 DEFUN (neighbor_capability_orf_prefix
,
5485 neighbor_capability_orf_prefix_cmd
,
5486 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5489 "Advertise capability to the peer\n"
5490 "Advertise ORF capability to the peer\n"
5491 "Advertise prefixlist ORF capability to this neighbor\n"
5492 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5493 "Capability to RECEIVE the ORF from this neighbor\n"
5494 "Capability to SEND the ORF to this neighbor\n")
5496 int idx_send_recv
= 5;
5497 char *peer_str
= argv
[1]->arg
;
5499 afi_t afi
= bgp_node_afi(vty
);
5500 safi_t safi
= bgp_node_safi(vty
);
5502 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5506 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5507 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5508 PEER_FLAG_ORF_PREFIX_SM
);
5510 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5511 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5512 PEER_FLAG_ORF_PREFIX_RM
);
5514 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5515 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5516 PEER_FLAG_ORF_PREFIX_SM
)
5517 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5518 PEER_FLAG_ORF_PREFIX_RM
);
5520 return CMD_WARNING_CONFIG_FAILED
;
5524 neighbor_capability_orf_prefix
,
5525 neighbor_capability_orf_prefix_hidden_cmd
,
5526 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5527 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5528 "Advertise capability to the peer\n"
5529 "Advertise ORF capability to the peer\n"
5530 "Advertise prefixlist ORF capability to this neighbor\n"
5531 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5532 "Capability to RECEIVE the ORF from this neighbor\n"
5533 "Capability to SEND the ORF to this neighbor\n")
5535 DEFUN (no_neighbor_capability_orf_prefix
,
5536 no_neighbor_capability_orf_prefix_cmd
,
5537 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5541 "Advertise capability to the peer\n"
5542 "Advertise ORF capability to the peer\n"
5543 "Advertise prefixlist ORF capability to this neighbor\n"
5544 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5545 "Capability to RECEIVE the ORF from this neighbor\n"
5546 "Capability to SEND the ORF to this neighbor\n")
5548 int idx_send_recv
= 6;
5549 char *peer_str
= argv
[2]->arg
;
5551 afi_t afi
= bgp_node_afi(vty
);
5552 safi_t safi
= bgp_node_safi(vty
);
5554 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5556 return CMD_WARNING_CONFIG_FAILED
;
5558 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5559 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5560 PEER_FLAG_ORF_PREFIX_SM
);
5562 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5563 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5564 PEER_FLAG_ORF_PREFIX_RM
);
5566 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5567 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5568 PEER_FLAG_ORF_PREFIX_SM
)
5569 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5570 PEER_FLAG_ORF_PREFIX_RM
);
5572 return CMD_WARNING_CONFIG_FAILED
;
5576 no_neighbor_capability_orf_prefix
,
5577 no_neighbor_capability_orf_prefix_hidden_cmd
,
5578 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5579 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5580 "Advertise capability to the peer\n"
5581 "Advertise ORF capability to the peer\n"
5582 "Advertise prefixlist ORF capability to this neighbor\n"
5583 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5584 "Capability to RECEIVE the ORF from this neighbor\n"
5585 "Capability to SEND the ORF to this neighbor\n")
5587 /* neighbor next-hop-self. */
5588 DEFUN (neighbor_nexthop_self
,
5589 neighbor_nexthop_self_cmd
,
5590 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5593 "Disable the next hop calculation for this neighbor\n")
5596 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5597 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5600 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5601 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5602 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5603 "Disable the next hop calculation for this neighbor\n")
5605 /* neighbor next-hop-self. */
5606 DEFUN (neighbor_nexthop_self_force
,
5607 neighbor_nexthop_self_force_cmd
,
5608 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5611 "Disable the next hop calculation for this neighbor\n"
5612 "Set the next hop to self for reflected routes\n")
5615 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5617 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5620 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5621 neighbor_nexthop_self_force_hidden_cmd
,
5622 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5623 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5624 "Disable the next hop calculation for this neighbor\n"
5625 "Set the next hop to self for reflected routes\n")
5627 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5628 neighbor_nexthop_self_all_hidden_cmd
,
5629 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5630 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Disable the next hop calculation for this neighbor\n"
5632 "Set the next hop to self for reflected routes\n")
5634 DEFUN (no_neighbor_nexthop_self
,
5635 no_neighbor_nexthop_self_cmd
,
5636 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5640 "Disable the next hop calculation for this neighbor\n")
5643 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5644 bgp_node_afi(vty
), bgp_node_safi(vty
),
5645 PEER_FLAG_NEXTHOP_SELF
);
5648 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5649 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5650 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5651 "Disable the next hop calculation for this neighbor\n")
5653 DEFUN (no_neighbor_nexthop_self_force
,
5654 no_neighbor_nexthop_self_force_cmd
,
5655 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5659 "Disable the next hop calculation for this neighbor\n"
5660 "Set the next hop to self for reflected routes\n")
5663 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5664 bgp_node_afi(vty
), bgp_node_safi(vty
),
5665 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5668 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5669 no_neighbor_nexthop_self_force_hidden_cmd
,
5670 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5671 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5672 "Disable the next hop calculation for this neighbor\n"
5673 "Set the next hop to self for reflected routes\n")
5675 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5676 no_neighbor_nexthop_self_all_hidden_cmd
,
5677 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5678 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5679 "Disable the next hop calculation for this neighbor\n"
5680 "Set the next hop to self for reflected routes\n")
5682 /* neighbor as-override */
5683 DEFUN (neighbor_as_override
,
5684 neighbor_as_override_cmd
,
5685 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5688 "Override ASNs in outbound updates if aspath equals remote-as\n")
5691 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5692 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5695 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5696 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5697 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5698 "Override ASNs in outbound updates if aspath equals remote-as\n")
5700 DEFUN (no_neighbor_as_override
,
5701 no_neighbor_as_override_cmd
,
5702 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5706 "Override ASNs in outbound updates if aspath equals remote-as\n")
5709 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5710 bgp_node_afi(vty
), bgp_node_safi(vty
),
5711 PEER_FLAG_AS_OVERRIDE
);
5714 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5715 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5716 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5717 "Override ASNs in outbound updates if aspath equals remote-as\n")
5719 /* neighbor remove-private-AS. */
5720 DEFUN (neighbor_remove_private_as
,
5721 neighbor_remove_private_as_cmd
,
5722 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5725 "Remove private ASNs in outbound updates\n")
5728 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5730 PEER_FLAG_REMOVE_PRIVATE_AS
);
5733 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5735 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Remove private ASNs in outbound updates\n")
5738 DEFUN (neighbor_remove_private_as_all
,
5739 neighbor_remove_private_as_all_cmd
,
5740 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5743 "Remove private ASNs in outbound updates\n"
5744 "Apply to all AS numbers\n")
5747 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5749 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5752 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5753 neighbor_remove_private_as_all_hidden_cmd
,
5754 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5755 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5756 "Remove private ASNs in outbound updates\n"
5757 "Apply to all AS numbers")
5759 DEFUN (neighbor_remove_private_as_replace_as
,
5760 neighbor_remove_private_as_replace_as_cmd
,
5761 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5764 "Remove private ASNs in outbound updates\n"
5765 "Replace private ASNs with our ASN in outbound updates\n")
5768 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5770 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5773 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5774 neighbor_remove_private_as_replace_as_hidden_cmd
,
5775 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5776 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5777 "Remove private ASNs in outbound updates\n"
5778 "Replace private ASNs with our ASN in outbound updates\n")
5780 DEFUN (neighbor_remove_private_as_all_replace_as
,
5781 neighbor_remove_private_as_all_replace_as_cmd
,
5782 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5785 "Remove private ASNs in outbound updates\n"
5786 "Apply to all AS numbers\n"
5787 "Replace private ASNs with our ASN in outbound updates\n")
5790 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5792 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5796 neighbor_remove_private_as_all_replace_as
,
5797 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5798 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5799 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5800 "Remove private ASNs in outbound updates\n"
5801 "Apply to all AS numbers\n"
5802 "Replace private ASNs with our ASN in outbound updates\n")
5804 DEFUN (no_neighbor_remove_private_as
,
5805 no_neighbor_remove_private_as_cmd
,
5806 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5810 "Remove private ASNs in outbound updates\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
);
5818 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5819 no_neighbor_remove_private_as_hidden_cmd
,
5820 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5821 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5822 "Remove private ASNs in outbound updates\n")
5824 DEFUN (no_neighbor_remove_private_as_all
,
5825 no_neighbor_remove_private_as_all_cmd
,
5826 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5830 "Remove private ASNs in outbound updates\n"
5831 "Apply to all AS numbers\n")
5834 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5835 bgp_node_afi(vty
), bgp_node_safi(vty
),
5836 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5839 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5840 no_neighbor_remove_private_as_all_hidden_cmd
,
5841 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5842 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5843 "Remove private ASNs in outbound updates\n"
5844 "Apply to all AS numbers\n")
5846 DEFUN (no_neighbor_remove_private_as_replace_as
,
5847 no_neighbor_remove_private_as_replace_as_cmd
,
5848 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5852 "Remove private ASNs in outbound updates\n"
5853 "Replace private ASNs with our ASN in outbound updates\n")
5856 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5857 bgp_node_afi(vty
), bgp_node_safi(vty
),
5858 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5861 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5862 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5863 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5864 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5865 "Remove private ASNs in outbound updates\n"
5866 "Replace private ASNs with our ASN in outbound updates\n")
5868 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5869 no_neighbor_remove_private_as_all_replace_as_cmd
,
5870 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5874 "Remove private ASNs in outbound updates\n"
5875 "Apply to all AS numbers\n"
5876 "Replace private ASNs with our ASN in outbound updates\n")
5879 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5880 bgp_node_afi(vty
), bgp_node_safi(vty
),
5881 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5885 no_neighbor_remove_private_as_all_replace_as
,
5886 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5887 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5888 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5889 "Remove private ASNs in outbound updates\n"
5890 "Apply to all AS numbers\n"
5891 "Replace private ASNs with our ASN in outbound updates\n")
5894 /* neighbor send-community. */
5895 DEFUN (neighbor_send_community
,
5896 neighbor_send_community_cmd
,
5897 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5900 "Send Community attribute to this neighbor\n")
5904 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5906 PEER_FLAG_SEND_COMMUNITY
);
5909 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5910 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5911 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5912 "Send Community attribute to this neighbor\n")
5914 DEFUN (no_neighbor_send_community
,
5915 no_neighbor_send_community_cmd
,
5916 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5920 "Send Community attribute to this neighbor\n")
5924 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5925 bgp_node_afi(vty
), bgp_node_safi(vty
),
5926 PEER_FLAG_SEND_COMMUNITY
);
5929 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5930 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5931 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5932 "Send Community attribute to this neighbor\n")
5934 /* neighbor send-community extended. */
5935 DEFUN (neighbor_send_community_type
,
5936 neighbor_send_community_type_cmd
,
5937 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5940 "Send Community attribute to this neighbor\n"
5941 "Send Standard and Extended Community attributes\n"
5942 "Send Standard, Large and Extended Community attributes\n"
5943 "Send Extended Community attributes\n"
5944 "Send Standard Community attributes\n"
5945 "Send Large Community attributes\n")
5947 const char *type
= argv
[argc
- 1]->text
;
5948 char *peer_str
= argv
[1]->arg
;
5950 afi_t afi
= bgp_node_afi(vty
);
5951 safi_t safi
= bgp_node_safi(vty
);
5953 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5955 return CMD_WARNING_CONFIG_FAILED
;
5957 if (strmatch(type
, "standard"))
5958 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5959 PEER_FLAG_SEND_COMMUNITY
);
5961 if (strmatch(type
, "extended"))
5962 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5963 PEER_FLAG_SEND_EXT_COMMUNITY
);
5965 if (strmatch(type
, "large"))
5966 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5967 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5969 if (strmatch(type
, "both")) {
5970 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5971 PEER_FLAG_SEND_COMMUNITY
)
5972 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5973 PEER_FLAG_SEND_EXT_COMMUNITY
);
5975 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5976 PEER_FLAG_SEND_COMMUNITY
)
5977 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5978 PEER_FLAG_SEND_EXT_COMMUNITY
)
5979 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5980 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5984 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5985 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5986 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5987 "Send Community attribute to this neighbor\n"
5988 "Send Standard and Extended Community attributes\n"
5989 "Send Standard, Large and Extended Community attributes\n"
5990 "Send Extended Community attributes\n"
5991 "Send Standard Community attributes\n"
5992 "Send Large Community attributes\n")
5994 DEFUN (no_neighbor_send_community_type
,
5995 no_neighbor_send_community_type_cmd
,
5996 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6000 "Send Community attribute to this neighbor\n"
6001 "Send Standard and Extended Community attributes\n"
6002 "Send Standard, Large and Extended Community attributes\n"
6003 "Send Extended Community attributes\n"
6004 "Send Standard Community attributes\n"
6005 "Send Large Community attributes\n")
6007 const char *type
= argv
[argc
- 1]->text
;
6008 char *peer_str
= argv
[2]->arg
;
6010 afi_t afi
= bgp_node_afi(vty
);
6011 safi_t safi
= bgp_node_safi(vty
);
6013 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6015 return CMD_WARNING_CONFIG_FAILED
;
6017 if (strmatch(type
, "standard"))
6018 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6019 PEER_FLAG_SEND_COMMUNITY
);
6021 if (strmatch(type
, "extended"))
6022 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6023 PEER_FLAG_SEND_EXT_COMMUNITY
);
6025 if (strmatch(type
, "large"))
6026 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6027 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6029 if (strmatch(type
, "both")) {
6031 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6032 PEER_FLAG_SEND_COMMUNITY
)
6033 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6034 PEER_FLAG_SEND_EXT_COMMUNITY
);
6037 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6038 PEER_FLAG_SEND_COMMUNITY
)
6039 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6040 PEER_FLAG_SEND_EXT_COMMUNITY
)
6041 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6042 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6046 no_neighbor_send_community_type
,
6047 no_neighbor_send_community_type_hidden_cmd
,
6048 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6049 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6050 "Send Community attribute to this neighbor\n"
6051 "Send Standard and Extended Community attributes\n"
6052 "Send Standard, Large and Extended Community attributes\n"
6053 "Send Extended Community attributes\n"
6054 "Send Standard Community attributes\n"
6055 "Send Large Community attributes\n")
6057 /* neighbor soft-reconfig. */
6058 DEFUN (neighbor_soft_reconfiguration
,
6059 neighbor_soft_reconfiguration_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6063 "Per neighbor soft reconfiguration\n"
6064 "Allow inbound soft reconfiguration for this neighbor\n")
6067 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6069 PEER_FLAG_SOFT_RECONFIG
);
6072 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6073 neighbor_soft_reconfiguration_hidden_cmd
,
6074 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6075 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6076 "Per neighbor soft reconfiguration\n"
6077 "Allow inbound soft reconfiguration for this neighbor\n")
6079 DEFUN (no_neighbor_soft_reconfiguration
,
6080 no_neighbor_soft_reconfiguration_cmd
,
6081 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6085 "Per neighbor soft reconfiguration\n"
6086 "Allow inbound soft reconfiguration for this neighbor\n")
6089 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6090 bgp_node_afi(vty
), bgp_node_safi(vty
),
6091 PEER_FLAG_SOFT_RECONFIG
);
6094 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6095 no_neighbor_soft_reconfiguration_hidden_cmd
,
6096 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6097 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6098 "Per neighbor soft reconfiguration\n"
6099 "Allow inbound soft reconfiguration for this neighbor\n")
6101 DEFUN (neighbor_route_reflector_client
,
6102 neighbor_route_reflector_client_cmd
,
6103 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6106 "Configure a neighbor as Route Reflector client\n")
6112 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6114 return CMD_WARNING_CONFIG_FAILED
;
6116 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6118 PEER_FLAG_REFLECTOR_CLIENT
);
6121 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6122 neighbor_route_reflector_client_hidden_cmd
,
6123 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6124 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6125 "Configure a neighbor as Route Reflector client\n")
6127 DEFUN (no_neighbor_route_reflector_client
,
6128 no_neighbor_route_reflector_client_cmd
,
6129 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6133 "Configure a neighbor as Route Reflector client\n")
6136 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6137 bgp_node_afi(vty
), bgp_node_safi(vty
),
6138 PEER_FLAG_REFLECTOR_CLIENT
);
6141 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6142 no_neighbor_route_reflector_client_hidden_cmd
,
6143 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6144 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6145 "Configure a neighbor as Route Reflector client\n")
6147 /* neighbor route-server-client. */
6148 DEFUN (neighbor_route_server_client
,
6149 neighbor_route_server_client_cmd
,
6150 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6153 "Configure a neighbor as Route Server client\n")
6158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6160 return CMD_WARNING_CONFIG_FAILED
;
6161 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6163 PEER_FLAG_RSERVER_CLIENT
);
6166 ALIAS_HIDDEN(neighbor_route_server_client
,
6167 neighbor_route_server_client_hidden_cmd
,
6168 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6169 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6170 "Configure a neighbor as Route Server client\n")
6172 DEFUN (no_neighbor_route_server_client
,
6173 no_neighbor_route_server_client_cmd
,
6174 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6178 "Configure a neighbor as Route Server client\n")
6181 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6182 bgp_node_afi(vty
), bgp_node_safi(vty
),
6183 PEER_FLAG_RSERVER_CLIENT
);
6186 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6187 no_neighbor_route_server_client_hidden_cmd
,
6188 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6189 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6190 "Configure a neighbor as Route Server client\n")
6192 DEFUN (neighbor_nexthop_local_unchanged
,
6193 neighbor_nexthop_local_unchanged_cmd
,
6194 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6197 "Configure treatment of outgoing link-local nexthop attribute\n"
6198 "Leave link-local nexthop unchanged for this peer\n")
6201 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6203 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6206 DEFUN (no_neighbor_nexthop_local_unchanged
,
6207 no_neighbor_nexthop_local_unchanged_cmd
,
6208 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6212 "Configure treatment of outgoing link-local-nexthop attribute\n"
6213 "Leave link-local nexthop unchanged for this peer\n")
6216 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6217 bgp_node_afi(vty
), bgp_node_safi(vty
),
6218 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6221 DEFUN (neighbor_attr_unchanged
,
6222 neighbor_attr_unchanged_cmd
,
6223 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6226 "BGP attribute is propagated unchanged to this neighbor\n"
6227 "As-path attribute\n"
6228 "Nexthop attribute\n"
6232 char *peer_str
= argv
[1]->arg
;
6234 bool aspath
= false;
6235 bool nexthop
= false;
6237 afi_t afi
= bgp_node_afi(vty
);
6238 safi_t safi
= bgp_node_safi(vty
);
6241 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6243 return CMD_WARNING_CONFIG_FAILED
;
6245 if (argv_find(argv
, argc
, "as-path", &idx
))
6249 if (argv_find(argv
, argc
, "next-hop", &idx
))
6253 if (argv_find(argv
, argc
, "med", &idx
))
6256 /* no flags means all of them! */
6257 if (!aspath
&& !nexthop
&& !med
) {
6258 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6259 PEER_FLAG_AS_PATH_UNCHANGED
);
6260 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6261 PEER_FLAG_NEXTHOP_UNCHANGED
);
6262 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6263 PEER_FLAG_MED_UNCHANGED
);
6266 if (peer_af_flag_check(peer
, afi
, safi
,
6267 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6268 ret
|= peer_af_flag_unset_vty(
6269 vty
, peer_str
, afi
, safi
,
6270 PEER_FLAG_AS_PATH_UNCHANGED
);
6273 ret
|= peer_af_flag_set_vty(
6274 vty
, peer_str
, afi
, safi
,
6275 PEER_FLAG_AS_PATH_UNCHANGED
);
6278 if (peer_af_flag_check(peer
, afi
, safi
,
6279 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6280 ret
|= peer_af_flag_unset_vty(
6281 vty
, peer_str
, afi
, safi
,
6282 PEER_FLAG_NEXTHOP_UNCHANGED
);
6285 ret
|= peer_af_flag_set_vty(
6286 vty
, peer_str
, afi
, safi
,
6287 PEER_FLAG_NEXTHOP_UNCHANGED
);
6290 if (peer_af_flag_check(peer
, afi
, safi
,
6291 PEER_FLAG_MED_UNCHANGED
)) {
6292 ret
|= peer_af_flag_unset_vty(
6293 vty
, peer_str
, afi
, safi
,
6294 PEER_FLAG_MED_UNCHANGED
);
6297 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6298 PEER_FLAG_MED_UNCHANGED
);
6305 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6306 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "BGP attribute is propagated unchanged to this neighbor\n"
6309 "As-path attribute\n"
6310 "Nexthop attribute\n"
6313 DEFUN (no_neighbor_attr_unchanged
,
6314 no_neighbor_attr_unchanged_cmd
,
6315 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6319 "BGP attribute is propagated unchanged to this neighbor\n"
6320 "As-path attribute\n"
6321 "Nexthop attribute\n"
6325 char *peer_str
= argv
[2]->arg
;
6327 bool aspath
= false;
6328 bool nexthop
= false;
6330 afi_t afi
= bgp_node_afi(vty
);
6331 safi_t safi
= bgp_node_safi(vty
);
6334 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6336 return CMD_WARNING_CONFIG_FAILED
;
6338 if (argv_find(argv
, argc
, "as-path", &idx
))
6342 if (argv_find(argv
, argc
, "next-hop", &idx
))
6346 if (argv_find(argv
, argc
, "med", &idx
))
6349 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6350 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6351 PEER_FLAG_AS_PATH_UNCHANGED
)
6352 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6353 PEER_FLAG_NEXTHOP_UNCHANGED
)
6354 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6355 PEER_FLAG_MED_UNCHANGED
);
6358 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6359 PEER_FLAG_AS_PATH_UNCHANGED
);
6362 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6363 PEER_FLAG_NEXTHOP_UNCHANGED
);
6366 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6367 PEER_FLAG_MED_UNCHANGED
);
6373 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6374 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6375 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6376 "BGP attribute is propagated unchanged to this neighbor\n"
6377 "As-path attribute\n"
6378 "Nexthop attribute\n"
6381 /* EBGP multihop configuration. */
6382 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6383 const char *ttl_str
)
6388 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6390 return CMD_WARNING_CONFIG_FAILED
;
6393 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6398 ttl
= strtoul(ttl_str
, NULL
, 10);
6400 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6403 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6407 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6409 return CMD_WARNING_CONFIG_FAILED
;
6411 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6414 /* neighbor ebgp-multihop. */
6415 DEFUN (neighbor_ebgp_multihop
,
6416 neighbor_ebgp_multihop_cmd
,
6417 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6420 "Allow EBGP neighbors not on directly connected networks\n")
6423 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6426 DEFUN (neighbor_ebgp_multihop_ttl
,
6427 neighbor_ebgp_multihop_ttl_cmd
,
6428 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6431 "Allow EBGP neighbors not on directly connected networks\n"
6432 "maximum hop count\n")
6436 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6437 argv
[idx_number
]->arg
);
6440 DEFUN (no_neighbor_ebgp_multihop
,
6441 no_neighbor_ebgp_multihop_cmd
,
6442 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6446 "Allow EBGP neighbors not on directly connected networks\n"
6447 "maximum hop count\n")
6450 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6453 static uint8_t get_role_by_name(const char *role_str
)
6455 if (strncmp(role_str
, "peer", 2) == 0)
6457 if (strncmp(role_str
, "provider", 2) == 0)
6458 return ROLE_PROVIDER
;
6459 if (strncmp(role_str
, "customer", 2) == 0)
6460 return ROLE_CUSTOMER
;
6461 if (strncmp(role_str
, "rs-server", 4) == 0)
6462 return ROLE_RS_SERVER
;
6463 if (strncmp(role_str
, "rs-client", 4) == 0)
6464 return ROLE_RS_CLIENT
;
6465 return ROLE_UNDEFINED
;
6468 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6469 const char *role_str
, bool strict_mode
)
6473 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6475 return CMD_WARNING_CONFIG_FAILED
;
6476 uint8_t role
= get_role_by_name(role_str
);
6478 if (role
== ROLE_UNDEFINED
)
6479 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6480 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6483 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6487 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6489 return CMD_WARNING_CONFIG_FAILED
;
6490 return bgp_vty_return(vty
, peer_role_unset(peer
));
6493 DEFPY(neighbor_role
,
6495 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6498 "Set session role\n"
6504 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6508 DEFPY(neighbor_role_strict
,
6509 neighbor_role_strict_cmd
,
6510 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6513 "Set session role\n"
6515 "Use additional restriction on peer\n")
6520 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6524 DEFPY(no_neighbor_role
,
6525 no_neighbor_role_cmd
,
6526 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6530 "Set session role\n"
6532 "Use additional restriction on peer\n")
6536 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6539 /* disable-connected-check */
6540 DEFUN (neighbor_disable_connected_check
,
6541 neighbor_disable_connected_check_cmd
,
6542 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6545 "one-hop away EBGP peer using loopback address\n"
6546 "Enforce EBGP neighbors perform multihop\n")
6549 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6550 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6553 DEFUN (no_neighbor_disable_connected_check
,
6554 no_neighbor_disable_connected_check_cmd
,
6555 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6559 "one-hop away EBGP peer using loopback address\n"
6560 "Enforce EBGP neighbors perform multihop\n")
6563 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6564 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6567 /* disable-link-bw-encoding-ieee */
6568 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6569 neighbor_disable_link_bw_encoding_ieee_cmd
,
6570 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6571 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6572 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6576 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6577 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6580 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6581 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6582 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6583 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6584 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6588 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6589 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6592 /* extended-optional-parameters */
6593 DEFUN(neighbor_extended_optional_parameters
,
6594 neighbor_extended_optional_parameters_cmd
,
6595 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6596 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6597 "Force the extended optional parameters format for OPEN messages\n")
6601 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6602 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6605 DEFUN(no_neighbor_extended_optional_parameters
,
6606 no_neighbor_extended_optional_parameters_cmd
,
6607 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6608 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6609 "Force the extended optional parameters format for OPEN messages\n")
6613 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6614 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6617 /* enforce-first-as */
6618 DEFUN (neighbor_enforce_first_as
,
6619 neighbor_enforce_first_as_cmd
,
6620 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6623 "Enforce the first AS for EBGP routes\n")
6627 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6628 PEER_FLAG_ENFORCE_FIRST_AS
);
6631 DEFUN (no_neighbor_enforce_first_as
,
6632 no_neighbor_enforce_first_as_cmd
,
6633 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6637 "Enforce the first AS for EBGP routes\n")
6641 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6642 PEER_FLAG_ENFORCE_FIRST_AS
);
6646 DEFUN (neighbor_description
,
6647 neighbor_description_cmd
,
6648 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6651 "Neighbor specific description\n"
6652 "Up to 80 characters describing this neighbor\n")
6659 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6661 return CMD_WARNING_CONFIG_FAILED
;
6663 str
= argv_concat(argv
, argc
, idx_line
);
6665 peer_description_set(peer
, str
);
6667 XFREE(MTYPE_TMP
, str
);
6672 DEFUN (no_neighbor_description
,
6673 no_neighbor_description_cmd
,
6674 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6678 "Neighbor specific description\n")
6683 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6685 return CMD_WARNING_CONFIG_FAILED
;
6687 peer_description_unset(peer
);
6692 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6693 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6694 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6695 "Neighbor specific description\n"
6696 "Up to 80 characters describing this neighbor\n")
6698 /* Neighbor update-source. */
6699 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6700 const char *source_str
)
6706 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6708 return CMD_WARNING_CONFIG_FAILED
;
6714 if (str2sockunion(source_str
, &su
) == 0)
6715 peer_update_source_addr_set(peer
, &su
);
6717 if (str2prefix(source_str
, &p
)) {
6719 "%% Invalid update-source, remove prefix length \n");
6720 return CMD_WARNING_CONFIG_FAILED
;
6722 peer_update_source_if_set(peer
, source_str
);
6725 peer_update_source_unset(peer
);
6730 #define BGP_UPDATE_SOURCE_HELP_STR \
6733 "Interface name (requires zebra to be running)\n"
6735 DEFUN (neighbor_update_source
,
6736 neighbor_update_source_cmd
,
6737 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6740 "Source of routing updates\n"
6741 BGP_UPDATE_SOURCE_HELP_STR
)
6745 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6746 argv
[idx_peer_2
]->arg
);
6749 DEFUN (no_neighbor_update_source
,
6750 no_neighbor_update_source_cmd
,
6751 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6755 "Source of routing updates\n"
6756 BGP_UPDATE_SOURCE_HELP_STR
)
6759 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6762 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6763 afi_t afi
, safi_t safi
,
6764 const char *rmap
, int set
)
6768 struct route_map
*route_map
= NULL
;
6770 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6772 return CMD_WARNING_CONFIG_FAILED
;
6776 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6777 ret
= peer_default_originate_set(peer
, afi
, safi
,
6780 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6782 return bgp_vty_return(vty
, ret
);
6785 /* neighbor default-originate. */
6786 DEFUN (neighbor_default_originate
,
6787 neighbor_default_originate_cmd
,
6788 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6791 "Originate default route to this neighbor\n")
6794 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6796 bgp_node_safi(vty
), NULL
, 1);
6799 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6800 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6801 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6802 "Originate default route to this neighbor\n")
6804 DEFUN (neighbor_default_originate_rmap
,
6805 neighbor_default_originate_rmap_cmd
,
6806 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6809 "Originate default route to this neighbor\n"
6810 "Route-map to specify criteria to originate default\n"
6815 return peer_default_originate_set_vty(
6816 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6817 argv
[idx_word
]->arg
, 1);
6821 neighbor_default_originate_rmap
,
6822 neighbor_default_originate_rmap_hidden_cmd
,
6823 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6824 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6825 "Originate default route to this neighbor\n"
6826 "Route-map to specify criteria to originate default\n"
6829 DEFUN (no_neighbor_default_originate
,
6830 no_neighbor_default_originate_cmd
,
6831 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6835 "Originate default route to this neighbor\n"
6836 "Route-map to specify criteria to originate default\n"
6840 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6842 bgp_node_safi(vty
), NULL
, 0);
6846 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6847 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6848 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6849 "Originate default route to this neighbor\n"
6850 "Route-map to specify criteria to originate default\n"
6854 /* Set neighbor's BGP port. */
6855 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6856 const char *port_str
)
6862 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6864 return CMD_WARNING_CONFIG_FAILED
;
6867 sp
= getservbyname("bgp", "tcp");
6868 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6870 port
= strtoul(port_str
, NULL
, 10);
6873 peer_port_set(peer
, port
);
6878 /* Set specified peer's BGP port. */
6879 DEFUN (neighbor_port
,
6881 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6884 "Neighbor's BGP port\n"
6885 "TCP port number\n")
6889 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6890 argv
[idx_number
]->arg
);
6893 DEFUN (no_neighbor_port
,
6894 no_neighbor_port_cmd
,
6895 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6899 "Neighbor's BGP port\n"
6900 "TCP port number\n")
6903 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6907 /* neighbor weight. */
6908 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6909 safi_t safi
, const char *weight_str
)
6913 unsigned long weight
;
6915 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6917 return CMD_WARNING_CONFIG_FAILED
;
6919 weight
= strtoul(weight_str
, NULL
, 10);
6921 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6922 return bgp_vty_return(vty
, ret
);
6925 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6931 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6933 return CMD_WARNING_CONFIG_FAILED
;
6935 ret
= peer_weight_unset(peer
, afi
, safi
);
6936 return bgp_vty_return(vty
, ret
);
6939 DEFUN (neighbor_weight
,
6940 neighbor_weight_cmd
,
6941 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6944 "Set default weight for routes from this neighbor\n"
6949 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6950 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6953 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6954 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6955 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6956 "Set default weight for routes from this neighbor\n"
6959 DEFUN (no_neighbor_weight
,
6960 no_neighbor_weight_cmd
,
6961 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6965 "Set default weight for routes from this neighbor\n"
6969 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6970 bgp_node_afi(vty
), bgp_node_safi(vty
));
6973 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6974 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6975 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6976 "Set default weight for routes from this neighbor\n"
6980 /* Override capability negotiation. */
6981 DEFUN (neighbor_override_capability
,
6982 neighbor_override_capability_cmd
,
6983 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6986 "Override capability negotiation result\n")
6989 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6990 PEER_FLAG_OVERRIDE_CAPABILITY
);
6993 DEFUN (no_neighbor_override_capability
,
6994 no_neighbor_override_capability_cmd
,
6995 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6999 "Override capability negotiation result\n")
7002 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7003 PEER_FLAG_OVERRIDE_CAPABILITY
);
7006 DEFUN (neighbor_strict_capability
,
7007 neighbor_strict_capability_cmd
,
7008 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7011 "Strict capability negotiation match\n")
7015 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7016 PEER_FLAG_STRICT_CAP_MATCH
);
7019 DEFUN (no_neighbor_strict_capability
,
7020 no_neighbor_strict_capability_cmd
,
7021 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7025 "Strict capability negotiation match\n")
7029 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7030 PEER_FLAG_STRICT_CAP_MATCH
);
7033 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7034 const char *keep_str
, const char *hold_str
)
7041 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7043 return CMD_WARNING_CONFIG_FAILED
;
7045 keepalive
= strtoul(keep_str
, NULL
, 10);
7046 holdtime
= strtoul(hold_str
, NULL
, 10);
7048 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7050 return bgp_vty_return(vty
, ret
);
7053 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7058 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7060 return CMD_WARNING_CONFIG_FAILED
;
7062 ret
= peer_timers_unset(peer
);
7064 return bgp_vty_return(vty
, ret
);
7067 DEFUN (neighbor_timers
,
7068 neighbor_timers_cmd
,
7069 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7072 "BGP per neighbor timers\n"
7073 "Keepalive interval\n"
7078 int idx_number_2
= 4;
7079 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7080 argv
[idx_number
]->arg
,
7081 argv
[idx_number_2
]->arg
);
7084 DEFUN (no_neighbor_timers
,
7085 no_neighbor_timers_cmd
,
7086 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7090 "BGP per neighbor timers\n"
7091 "Keepalive interval\n"
7095 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7099 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7100 const char *time_str
)
7106 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7108 return CMD_WARNING_CONFIG_FAILED
;
7110 connect
= strtoul(time_str
, NULL
, 10);
7112 ret
= peer_timers_connect_set(peer
, connect
);
7114 return bgp_vty_return(vty
, ret
);
7117 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7122 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7124 return CMD_WARNING_CONFIG_FAILED
;
7126 ret
= peer_timers_connect_unset(peer
);
7128 return bgp_vty_return(vty
, ret
);
7131 DEFUN (neighbor_timers_connect
,
7132 neighbor_timers_connect_cmd
,
7133 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7136 "BGP per neighbor timers\n"
7137 "BGP connect timer\n"
7142 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7143 argv
[idx_number
]->arg
);
7146 DEFUN (no_neighbor_timers_connect
,
7147 no_neighbor_timers_connect_cmd
,
7148 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7152 "BGP per neighbor timers\n"
7153 "BGP connect timer\n"
7157 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7160 DEFPY (neighbor_timers_delayopen
,
7161 neighbor_timers_delayopen_cmd
,
7162 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7165 "BGP per neighbor timers\n"
7166 "RFC 4271 DelayOpenTimer\n"
7167 "DelayOpenTime timer interval\n")
7171 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7173 return CMD_WARNING_CONFIG_FAILED
;
7176 if (peer_timers_delayopen_unset(peer
))
7177 return CMD_WARNING_CONFIG_FAILED
;
7179 if (peer_timers_delayopen_set(peer
, interval
))
7180 return CMD_WARNING_CONFIG_FAILED
;
7186 DEFPY (no_neighbor_timers_delayopen
,
7187 no_neighbor_timers_delayopen_cmd
,
7188 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7192 "BGP per neighbor timers\n"
7193 "RFC 4271 DelayOpenTimer\n"
7194 "DelayOpenTime timer interval\n")
7198 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7200 return CMD_WARNING_CONFIG_FAILED
;
7202 if (peer_timers_delayopen_unset(peer
))
7203 return CMD_WARNING_CONFIG_FAILED
;
7208 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7209 const char *time_str
, int set
)
7213 uint32_t routeadv
= 0;
7215 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7217 return CMD_WARNING_CONFIG_FAILED
;
7220 routeadv
= strtoul(time_str
, NULL
, 10);
7223 ret
= peer_advertise_interval_set(peer
, routeadv
);
7225 ret
= peer_advertise_interval_unset(peer
);
7227 return bgp_vty_return(vty
, ret
);
7230 DEFUN (neighbor_advertise_interval
,
7231 neighbor_advertise_interval_cmd
,
7232 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7235 "Minimum interval between sending BGP routing updates\n"
7236 "time in seconds\n")
7240 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7241 argv
[idx_number
]->arg
, 1);
7244 DEFUN (no_neighbor_advertise_interval
,
7245 no_neighbor_advertise_interval_cmd
,
7246 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7250 "Minimum interval between sending BGP routing updates\n"
7251 "time in seconds\n")
7254 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7258 /* Time to wait before processing route-map updates */
7259 DEFUN (bgp_set_route_map_delay_timer
,
7260 bgp_set_route_map_delay_timer_cmd
,
7261 "bgp route-map delay-timer (0-600)",
7263 "BGP route-map delay timer\n"
7264 "Time in secs to wait before processing route-map changes\n"
7265 "0 disables the timer, no route updates happen when route-maps change\n")
7268 uint32_t rmap_delay_timer
;
7270 if (argv
[idx_number
]->arg
) {
7271 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7272 bm
->rmap_update_timer
= rmap_delay_timer
;
7274 /* if the dynamic update handling is being disabled, and a timer
7276 * running, stop the timer and act as if the timer has already
7279 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7280 THREAD_OFF(bm
->t_rmap_update
);
7281 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7286 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7287 return CMD_WARNING_CONFIG_FAILED
;
7291 DEFUN (no_bgp_set_route_map_delay_timer
,
7292 no_bgp_set_route_map_delay_timer_cmd
,
7293 "no bgp route-map delay-timer [(0-600)]",
7296 "Default BGP route-map delay timer\n"
7297 "Reset to default time to wait for processing route-map changes\n"
7298 "0 disables the timer, no route updates happen when route-maps change\n")
7301 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7306 /* neighbor interface */
7307 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7312 peer
= peer_lookup_vty(vty
, ip_str
);
7313 if (!peer
|| peer
->conf_if
) {
7314 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7315 return CMD_WARNING_CONFIG_FAILED
;
7319 peer_interface_set(peer
, str
);
7321 peer_interface_unset(peer
);
7326 DEFUN (neighbor_interface
,
7327 neighbor_interface_cmd
,
7328 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7337 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7340 DEFUN (no_neighbor_interface
,
7341 no_neighbor_interface_cmd
,
7342 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7351 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7354 DEFUN (neighbor_distribute_list
,
7355 neighbor_distribute_list_cmd
,
7356 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7359 "Filter updates to/from this neighbor\n"
7360 "IP Access-list name\n"
7361 "Filter incoming updates\n"
7362 "Filter outgoing updates\n")
7369 const char *pstr
= argv
[idx_peer
]->arg
;
7370 const char *acl
= argv
[idx_acl
]->arg
;
7371 const char *inout
= argv
[argc
- 1]->text
;
7373 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7375 return CMD_WARNING_CONFIG_FAILED
;
7377 /* Check filter direction. */
7378 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7379 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7382 return bgp_vty_return(vty
, ret
);
7386 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7387 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7388 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7389 "Filter updates to/from this neighbor\n"
7390 "IP Access-list name\n"
7391 "Filter incoming updates\n"
7392 "Filter outgoing updates\n")
7394 DEFUN (no_neighbor_distribute_list
,
7395 no_neighbor_distribute_list_cmd
,
7396 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7400 "Filter updates to/from this neighbor\n"
7401 "IP Access-list name\n"
7402 "Filter incoming updates\n"
7403 "Filter outgoing updates\n")
7409 const char *pstr
= argv
[idx_peer
]->arg
;
7410 const char *inout
= argv
[argc
- 1]->text
;
7412 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7414 return CMD_WARNING_CONFIG_FAILED
;
7416 /* Check filter direction. */
7417 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7418 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7421 return bgp_vty_return(vty
, ret
);
7425 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7426 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7427 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7428 "Filter updates to/from this neighbor\n"
7429 "IP Access-list name\n"
7430 "Filter incoming updates\n"
7431 "Filter outgoing updates\n")
7433 /* Set prefix list to the peer. */
7434 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7435 afi_t afi
, safi_t safi
,
7436 const char *name_str
,
7437 const char *direct_str
)
7440 int direct
= FILTER_IN
;
7443 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7445 return CMD_WARNING_CONFIG_FAILED
;
7447 /* Check filter direction. */
7448 if (strncmp(direct_str
, "i", 1) == 0)
7450 else if (strncmp(direct_str
, "o", 1) == 0)
7451 direct
= FILTER_OUT
;
7453 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7455 return bgp_vty_return(vty
, ret
);
7458 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7459 afi_t afi
, safi_t safi
,
7460 const char *direct_str
)
7464 int direct
= FILTER_IN
;
7466 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7468 return CMD_WARNING_CONFIG_FAILED
;
7470 /* Check filter direction. */
7471 if (strncmp(direct_str
, "i", 1) == 0)
7473 else if (strncmp(direct_str
, "o", 1) == 0)
7474 direct
= FILTER_OUT
;
7476 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7478 return bgp_vty_return(vty
, ret
);
7481 DEFUN (neighbor_prefix_list
,
7482 neighbor_prefix_list_cmd
,
7483 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7486 "Filter updates to/from this neighbor\n"
7487 "Name of a prefix list\n"
7488 "Filter incoming updates\n"
7489 "Filter outgoing updates\n")
7494 return peer_prefix_list_set_vty(
7495 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7496 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7499 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7500 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7501 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7502 "Filter updates to/from this neighbor\n"
7503 "Name of a prefix list\n"
7504 "Filter incoming updates\n"
7505 "Filter outgoing updates\n")
7507 DEFUN (no_neighbor_prefix_list
,
7508 no_neighbor_prefix_list_cmd
,
7509 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7513 "Filter updates to/from this neighbor\n"
7514 "Name of a prefix list\n"
7515 "Filter incoming updates\n"
7516 "Filter outgoing updates\n")
7520 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7521 bgp_node_afi(vty
), bgp_node_safi(vty
),
7522 argv
[idx_in_out
]->arg
);
7525 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7526 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7527 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7528 "Filter updates to/from this neighbor\n"
7529 "Name of a prefix list\n"
7530 "Filter incoming updates\n"
7531 "Filter outgoing updates\n")
7533 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7534 safi_t safi
, const char *name_str
,
7535 const char *direct_str
)
7539 int direct
= FILTER_IN
;
7541 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7543 return CMD_WARNING_CONFIG_FAILED
;
7545 /* Check filter direction. */
7546 if (strncmp(direct_str
, "i", 1) == 0)
7548 else if (strncmp(direct_str
, "o", 1) == 0)
7549 direct
= FILTER_OUT
;
7551 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7553 return bgp_vty_return(vty
, ret
);
7556 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7557 safi_t safi
, const char *direct_str
)
7561 int direct
= FILTER_IN
;
7563 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7565 return CMD_WARNING_CONFIG_FAILED
;
7567 /* Check filter direction. */
7568 if (strncmp(direct_str
, "i", 1) == 0)
7570 else if (strncmp(direct_str
, "o", 1) == 0)
7571 direct
= FILTER_OUT
;
7573 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7575 return bgp_vty_return(vty
, ret
);
7578 DEFUN (neighbor_filter_list
,
7579 neighbor_filter_list_cmd
,
7580 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7583 "Establish BGP filters\n"
7584 "AS path access-list name\n"
7585 "Filter incoming routes\n"
7586 "Filter outgoing routes\n")
7591 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7592 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7593 argv
[idx_in_out
]->arg
);
7596 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7597 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7598 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7599 "Establish BGP filters\n"
7600 "AS path access-list name\n"
7601 "Filter incoming routes\n"
7602 "Filter outgoing routes\n")
7604 DEFUN (no_neighbor_filter_list
,
7605 no_neighbor_filter_list_cmd
,
7606 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7610 "Establish BGP filters\n"
7611 "AS path access-list name\n"
7612 "Filter incoming routes\n"
7613 "Filter outgoing routes\n")
7617 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7618 bgp_node_afi(vty
), bgp_node_safi(vty
),
7619 argv
[idx_in_out
]->arg
);
7622 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7623 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7624 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7625 "Establish BGP filters\n"
7626 "AS path access-list name\n"
7627 "Filter incoming routes\n"
7628 "Filter outgoing routes\n")
7630 /* Set advertise-map to the peer. */
7631 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7632 afi_t afi
, safi_t safi
,
7633 const char *advertise_str
,
7634 const char *condition_str
, bool condition
,
7637 int ret
= CMD_WARNING_CONFIG_FAILED
;
7639 struct route_map
*advertise_map
;
7640 struct route_map
*condition_map
;
7642 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7646 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7647 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7650 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7651 advertise_map
, condition_str
,
7652 condition_map
, condition
);
7654 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7655 advertise_map
, condition_str
,
7656 condition_map
, condition
);
7658 return bgp_vty_return(vty
, ret
);
7661 DEFPY (bgp_condadv_period
,
7662 bgp_condadv_period_cmd
,
7663 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7666 "Conditional advertisement settings\n"
7667 "Set period to rescan BGP table to check if condition is met\n"
7668 "Period between BGP table scans, in seconds; default 60\n")
7670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7672 bgp
->condition_check_period
=
7673 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7678 DEFPY (neighbor_advertise_map
,
7679 neighbor_advertise_map_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",
7684 "Route-map to conditionally advertise routes\n"
7685 "Name of advertise map\n"
7686 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7687 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7688 "Name of the exist or non exist map\n")
7690 bool condition
= CONDITION_EXIST
;
7692 if (!strcmp(exist
, "non-exist-map"))
7693 condition
= CONDITION_NON_EXIST
;
7695 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7696 bgp_node_safi(vty
), advertise_str
,
7697 condition_str
, condition
, !no
);
7700 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7701 "[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",
7702 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7703 "Route-map to conditionally advertise routes\n"
7704 "Name of advertise map\n"
7705 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7706 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7707 "Name of the exist or non exist map\n")
7709 /* Set route-map to the peer. */
7710 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7711 afi_t afi
, safi_t safi
, const char *name_str
,
7712 const char *direct_str
)
7716 int direct
= RMAP_IN
;
7717 struct route_map
*route_map
;
7719 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7721 return CMD_WARNING_CONFIG_FAILED
;
7723 /* Check filter direction. */
7724 if (strncmp(direct_str
, "in", 2) == 0)
7726 else if (strncmp(direct_str
, "o", 1) == 0)
7729 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7730 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7732 return bgp_vty_return(vty
, ret
);
7735 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7736 afi_t afi
, safi_t safi
,
7737 const char *direct_str
)
7741 int direct
= RMAP_IN
;
7743 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7745 return CMD_WARNING_CONFIG_FAILED
;
7747 /* Check filter direction. */
7748 if (strncmp(direct_str
, "in", 2) == 0)
7750 else if (strncmp(direct_str
, "o", 1) == 0)
7753 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7755 return bgp_vty_return(vty
, ret
);
7758 DEFUN (neighbor_route_map
,
7759 neighbor_route_map_cmd
,
7760 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7763 "Apply route map to neighbor\n"
7764 "Name of route map\n"
7765 "Apply map to incoming routes\n"
7766 "Apply map to outbound routes\n")
7771 return peer_route_map_set_vty(
7772 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7773 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7776 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7777 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7778 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7779 "Apply route map to neighbor\n"
7780 "Name of route map\n"
7781 "Apply map to incoming routes\n"
7782 "Apply map to outbound routes\n")
7784 DEFUN (no_neighbor_route_map
,
7785 no_neighbor_route_map_cmd
,
7786 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7790 "Apply route map to neighbor\n"
7791 "Name of route map\n"
7792 "Apply map to incoming routes\n"
7793 "Apply map to outbound routes\n")
7797 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7798 bgp_node_afi(vty
), bgp_node_safi(vty
),
7799 argv
[idx_in_out
]->arg
);
7802 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7803 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7804 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7805 "Apply route map to neighbor\n"
7806 "Name of route map\n"
7807 "Apply map to incoming routes\n"
7808 "Apply map to outbound routes\n")
7810 /* Set unsuppress-map to the peer. */
7811 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7812 afi_t afi
, safi_t safi
,
7813 const char *name_str
)
7817 struct route_map
*route_map
;
7819 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7821 return CMD_WARNING_CONFIG_FAILED
;
7823 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7824 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7826 return bgp_vty_return(vty
, ret
);
7829 /* Unset route-map from the peer. */
7830 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7831 afi_t afi
, safi_t safi
)
7836 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7838 return CMD_WARNING_CONFIG_FAILED
;
7840 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7842 return bgp_vty_return(vty
, ret
);
7845 DEFUN (neighbor_unsuppress_map
,
7846 neighbor_unsuppress_map_cmd
,
7847 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7850 "Route-map to selectively unsuppress suppressed routes\n"
7851 "Name of route map\n")
7855 return peer_unsuppress_map_set_vty(
7856 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7857 argv
[idx_word
]->arg
);
7860 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7861 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7862 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7863 "Route-map to selectively unsuppress suppressed routes\n"
7864 "Name of route map\n")
7866 DEFUN (no_neighbor_unsuppress_map
,
7867 no_neighbor_unsuppress_map_cmd
,
7868 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7872 "Route-map to selectively unsuppress suppressed routes\n"
7873 "Name of route map\n")
7876 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7878 bgp_node_safi(vty
));
7881 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7882 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7883 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7884 "Route-map to selectively unsuppress suppressed routes\n"
7885 "Name of route map\n")
7887 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7888 afi_t afi
, safi_t safi
,
7889 const char *num_str
,
7890 const char *threshold_str
, int warning
,
7891 const char *restart_str
,
7892 const char *force_str
)
7900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7902 return CMD_WARNING_CONFIG_FAILED
;
7904 max
= strtoul(num_str
, NULL
, 10);
7906 threshold
= atoi(threshold_str
);
7908 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7911 restart
= atoi(restart_str
);
7915 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7916 restart
, force_str
? true : false);
7918 return bgp_vty_return(vty
, ret
);
7921 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7922 afi_t afi
, safi_t safi
)
7927 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7929 return CMD_WARNING_CONFIG_FAILED
;
7931 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7933 return bgp_vty_return(vty
, ret
);
7936 /* Maximum number of prefix to be sent to the neighbor. */
7937 DEFUN(neighbor_maximum_prefix_out
,
7938 neighbor_maximum_prefix_out_cmd
,
7939 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7942 "Maximum number of prefixes to be sent to this peer\n"
7943 "Maximum no. of prefix limit\n")
7950 afi_t afi
= bgp_node_afi(vty
);
7951 safi_t safi
= bgp_node_safi(vty
);
7953 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7955 return CMD_WARNING_CONFIG_FAILED
;
7957 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7959 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7961 return bgp_vty_return(vty
, ret
);
7964 DEFUN(no_neighbor_maximum_prefix_out
,
7965 no_neighbor_maximum_prefix_out_cmd
,
7966 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7970 "Maximum number of prefixes to be sent to this peer\n"
7971 "Maximum no. of prefix limit\n")
7976 afi_t afi
= bgp_node_afi(vty
);
7977 safi_t safi
= bgp_node_safi(vty
);
7979 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7981 return CMD_WARNING_CONFIG_FAILED
;
7983 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
7985 return bgp_vty_return(vty
, ret
);
7988 /* Maximum number of prefix configuration. Prefix count is different
7989 for each peer configuration. So this configuration can be set for
7990 each peer configuration. */
7991 DEFUN (neighbor_maximum_prefix
,
7992 neighbor_maximum_prefix_cmd
,
7993 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7996 "Maximum number of prefix accept from this peer\n"
7997 "maximum no. of prefix limit\n"
7998 "Force checking all received routes not only accepted\n")
8005 if (argv_find(argv
, argc
, "force", &idx_force
))
8006 force
= argv
[idx_force
]->arg
;
8008 return peer_maximum_prefix_set_vty(
8009 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8010 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8013 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8014 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8015 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8016 "Maximum number of prefix accept from this peer\n"
8017 "maximum no. of prefix limit\n"
8018 "Force checking all received routes not only accepted\n")
8020 DEFUN (neighbor_maximum_prefix_threshold
,
8021 neighbor_maximum_prefix_threshold_cmd
,
8022 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8025 "Maximum number of prefix accept from this peer\n"
8026 "maximum no. of prefix limit\n"
8027 "Threshold value (%) at which to generate a warning msg\n"
8028 "Force checking all received routes not only accepted\n")
8032 int idx_number_2
= 4;
8036 if (argv_find(argv
, argc
, "force", &idx_force
))
8037 force
= argv
[idx_force
]->arg
;
8039 return peer_maximum_prefix_set_vty(
8040 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8041 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8045 neighbor_maximum_prefix_threshold
,
8046 neighbor_maximum_prefix_threshold_hidden_cmd
,
8047 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8048 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8049 "Maximum number of prefix accept from this peer\n"
8050 "maximum no. of prefix limit\n"
8051 "Threshold value (%) at which to generate a warning msg\n"
8052 "Force checking all received routes not only accepted\n")
8054 DEFUN (neighbor_maximum_prefix_warning
,
8055 neighbor_maximum_prefix_warning_cmd
,
8056 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8059 "Maximum number of prefix accept from this peer\n"
8060 "maximum no. of prefix limit\n"
8061 "Only give warning message when limit is exceeded\n"
8062 "Force checking all received routes not only accepted\n")
8069 if (argv_find(argv
, argc
, "force", &idx_force
))
8070 force
= argv
[idx_force
]->arg
;
8072 return peer_maximum_prefix_set_vty(
8073 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8074 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8078 neighbor_maximum_prefix_warning
,
8079 neighbor_maximum_prefix_warning_hidden_cmd
,
8080 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8081 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8082 "Maximum number of prefix accept from this peer\n"
8083 "maximum no. of prefix limit\n"
8084 "Only give warning message when limit is exceeded\n"
8085 "Force checking all received routes not only accepted\n")
8087 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8088 neighbor_maximum_prefix_threshold_warning_cmd
,
8089 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8092 "Maximum number of prefix accept from this peer\n"
8093 "maximum no. of prefix limit\n"
8094 "Threshold value (%) at which to generate a warning msg\n"
8095 "Only give warning message when limit is exceeded\n"
8096 "Force checking all received routes not only accepted\n")
8100 int idx_number_2
= 4;
8104 if (argv_find(argv
, argc
, "force", &idx_force
))
8105 force
= argv
[idx_force
]->arg
;
8107 return peer_maximum_prefix_set_vty(
8108 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8109 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8113 neighbor_maximum_prefix_threshold_warning
,
8114 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8115 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8116 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8117 "Maximum number of prefix accept from this peer\n"
8118 "maximum no. of prefix limit\n"
8119 "Threshold value (%) at which to generate a warning msg\n"
8120 "Only give warning message when limit is exceeded\n"
8121 "Force checking all received routes not only accepted\n")
8123 DEFUN (neighbor_maximum_prefix_restart
,
8124 neighbor_maximum_prefix_restart_cmd
,
8125 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8128 "Maximum number of prefix accept from this peer\n"
8129 "maximum no. of prefix limit\n"
8130 "Restart bgp connection after limit is exceeded\n"
8131 "Restart interval in minutes\n"
8132 "Force checking all received routes not only accepted\n")
8136 int idx_number_2
= 5;
8140 if (argv_find(argv
, argc
, "force", &idx_force
))
8141 force
= argv
[idx_force
]->arg
;
8143 return peer_maximum_prefix_set_vty(
8144 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8145 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8149 neighbor_maximum_prefix_restart
,
8150 neighbor_maximum_prefix_restart_hidden_cmd
,
8151 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8152 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8153 "Maximum number of prefix accept from this peer\n"
8154 "maximum no. of prefix limit\n"
8155 "Restart bgp connection after limit is exceeded\n"
8156 "Restart interval in minutes\n"
8157 "Force checking all received routes not only accepted\n")
8159 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8160 neighbor_maximum_prefix_threshold_restart_cmd
,
8161 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8164 "Maximum number of prefixes to accept from this peer\n"
8165 "maximum no. of prefix limit\n"
8166 "Threshold value (%) at which to generate a warning msg\n"
8167 "Restart bgp connection after limit is exceeded\n"
8168 "Restart interval in minutes\n"
8169 "Force checking all received routes not only accepted\n")
8173 int idx_number_2
= 4;
8174 int idx_number_3
= 6;
8178 if (argv_find(argv
, argc
, "force", &idx_force
))
8179 force
= argv
[idx_force
]->arg
;
8181 return peer_maximum_prefix_set_vty(
8182 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8183 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8184 argv
[idx_number_3
]->arg
, force
);
8188 neighbor_maximum_prefix_threshold_restart
,
8189 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8190 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8191 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8192 "Maximum number of prefixes to accept from this peer\n"
8193 "maximum no. of prefix limit\n"
8194 "Threshold value (%) at which to generate a warning msg\n"
8195 "Restart bgp connection after limit is exceeded\n"
8196 "Restart interval in minutes\n"
8197 "Force checking all received routes not only accepted\n")
8199 DEFUN (no_neighbor_maximum_prefix
,
8200 no_neighbor_maximum_prefix_cmd
,
8201 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8205 "Maximum number of prefixes to accept from this peer\n"
8206 "maximum no. of prefix limit\n"
8207 "Threshold value (%) at which to generate a warning msg\n"
8208 "Restart bgp connection after limit is exceeded\n"
8209 "Restart interval in minutes\n"
8210 "Only give warning message when limit is exceeded\n"
8211 "Force checking all received routes not only accepted\n")
8214 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8216 bgp_node_safi(vty
));
8220 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8221 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8222 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8223 "Maximum number of prefixes to accept from this peer\n"
8224 "maximum no. of prefix limit\n"
8225 "Threshold value (%) at which to generate a warning msg\n"
8226 "Restart bgp connection after limit is exceeded\n"
8227 "Restart interval in minutes\n"
8228 "Only give warning message when limit is exceeded\n"
8229 "Force checking all received routes not only accepted\n")
8232 /* "neighbor allowas-in" */
8233 DEFUN (neighbor_allowas_in
,
8234 neighbor_allowas_in_cmd
,
8235 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8238 "Accept as-path with my AS present in it\n"
8239 "Number of occurrences of AS number\n"
8240 "Only accept my AS in the as-path if the route was originated in my AS\n")
8243 int idx_number_origin
= 3;
8249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8251 return CMD_WARNING_CONFIG_FAILED
;
8253 if (argc
<= idx_number_origin
)
8256 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8259 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8262 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8265 return bgp_vty_return(vty
, ret
);
8269 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8270 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8271 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8272 "Accept as-path with my AS present in it\n"
8273 "Number of occurrences of AS number\n"
8274 "Only accept my AS in the as-path if the route was originated in my AS\n")
8276 DEFUN (no_neighbor_allowas_in
,
8277 no_neighbor_allowas_in_cmd
,
8278 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8282 "allow local ASN appears in aspath attribute\n"
8283 "Number of occurrences of AS number\n"
8284 "Only accept my AS in the as-path if the route was originated in my AS\n")
8290 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8292 return CMD_WARNING_CONFIG_FAILED
;
8294 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8295 bgp_node_safi(vty
));
8297 return bgp_vty_return(vty
, ret
);
8301 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8302 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8303 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8304 "allow local ASN appears in aspath attribute\n"
8305 "Number of occurrences of AS number\n"
8306 "Only accept my AS in the as-path if the route was originated in my AS\n")
8308 DEFUN (neighbor_ttl_security
,
8309 neighbor_ttl_security_cmd
,
8310 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8313 "BGP ttl-security parameters\n"
8314 "Specify the maximum number of hops to the BGP peer\n"
8315 "Number of hops to BGP peer\n")
8322 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8324 return CMD_WARNING_CONFIG_FAILED
;
8326 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8329 * If 'neighbor swpX', then this is for directly connected peers,
8330 * we should not accept a ttl-security hops value greater than 1.
8332 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8334 "%s is directly connected peer, hops cannot exceed 1\n",
8335 argv
[idx_peer
]->arg
);
8336 return CMD_WARNING_CONFIG_FAILED
;
8339 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8342 DEFUN (no_neighbor_ttl_security
,
8343 no_neighbor_ttl_security_cmd
,
8344 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8348 "BGP ttl-security parameters\n"
8349 "Specify the maximum number of hops to the BGP peer\n"
8350 "Number of hops to BGP peer\n")
8355 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8357 return CMD_WARNING_CONFIG_FAILED
;
8359 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8362 /* disable-addpath-rx */
8363 DEFUN(neighbor_disable_addpath_rx
,
8364 neighbor_disable_addpath_rx_cmd
,
8365 "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
[1]->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_set_vty(vty
, peer_str
, afi
, safi
,
8380 PEER_FLAG_DISABLE_ADDPATH_RX
);
8383 DEFUN(no_neighbor_disable_addpath_rx
,
8384 no_neighbor_disable_addpath_rx_cmd
,
8385 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8389 "Do not accept additional paths\n")
8391 char *peer_str
= argv
[2]->arg
;
8393 afi_t afi
= bgp_node_afi(vty
);
8394 safi_t safi
= bgp_node_safi(vty
);
8396 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8398 return CMD_WARNING_CONFIG_FAILED
;
8400 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8401 PEER_FLAG_DISABLE_ADDPATH_RX
);
8404 DEFUN (neighbor_addpath_tx_all_paths
,
8405 neighbor_addpath_tx_all_paths_cmd
,
8406 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8409 "Use addpath to advertise all paths to a neighbor\n")
8414 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8416 return CMD_WARNING_CONFIG_FAILED
;
8418 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8423 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8424 neighbor_addpath_tx_all_paths_hidden_cmd
,
8425 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8426 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8427 "Use addpath to advertise all paths to a neighbor\n")
8429 DEFUN (no_neighbor_addpath_tx_all_paths
,
8430 no_neighbor_addpath_tx_all_paths_cmd
,
8431 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8435 "Use addpath to advertise all paths to a neighbor\n")
8440 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8442 return CMD_WARNING_CONFIG_FAILED
;
8444 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8445 != BGP_ADDPATH_ALL
) {
8447 "%% Peer not currently configured to transmit all paths.");
8448 return CMD_WARNING_CONFIG_FAILED
;
8451 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8457 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8458 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8459 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8460 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8461 "Use addpath to advertise all paths to a neighbor\n")
8463 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8464 neighbor_addpath_tx_bestpath_per_as_cmd
,
8465 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8468 "Use addpath to advertise the bestpath per each neighboring AS\n")
8473 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8475 return CMD_WARNING_CONFIG_FAILED
;
8477 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8478 BGP_ADDPATH_BEST_PER_AS
);
8483 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8484 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8485 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8486 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8487 "Use addpath to advertise the bestpath per each neighboring AS\n")
8489 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8490 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8491 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8495 "Use addpath to advertise the bestpath per each neighboring AS\n")
8500 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8502 return CMD_WARNING_CONFIG_FAILED
;
8504 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8505 != BGP_ADDPATH_BEST_PER_AS
) {
8507 "%% Peer not currently configured to transmit all best path per as.");
8508 return CMD_WARNING_CONFIG_FAILED
;
8511 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8517 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8518 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8519 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8520 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8521 "Use addpath to advertise the bestpath per each neighboring AS\n")
8524 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8525 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8528 "Detect AS loops before sending to neighbor\n")
8532 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8534 return CMD_WARNING_CONFIG_FAILED
;
8536 peer
->as_path_loop_detection
= true;
8542 no_neighbor_aspath_loop_detection
,
8543 no_neighbor_aspath_loop_detection_cmd
,
8544 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8548 "Detect AS loops before sending to neighbor\n")
8552 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8554 return CMD_WARNING_CONFIG_FAILED
;
8556 peer
->as_path_loop_detection
= false;
8561 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8562 struct ecommunity
**list
, bool is_rt6
)
8564 struct ecommunity
*ecom
= NULL
;
8565 struct ecommunity
*ecomadd
;
8567 for (; argc
; --argc
, ++argv
) {
8569 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8570 ECOMMUNITY_ROUTE_TARGET
,
8573 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8574 ECOMMUNITY_ROUTE_TARGET
,
8577 vty_out(vty
, "Malformed community-list value\n");
8579 ecommunity_free(&ecom
);
8580 return CMD_WARNING_CONFIG_FAILED
;
8584 ecommunity_merge(ecom
, ecomadd
);
8585 ecommunity_free(&ecomadd
);
8592 ecommunity_free(&*list
);
8600 * v2vimport is true if we are handling a `import vrf ...` command
8602 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8606 switch (vty
->node
) {
8615 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8620 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8621 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8622 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8623 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8625 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8629 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8630 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8631 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8632 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8634 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8641 DEFPY (af_rd_vpn_export
,
8642 af_rd_vpn_export_cmd
,
8643 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8645 "Specify route distinguisher\n"
8646 "Between current address-family and vpn\n"
8647 "For routes leaked from current address-family to vpn\n"
8648 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8651 struct prefix_rd prd
;
8657 if (argv_find(argv
, argc
, "no", &idx
))
8661 ret
= str2prefix_rd(rd_str
, &prd
);
8663 vty_out(vty
, "%% Malformed rd\n");
8664 return CMD_WARNING_CONFIG_FAILED
;
8668 afi
= vpn_policy_getafi(vty
, bgp
, false);
8670 return CMD_WARNING_CONFIG_FAILED
;
8673 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8675 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8676 bgp_get_default(), bgp
);
8679 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8680 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8681 BGP_VPN_POLICY_TOVPN_RD_SET
);
8683 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8684 BGP_VPN_POLICY_TOVPN_RD_SET
);
8687 /* post-change: re-export vpn routes */
8688 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8689 bgp_get_default(), bgp
);
8694 ALIAS (af_rd_vpn_export
,
8695 af_no_rd_vpn_export_cmd
,
8698 "Specify route distinguisher\n"
8699 "Between current address-family and vpn\n"
8700 "For routes leaked from current address-family to vpn\n")
8702 DEFPY (af_label_vpn_export
,
8703 af_label_vpn_export_cmd
,
8704 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8706 "label value for VRF\n"
8707 "Between current address-family and vpn\n"
8708 "For routes leaked from current address-family to vpn\n"
8709 "Label Value <0-1048575>\n"
8710 "Automatically assign a label\n")
8712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8713 mpls_label_t label
= MPLS_LABEL_NONE
;
8718 if (argv_find(argv
, argc
, "no", &idx
))
8721 /* If "no ...", squash trailing parameter */
8727 label
= label_val
; /* parser should force unsigned */
8730 afi
= vpn_policy_getafi(vty
, bgp
, false);
8732 return CMD_WARNING_CONFIG_FAILED
;
8735 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8736 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8741 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8743 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8744 bgp_get_default(), bgp
);
8746 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8747 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8749 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8752 * label has previously been automatically
8753 * assigned by labelpool: release it
8755 * NB if tovpn_label == MPLS_LABEL_NONE it
8756 * means the automatic assignment is in flight
8757 * and therefore the labelpool callback must
8758 * detect that the auto label is not needed.
8761 bgp_lp_release(LP_TYPE_VRF
,
8762 &bgp
->vpn_policy
[afi
],
8763 bgp
->vpn_policy
[afi
].tovpn_label
);
8765 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8766 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8769 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8771 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8772 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8773 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8774 vpn_leak_label_callback
);
8777 /* post-change: re-export vpn routes */
8778 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8779 bgp_get_default(), bgp
);
8781 hook_call(bgp_snmp_update_last_changed
, bgp
);
8785 DEFPY (af_sid_vpn_export
,
8786 af_sid_vpn_export_cmd
,
8787 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8789 "sid value for VRF\n"
8790 "Between current address-family and vpn\n"
8791 "For routes leaked from current address-family to vpn\n"
8792 "Sid allocation index\n"
8793 "Automatically assign a label\n")
8795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8801 if (argv_find(argv
, argc
, "no", &idx
))
8803 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8804 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8806 afi
= vpn_policy_getafi(vty
, bgp
, false);
8808 return CMD_WARNING_CONFIG_FAILED
;
8812 vty_out(vty
, "It's not implemented\n");
8813 return CMD_WARNING_CONFIG_FAILED
;
8816 /* skip when it's already configured */
8817 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8818 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8819 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8823 * mode change between sid_idx and sid_auto isn't supported.
8824 * user must negate sid vpn export when they want to change the mode
8826 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8827 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8828 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8829 vty_out(vty
, "it's already configured as %s.\n",
8830 sid_auto
? "auto-mode" : "idx-mode");
8831 return CMD_WARNING_CONFIG_FAILED
;
8835 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8836 bgp_get_default(), bgp
);
8839 /* SID allocation auto-mode */
8841 zlog_debug("%s: auto sid alloc.", __func__
);
8842 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8843 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8845 /* SID allocation index-mode */
8847 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8848 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8852 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8853 bgp_get_default(), bgp
);
8857 ALIAS (af_label_vpn_export
,
8858 af_no_label_vpn_export_cmd
,
8859 "no label vpn export",
8861 "label value for VRF\n"
8862 "Between current address-family and vpn\n"
8863 "For routes leaked from current address-family to vpn\n")
8865 DEFPY (af_nexthop_vpn_export
,
8866 af_nexthop_vpn_export_cmd
,
8867 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8869 "Specify next hop to use for VRF advertised prefixes\n"
8870 "Between current address-family and vpn\n"
8871 "For routes leaked from current address-family to vpn\n"
8875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8881 vty_out(vty
, "%% Nexthop required\n");
8882 return CMD_WARNING_CONFIG_FAILED
;
8884 if (!sockunion2hostprefix(nexthop_su
, &p
))
8885 return CMD_WARNING_CONFIG_FAILED
;
8888 afi
= vpn_policy_getafi(vty
, bgp
, false);
8890 return CMD_WARNING_CONFIG_FAILED
;
8893 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8895 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8896 bgp_get_default(), bgp
);
8899 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8900 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8901 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8903 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8904 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8907 /* post-change: re-export vpn routes */
8908 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8909 bgp_get_default(), bgp
);
8914 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8916 if (!strcmp(dstr
, "import")) {
8917 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8918 } else if (!strcmp(dstr
, "export")) {
8919 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8920 } else if (!strcmp(dstr
, "both")) {
8921 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8922 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8924 vty_out(vty
, "%% direction parse error\n");
8925 return CMD_WARNING_CONFIG_FAILED
;
8930 DEFPY (af_rt_vpn_imexport
,
8931 af_rt_vpn_imexport_cmd
,
8932 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8934 "Specify route target list\n"
8935 "Specify route target list\n"
8936 "Between current address-family and vpn\n"
8937 "For routes leaked from vpn to current address-family: match any\n"
8938 "For routes leaked from current address-family to vpn: set\n"
8939 "both import: match any and export: set\n"
8940 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8944 struct ecommunity
*ecom
= NULL
;
8945 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8946 enum vpn_policy_direction dir
;
8951 if (argv_find(argv
, argc
, "no", &idx
))
8954 afi
= vpn_policy_getafi(vty
, bgp
, false);
8956 return CMD_WARNING_CONFIG_FAILED
;
8958 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8959 if (ret
!= CMD_SUCCESS
)
8963 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8964 vty_out(vty
, "%% Missing RTLIST\n");
8965 return CMD_WARNING_CONFIG_FAILED
;
8967 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8968 if (ret
!= CMD_SUCCESS
) {
8973 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8977 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8980 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8982 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8983 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8984 ecommunity_dup(ecom
);
8986 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8988 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8989 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8992 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8996 ecommunity_free(&ecom
);
9001 ALIAS (af_rt_vpn_imexport
,
9002 af_no_rt_vpn_imexport_cmd
,
9003 "no <rt|route-target> vpn <import|export|both>$direction_str",
9005 "Specify route target list\n"
9006 "Specify route target list\n"
9007 "Between current address-family and vpn\n"
9008 "For routes leaked from vpn to current address-family\n"
9009 "For routes leaked from current address-family to vpn\n"
9010 "both import and export\n")
9012 DEFPY (af_route_map_vpn_imexport
,
9013 af_route_map_vpn_imexport_cmd
,
9014 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9015 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9017 "Specify route map\n"
9018 "Between current address-family and vpn\n"
9019 "For routes leaked from vpn to current address-family\n"
9020 "For routes leaked from current address-family to vpn\n"
9021 "name of route-map\n")
9023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9025 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9026 enum vpn_policy_direction dir
;
9031 if (argv_find(argv
, argc
, "no", &idx
))
9034 afi
= vpn_policy_getafi(vty
, bgp
, false);
9036 return CMD_WARNING_CONFIG_FAILED
;
9038 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9039 if (ret
!= CMD_SUCCESS
)
9042 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9046 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9049 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9050 XFREE(MTYPE_ROUTE_MAP_NAME
,
9051 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9052 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9053 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9054 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9055 route_map_lookup_warn_noexist(vty
, rmap_str
);
9056 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9059 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9060 XFREE(MTYPE_ROUTE_MAP_NAME
,
9061 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9062 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9063 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9066 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9072 ALIAS (af_route_map_vpn_imexport
,
9073 af_no_route_map_vpn_imexport_cmd
,
9074 "no route-map vpn <import|export>$direction_str",
9076 "Specify route map\n"
9077 "Between current address-family and vpn\n"
9078 "For routes leaked from vpn to current address-family\n"
9079 "For routes leaked from current address-family to vpn\n")
9081 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9082 "import vrf route-map RMAP$rmap_str",
9083 "Import routes from another VRF\n"
9084 "Vrf routes being filtered\n"
9085 "Specify route map\n"
9086 "name of route-map\n")
9088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9089 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9091 struct bgp
*bgp_default
;
9093 afi
= vpn_policy_getafi(vty
, bgp
, true);
9095 return CMD_WARNING_CONFIG_FAILED
;
9097 bgp_default
= bgp_get_default();
9102 /* Auto-create assuming the same AS */
9103 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9104 BGP_INSTANCE_TYPE_DEFAULT
);
9108 "VRF default is not configured as a bgp instance\n");
9113 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9115 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9116 XFREE(MTYPE_ROUTE_MAP_NAME
,
9117 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9118 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9119 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9120 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9121 route_map_lookup_warn_noexist(vty
, rmap_str
);
9122 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9125 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9126 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9128 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9133 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9134 "no import vrf route-map [RMAP$rmap_str]",
9136 "Import routes from another VRF\n"
9137 "Vrf routes being filtered\n"
9138 "Specify route map\n"
9139 "name of route-map\n")
9141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9142 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9145 afi
= vpn_policy_getafi(vty
, bgp
, true);
9147 return CMD_WARNING_CONFIG_FAILED
;
9149 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9151 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9152 XFREE(MTYPE_ROUTE_MAP_NAME
,
9153 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9154 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9155 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9157 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9158 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9159 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9161 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9166 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9167 "[no] import vrf VIEWVRFNAME$import_name",
9169 "Import routes from another VRF\n"
9170 "VRF to import from\n"
9171 "The name of the VRF\n")
9173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9174 struct listnode
*node
;
9175 struct bgp
*vrf_bgp
, *bgp_default
;
9178 bool remove
= false;
9181 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9185 if (import_name
== NULL
) {
9186 vty_out(vty
, "%% Missing import name\n");
9190 if (strcmp(import_name
, "route-map") == 0) {
9191 vty_out(vty
, "%% Must include route-map name\n");
9195 if (argv_find(argv
, argc
, "no", &idx
))
9198 afi
= vpn_policy_getafi(vty
, bgp
, true);
9200 return CMD_WARNING_CONFIG_FAILED
;
9202 safi
= bgp_node_safi(vty
);
9204 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9205 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9206 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9207 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9208 remove
? "unimport" : "import", import_name
);
9212 bgp_default
= bgp_get_default();
9214 /* Auto-create assuming the same AS */
9215 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9216 BGP_INSTANCE_TYPE_DEFAULT
);
9220 "VRF default is not configured as a bgp instance\n");
9225 vrf_bgp
= bgp_lookup_by_name(import_name
);
9227 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9228 vrf_bgp
= bgp_default
;
9230 /* Auto-create assuming the same AS */
9231 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9235 "VRF %s is not configured as a bgp instance\n",
9242 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9244 /* Already importing from "import_vrf"? */
9245 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9247 if (strcmp(vname
, import_name
) == 0)
9251 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9257 /* This command is valid only in a bgp vrf instance or the default instance */
9258 DEFPY (bgp_imexport_vpn
,
9259 bgp_imexport_vpn_cmd
,
9260 "[no] <import|export>$direction_str vpn",
9262 "Import routes to this address-family\n"
9263 "Export routes from this address-family\n"
9264 "to/from default instance VPN RIB\n")
9266 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9273 enum vpn_policy_direction dir
;
9275 if (argv_find(argv
, argc
, "no", &idx
))
9278 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9279 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9281 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9282 return CMD_WARNING_CONFIG_FAILED
;
9285 afi
= bgp_node_afi(vty
);
9286 safi
= bgp_node_safi(vty
);
9287 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9288 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9289 return CMD_WARNING_CONFIG_FAILED
;
9292 if (!strcmp(direction_str
, "import")) {
9293 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9294 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9295 } else if (!strcmp(direction_str
, "export")) {
9296 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9297 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9299 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9300 return CMD_WARNING_CONFIG_FAILED
;
9303 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9306 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9307 if (!previous_state
) {
9308 /* trigger export current vrf */
9309 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9312 if (previous_state
) {
9313 /* trigger un-export current vrf */
9314 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9316 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9319 hook_call(bgp_snmp_init_stats
, bgp
);
9324 DEFPY (af_routetarget_import
,
9325 af_routetarget_import_cmd
,
9326 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9328 "Specify route target list\n"
9329 "Specify route target list\n"
9330 "Specify route target list\n"
9331 "Specify route target list\n"
9332 "Flow-spec redirect type route target\n"
9333 "Import routes to this address-family\n"
9334 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9338 struct ecommunity
*ecom
= NULL
;
9340 int idx
= 0, idx_unused
= 0;
9344 if (argv_find(argv
, argc
, "no", &idx
))
9347 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9348 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9351 afi
= vpn_policy_getafi(vty
, bgp
, false);
9353 return CMD_WARNING_CONFIG_FAILED
;
9355 if (rt6
&& afi
!= AFI_IP6
)
9356 return CMD_WARNING_CONFIG_FAILED
;
9359 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9360 vty_out(vty
, "%% Missing RTLIST\n");
9361 return CMD_WARNING_CONFIG_FAILED
;
9363 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9364 if (ret
!= CMD_SUCCESS
)
9369 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9370 ecommunity_free(&bgp
->vpn_policy
[afi
]
9371 .import_redirect_rtlist
);
9372 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9373 ecommunity_dup(ecom
);
9375 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9376 ecommunity_free(&bgp
->vpn_policy
[afi
]
9377 .import_redirect_rtlist
);
9378 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9382 ecommunity_free(&ecom
);
9387 DEFUN_NOSH (address_family_ipv4_safi
,
9388 address_family_ipv4_safi_cmd
,
9389 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9390 "Enter Address Family command mode\n"
9392 BGP_SAFI_WITH_LABEL_HELP_STR
)
9396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9397 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9398 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9399 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9400 && safi
!= SAFI_EVPN
) {
9402 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9403 return CMD_WARNING_CONFIG_FAILED
;
9405 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9407 vty
->node
= BGP_IPV4_NODE
;
9412 DEFUN_NOSH (address_family_ipv6_safi
,
9413 address_family_ipv6_safi_cmd
,
9414 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9415 "Enter Address Family command mode\n"
9417 BGP_SAFI_WITH_LABEL_HELP_STR
)
9420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9421 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9422 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9423 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9424 && safi
!= SAFI_EVPN
) {
9426 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9427 return CMD_WARNING_CONFIG_FAILED
;
9429 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9431 vty
->node
= BGP_IPV6_NODE
;
9436 #ifdef KEEP_OLD_VPN_COMMANDS
9437 DEFUN_NOSH (address_family_vpnv4
,
9438 address_family_vpnv4_cmd
,
9439 "address-family vpnv4 [unicast]",
9440 "Enter Address Family command mode\n"
9442 BGP_AF_MODIFIER_STR
)
9444 vty
->node
= BGP_VPNV4_NODE
;
9448 DEFUN_NOSH (address_family_vpnv6
,
9449 address_family_vpnv6_cmd
,
9450 "address-family vpnv6 [unicast]",
9451 "Enter Address Family command mode\n"
9453 BGP_AF_MODIFIER_STR
)
9455 vty
->node
= BGP_VPNV6_NODE
;
9458 #endif /* KEEP_OLD_VPN_COMMANDS */
9460 DEFUN_NOSH (address_family_evpn
,
9461 address_family_evpn_cmd
,
9462 "address-family l2vpn evpn",
9463 "Enter Address Family command mode\n"
9465 BGP_AF_MODIFIER_STR
)
9467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9468 vty
->node
= BGP_EVPN_NODE
;
9472 DEFUN_NOSH (bgp_segment_routing_srv6
,
9473 bgp_segment_routing_srv6_cmd
,
9474 "segment-routing srv6",
9475 "Segment-Routing configuration\n"
9476 "Segment-Routing SRv6 configuration\n")
9478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9479 bgp
->srv6_enabled
= true;
9480 vty
->node
= BGP_SRV6_NODE
;
9484 DEFUN (no_bgp_segment_routing_srv6
,
9485 no_bgp_segment_routing_srv6_cmd
,
9486 "no segment-routing srv6",
9488 "Segment-Routing configuration\n"
9489 "Segment-Routing SRv6 configuration\n")
9491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9493 if (strlen(bgp
->srv6_locator_name
) > 0)
9494 if (bgp_srv6_locator_unset(bgp
) < 0)
9495 return CMD_WARNING_CONFIG_FAILED
;
9497 bgp
->srv6_enabled
= false;
9501 DEFPY (bgp_srv6_locator
,
9502 bgp_srv6_locator_cmd
,
9503 "locator NAME$name",
9504 "Specify SRv6 locator\n"
9505 "Specify SRv6 locator\n")
9507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9510 if (strlen(bgp
->srv6_locator_name
) > 0
9511 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9512 vty_out(vty
, "srv6 locator is already configured\n");
9513 return CMD_WARNING_CONFIG_FAILED
;
9516 snprintf(bgp
->srv6_locator_name
,
9517 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9519 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9521 return CMD_WARNING_CONFIG_FAILED
;
9526 DEFPY (no_bgp_srv6_locator
,
9527 no_bgp_srv6_locator_cmd
,
9528 "no locator NAME$name",
9530 "Specify SRv6 locator\n"
9531 "Specify SRv6 locator\n")
9533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9535 /* when locator isn't configured, do nothing */
9536 if (strlen(bgp
->srv6_locator_name
) < 1)
9539 /* name validation */
9540 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9541 vty_out(vty
, "%% No srv6 locator is configured\n");
9542 return CMD_WARNING_CONFIG_FAILED
;
9546 if (bgp_srv6_locator_unset(bgp
) < 0)
9547 return CMD_WARNING_CONFIG_FAILED
;
9552 DEFPY (show_bgp_srv6
,
9554 "show bgp segment-routing srv6",
9557 "BGP Segment Routing\n"
9558 "BGP Segment Routing SRv6\n")
9561 struct listnode
*node
;
9562 struct srv6_locator_chunk
*chunk
;
9563 struct bgp_srv6_function
*func
;
9564 struct in6_addr
*tovpn4_sid
;
9565 struct in6_addr
*tovpn6_sid
;
9567 char buf_tovpn4_sid
[256];
9568 char buf_tovpn6_sid
[256];
9570 bgp
= bgp_get_default();
9574 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9575 vty_out(vty
, "locator_chunks:\n");
9576 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9577 prefix2str(&chunk
->prefix
, buf
, sizeof(buf
));
9578 vty_out(vty
, "- %s\n", buf
);
9581 vty_out(vty
, "functions:\n");
9582 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9583 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9584 vty_out(vty
, "- sid: %s\n", buf
);
9585 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9588 vty_out(vty
, "bgps:\n");
9589 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9590 vty_out(vty
, "- name: %s\n",
9591 bgp
->name
? bgp
->name
: "default");
9593 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9594 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9596 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9597 sizeof(buf_tovpn4_sid
));
9599 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9600 sizeof(buf_tovpn6_sid
));
9602 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9603 tovpn4_sid
? buf_tovpn4_sid
: "none");
9604 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9605 tovpn6_sid
? buf_tovpn6_sid
: "none");
9611 DEFUN_NOSH (exit_address_family
,
9612 exit_address_family_cmd
,
9613 "exit-address-family",
9614 "Exit from Address Family configuration mode\n")
9616 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9617 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9618 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9619 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9620 || vty
->node
== BGP_EVPN_NODE
9621 || vty
->node
== BGP_FLOWSPECV4_NODE
9622 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9623 vty
->node
= BGP_NODE
;
9627 /* Recalculate bestpath and re-advertise a prefix */
9628 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9629 const char *ip_str
, afi_t afi
, safi_t safi
,
9630 struct prefix_rd
*prd
)
9633 struct prefix match
;
9634 struct bgp_dest
*dest
;
9635 struct bgp_dest
*rm
;
9637 struct bgp_table
*table
;
9638 struct bgp_table
*rib
;
9640 /* BGP structure lookup. */
9642 bgp
= bgp_lookup_by_name(view_name
);
9644 vty_out(vty
, "%% Can't find BGP instance %s\n",
9649 bgp
= bgp_get_default();
9651 vty_out(vty
, "%% No BGP process is configured\n");
9656 /* Check IP address argument. */
9657 ret
= str2prefix(ip_str
, &match
);
9659 vty_out(vty
, "%% address is malformed\n");
9663 match
.family
= afi2family(afi
);
9664 rib
= bgp
->rib
[afi
][safi
];
9666 if (safi
== SAFI_MPLS_VPN
) {
9667 for (dest
= bgp_table_top(rib
); dest
;
9668 dest
= bgp_route_next(dest
)) {
9669 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9671 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9674 table
= bgp_dest_get_bgp_table_info(dest
);
9678 rm
= bgp_node_match(table
, &match
);
9680 const struct prefix
*rm_p
=
9681 bgp_dest_get_prefix(rm
);
9683 if (rm_p
->prefixlen
== match
.prefixlen
) {
9685 BGP_NODE_USER_CLEAR
);
9686 bgp_process(bgp
, rm
, afi
, safi
);
9688 bgp_dest_unlock_node(rm
);
9692 dest
= bgp_node_match(rib
, &match
);
9694 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9696 if (dest_p
->prefixlen
== match
.prefixlen
) {
9697 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9698 bgp_process(bgp
, dest
, afi
, safi
);
9700 bgp_dest_unlock_node(dest
);
9707 /* one clear bgp command to rule them all */
9708 DEFUN (clear_ip_bgp_all
,
9709 clear_ip_bgp_all_cmd
,
9710 "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>]",
9714 BGP_INSTANCE_HELP_STR
9717 BGP_SAFI_WITH_LABEL_HELP_STR
9720 "BGP IPv4 neighbor to clear\n"
9721 "BGP IPv6 neighbor to clear\n"
9722 "BGP neighbor on interface to clear\n"
9723 "Clear peers with the AS number\n"
9724 "Clear all external peers\n"
9725 "Clear all members of peer-group\n"
9726 "BGP peer-group name\n"
9731 "Push out prefix-list ORF and do inbound soft reconfig\n"
9733 "Reset message statistics\n")
9737 afi_t afi
= AFI_UNSPEC
;
9738 safi_t safi
= SAFI_UNSPEC
;
9739 enum clear_sort clr_sort
= clear_peer
;
9740 enum bgp_clear_type clr_type
;
9741 char *clr_arg
= NULL
;
9745 /* clear [ip] bgp */
9746 if (argv_find(argv
, argc
, "ip", &idx
))
9749 /* [<vrf> VIEWVRFNAME] */
9750 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9751 vrf
= argv
[idx
+ 1]->arg
;
9753 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9755 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9756 /* [<view> VIEWVRFNAME] */
9757 vrf
= argv
[idx
+ 1]->arg
;
9760 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9761 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9762 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9764 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9765 if (argv_find(argv
, argc
, "*", &idx
)) {
9766 clr_sort
= clear_all
;
9767 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9768 clr_sort
= clear_peer
;
9769 clr_arg
= argv
[idx
]->arg
;
9770 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9771 clr_sort
= clear_peer
;
9772 clr_arg
= argv
[idx
]->arg
;
9773 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9774 clr_sort
= clear_group
;
9776 clr_arg
= argv
[idx
]->arg
;
9777 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9778 clr_sort
= clear_peer
;
9779 clr_arg
= argv
[idx
]->arg
;
9780 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9781 clr_sort
= clear_peer
;
9782 clr_arg
= argv
[idx
]->arg
;
9783 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9784 clr_sort
= clear_as
;
9785 clr_arg
= argv
[idx
]->arg
;
9786 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9787 clr_sort
= clear_external
;
9790 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9791 if (argv_find(argv
, argc
, "soft", &idx
)) {
9792 if (argv_find(argv
, argc
, "in", &idx
)
9793 || argv_find(argv
, argc
, "out", &idx
))
9794 clr_type
= strmatch(argv
[idx
]->text
, "in")
9796 : BGP_CLEAR_SOFT_OUT
;
9798 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9799 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9800 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9801 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9802 : BGP_CLEAR_SOFT_IN
;
9803 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9804 clr_type
= BGP_CLEAR_SOFT_OUT
;
9805 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9806 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9808 clr_type
= BGP_CLEAR_SOFT_NONE
;
9810 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9813 DEFUN (clear_ip_bgp_prefix
,
9814 clear_ip_bgp_prefix_cmd
,
9815 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9819 BGP_INSTANCE_HELP_STR
9820 "Clear bestpath and re-advertise\n"
9824 char *prefix
= NULL
;
9828 /* [<view|vrf> VIEWVRFNAME] */
9829 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9830 vrf
= argv
[idx
+ 1]->arg
;
9832 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9834 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9835 /* [<view> VIEWVRFNAME] */
9836 vrf
= argv
[idx
+ 1]->arg
;
9840 prefix
= argv
[argc
- 1]->arg
;
9842 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9845 DEFUN (clear_bgp_ipv6_safi_prefix
,
9846 clear_bgp_ipv6_safi_prefix_cmd
,
9847 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9853 "Clear bestpath and re-advertise\n"
9857 int idx_ipv6_prefix
= 0;
9858 safi_t safi
= SAFI_UNICAST
;
9859 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9860 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9862 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9863 return bgp_clear_prefix(
9864 vty
, NULL
, prefix
, AFI_IP6
,
9868 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9869 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9870 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9874 BGP_INSTANCE_HELP_STR
9877 "Clear bestpath and re-advertise\n"
9881 int idx_vrfview
= 0;
9882 int idx_ipv6_prefix
= 0;
9883 safi_t safi
= SAFI_UNICAST
;
9884 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9885 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9886 char *vrfview
= NULL
;
9888 /* [<view|vrf> VIEWVRFNAME] */
9889 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9890 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9891 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9893 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9894 /* [<view> VIEWVRFNAME] */
9895 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9897 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9899 return bgp_clear_prefix(
9900 vty
, vrfview
, prefix
,
9901 AFI_IP6
, safi
, NULL
);
9904 DEFUN (show_bgp_views
,
9906 "show [ip] bgp views",
9910 "Show the defined BGP views\n")
9912 struct list
*inst
= bm
->bgp
;
9913 struct listnode
*node
;
9916 vty_out(vty
, "Defined BGP views:\n");
9917 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9919 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9921 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9928 DEFUN (show_bgp_vrfs
,
9930 "show [ip] bgp vrfs [json]",
9937 char buf
[ETHER_ADDR_STRLEN
];
9938 struct list
*inst
= bm
->bgp
;
9939 struct listnode
*node
;
9941 bool uj
= use_json(argc
, argv
);
9942 json_object
*json
= NULL
;
9943 json_object
*json_vrfs
= NULL
;
9947 json
= json_object_new_object();
9948 json_vrfs
= json_object_new_object();
9951 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9952 const char *name
, *type
;
9954 struct listnode
*node2
, *nnode2
;
9955 int peers_cfg
, peers_estb
;
9956 json_object
*json_vrf
= NULL
;
9959 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9963 if (!uj
&& count
== 1) {
9965 "%4s %-5s %-16s %9s %10s %-37s\n",
9966 "Type", "Id", "routerId", "#PeersCfg",
9967 "#PeersEstb", "Name");
9968 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9969 "L3-VNI", "RouterMAC", "Interface");
9972 peers_cfg
= peers_estb
= 0;
9974 json_vrf
= json_object_new_object();
9977 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9978 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9981 if (peer_established(peer
))
9985 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9986 name
= VRF_DEFAULT_NAME
;
9995 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9997 : (int64_t)bgp
->vrf_id
;
9998 char buf
[BUFSIZ
] = {0};
10000 json_object_string_add(json_vrf
, "type", type
);
10001 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10002 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10004 json_object_int_add(json_vrf
, "numConfiguredPeers",
10006 json_object_int_add(json_vrf
, "numEstablishedPeers",
10009 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10010 json_object_string_add(
10012 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10013 json_object_string_add(json_vrf
, "interface",
10014 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10016 json_object_object_add(json_vrfs
, name
, json_vrf
);
10018 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10020 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10021 : (int)bgp
->vrf_id
,
10022 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10023 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10025 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10026 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10032 json_object_object_add(json
, "vrfs", json_vrfs
);
10034 json_object_int_add(json
, "totalVrfs", count
);
10036 vty_json(vty
, json
);
10040 "\nTotal number of VRFs (including default): %d\n",
10044 return CMD_SUCCESS
;
10047 DEFUN (show_bgp_mac_hash
,
10048 show_bgp_mac_hash_cmd
,
10049 "show bgp mac hash",
10053 "Mac Address database\n")
10055 bgp_mac_dump_table(vty
);
10057 return CMD_SUCCESS
;
10060 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10062 struct vty
*vty
= (struct vty
*)args
;
10063 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10065 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10068 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10070 vty_out(vty
, "self nexthop database:\n");
10071 bgp_nexthop_show_address_hash(vty
, bgp
);
10073 vty_out(vty
, "Tunnel-ip database:\n");
10074 hash_iterate(bgp
->tip_hash
,
10075 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10079 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10080 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10081 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10082 "martian next-hops\n"
10083 "martian next-hop database\n")
10085 struct bgp
*bgp
= NULL
;
10089 /* [<vrf> VIEWVRFNAME] */
10090 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10091 name
= argv
[idx
+ 1]->arg
;
10092 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10094 } else if (argv_find(argv
, argc
, "view", &idx
))
10095 /* [<view> VIEWVRFNAME] */
10096 name
= argv
[idx
+ 1]->arg
;
10098 bgp
= bgp_lookup_by_name(name
);
10100 bgp
= bgp_get_default();
10103 vty_out(vty
, "%% No BGP process is configured\n");
10104 return CMD_WARNING
;
10106 bgp_show_martian_nexthops(vty
, bgp
);
10108 return CMD_SUCCESS
;
10111 DEFUN (show_bgp_memory
,
10112 show_bgp_memory_cmd
,
10113 "show [ip] bgp memory",
10117 "Global BGP memory statistics\n")
10119 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10120 unsigned long count
;
10122 /* RIB related usage stats */
10123 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10124 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10125 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10126 count
* sizeof(struct bgp_dest
)));
10128 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10129 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10130 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10131 count
* sizeof(struct bgp_path_info
)));
10132 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10133 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10136 memstrbuf
, sizeof(memstrbuf
),
10137 count
* sizeof(struct bgp_path_info_extra
)));
10139 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10140 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10141 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10142 count
* sizeof(struct bgp_static
)));
10144 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10145 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10146 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10147 count
* sizeof(struct bpacket
)));
10150 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10151 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10152 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10153 count
* sizeof(struct bgp_adj_in
)));
10154 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10155 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10156 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10157 count
* sizeof(struct bgp_adj_out
)));
10159 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10160 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10162 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10163 count
* sizeof(struct bgp_nexthop_cache
)));
10165 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10166 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10168 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10169 count
* sizeof(struct bgp_damp_info
)));
10172 count
= attr_count();
10173 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10174 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10175 count
* sizeof(struct attr
)));
10177 if ((count
= attr_unknown_count()))
10178 vty_out(vty
, "%ld unknown attributes\n", count
);
10180 /* AS_PATH attributes */
10181 count
= aspath_count();
10182 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10183 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10184 count
* sizeof(struct aspath
)));
10186 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10187 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10188 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10189 count
* sizeof(struct assegment
)));
10191 /* Other attributes */
10192 if ((count
= community_count()))
10193 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10194 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10195 count
* sizeof(struct community
)));
10196 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10198 "%ld BGP ext-community entries, using %s of memory\n",
10200 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10201 count
* sizeof(struct ecommunity
)));
10202 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10204 "%ld BGP large-community entries, using %s of memory\n",
10205 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10206 count
* sizeof(struct lcommunity
)));
10208 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10209 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10210 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10211 count
* sizeof(struct cluster_list
)));
10213 /* Peer related usage */
10214 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10215 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10216 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10217 count
* sizeof(struct peer
)));
10219 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10220 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10221 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10222 count
* sizeof(struct peer_group
)));
10225 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10226 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10227 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10228 count
* sizeof(regex_t
)));
10229 return CMD_SUCCESS
;
10232 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10234 json_object
*bestpath
= json_object_new_object();
10236 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10237 json_object_string_add(bestpath
, "asPath", "ignore");
10239 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10240 json_object_string_add(bestpath
, "asPath", "confed");
10242 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10243 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10244 json_object_string_add(bestpath
, "multiPathRelax",
10247 json_object_string_add(bestpath
, "multiPathRelax",
10250 json_object_string_add(bestpath
, "multiPathRelax", "false");
10252 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10253 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10255 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10256 json_object_string_add(bestpath
, "compareRouterId", "true");
10257 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10258 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10259 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10260 json_object_string_add(bestpath
, "med", "confed");
10261 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10262 json_object_string_add(bestpath
, "med",
10263 "missing-as-worst");
10265 json_object_string_add(bestpath
, "med", "true");
10268 json_object_object_add(json
, "bestPath", bestpath
);
10271 /* Print the error code/subcode for why the peer is down */
10272 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10273 json_object
*json_peer
, bool use_json
)
10275 const char *code_str
;
10276 const char *subcode_str
;
10279 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10280 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10281 char errorcodesubcode_hexstr
[5];
10282 char errorcodesubcode_str
[256];
10284 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10285 subcode_str
= bgp_notify_subcode_str(
10287 peer
->notify
.subcode
);
10289 snprintf(errorcodesubcode_hexstr
,
10290 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10291 peer
->notify
.code
, peer
->notify
.subcode
);
10292 json_object_string_add(json_peer
,
10293 "lastErrorCodeSubcode",
10294 errorcodesubcode_hexstr
);
10295 snprintf(errorcodesubcode_str
, 255, "%s%s",
10296 code_str
, subcode_str
);
10297 json_object_string_add(json_peer
,
10298 "lastNotificationReason",
10299 errorcodesubcode_str
);
10300 json_object_boolean_add(json_peer
,
10301 "lastNotificationHardReset",
10302 peer
->notify
.hard_reset
);
10303 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10304 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10305 && (peer
->notify
.subcode
10306 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10307 || peer
->notify
.subcode
10308 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10309 && peer
->notify
.length
) {
10311 const char *msg_str
;
10313 msg_str
= bgp_notify_admin_message(
10314 msgbuf
, sizeof(msgbuf
),
10315 (uint8_t *)peer
->notify
.data
,
10316 peer
->notify
.length
);
10318 json_object_string_add(
10320 "lastShutdownDescription",
10325 json_object_string_add(json_peer
, "lastResetDueTo",
10326 peer_down_str
[(int)peer
->last_reset
]);
10327 json_object_int_add(json_peer
, "lastResetCode",
10330 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10331 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10332 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10334 bgp_notify_subcode_str(peer
->notify
.code
,
10335 peer
->notify
.subcode
);
10336 vty_out(vty
, " Notification %s (%s%s%s)\n",
10337 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10340 code_str
, subcode_str
,
10341 peer
->notify
.hard_reset
10342 ? bgp_notify_subcode_str(
10344 BGP_NOTIFY_CEASE_HARD_RESET
)
10347 vty_out(vty
, " %s\n",
10348 peer_down_str
[(int)peer
->last_reset
]);
10353 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10356 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10359 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10360 struct peer
*peer
, json_object
*json_peer
,
10361 int max_neighbor_width
, bool use_json
)
10363 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10367 if (peer_dynamic_neighbor(peer
))
10368 json_object_boolean_true_add(json_peer
,
10370 if (peer
->hostname
)
10371 json_object_string_add(json_peer
, "hostname",
10374 if (peer
->domainname
)
10375 json_object_string_add(json_peer
, "domainname",
10377 json_object_int_add(json_peer
, "connectionsEstablished",
10378 peer
->established
);
10379 json_object_int_add(json_peer
, "connectionsDropped",
10381 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10382 use_json
, json_peer
);
10383 if (peer_established(peer
))
10384 json_object_string_add(json_peer
, "lastResetDueTo",
10385 "AFI/SAFI Not Negotiated");
10387 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10390 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10392 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10393 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10394 peer
->hostname
, peer
->host
);
10396 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10398 /* pad the neighbor column with spaces */
10399 if (len
< max_neighbor_width
)
10400 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10402 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10404 peer_uptime(peer
->uptime
, timebuf
,
10405 BGP_UPTIME_LEN
, 0, NULL
));
10406 if (peer_established(peer
))
10407 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10409 bgp_show_peer_reset(vty
, peer
, NULL
,
10414 /* Strip peer's description to the given size. */
10415 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10417 static char stripped
[BUFSIZ
];
10419 uint32_t last_space
= 0;
10422 if (*(desc
+ i
) == 0) {
10423 stripped
[i
] = '\0';
10426 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10428 stripped
[i
] = *(desc
+ i
);
10432 if (last_space
> size
)
10433 stripped
[size
+ 1] = '\0';
10435 stripped
[last_space
] = '\0';
10440 /* Determine whether var peer should be filtered out of the summary. */
10441 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10442 struct peer
*fpeer
, int as_type
,
10446 /* filter neighbor XXXX */
10447 if (fpeer
&& fpeer
!= peer
)
10450 /* filter remote-as (internal|external) */
10451 if (as_type
!= AS_UNSPECIFIED
) {
10452 if (peer
->as_type
== AS_SPECIFIED
) {
10453 if (as_type
== AS_INTERNAL
) {
10454 if (peer
->as
!= peer
->local_as
)
10456 } else if (peer
->as
== peer
->local_as
)
10458 } else if (as_type
!= peer
->as_type
)
10460 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10466 /* Show BGP peer's summary information.
10468 * Peer's description is stripped according to if `wide` option is given
10471 * When adding new columns to `show bgp summary` output, please make
10472 * sure `Desc` is the lastest column to show because it can contain
10473 * whitespaces and the whole output will be tricky.
10475 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10476 struct peer
*fpeer
, int as_type
, as_t as
,
10477 uint16_t show_flags
)
10480 struct listnode
*node
, *nnode
;
10481 unsigned int count
= 0, dn_count
= 0;
10482 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10483 char neighbor_buf
[VTY_BUFSIZ
];
10484 int neighbor_col_default_width
= 16;
10485 int len
, failed_count
= 0;
10486 unsigned int filtered_count
= 0;
10487 int max_neighbor_width
= 0;
10489 json_object
*json
= NULL
;
10490 json_object
*json_peer
= NULL
;
10491 json_object
*json_peers
= NULL
;
10492 struct peer_af
*paf
;
10493 struct bgp_filter
*filter
;
10494 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10495 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10496 bool show_established
=
10497 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10498 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10499 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10501 /* labeled-unicast routes are installed in the unicast table so in order
10503 * display the correct PfxRcd value we must look at SAFI_UNICAST
10506 if (safi
== SAFI_LABELED_UNICAST
)
10507 pfx_rcd_safi
= SAFI_UNICAST
;
10509 pfx_rcd_safi
= safi
;
10512 json
= json_object_new_object();
10513 json_peers
= json_object_new_object();
10514 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10515 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10522 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10525 if (peer
->afc
[afi
][safi
]) {
10526 /* See if we have at least a single failed peer */
10527 if (bgp_has_peer_failed(peer
, afi
, safi
))
10531 if (peer_dynamic_neighbor(peer
))
10536 /* Loop over all neighbors that will be displayed to determine
10538 * characters are needed for the Neighbor column
10540 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10541 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10548 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10551 if (peer
->afc
[afi
][safi
]) {
10552 memset(dn_flag
, '\0', sizeof(dn_flag
));
10553 if (peer_dynamic_neighbor(peer
))
10557 && CHECK_FLAG(bgp
->flags
,
10558 BGP_FLAG_SHOW_HOSTNAME
))
10559 snprintf(neighbor_buf
,
10560 sizeof(neighbor_buf
),
10561 "%s%s(%s) ", dn_flag
,
10562 peer
->hostname
, peer
->host
);
10564 snprintf(neighbor_buf
,
10565 sizeof(neighbor_buf
), "%s%s ",
10566 dn_flag
, peer
->host
);
10568 len
= strlen(neighbor_buf
);
10570 if (len
> max_neighbor_width
)
10571 max_neighbor_width
= len
;
10573 /* See if we have at least a single failed peer */
10574 if (bgp_has_peer_failed(peer
, afi
, safi
))
10580 /* Originally we displayed the Neighbor column as 16
10581 * characters wide so make that the default
10583 if (max_neighbor_width
< neighbor_col_default_width
)
10584 max_neighbor_width
= neighbor_col_default_width
;
10587 if (show_failed
&& !failed_count
) {
10589 json_object_int_add(json
, "failedPeersCount", 0);
10590 json_object_int_add(json
, "dynamicPeers", dn_count
);
10591 json_object_int_add(json
, "totalPeers", count
);
10593 vty_json(vty
, json
);
10595 vty_out(vty
, "%% No failed BGP neighbors found\n");
10597 return CMD_SUCCESS
;
10600 count
= 0; /* Reset the value as its used again */
10601 filtered_count
= 0;
10603 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10604 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10607 if (!peer
->afc
[afi
][safi
])
10611 unsigned long ents
;
10612 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10615 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10617 : (int64_t)bgp
->vrf_id
;
10619 /* Usage summary and header */
10621 json_object_string_addf(json
, "routerId",
10624 json_object_int_add(json
, "as", bgp
->as
);
10625 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10626 json_object_string_add(
10629 == BGP_INSTANCE_TYPE_DEFAULT
)
10634 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10635 &bgp
->router_id
, bgp
->as
,
10636 bgp
->vrf_id
== VRF_UNKNOWN
10638 : (int)bgp
->vrf_id
);
10639 vty_out(vty
, "\n");
10642 if (bgp_update_delay_configured(bgp
)) {
10644 json_object_int_add(
10645 json
, "updateDelayLimit",
10646 bgp
->v_update_delay
);
10648 if (bgp
->v_update_delay
10649 != bgp
->v_establish_wait
)
10650 json_object_int_add(
10652 "updateDelayEstablishWait",
10653 bgp
->v_establish_wait
);
10655 if (bgp_update_delay_active(bgp
)) {
10656 json_object_string_add(
10658 "updateDelayFirstNeighbor",
10659 bgp
->update_delay_begin_time
);
10660 json_object_boolean_true_add(
10662 "updateDelayInProgress");
10664 if (bgp
->update_delay_over
) {
10665 json_object_string_add(
10667 "updateDelayFirstNeighbor",
10668 bgp
->update_delay_begin_time
);
10669 json_object_string_add(
10671 "updateDelayBestpathResumed",
10672 bgp
->update_delay_end_time
);
10673 json_object_string_add(
10675 "updateDelayZebraUpdateResume",
10676 bgp
->update_delay_zebra_resume_time
);
10677 json_object_string_add(
10679 "updateDelayPeerUpdateResume",
10680 bgp
->update_delay_peers_resume_time
);
10685 "Read-only mode update-delay limit: %d seconds\n",
10686 bgp
->v_update_delay
);
10687 if (bgp
->v_update_delay
10688 != bgp
->v_establish_wait
)
10690 " Establish wait: %d seconds\n",
10691 bgp
->v_establish_wait
);
10693 if (bgp_update_delay_active(bgp
)) {
10695 " First neighbor established: %s\n",
10696 bgp
->update_delay_begin_time
);
10698 " Delay in progress\n");
10700 if (bgp
->update_delay_over
) {
10702 " First neighbor established: %s\n",
10703 bgp
->update_delay_begin_time
);
10705 " Best-paths resumed: %s\n",
10706 bgp
->update_delay_end_time
);
10708 " zebra update resumed: %s\n",
10709 bgp
->update_delay_zebra_resume_time
);
10711 " peers update resumed: %s\n",
10712 bgp
->update_delay_peers_resume_time
);
10719 if (bgp_maxmed_onstartup_configured(bgp
)
10720 && bgp
->maxmed_active
)
10721 json_object_boolean_true_add(
10722 json
, "maxMedOnStartup");
10723 if (bgp
->v_maxmed_admin
)
10724 json_object_boolean_true_add(
10725 json
, "maxMedAdministrative");
10727 json_object_int_add(
10728 json
, "tableVersion",
10729 bgp_table_version(bgp
->rib
[afi
][safi
]));
10731 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10732 json_object_int_add(json
, "ribCount", ents
);
10733 json_object_int_add(
10735 ents
* sizeof(struct bgp_dest
));
10737 ents
= bgp
->af_peer_count
[afi
][safi
];
10738 json_object_int_add(json
, "peerCount", ents
);
10739 json_object_int_add(json
, "peerMemory",
10740 ents
* sizeof(struct peer
));
10742 if ((ents
= listcount(bgp
->group
))) {
10743 json_object_int_add(
10744 json
, "peerGroupCount", ents
);
10745 json_object_int_add(
10746 json
, "peerGroupMemory",
10747 ents
* sizeof(struct
10751 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10752 BGP_CONFIG_DAMPENING
))
10753 json_object_boolean_true_add(
10754 json
, "dampeningEnabled");
10757 if (bgp_maxmed_onstartup_configured(bgp
)
10758 && bgp
->maxmed_active
)
10760 "Max-med on-startup active\n");
10761 if (bgp
->v_maxmed_admin
)
10763 "Max-med administrative active\n");
10766 "BGP table version %" PRIu64
10769 bgp
->rib
[afi
][safi
]));
10771 ents
= bgp_table_count(
10772 bgp
->rib
[afi
][safi
]);
10774 "RIB entries %ld, using %s of memory\n",
10784 /* Peer related usage */
10785 ents
= bgp
->af_peer_count
[afi
][safi
];
10787 "Peers %ld, using %s of memory\n",
10797 if ((ents
= listcount(bgp
->group
)))
10799 "Peer groups %ld, using %s of memory\n",
10809 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10810 BGP_CONFIG_DAMPENING
))
10812 "Dampening enabled.\n");
10815 vty_out(vty
, "\n");
10817 /* Subtract 8 here because 'Neighbor' is
10819 vty_out(vty
, "Neighbor");
10820 vty_out(vty
, "%*s",
10821 max_neighbor_width
- 8, " ");
10823 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10828 paf
= peer_af_find(peer
, afi
, safi
);
10829 filter
= &peer
->filter
[afi
][safi
];
10832 /* Works for both failed & successful cases */
10833 if (peer_dynamic_neighbor(peer
))
10838 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10844 bgp_has_peer_failed(peer
, afi
, safi
)) {
10845 json_peer
= json_object_new_object();
10846 bgp_show_failed_summary(vty
, bgp
, peer
,
10847 json_peer
, 0, use_json
);
10848 } else if (!show_failed
) {
10849 if (show_established
10850 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10855 json_peer
= json_object_new_object();
10856 if (peer_dynamic_neighbor(peer
)) {
10857 json_object_boolean_true_add(json_peer
,
10861 if (peer
->hostname
)
10862 json_object_string_add(json_peer
, "hostname",
10865 if (peer
->domainname
)
10866 json_object_string_add(json_peer
, "domainname",
10869 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10870 json_object_int_add(
10871 json_peer
, "localAs",
10872 peer
->change_local_as
10873 ? peer
->change_local_as
10875 json_object_int_add(json_peer
, "version", 4);
10876 json_object_int_add(json_peer
, "msgRcvd",
10877 PEER_TOTAL_RX(peer
));
10878 json_object_int_add(json_peer
, "msgSent",
10879 PEER_TOTAL_TX(peer
));
10881 atomic_size_t outq_count
, inq_count
;
10882 outq_count
= atomic_load_explicit(
10883 &peer
->obuf
->count
,
10884 memory_order_relaxed
);
10885 inq_count
= atomic_load_explicit(
10886 &peer
->ibuf
->count
,
10887 memory_order_relaxed
);
10889 json_object_int_add(json_peer
, "tableVersion",
10890 peer
->version
[afi
][safi
]);
10891 json_object_int_add(json_peer
, "outq",
10893 json_object_int_add(json_peer
, "inq",
10895 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10896 use_json
, json_peer
);
10898 json_object_int_add(json_peer
, "pfxRcd",
10899 peer
->pcount
[afi
][pfx_rcd_safi
]);
10901 if (paf
&& PAF_SUBGRP(paf
))
10902 json_object_int_add(
10903 json_peer
, "pfxSnt",
10904 (PAF_SUBGRP(paf
))->scount
);
10906 json_object_int_add(json_peer
, "pfxSnt",
10909 /* BGP FSM state */
10910 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10911 || CHECK_FLAG(peer
->bgp
->flags
,
10912 BGP_FLAG_SHUTDOWN
))
10913 json_object_string_add(json_peer
,
10916 else if (peer
->afc_recv
[afi
][safi
])
10917 json_object_string_add(
10918 json_peer
, "state",
10919 lookup_msg(bgp_status_msg
,
10920 peer
->status
, NULL
));
10921 else if (CHECK_FLAG(
10923 PEER_STATUS_PREFIX_OVERFLOW
))
10924 json_object_string_add(json_peer
,
10928 json_object_string_add(
10929 json_peer
, "state",
10930 lookup_msg(bgp_status_msg
,
10931 peer
->status
, NULL
));
10933 /* BGP peer state */
10934 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10935 || CHECK_FLAG(peer
->bgp
->flags
,
10936 BGP_FLAG_SHUTDOWN
))
10937 json_object_string_add(json_peer
,
10940 else if (CHECK_FLAG(
10942 PEER_STATUS_PREFIX_OVERFLOW
))
10943 json_object_string_add(json_peer
,
10946 else if (CHECK_FLAG(peer
->flags
,
10947 PEER_FLAG_PASSIVE
))
10948 json_object_string_add(json_peer
,
10951 else if (CHECK_FLAG(peer
->sflags
,
10952 PEER_STATUS_NSF_WAIT
))
10953 json_object_string_add(json_peer
,
10956 else if (CHECK_FLAG(
10958 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10959 && (!bgp_inbound_policy_exists(peer
,
10961 || !bgp_outbound_policy_exists(
10963 json_object_string_add(json_peer
,
10967 json_object_string_add(
10968 json_peer
, "peerState", "OK");
10970 json_object_int_add(json_peer
, "connectionsEstablished",
10971 peer
->established
);
10972 json_object_int_add(json_peer
, "connectionsDropped",
10975 json_object_string_add(
10976 json_peer
, "desc", peer
->desc
);
10978 /* Avoid creating empty peer dicts in JSON */
10979 if (json_peer
== NULL
)
10983 json_object_string_add(json_peer
, "idType",
10985 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10986 json_object_string_add(json_peer
, "idType",
10988 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10989 json_object_string_add(json_peer
, "idType",
10991 json_object_object_add(json_peers
, peer
->host
,
10994 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11000 bgp_has_peer_failed(peer
, afi
, safi
)) {
11001 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11002 max_neighbor_width
,
11004 } else if (!show_failed
) {
11005 if (show_established
11006 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11011 if ((count
- filtered_count
) == 1) {
11012 /* display headline before the first
11014 vty_out(vty
, "\n");
11016 /* Subtract 8 here because 'Neighbor' is
11018 vty_out(vty
, "Neighbor");
11019 vty_out(vty
, "%*s",
11020 max_neighbor_width
- 8, " ");
11023 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11024 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11027 memset(dn_flag
, '\0', sizeof(dn_flag
));
11028 if (peer_dynamic_neighbor(peer
)) {
11033 && CHECK_FLAG(bgp
->flags
,
11034 BGP_FLAG_SHOW_HOSTNAME
))
11035 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11039 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11041 /* pad the neighbor column with spaces */
11042 if (len
< max_neighbor_width
)
11043 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11046 atomic_size_t outq_count
, inq_count
;
11047 outq_count
= atomic_load_explicit(
11048 &peer
->obuf
->count
,
11049 memory_order_relaxed
);
11050 inq_count
= atomic_load_explicit(
11051 &peer
->ibuf
->count
,
11052 memory_order_relaxed
);
11056 "4 %10u %10u %9u %9u %8" PRIu64
11059 peer
->change_local_as
11060 ? peer
->change_local_as
11062 PEER_TOTAL_RX(peer
),
11063 PEER_TOTAL_TX(peer
),
11064 peer
->version
[afi
][safi
],
11065 inq_count
, outq_count
,
11066 peer_uptime(peer
->uptime
,
11071 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11073 peer
->as
, PEER_TOTAL_RX(peer
),
11074 PEER_TOTAL_TX(peer
),
11075 peer
->version
[afi
][safi
],
11076 inq_count
, outq_count
,
11077 peer_uptime(peer
->uptime
,
11082 if (peer_established(peer
)) {
11083 if (peer
->afc_recv
[afi
][safi
]) {
11086 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11087 && !bgp_inbound_policy_exists(
11089 vty_out(vty
, " %12s",
11098 vty_out(vty
, " NoNeg");
11101 if (paf
&& PAF_SUBGRP(paf
)) {
11104 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11105 && !bgp_outbound_policy_exists(
11107 vty_out(vty
, " %8s",
11116 vty_out(vty
, " NoNeg");
11119 if (CHECK_FLAG(peer
->flags
,
11120 PEER_FLAG_SHUTDOWN
)
11121 || CHECK_FLAG(peer
->bgp
->flags
,
11122 BGP_FLAG_SHUTDOWN
))
11123 vty_out(vty
, " Idle (Admin)");
11124 else if (CHECK_FLAG(
11126 PEER_STATUS_PREFIX_OVERFLOW
))
11127 vty_out(vty
, " Idle (PfxCt)");
11129 vty_out(vty
, " %12s",
11130 lookup_msg(bgp_status_msg
,
11131 peer
->status
, NULL
));
11133 vty_out(vty
, " %8u", 0);
11135 /* Make sure `Desc` column is the lastest in
11139 vty_out(vty
, " %s",
11140 bgp_peer_description_stripped(
11142 show_wide
? 64 : 20));
11144 vty_out(vty
, " N/A");
11145 vty_out(vty
, "\n");
11152 json_object_object_add(json
, "peers", json_peers
);
11153 json_object_int_add(json
, "failedPeers", failed_count
);
11154 json_object_int_add(json
, "displayedPeers",
11155 count
- filtered_count
);
11156 json_object_int_add(json
, "totalPeers", count
);
11157 json_object_int_add(json
, "dynamicPeers", dn_count
);
11160 bgp_show_bestpath_json(bgp
, json
);
11162 vty_json(vty
, json
);
11165 if (filtered_count
== count
)
11166 vty_out(vty
, "\n%% No matching neighbor\n");
11169 vty_out(vty
, "\nDisplayed neighbors %d",
11171 else if (as_type
!= AS_UNSPECIFIED
|| as
11172 || fpeer
|| show_established
)
11173 vty_out(vty
, "\nDisplayed neighbors %d",
11174 count
- filtered_count
);
11176 vty_out(vty
, "\nTotal number of neighbors %d\n",
11180 vty_out(vty
, "No %s neighbor is configured\n",
11181 get_afi_safi_str(afi
, safi
, false));
11185 vty_out(vty
, "* - dynamic neighbor\n");
11186 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11187 dn_count
, bgp
->dynamic_neighbors_limit
);
11191 return CMD_SUCCESS
;
11194 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11195 int safi
, struct peer
*fpeer
, int as_type
,
11196 as_t as
, uint16_t show_flags
)
11199 int afi_wildcard
= (afi
== AFI_MAX
);
11200 int safi_wildcard
= (safi
== SAFI_MAX
);
11201 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11202 bool nbr_output
= false;
11203 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11205 if (use_json
&& is_wildcard
)
11206 vty_out(vty
, "{\n");
11208 afi
= 1; /* AFI_IP */
11209 while (afi
< AFI_MAX
) {
11211 safi
= 1; /* SAFI_UNICAST */
11212 while (safi
< SAFI_MAX
) {
11213 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11218 * So limit output to those afi/safi
11220 * actualy have something interesting in
11225 vty_out(vty
, ",\n");
11229 vty_out(vty
, "\"%s\":",
11230 get_afi_safi_str(afi
,
11235 "\n%s Summary (%s):\n",
11236 get_afi_safi_str(afi
,
11242 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11243 as_type
, as
, show_flags
);
11246 if (!safi_wildcard
)
11254 if (use_json
&& is_wildcard
)
11255 vty_out(vty
, "}\n");
11256 else if (!nbr_output
) {
11258 vty_out(vty
, "{}\n");
11260 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11265 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11267 const char *neighbor
,
11268 int as_type
, as_t as
,
11269 uint16_t show_flags
)
11271 struct listnode
*node
, *nnode
;
11273 struct peer
*fpeer
= NULL
;
11275 bool nbr_output
= false;
11276 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11279 vty_out(vty
, "{\n");
11281 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11285 vty_out(vty
, ",\n");
11289 vty_out(vty
, "\"%s\":",
11290 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11295 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11300 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11305 vty_out(vty
, "}\n");
11306 else if (!nbr_output
)
11307 vty_out(vty
, "%% BGP instance not found\n");
11310 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11311 safi_t safi
, const char *neighbor
, int as_type
,
11312 as_t as
, uint16_t show_flags
)
11315 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11316 struct peer
*fpeer
= NULL
;
11319 if (strmatch(name
, "all")) {
11320 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11323 return CMD_SUCCESS
;
11325 bgp
= bgp_lookup_by_name(name
);
11329 vty_out(vty
, "{}\n");
11332 "%% BGP instance not found\n");
11333 return CMD_WARNING
;
11337 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11340 return CMD_WARNING
;
11342 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11343 as_type
, as
, show_flags
);
11344 return CMD_SUCCESS
;
11348 bgp
= bgp_get_default();
11352 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11355 return CMD_WARNING
;
11357 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11361 vty_out(vty
, "{}\n");
11363 vty_out(vty
, "%% BGP instance not found\n");
11364 return CMD_WARNING
;
11367 return CMD_SUCCESS
;
11370 /* `show [ip] bgp summary' commands. */
11371 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11372 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11373 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11374 "]] [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]",
11375 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11376 BGP_SAFI_WITH_LABEL_HELP_STR
11377 "Display the entries for all address families\n"
11378 "Summary of BGP neighbor status\n"
11379 "Show only sessions in Established state\n"
11380 "Show only sessions not in Established state\n"
11381 "Show only the specified neighbor session\n"
11382 "Neighbor to display information about\n"
11383 "Neighbor to display information about\n"
11384 "Neighbor on BGP configured interface\n"
11385 "Show only the specified remote AS sessions\n"
11387 "Internal (iBGP) AS sessions\n"
11388 "External (eBGP) AS sessions\n"
11389 "Shorten the information on BGP instances\n"
11390 "Increase table width for longer output\n" JSON_STR
)
11393 afi_t afi
= AFI_MAX
;
11394 safi_t safi
= SAFI_MAX
;
11395 as_t as
= 0; /* 0 means AS filter not set */
11396 int as_type
= AS_UNSPECIFIED
;
11397 uint16_t show_flags
= 0;
11401 /* show [ip] bgp */
11402 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11404 /* [<vrf> VIEWVRFNAME] */
11405 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11406 vrf
= argv
[idx
+ 1]->arg
;
11407 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11409 } else if (argv_find(argv
, argc
, "view", &idx
))
11410 /* [<view> VIEWVRFNAME] */
11411 vrf
= argv
[idx
+ 1]->arg
;
11412 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11413 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11414 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11417 if (argv_find(argv
, argc
, "failed", &idx
))
11418 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11420 if (argv_find(argv
, argc
, "established", &idx
))
11421 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11423 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11424 if (argv
[idx
+ 1]->arg
[0] == 'i')
11425 as_type
= AS_INTERNAL
;
11426 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11427 as_type
= AS_EXTERNAL
;
11429 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11432 if (argv_find(argv
, argc
, "terse", &idx
))
11433 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11435 if (argv_find(argv
, argc
, "wide", &idx
))
11436 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11438 if (argv_find(argv
, argc
, "json", &idx
))
11439 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11441 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11445 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11448 return get_afi_safi_json_str(afi
, safi
);
11450 return get_afi_safi_vty_str(afi
, safi
);
11454 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11455 afi_t afi
, safi_t safi
,
11456 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11457 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11458 bool use_json
, json_object
*json_pref
)
11461 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11462 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11464 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11465 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11466 json_object_string_add(json_pref
, "sendMode",
11467 "advertisedAndReceived");
11468 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11469 json_object_string_add(json_pref
, "sendMode",
11471 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11472 json_object_string_add(json_pref
, "sendMode",
11475 vty_out(vty
, " Send-mode: ");
11476 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11477 vty_out(vty
, "advertised");
11478 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11479 vty_out(vty
, "%sreceived",
11480 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11484 vty_out(vty
, "\n");
11489 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11490 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11492 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11493 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11494 json_object_string_add(json_pref
, "recvMode",
11495 "advertisedAndReceived");
11496 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11497 json_object_string_add(json_pref
, "recvMode",
11499 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11500 json_object_string_add(json_pref
, "recvMode",
11503 vty_out(vty
, " Receive-mode: ");
11504 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11505 vty_out(vty
, "advertised");
11506 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11507 vty_out(vty
, "%sreceived",
11508 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11512 vty_out(vty
, "\n");
11517 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11525 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11526 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11527 && (peer_established(p
))) {
11528 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11529 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11533 json_object_boolean_add(json
, "rBit", rbit
);
11534 json_object_boolean_add(json
, "nBit", nbit
);
11536 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11537 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11541 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11546 const char *mode
= "NotApplicable";
11549 vty_out(vty
, "\n Remote GR Mode: ");
11551 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11552 && (peer_established(peer
))) {
11554 if ((peer
->nsf_af_count
== 0)
11555 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11559 } else if (peer
->nsf_af_count
== 0
11560 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11564 } else if (peer
->nsf_af_count
!= 0
11565 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11572 json_object_string_add(json
, "remoteGrMode", mode
);
11574 vty_out(vty
, mode
, "\n");
11577 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11582 const char *mode
= "Invalid";
11585 vty_out(vty
, " Local GR Mode: ");
11587 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11589 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11591 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11593 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11594 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11596 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11598 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11605 json_object_string_add(json
, "localGrMode", mode
);
11607 vty_out(vty
, mode
, "\n");
11611 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11612 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11616 json_object
*json_afi_safi
= NULL
;
11617 json_object
*json_timer
= NULL
;
11618 json_object
*json_endofrib_status
= NULL
;
11619 bool eor_flag
= false;
11621 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11622 if (!peer
->afc
[afi
][safi
])
11625 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11626 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11630 json_afi_safi
= json_object_new_object();
11631 json_endofrib_status
= json_object_new_object();
11632 json_timer
= json_object_new_object();
11635 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11641 vty_out(vty
, " %s:\n",
11642 get_afi_safi_str(afi
, safi
, false));
11644 vty_out(vty
, " F bit: ");
11647 if (peer
->nsf
[afi
][safi
] &&
11648 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11649 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11652 json_object_boolean_true_add(json_afi_safi
,
11655 vty_out(vty
, "True\n");
11658 json_object_boolean_false_add(json_afi_safi
,
11661 vty_out(vty
, "False\n");
11665 vty_out(vty
, " End-of-RIB sent: ");
11667 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11668 PEER_STATUS_EOR_SEND
)) {
11670 json_object_boolean_true_add(
11671 json_endofrib_status
, "endOfRibSend");
11673 PRINT_EOR_JSON(eor_flag
);
11675 vty_out(vty
, "Yes\n");
11677 " End-of-RIB sent after update: ");
11679 PRINT_EOR(eor_flag
);
11683 json_object_boolean_false_add(
11684 json_endofrib_status
, "endOfRibSend");
11685 json_object_boolean_false_add(
11686 json_endofrib_status
,
11687 "endOfRibSentAfterUpdate");
11689 vty_out(vty
, "No\n");
11691 " End-of-RIB sent after update: ");
11692 vty_out(vty
, "No\n");
11697 vty_out(vty
, " End-of-RIB received: ");
11699 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11700 PEER_STATUS_EOR_RECEIVED
)) {
11702 json_object_boolean_true_add(
11703 json_endofrib_status
, "endOfRibRecv");
11705 vty_out(vty
, "Yes\n");
11708 json_object_boolean_false_add(
11709 json_endofrib_status
, "endOfRibRecv");
11711 vty_out(vty
, "No\n");
11715 json_object_int_add(json_timer
, "stalePathTimer",
11716 peer
->bgp
->stalepath_time
);
11718 if (peer
->t_gr_stale
!= NULL
) {
11719 json_object_int_add(json_timer
,
11720 "stalePathTimerRemaining",
11721 thread_timer_remain_second(
11722 peer
->t_gr_stale
));
11725 /* Display Configured Selection
11726 * Deferral only when when
11727 * Gr mode is enabled.
11729 if (CHECK_FLAG(peer
->flags
,
11730 PEER_FLAG_GRACEFUL_RESTART
)) {
11731 json_object_int_add(json_timer
,
11732 "selectionDeferralTimer",
11733 peer
->bgp
->stalepath_time
);
11736 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11739 json_object_int_add(
11741 "selectionDeferralTimerRemaining",
11742 thread_timer_remain_second(
11743 peer
->bgp
->gr_info
[afi
][safi
]
11744 .t_select_deferral
));
11747 vty_out(vty
, " Timers:\n");
11749 " Configured Stale Path Time(sec): %u\n",
11750 peer
->bgp
->stalepath_time
);
11752 if (peer
->t_gr_stale
!= NULL
)
11754 " Stale Path Remaining(sec): %ld\n",
11755 thread_timer_remain_second(
11756 peer
->t_gr_stale
));
11757 /* Display Configured Selection
11758 * Deferral only when when
11759 * Gr mode is enabled.
11761 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11763 " Configured Selection Deferral Time(sec): %u\n",
11764 peer
->bgp
->select_defer_time
);
11766 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11769 " Selection Deferral Time Remaining(sec): %ld\n",
11770 thread_timer_remain_second(
11771 peer
->bgp
->gr_info
[afi
][safi
]
11772 .t_select_deferral
));
11775 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11776 json_endofrib_status
);
11777 json_object_object_add(json_afi_safi
, "timers",
11779 json_object_object_add(
11780 json
, get_afi_safi_str(afi
, safi
, true),
11786 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11792 json_object
*json_timer
= NULL
;
11794 json_timer
= json_object_new_object();
11796 json_object_int_add(json_timer
, "configuredRestartTimer",
11797 p
->bgp
->restart_time
);
11799 json_object_int_add(json_timer
, "receivedRestartTimer",
11802 if (p
->t_gr_restart
!= NULL
)
11803 json_object_int_add(
11804 json_timer
, "restartTimerRemaining",
11805 thread_timer_remain_second(p
->t_gr_restart
));
11807 json_object_object_add(json
, "timers", json_timer
);
11810 vty_out(vty
, " Timers:\n");
11811 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11812 p
->bgp
->restart_time
);
11814 vty_out(vty
, " Received Restart Time(sec): %u\n",
11816 if (p
->t_gr_restart
!= NULL
)
11817 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11818 thread_timer_remain_second(p
->t_gr_restart
));
11819 if (p
->t_gr_restart
!= NULL
) {
11820 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11821 thread_timer_remain_second(p
->t_gr_restart
));
11826 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11827 bool use_json
, json_object
*json
)
11829 char dn_flag
[2] = {0};
11830 /* '*' + v6 address of neighbor */
11831 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11833 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11838 json_object_string_addf(json
, "neighborAddr", "%pSU",
11841 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11844 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11848 json_object_string_add(json
, "neighborAddr",
11851 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11854 /* more gr info in new format */
11855 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11858 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11859 safi_t safi
, bool use_json
,
11860 json_object
*json_neigh
)
11862 struct bgp_filter
*filter
;
11863 struct peer_af
*paf
;
11864 char orf_pfx_name
[BUFSIZ
];
11866 json_object
*json_af
= NULL
;
11867 json_object
*json_prefA
= NULL
;
11868 json_object
*json_prefB
= NULL
;
11869 json_object
*json_addr
= NULL
;
11870 json_object
*json_advmap
= NULL
;
11873 json_addr
= json_object_new_object();
11874 json_af
= json_object_new_object();
11875 filter
= &p
->filter
[afi
][safi
];
11877 if (peer_group_active(p
))
11878 json_object_string_add(json_addr
, "peerGroupMember",
11881 paf
= peer_af_find(p
, afi
, safi
);
11882 if (paf
&& PAF_SUBGRP(paf
)) {
11883 json_object_int_add(json_addr
, "updateGroupId",
11884 PAF_UPDGRP(paf
)->id
);
11885 json_object_int_add(json_addr
, "subGroupId",
11886 PAF_SUBGRP(paf
)->id
);
11887 json_object_int_add(json_addr
, "packetQueueLength",
11888 bpacket_queue_virtual_length(paf
));
11891 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11892 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11893 PEER_CAP_ORF_PREFIX_SM_RCV
)
11894 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11895 PEER_CAP_ORF_PREFIX_RM_ADV
)
11896 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11897 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11898 json_object_int_add(json_af
, "orfType",
11900 json_prefA
= json_object_new_object();
11901 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11902 PEER_CAP_ORF_PREFIX_SM_ADV
,
11903 PEER_CAP_ORF_PREFIX_RM_ADV
,
11904 PEER_CAP_ORF_PREFIX_SM_RCV
,
11905 PEER_CAP_ORF_PREFIX_RM_RCV
,
11906 use_json
, json_prefA
);
11907 json_object_object_add(json_af
, "orfPrefixList",
11911 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11912 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11913 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11914 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11915 PEER_CAP_ORF_PREFIX_RM_ADV
)
11916 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11917 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11918 json_object_int_add(json_af
, "orfOldType",
11919 ORF_TYPE_PREFIX_OLD
);
11920 json_prefB
= json_object_new_object();
11921 bgp_show_peer_afi_orf_cap(
11922 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11923 PEER_CAP_ORF_PREFIX_RM_ADV
,
11924 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11925 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11927 json_object_object_add(json_af
, "orfOldPrefixList",
11931 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11932 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11933 PEER_CAP_ORF_PREFIX_SM_RCV
)
11934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11935 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11937 PEER_CAP_ORF_PREFIX_RM_ADV
)
11938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11939 PEER_CAP_ORF_PREFIX_RM_RCV
)
11940 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11941 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11942 json_object_object_add(json_addr
, "afDependentCap",
11945 json_object_free(json_af
);
11947 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11948 p
->host
, afi
, safi
);
11949 orf_pfx_count
= prefix_bgp_show_prefix_list(
11950 NULL
, afi
, orf_pfx_name
, use_json
);
11952 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11953 PEER_STATUS_ORF_PREFIX_SEND
)
11954 || orf_pfx_count
) {
11955 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11956 PEER_STATUS_ORF_PREFIX_SEND
))
11957 json_object_boolean_true_add(json_neigh
,
11960 json_object_int_add(json_addr
, "orfRecvCounter",
11963 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11964 PEER_STATUS_ORF_WAIT_REFRESH
))
11965 json_object_string_add(
11966 json_addr
, "orfFirstUpdate",
11967 "deferredUntilORFOrRouteRefreshRecvd");
11969 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11970 PEER_FLAG_REFLECTOR_CLIENT
))
11971 json_object_boolean_true_add(json_addr
,
11972 "routeReflectorClient");
11973 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11974 PEER_FLAG_RSERVER_CLIENT
))
11975 json_object_boolean_true_add(json_addr
,
11976 "routeServerClient");
11977 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11978 json_object_boolean_true_add(json_addr
,
11979 "inboundSoftConfigPermit");
11981 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11982 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11983 json_object_boolean_true_add(
11985 "privateAsNumsAllReplacedInUpdatesToNbr");
11986 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11987 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11988 json_object_boolean_true_add(
11990 "privateAsNumsReplacedInUpdatesToNbr");
11991 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11992 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11993 json_object_boolean_true_add(
11995 "privateAsNumsAllRemovedInUpdatesToNbr");
11996 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11997 PEER_FLAG_REMOVE_PRIVATE_AS
))
11998 json_object_boolean_true_add(
12000 "privateAsNumsRemovedInUpdatesToNbr");
12002 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12003 json_object_boolean_true_add(
12005 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12008 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12009 json_object_string_add(json_addr
,
12010 "overrideASNsInOutboundUpdates",
12011 "ifAspathEqualRemoteAs");
12013 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12014 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12015 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12016 json_object_boolean_true_add(json_addr
,
12017 "routerAlwaysNextHop");
12018 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12019 PEER_FLAG_AS_PATH_UNCHANGED
))
12020 json_object_boolean_true_add(
12021 json_addr
, "unchangedAsPathPropogatedToNbr");
12022 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12023 PEER_FLAG_NEXTHOP_UNCHANGED
))
12024 json_object_boolean_true_add(
12025 json_addr
, "unchangedNextHopPropogatedToNbr");
12026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12027 json_object_boolean_true_add(
12028 json_addr
, "unchangedMedPropogatedToNbr");
12029 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12030 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12031 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12032 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12033 PEER_FLAG_SEND_COMMUNITY
)
12034 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12035 PEER_FLAG_SEND_EXT_COMMUNITY
))
12036 json_object_string_add(json_addr
,
12037 "commAttriSentToNbr",
12038 "extendedAndStandard");
12039 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12040 PEER_FLAG_SEND_EXT_COMMUNITY
))
12041 json_object_string_add(json_addr
,
12042 "commAttriSentToNbr",
12045 json_object_string_add(json_addr
,
12046 "commAttriSentToNbr",
12049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12050 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12051 if (p
->default_rmap
[afi
][safi
].name
)
12052 json_object_string_add(
12053 json_addr
, "defaultRouteMap",
12054 p
->default_rmap
[afi
][safi
].name
);
12056 if (paf
&& PAF_SUBGRP(paf
)
12057 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12058 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12059 json_object_boolean_true_add(json_addr
,
12062 json_object_boolean_true_add(json_addr
,
12066 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12067 if (is_evpn_enabled())
12068 json_object_boolean_true_add(
12069 json_addr
, "advertiseAllVnis");
12072 if (filter
->plist
[FILTER_IN
].name
12073 || filter
->dlist
[FILTER_IN
].name
12074 || filter
->aslist
[FILTER_IN
].name
12075 || filter
->map
[RMAP_IN
].name
)
12076 json_object_boolean_true_add(json_addr
,
12077 "inboundPathPolicyConfig");
12078 if (filter
->plist
[FILTER_OUT
].name
12079 || filter
->dlist
[FILTER_OUT
].name
12080 || filter
->aslist
[FILTER_OUT
].name
12081 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12082 json_object_boolean_true_add(
12083 json_addr
, "outboundPathPolicyConfig");
12086 if (filter
->plist
[FILTER_IN
].name
)
12087 json_object_string_add(json_addr
,
12088 "incomingUpdatePrefixFilterList",
12089 filter
->plist
[FILTER_IN
].name
);
12090 if (filter
->plist
[FILTER_OUT
].name
)
12091 json_object_string_add(json_addr
,
12092 "outgoingUpdatePrefixFilterList",
12093 filter
->plist
[FILTER_OUT
].name
);
12095 /* distribute-list */
12096 if (filter
->dlist
[FILTER_IN
].name
)
12097 json_object_string_add(
12098 json_addr
, "incomingUpdateNetworkFilterList",
12099 filter
->dlist
[FILTER_IN
].name
);
12100 if (filter
->dlist
[FILTER_OUT
].name
)
12101 json_object_string_add(
12102 json_addr
, "outgoingUpdateNetworkFilterList",
12103 filter
->dlist
[FILTER_OUT
].name
);
12106 if (filter
->aslist
[FILTER_IN
].name
)
12107 json_object_string_add(json_addr
,
12108 "incomingUpdateAsPathFilterList",
12109 filter
->aslist
[FILTER_IN
].name
);
12110 if (filter
->aslist
[FILTER_OUT
].name
)
12111 json_object_string_add(json_addr
,
12112 "outgoingUpdateAsPathFilterList",
12113 filter
->aslist
[FILTER_OUT
].name
);
12116 if (filter
->map
[RMAP_IN
].name
)
12117 json_object_string_add(
12118 json_addr
, "routeMapForIncomingAdvertisements",
12119 filter
->map
[RMAP_IN
].name
);
12120 if (filter
->map
[RMAP_OUT
].name
)
12121 json_object_string_add(
12122 json_addr
, "routeMapForOutgoingAdvertisements",
12123 filter
->map
[RMAP_OUT
].name
);
12125 /* ebgp-requires-policy (inbound) */
12126 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12127 && !bgp_inbound_policy_exists(p
, filter
))
12128 json_object_string_add(
12129 json_addr
, "inboundEbgpRequiresPolicy",
12130 "Inbound updates discarded due to missing policy");
12132 /* ebgp-requires-policy (outbound) */
12133 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12134 && (!bgp_outbound_policy_exists(p
, filter
)))
12135 json_object_string_add(
12136 json_addr
, "outboundEbgpRequiresPolicy",
12137 "Outbound updates discarded due to missing policy");
12139 /* unsuppress-map */
12140 if (filter
->usmap
.name
)
12141 json_object_string_add(json_addr
,
12142 "selectiveUnsuppressRouteMap",
12143 filter
->usmap
.name
);
12145 /* advertise-map */
12146 if (filter
->advmap
.aname
) {
12147 json_advmap
= json_object_new_object();
12148 json_object_string_add(json_advmap
, "condition",
12149 filter
->advmap
.condition
12152 json_object_string_add(json_advmap
, "conditionMap",
12153 filter
->advmap
.cname
);
12154 json_object_string_add(json_advmap
, "advertiseMap",
12155 filter
->advmap
.aname
);
12156 json_object_string_add(
12157 json_advmap
, "advertiseStatus",
12158 filter
->advmap
.update_type
==
12159 UPDATE_TYPE_ADVERTISE
12162 json_object_object_add(json_addr
, "advertiseMap",
12166 /* Receive prefix count */
12167 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12168 p
->pcount
[afi
][safi
]);
12169 if (paf
&& PAF_SUBGRP(paf
))
12170 json_object_int_add(json_addr
, "sentPrefixCounter",
12171 (PAF_SUBGRP(paf
))->scount
);
12173 /* Maximum prefix */
12174 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12175 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12176 p
->pmax_out
[afi
][safi
]);
12178 /* Maximum prefix */
12179 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12180 json_object_int_add(json_addr
, "prefixAllowedMax",
12181 p
->pmax
[afi
][safi
]);
12182 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12183 PEER_FLAG_MAX_PREFIX_WARNING
))
12184 json_object_boolean_true_add(
12185 json_addr
, "prefixAllowedMaxWarning");
12186 json_object_int_add(json_addr
,
12187 "prefixAllowedWarningThresh",
12188 p
->pmax_threshold
[afi
][safi
]);
12189 if (p
->pmax_restart
[afi
][safi
])
12190 json_object_int_add(
12192 "prefixAllowedRestartIntervalMsecs",
12193 p
->pmax_restart
[afi
][safi
] * 60000);
12195 json_object_object_add(json_neigh
,
12196 get_afi_safi_str(afi
, safi
, true),
12200 filter
= &p
->filter
[afi
][safi
];
12202 vty_out(vty
, " For address family: %s\n",
12203 get_afi_safi_str(afi
, safi
, false));
12205 if (peer_group_active(p
))
12206 vty_out(vty
, " %s peer-group member\n",
12209 paf
= peer_af_find(p
, afi
, safi
);
12210 if (paf
&& PAF_SUBGRP(paf
)) {
12211 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12212 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12213 vty_out(vty
, " Packet Queue length %d\n",
12214 bpacket_queue_virtual_length(paf
));
12216 vty_out(vty
, " Not part of any update group\n");
12218 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12219 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12220 PEER_CAP_ORF_PREFIX_SM_RCV
)
12221 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12222 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12223 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12224 PEER_CAP_ORF_PREFIX_RM_ADV
)
12225 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12226 PEER_CAP_ORF_PREFIX_RM_RCV
)
12227 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12228 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12229 vty_out(vty
, " AF-dependant capabilities:\n");
12231 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12232 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12233 PEER_CAP_ORF_PREFIX_SM_RCV
)
12234 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12235 PEER_CAP_ORF_PREFIX_RM_ADV
)
12236 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12237 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12239 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12241 bgp_show_peer_afi_orf_cap(
12242 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12243 PEER_CAP_ORF_PREFIX_RM_ADV
,
12244 PEER_CAP_ORF_PREFIX_SM_RCV
,
12245 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12247 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12248 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12249 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12250 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12251 PEER_CAP_ORF_PREFIX_RM_ADV
)
12252 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12253 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12255 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12256 ORF_TYPE_PREFIX_OLD
);
12257 bgp_show_peer_afi_orf_cap(
12258 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12259 PEER_CAP_ORF_PREFIX_RM_ADV
,
12260 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12261 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12264 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12265 p
->host
, afi
, safi
);
12266 orf_pfx_count
= prefix_bgp_show_prefix_list(
12267 NULL
, afi
, orf_pfx_name
, use_json
);
12269 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12270 PEER_STATUS_ORF_PREFIX_SEND
)
12271 || orf_pfx_count
) {
12272 vty_out(vty
, " Outbound Route Filter (ORF):");
12273 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12274 PEER_STATUS_ORF_PREFIX_SEND
))
12275 vty_out(vty
, " sent;");
12277 vty_out(vty
, " received (%d entries)",
12279 vty_out(vty
, "\n");
12281 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12282 PEER_STATUS_ORF_WAIT_REFRESH
))
12284 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12286 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12287 PEER_FLAG_REFLECTOR_CLIENT
))
12288 vty_out(vty
, " Route-Reflector Client\n");
12289 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12290 PEER_FLAG_RSERVER_CLIENT
))
12291 vty_out(vty
, " Route-Server Client\n");
12292 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12294 " Inbound soft reconfiguration allowed\n");
12296 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12297 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12299 " Private AS numbers (all) replaced in updates to this neighbor\n");
12300 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12301 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12303 " Private AS numbers replaced in updates to this neighbor\n");
12304 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12305 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12307 " Private AS numbers (all) removed in updates to this neighbor\n");
12308 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12309 PEER_FLAG_REMOVE_PRIVATE_AS
))
12311 " Private AS numbers removed in updates to this neighbor\n");
12313 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12314 vty_out(vty
, " %s\n",
12315 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12316 ->human_description
);
12318 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12320 " Override ASNs in outbound updates if aspath equals remote-as\n");
12322 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12323 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12324 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12325 vty_out(vty
, " NEXT_HOP is always this router\n");
12326 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12327 PEER_FLAG_AS_PATH_UNCHANGED
))
12329 " AS_PATH is propagated unchanged to this neighbor\n");
12330 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12331 PEER_FLAG_NEXTHOP_UNCHANGED
))
12333 " NEXT_HOP is propagated unchanged to this neighbor\n");
12334 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12336 " MED is propagated unchanged to this neighbor\n");
12337 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12338 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12339 PEER_FLAG_SEND_EXT_COMMUNITY
)
12340 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12341 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12343 " Community attribute sent to this neighbor");
12344 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12345 PEER_FLAG_SEND_COMMUNITY
)
12346 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12347 PEER_FLAG_SEND_EXT_COMMUNITY
)
12348 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12349 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12350 vty_out(vty
, "(all)\n");
12351 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12352 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12353 vty_out(vty
, "(large)\n");
12354 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12355 PEER_FLAG_SEND_EXT_COMMUNITY
))
12356 vty_out(vty
, "(extended)\n");
12358 vty_out(vty
, "(standard)\n");
12360 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12361 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12362 vty_out(vty
, " Default information originate,");
12364 if (p
->default_rmap
[afi
][safi
].name
)
12365 vty_out(vty
, " default route-map %s%s,",
12366 p
->default_rmap
[afi
][safi
].map
? "*"
12368 p
->default_rmap
[afi
][safi
].name
);
12369 if (paf
&& PAF_SUBGRP(paf
)
12370 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12371 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12372 vty_out(vty
, " default sent\n");
12374 vty_out(vty
, " default not sent\n");
12377 /* advertise-vni-all */
12378 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12379 if (is_evpn_enabled())
12380 vty_out(vty
, " advertise-all-vni\n");
12383 if (filter
->plist
[FILTER_IN
].name
12384 || filter
->dlist
[FILTER_IN
].name
12385 || filter
->aslist
[FILTER_IN
].name
12386 || filter
->map
[RMAP_IN
].name
)
12387 vty_out(vty
, " Inbound path policy configured\n");
12388 if (filter
->plist
[FILTER_OUT
].name
12389 || filter
->dlist
[FILTER_OUT
].name
12390 || filter
->aslist
[FILTER_OUT
].name
12391 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12392 vty_out(vty
, " Outbound path policy configured\n");
12395 if (filter
->plist
[FILTER_IN
].name
)
12397 " Incoming update prefix filter list is %s%s\n",
12398 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12399 filter
->plist
[FILTER_IN
].name
);
12400 if (filter
->plist
[FILTER_OUT
].name
)
12402 " Outgoing update prefix filter list is %s%s\n",
12403 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12404 filter
->plist
[FILTER_OUT
].name
);
12406 /* distribute-list */
12407 if (filter
->dlist
[FILTER_IN
].name
)
12409 " Incoming update network filter list is %s%s\n",
12410 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12411 filter
->dlist
[FILTER_IN
].name
);
12412 if (filter
->dlist
[FILTER_OUT
].name
)
12414 " Outgoing update network filter list is %s%s\n",
12415 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12416 filter
->dlist
[FILTER_OUT
].name
);
12419 if (filter
->aslist
[FILTER_IN
].name
)
12421 " Incoming update AS path filter list is %s%s\n",
12422 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12423 filter
->aslist
[FILTER_IN
].name
);
12424 if (filter
->aslist
[FILTER_OUT
].name
)
12426 " Outgoing update AS path filter list is %s%s\n",
12427 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12428 filter
->aslist
[FILTER_OUT
].name
);
12431 if (filter
->map
[RMAP_IN
].name
)
12433 " Route map for incoming advertisements is %s%s\n",
12434 filter
->map
[RMAP_IN
].map
? "*" : "",
12435 filter
->map
[RMAP_IN
].name
);
12436 if (filter
->map
[RMAP_OUT
].name
)
12438 " Route map for outgoing advertisements is %s%s\n",
12439 filter
->map
[RMAP_OUT
].map
? "*" : "",
12440 filter
->map
[RMAP_OUT
].name
);
12442 /* ebgp-requires-policy (inbound) */
12443 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12444 && !bgp_inbound_policy_exists(p
, filter
))
12446 " Inbound updates discarded due to missing policy\n");
12448 /* ebgp-requires-policy (outbound) */
12449 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12450 && !bgp_outbound_policy_exists(p
, filter
))
12452 " Outbound updates discarded due to missing policy\n");
12454 /* unsuppress-map */
12455 if (filter
->usmap
.name
)
12457 " Route map for selective unsuppress is %s%s\n",
12458 filter
->usmap
.map
? "*" : "",
12459 filter
->usmap
.name
);
12461 /* advertise-map */
12462 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12464 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12465 filter
->advmap
.condition
? "EXIST"
12467 filter
->advmap
.cmap
? "*" : "",
12468 filter
->advmap
.cname
,
12469 filter
->advmap
.amap
? "*" : "",
12470 filter
->advmap
.aname
,
12471 filter
->advmap
.update_type
==
12472 UPDATE_TYPE_ADVERTISE
12476 /* Receive prefix count */
12477 vty_out(vty
, " %u accepted prefixes\n",
12478 p
->pcount
[afi
][safi
]);
12480 /* maximum-prefix-out */
12481 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12482 PEER_FLAG_MAX_PREFIX_OUT
))
12484 " Maximum allowed prefixes sent %u\n",
12485 p
->pmax_out
[afi
][safi
]);
12487 /* Maximum prefix */
12488 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12490 " Maximum prefixes allowed %u%s\n",
12491 p
->pmax
[afi
][safi
],
12492 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12493 PEER_FLAG_MAX_PREFIX_WARNING
)
12494 ? " (warning-only)"
12496 vty_out(vty
, " Threshold for warning message %d%%",
12497 p
->pmax_threshold
[afi
][safi
]);
12498 if (p
->pmax_restart
[afi
][safi
])
12499 vty_out(vty
, ", restart interval %d min",
12500 p
->pmax_restart
[afi
][safi
]);
12501 vty_out(vty
, "\n");
12504 vty_out(vty
, "\n");
12508 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12512 char buf1
[PREFIX2STR_BUFFER
];
12513 char timebuf
[BGP_UPTIME_LEN
];
12519 json_object
*json_neigh
= NULL
;
12521 uint32_t sync_tcp_mss
;
12526 json_neigh
= json_object_new_object();
12528 memset(dn_flag
, '\0', sizeof(dn_flag
));
12529 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12533 if (p
->conf_if
) /* Configured interface name. */
12534 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12536 else /* Configured IP address. */
12537 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12542 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12543 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12545 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12546 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12549 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12551 if (p
->change_local_as
)
12552 json_object_int_add(json_neigh
, "localAs",
12553 p
->change_local_as
);
12555 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12557 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12558 json_object_boolean_true_add(json_neigh
,
12559 "localAsNoPrepend");
12561 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12562 json_object_boolean_true_add(json_neigh
,
12563 "localAsReplaceAs");
12565 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12566 || (p
->as_type
== AS_INTERNAL
))
12567 vty_out(vty
, "remote AS %u, ", p
->as
);
12569 vty_out(vty
, "remote AS Unspecified, ");
12570 vty_out(vty
, "local AS %u%s%s, ",
12571 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12572 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12575 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12579 /* peer type internal or confed-internal */
12580 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12582 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12583 json_object_boolean_true_add(
12584 json_neigh
, "nbrConfedInternalLink");
12586 json_object_boolean_true_add(json_neigh
,
12587 "nbrInternalLink");
12589 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12590 vty_out(vty
, "confed-internal link\n");
12592 vty_out(vty
, "internal link\n");
12594 /* peer type external or confed-external */
12595 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12597 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12598 json_object_boolean_true_add(
12599 json_neigh
, "nbrConfedExternalLink");
12601 json_object_boolean_true_add(json_neigh
,
12602 "nbrExternalLink");
12604 if (bgp_confederation_peers_check(bgp
, p
->as
))
12605 vty_out(vty
, "confed-external link\n");
12607 vty_out(vty
, "external link\n");
12611 json_object_boolean_true_add(json_neigh
,
12612 "nbrUnspecifiedLink");
12614 vty_out(vty
, "unspecified link\n");
12619 json_object_string_add(json_neigh
, "localRole",
12620 bgp_get_name_by_role(p
->local_role
));
12621 json_object_string_add(json_neigh
, "remoteRole",
12622 bgp_get_name_by_role(p
->remote_role
));
12624 vty_out(vty
, " Local Role: %s\n",
12625 bgp_get_name_by_role(p
->local_role
));
12626 vty_out(vty
, " Remote Role: %s\n",
12627 bgp_get_name_by_role(p
->remote_role
));
12634 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12636 vty_out(vty
, " Description: %s\n", p
->desc
);
12642 json_object_string_add(json_neigh
, "hostname",
12646 json_object_string_add(json_neigh
, "domainname",
12649 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12650 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12653 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12660 json_object_string_add(json_neigh
, "peerGroup",
12664 struct prefix prefix
, *range
= NULL
;
12666 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12667 range
= peer_group_lookup_dynamic_neighbor_range(
12668 p
->group
, &prefix
);
12671 json_object_string_addf(
12673 "peerSubnetRangeGroup", "%pFX",
12679 " Member of peer-group %s for session parameters\n",
12683 struct prefix prefix
, *range
= NULL
;
12685 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12686 range
= peer_group_lookup_dynamic_neighbor_range(
12687 p
->group
, &prefix
);
12691 " Belongs to the subnet range group: %pFX\n",
12699 /* Administrative shutdown. */
12700 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12701 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12702 json_object_boolean_true_add(json_neigh
,
12706 json_object_int_add(json_neigh
, "bgpVersion", 4);
12707 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12709 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12712 /* Confederation */
12713 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12714 && bgp_confederation_peers_check(bgp
, p
->as
))
12715 json_object_boolean_true_add(json_neigh
,
12719 json_object_string_add(
12720 json_neigh
, "bgpState",
12721 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12723 if (peer_established(p
)) {
12726 uptime
= bgp_clock();
12727 uptime
-= p
->uptime
;
12728 epoch_tbuf
= time(NULL
) - uptime
;
12730 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12732 json_object_string_add(json_neigh
, "bgpTimerUpString",
12733 peer_uptime(p
->uptime
, timebuf
,
12736 json_object_int_add(json_neigh
,
12737 "bgpTimerUpEstablishedEpoch",
12741 else if (p
->status
== Active
) {
12742 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12743 json_object_string_add(json_neigh
, "bgpStateIs",
12745 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12746 json_object_string_add(json_neigh
, "bgpStateIs",
12754 uptime
= bgp_clock();
12755 uptime
-= p
->readtime
;
12756 gmtime_r(&uptime
, &tm
);
12758 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12759 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12760 + (tm
.tm_hour
* 3600000));
12762 uptime
= bgp_clock();
12763 uptime
-= p
->last_write
;
12764 gmtime_r(&uptime
, &tm
);
12766 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12767 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12768 + (tm
.tm_hour
* 3600000));
12770 uptime
= bgp_clock();
12771 uptime
-= p
->update_time
;
12772 gmtime_r(&uptime
, &tm
);
12774 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12775 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12776 + (tm
.tm_hour
* 3600000));
12778 /* Configured timer values. */
12779 json_object_int_add(json_neigh
,
12780 "bgpTimerConfiguredHoldTimeMsecs",
12781 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12782 ? p
->holdtime
* 1000
12783 : bgp
->default_holdtime
* 1000);
12784 json_object_int_add(json_neigh
,
12785 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12786 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12787 ? p
->keepalive
* 1000
12788 : bgp
->default_keepalive
* 1000);
12789 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12790 p
->v_holdtime
* 1000);
12791 json_object_int_add(json_neigh
,
12792 "bgpTimerKeepAliveIntervalMsecs",
12793 p
->v_keepalive
* 1000);
12794 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12795 json_object_int_add(json_neigh
,
12796 "bgpTimerDelayOpenTimeMsecs",
12797 p
->v_delayopen
* 1000);
12800 /* Configured and Synced tcp-mss value for peer */
12801 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12802 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12803 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12805 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12809 /* Extended Optional Parameters Length for BGP OPEN Message */
12810 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12811 json_object_boolean_true_add(
12812 json_neigh
, "extendedOptionalParametersLength");
12814 json_object_boolean_false_add(
12815 json_neigh
, "extendedOptionalParametersLength");
12817 /* Conditional advertisements */
12818 json_object_int_add(
12820 "bgpTimerConfiguredConditionalAdvertisementsSec",
12821 bgp
->condition_check_period
);
12822 if (thread_is_scheduled(bgp
->t_condition_check
))
12823 json_object_int_add(
12825 "bgpTimerUntilConditionalAdvertisementsSec",
12826 thread_timer_remain_second(
12827 bgp
->t_condition_check
));
12829 /* Administrative shutdown. */
12830 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12831 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12832 vty_out(vty
, " Administratively shut down\n");
12835 vty_out(vty
, " BGP version 4");
12836 vty_out(vty
, ", remote router ID %s",
12837 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12838 vty_out(vty
, ", local router ID %s\n",
12839 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12842 /* Confederation */
12843 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12844 && bgp_confederation_peers_check(bgp
, p
->as
))
12846 " Neighbor under common administration\n");
12849 vty_out(vty
, " BGP state = %s",
12850 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12852 if (peer_established(p
))
12853 vty_out(vty
, ", up for %8s",
12854 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12857 else if (p
->status
== Active
) {
12858 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12859 vty_out(vty
, " (passive)");
12860 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12861 vty_out(vty
, " (NSF passive)");
12863 vty_out(vty
, "\n");
12866 vty_out(vty
, " Last read %s",
12867 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12869 vty_out(vty
, ", Last write %s\n",
12870 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12873 /* Configured timer values. */
12875 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12876 p
->v_holdtime
, p
->v_keepalive
);
12877 vty_out(vty
, " Configured hold time is %d seconds",
12878 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12880 : bgp
->default_holdtime
);
12881 vty_out(vty
, ", keepalive interval is %d seconds\n",
12882 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12884 : bgp
->default_keepalive
);
12885 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12887 " Configured DelayOpenTime is %d seconds\n",
12890 /* Configured and synced tcp-mss value for peer */
12891 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12892 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12893 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12894 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12897 /* Extended Optional Parameters Length for BGP OPEN Message */
12898 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12900 " Extended Optional Parameters Length is enabled\n");
12902 /* Conditional advertisements */
12904 " Configured conditional advertisements interval is %d seconds\n",
12905 bgp
->condition_check_period
);
12906 if (thread_is_scheduled(bgp
->t_condition_check
))
12908 " Time until conditional advertisements begin is %lu seconds\n",
12909 thread_timer_remain_second(
12910 bgp
->t_condition_check
));
12913 if (peer_established(p
) &&
12914 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12916 json_object
*json_cap
= NULL
;
12918 json_cap
= json_object_new_object();
12921 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12922 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12923 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12924 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12925 json_object_string_add(
12926 json_cap
, "4byteAs",
12927 "advertisedAndReceived");
12928 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12929 json_object_string_add(json_cap
,
12932 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12933 json_object_string_add(json_cap
,
12938 /* Extended Message Support */
12939 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12940 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12941 json_object_string_add(json_cap
,
12943 "advertisedAndReceived");
12944 else if (CHECK_FLAG(p
->cap
,
12945 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12946 json_object_string_add(json_cap
,
12949 else if (CHECK_FLAG(p
->cap
,
12950 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12951 json_object_string_add(json_cap
,
12956 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12957 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12958 json_object
*json_add
= NULL
;
12959 const char *print_store
;
12961 json_add
= json_object_new_object();
12963 FOREACH_AFI_SAFI (afi
, safi
) {
12964 json_object
*json_sub
= NULL
;
12965 json_sub
= json_object_new_object();
12966 print_store
= get_afi_safi_str(
12970 p
->af_cap
[afi
][safi
],
12971 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12973 p
->af_cap
[afi
][safi
],
12974 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12978 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12982 PEER_CAP_ADDPATH_AF_TX_RCV
))
12983 json_object_boolean_true_add(
12985 "txAdvertisedAndReceived");
12990 PEER_CAP_ADDPATH_AF_TX_ADV
))
12991 json_object_boolean_true_add(
12998 PEER_CAP_ADDPATH_AF_TX_RCV
))
12999 json_object_boolean_true_add(
13005 p
->af_cap
[afi
][safi
],
13006 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13008 p
->af_cap
[afi
][safi
],
13009 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13013 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13017 PEER_CAP_ADDPATH_AF_RX_RCV
))
13018 json_object_boolean_true_add(
13020 "rxAdvertisedAndReceived");
13025 PEER_CAP_ADDPATH_AF_RX_ADV
))
13026 json_object_boolean_true_add(
13033 PEER_CAP_ADDPATH_AF_RX_RCV
))
13034 json_object_boolean_true_add(
13040 p
->af_cap
[afi
][safi
],
13041 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13043 p
->af_cap
[afi
][safi
],
13044 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13046 p
->af_cap
[afi
][safi
],
13047 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13049 p
->af_cap
[afi
][safi
],
13050 PEER_CAP_ADDPATH_AF_RX_RCV
))
13051 json_object_object_add(
13052 json_add
, print_store
,
13055 json_object_free(json_sub
);
13058 json_object_object_add(json_cap
, "addPath",
13063 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13064 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13065 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13066 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13067 json_object_string_add(
13068 json_cap
, "dynamic",
13069 "advertisedAndReceived");
13070 else if (CHECK_FLAG(p
->cap
,
13071 PEER_CAP_DYNAMIC_ADV
))
13072 json_object_string_add(json_cap
,
13075 else if (CHECK_FLAG(p
->cap
,
13076 PEER_CAP_DYNAMIC_RCV
))
13077 json_object_string_add(json_cap
,
13083 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13084 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13085 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13086 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13087 json_object_string_add(
13089 "advertisedAndReceived");
13090 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13091 json_object_string_add(json_cap
, "role",
13093 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13094 json_object_string_add(json_cap
, "role",
13098 /* Extended nexthop */
13099 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13100 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13101 json_object
*json_nxt
= NULL
;
13102 const char *print_store
;
13105 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13106 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13107 json_object_string_add(
13108 json_cap
, "extendedNexthop",
13109 "advertisedAndReceived");
13110 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13111 json_object_string_add(
13112 json_cap
, "extendedNexthop",
13114 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13115 json_object_string_add(
13116 json_cap
, "extendedNexthop",
13119 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13120 json_nxt
= json_object_new_object();
13122 for (safi
= SAFI_UNICAST
;
13123 safi
< SAFI_MAX
; safi
++) {
13127 PEER_CAP_ENHE_AF_RCV
)) {
13133 json_object_string_add(
13136 "recieved"); /* misspelled for compatibility */
13139 json_object_object_add(
13141 "extendedNexthopFamililesByPeer",
13146 /* Long-lived Graceful Restart */
13147 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13148 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13149 json_object
*json_llgr
= NULL
;
13150 const char *afi_safi_str
;
13152 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13153 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13154 json_object_string_add(
13156 "longLivedGracefulRestart",
13157 "advertisedAndReceived");
13158 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13159 json_object_string_add(
13161 "longLivedGracefulRestart",
13163 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13164 json_object_string_add(
13166 "longLivedGracefulRestart",
13169 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13170 json_llgr
= json_object_new_object();
13172 FOREACH_AFI_SAFI (afi
, safi
) {
13176 PEER_CAP_ENHE_AF_RCV
)) {
13182 json_object_string_add(
13188 json_object_object_add(
13190 "longLivedGracefulRestartByPeer",
13195 /* Route Refresh */
13196 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13197 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13198 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13199 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13200 (CHECK_FLAG(p
->cap
,
13201 PEER_CAP_REFRESH_NEW_RCV
) ||
13203 PEER_CAP_REFRESH_OLD_RCV
))) {
13206 PEER_CAP_REFRESH_OLD_RCV
) &&
13209 PEER_CAP_REFRESH_NEW_RCV
))
13210 json_object_string_add(
13213 "advertisedAndReceivedOldNew");
13217 PEER_CAP_REFRESH_OLD_RCV
))
13218 json_object_string_add(
13221 "advertisedAndReceivedOld");
13223 json_object_string_add(
13226 "advertisedAndReceivedNew");
13228 } else if (CHECK_FLAG(p
->cap
,
13229 PEER_CAP_REFRESH_ADV
))
13230 json_object_string_add(json_cap
,
13233 else if (CHECK_FLAG(p
->cap
,
13234 PEER_CAP_REFRESH_NEW_RCV
) ||
13236 PEER_CAP_REFRESH_OLD_RCV
))
13237 json_object_string_add(json_cap
,
13242 /* Enhanced Route Refresh */
13243 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13244 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13245 if (CHECK_FLAG(p
->cap
,
13246 PEER_CAP_ENHANCED_RR_ADV
) &&
13248 PEER_CAP_ENHANCED_RR_RCV
))
13249 json_object_string_add(
13251 "enhancedRouteRefresh",
13252 "advertisedAndReceived");
13253 else if (CHECK_FLAG(p
->cap
,
13254 PEER_CAP_ENHANCED_RR_ADV
))
13255 json_object_string_add(
13257 "enhancedRouteRefresh",
13259 else if (CHECK_FLAG(p
->cap
,
13260 PEER_CAP_ENHANCED_RR_RCV
))
13261 json_object_string_add(
13263 "enhancedRouteRefresh",
13267 /* Multiprotocol Extensions */
13268 json_object
*json_multi
= NULL
;
13270 json_multi
= json_object_new_object();
13272 FOREACH_AFI_SAFI (afi
, safi
) {
13273 if (p
->afc_adv
[afi
][safi
] ||
13274 p
->afc_recv
[afi
][safi
]) {
13275 json_object
*json_exten
= NULL
;
13276 json_exten
= json_object_new_object();
13278 if (p
->afc_adv
[afi
][safi
] &&
13279 p
->afc_recv
[afi
][safi
])
13280 json_object_boolean_true_add(
13282 "advertisedAndReceived");
13283 else if (p
->afc_adv
[afi
][safi
])
13284 json_object_boolean_true_add(
13287 else if (p
->afc_recv
[afi
][safi
])
13288 json_object_boolean_true_add(
13289 json_exten
, "received");
13291 json_object_object_add(
13293 get_afi_safi_str(afi
, safi
,
13298 json_object_object_add(json_cap
,
13299 "multiprotocolExtensions",
13302 /* Hostname capabilities */
13303 json_object
*json_hname
= NULL
;
13305 json_hname
= json_object_new_object();
13307 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13308 json_object_string_add(
13309 json_hname
, "advHostName",
13310 bgp
->peer_self
->hostname
13311 ? bgp
->peer_self
->hostname
13313 json_object_string_add(
13314 json_hname
, "advDomainName",
13315 bgp
->peer_self
->domainname
13316 ? bgp
->peer_self
->domainname
13321 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13322 json_object_string_add(
13323 json_hname
, "rcvHostName",
13324 p
->hostname
? p
->hostname
: "n/a");
13325 json_object_string_add(
13326 json_hname
, "rcvDomainName",
13327 p
->domainname
? p
->domainname
: "n/a");
13330 json_object_object_add(json_cap
, "hostName",
13333 /* Graceful Restart */
13334 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13335 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13336 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13337 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13338 json_object_string_add(
13339 json_cap
, "gracefulRestart",
13340 "advertisedAndReceived");
13341 else if (CHECK_FLAG(p
->cap
,
13342 PEER_CAP_RESTART_ADV
))
13343 json_object_string_add(
13345 "gracefulRestartCapability",
13347 else if (CHECK_FLAG(p
->cap
,
13348 PEER_CAP_RESTART_RCV
))
13349 json_object_string_add(
13351 "gracefulRestartCapability",
13354 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13355 int restart_af_count
= 0;
13356 json_object
*json_restart
= NULL
;
13357 json_restart
= json_object_new_object();
13359 json_object_int_add(
13361 "gracefulRestartRemoteTimerMsecs",
13362 p
->v_gr_restart
* 1000);
13364 FOREACH_AFI_SAFI (afi
, safi
) {
13368 PEER_CAP_RESTART_AF_RCV
)) {
13369 json_object
*json_sub
=
13372 json_object_new_object();
13378 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13379 json_object_boolean_true_add(
13382 restart_af_count
++;
13383 json_object_object_add(
13392 if (!restart_af_count
) {
13393 json_object_string_add(
13395 "addressFamiliesByPeer",
13397 json_object_free(json_restart
);
13399 json_object_object_add(
13401 "addressFamiliesByPeer",
13405 json_object_object_add(
13406 json_neigh
, "neighborCapabilities", json_cap
);
13408 vty_out(vty
, " Neighbor capabilities:\n");
13411 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13412 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13413 vty_out(vty
, " 4 Byte AS:");
13414 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13415 vty_out(vty
, " advertised");
13416 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13417 vty_out(vty
, " %sreceived",
13422 vty_out(vty
, "\n");
13425 /* Extended Message Support */
13426 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13427 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13428 vty_out(vty
, " Extended Message:");
13429 if (CHECK_FLAG(p
->cap
,
13430 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13431 vty_out(vty
, " advertised");
13432 if (CHECK_FLAG(p
->cap
,
13433 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13434 vty_out(vty
, " %sreceived",
13437 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13440 vty_out(vty
, "\n");
13444 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13445 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13446 vty_out(vty
, " AddPath:\n");
13448 FOREACH_AFI_SAFI (afi
, safi
) {
13450 p
->af_cap
[afi
][safi
],
13451 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13453 p
->af_cap
[afi
][safi
],
13454 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13455 vty_out(vty
, " %s: TX ",
13463 PEER_CAP_ADDPATH_AF_TX_ADV
))
13470 PEER_CAP_ADDPATH_AF_TX_RCV
))
13477 PEER_CAP_ADDPATH_AF_TX_ADV
)
13481 vty_out(vty
, "\n");
13485 p
->af_cap
[afi
][safi
],
13486 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13488 p
->af_cap
[afi
][safi
],
13489 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13490 vty_out(vty
, " %s: RX ",
13498 PEER_CAP_ADDPATH_AF_RX_ADV
))
13505 PEER_CAP_ADDPATH_AF_RX_RCV
))
13512 PEER_CAP_ADDPATH_AF_RX_ADV
)
13516 vty_out(vty
, "\n");
13522 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13523 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13524 vty_out(vty
, " Dynamic:");
13525 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13526 vty_out(vty
, " advertised");
13527 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13528 vty_out(vty
, " %sreceived",
13530 PEER_CAP_DYNAMIC_ADV
)
13533 vty_out(vty
, "\n");
13537 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13538 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13539 vty_out(vty
, " Role:");
13540 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13541 vty_out(vty
, " advertised");
13542 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13543 vty_out(vty
, " %sreceived",
13548 vty_out(vty
, "\n");
13551 /* Extended nexthop */
13552 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13553 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13554 vty_out(vty
, " Extended nexthop:");
13555 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13556 vty_out(vty
, " advertised");
13557 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13558 vty_out(vty
, " %sreceived",
13563 vty_out(vty
, "\n");
13565 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13567 " Address families by peer:\n ");
13568 for (safi
= SAFI_UNICAST
;
13569 safi
< SAFI_MAX
; safi
++)
13573 PEER_CAP_ENHE_AF_RCV
))
13583 /* Long-lived Graceful Restart */
13584 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13585 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13587 " Long-lived Graceful Restart:");
13588 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13589 vty_out(vty
, " advertised");
13590 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13591 vty_out(vty
, " %sreceived",
13596 vty_out(vty
, "\n");
13598 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13600 " Address families by peer:\n");
13601 FOREACH_AFI_SAFI (afi
, safi
)
13605 PEER_CAP_LLGR_AF_RCV
))
13615 /* Route Refresh */
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13617 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13618 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13619 vty_out(vty
, " Route refresh:");
13620 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13621 vty_out(vty
, " advertised");
13622 if (CHECK_FLAG(p
->cap
,
13623 PEER_CAP_REFRESH_NEW_RCV
) ||
13625 PEER_CAP_REFRESH_OLD_RCV
))
13626 vty_out(vty
, " %sreceived(%s)",
13628 PEER_CAP_REFRESH_ADV
)
13633 PEER_CAP_REFRESH_OLD_RCV
) &&
13636 PEER_CAP_REFRESH_NEW_RCV
))
13640 PEER_CAP_REFRESH_OLD_RCV
)
13644 vty_out(vty
, "\n");
13647 /* Enhanced Route Refresh */
13648 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13649 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13650 vty_out(vty
, " Enhanced Route Refresh:");
13651 if (CHECK_FLAG(p
->cap
,
13652 PEER_CAP_ENHANCED_RR_ADV
))
13653 vty_out(vty
, " advertised");
13654 if (CHECK_FLAG(p
->cap
,
13655 PEER_CAP_ENHANCED_RR_RCV
))
13656 vty_out(vty
, " %sreceived",
13658 PEER_CAP_REFRESH_ADV
)
13661 vty_out(vty
, "\n");
13664 /* Multiprotocol Extensions */
13665 FOREACH_AFI_SAFI (afi
, safi
)
13666 if (p
->afc_adv
[afi
][safi
] ||
13667 p
->afc_recv
[afi
][safi
]) {
13668 vty_out(vty
, " Address Family %s:",
13669 get_afi_safi_str(afi
, safi
,
13671 if (p
->afc_adv
[afi
][safi
])
13672 vty_out(vty
, " advertised");
13673 if (p
->afc_recv
[afi
][safi
])
13674 vty_out(vty
, " %sreceived",
13675 p
->afc_adv
[afi
][safi
]
13678 vty_out(vty
, "\n");
13681 /* Hostname capability */
13682 vty_out(vty
, " Hostname Capability:");
13684 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13686 " advertised (name: %s,domain name: %s)",
13687 bgp
->peer_self
->hostname
13688 ? bgp
->peer_self
->hostname
13690 bgp
->peer_self
->domainname
13691 ? bgp
->peer_self
->domainname
13694 vty_out(vty
, " not advertised");
13697 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13699 " received (name: %s,domain name: %s)",
13700 p
->hostname
? p
->hostname
: "n/a",
13701 p
->domainname
? p
->domainname
: "n/a");
13703 vty_out(vty
, " not received");
13706 vty_out(vty
, "\n");
13708 /* Graceful Restart */
13709 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13710 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13712 " Graceful Restart Capability:");
13713 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13714 vty_out(vty
, " advertised");
13715 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13716 vty_out(vty
, " %sreceived",
13718 PEER_CAP_RESTART_ADV
)
13721 vty_out(vty
, "\n");
13723 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13724 int restart_af_count
= 0;
13727 " Remote Restart timer is %d seconds\n",
13730 " Address families by peer:\n ");
13732 FOREACH_AFI_SAFI (afi
, safi
)
13736 PEER_CAP_RESTART_AF_RCV
)) {
13737 vty_out(vty
, "%s%s(%s)",
13749 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13751 : "not preserved");
13752 restart_af_count
++;
13754 if (!restart_af_count
)
13755 vty_out(vty
, "none");
13756 vty_out(vty
, "\n");
13758 } /* Graceful Restart */
13762 /* graceful restart information */
13763 json_object
*json_grace
= NULL
;
13764 json_object
*json_grace_send
= NULL
;
13765 json_object
*json_grace_recv
= NULL
;
13766 int eor_send_af_count
= 0;
13767 int eor_receive_af_count
= 0;
13770 json_grace
= json_object_new_object();
13771 json_grace_send
= json_object_new_object();
13772 json_grace_recv
= json_object_new_object();
13774 if ((peer_established(p
)) &&
13775 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13776 FOREACH_AFI_SAFI (afi
, safi
) {
13777 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13778 PEER_STATUS_EOR_SEND
)) {
13779 json_object_boolean_true_add(
13781 get_afi_safi_str(afi
, safi
,
13783 eor_send_af_count
++;
13786 FOREACH_AFI_SAFI (afi
, safi
) {
13787 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13788 PEER_STATUS_EOR_RECEIVED
)) {
13789 json_object_boolean_true_add(
13791 get_afi_safi_str(afi
, safi
,
13793 eor_receive_af_count
++;
13797 json_object_object_add(json_grace
, "endOfRibSend",
13799 json_object_object_add(json_grace
, "endOfRibRecv",
13803 if (p
->t_gr_restart
)
13804 json_object_int_add(
13805 json_grace
, "gracefulRestartTimerMsecs",
13806 thread_timer_remain_second(p
->t_gr_restart
) *
13810 json_object_int_add(
13811 json_grace
, "gracefulStalepathTimerMsecs",
13812 thread_timer_remain_second(p
->t_gr_stale
) *
13814 /* more gr info in new format */
13815 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13816 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13819 vty_out(vty
, " Graceful restart information:\n");
13820 if ((peer_established(p
)) &&
13821 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13823 vty_out(vty
, " End-of-RIB send: ");
13824 FOREACH_AFI_SAFI (afi
, safi
) {
13825 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13826 PEER_STATUS_EOR_SEND
)) {
13827 vty_out(vty
, "%s%s",
13828 eor_send_af_count
? ", " : "",
13829 get_afi_safi_str(afi
, safi
,
13831 eor_send_af_count
++;
13834 vty_out(vty
, "\n");
13835 vty_out(vty
, " End-of-RIB received: ");
13836 FOREACH_AFI_SAFI (afi
, safi
) {
13837 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13838 PEER_STATUS_EOR_RECEIVED
)) {
13839 vty_out(vty
, "%s%s",
13840 eor_receive_af_count
? ", "
13842 get_afi_safi_str(afi
, safi
,
13844 eor_receive_af_count
++;
13847 vty_out(vty
, "\n");
13850 if (p
->t_gr_restart
)
13852 " The remaining time of restart timer is %ld\n",
13853 thread_timer_remain_second(p
->t_gr_restart
));
13857 " The remaining time of stalepath timer is %ld\n",
13858 thread_timer_remain_second(p
->t_gr_stale
));
13860 /* more gr info in new format */
13861 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13865 json_object
*json_stat
= NULL
;
13866 json_stat
= json_object_new_object();
13867 /* Packet counts. */
13869 atomic_size_t outq_count
, inq_count
;
13870 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13871 memory_order_relaxed
);
13872 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13873 memory_order_relaxed
);
13875 json_object_int_add(json_stat
, "depthInq",
13876 (unsigned long)inq_count
);
13877 json_object_int_add(json_stat
, "depthOutq",
13878 (unsigned long)outq_count
);
13879 json_object_int_add(json_stat
, "opensSent",
13880 atomic_load_explicit(&p
->open_out
,
13881 memory_order_relaxed
));
13882 json_object_int_add(json_stat
, "opensRecv",
13883 atomic_load_explicit(&p
->open_in
,
13884 memory_order_relaxed
));
13885 json_object_int_add(json_stat
, "notificationsSent",
13886 atomic_load_explicit(&p
->notify_out
,
13887 memory_order_relaxed
));
13888 json_object_int_add(json_stat
, "notificationsRecv",
13889 atomic_load_explicit(&p
->notify_in
,
13890 memory_order_relaxed
));
13891 json_object_int_add(json_stat
, "updatesSent",
13892 atomic_load_explicit(&p
->update_out
,
13893 memory_order_relaxed
));
13894 json_object_int_add(json_stat
, "updatesRecv",
13895 atomic_load_explicit(&p
->update_in
,
13896 memory_order_relaxed
));
13897 json_object_int_add(json_stat
, "keepalivesSent",
13898 atomic_load_explicit(&p
->keepalive_out
,
13899 memory_order_relaxed
));
13900 json_object_int_add(json_stat
, "keepalivesRecv",
13901 atomic_load_explicit(&p
->keepalive_in
,
13902 memory_order_relaxed
));
13903 json_object_int_add(json_stat
, "routeRefreshSent",
13904 atomic_load_explicit(&p
->refresh_out
,
13905 memory_order_relaxed
));
13906 json_object_int_add(json_stat
, "routeRefreshRecv",
13907 atomic_load_explicit(&p
->refresh_in
,
13908 memory_order_relaxed
));
13909 json_object_int_add(json_stat
, "capabilitySent",
13910 atomic_load_explicit(&p
->dynamic_cap_out
,
13911 memory_order_relaxed
));
13912 json_object_int_add(json_stat
, "capabilityRecv",
13913 atomic_load_explicit(&p
->dynamic_cap_in
,
13914 memory_order_relaxed
));
13915 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13916 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13917 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13919 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13920 notify_out
, notify_in
, update_out
, update_in
,
13921 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13922 dynamic_cap_out
, dynamic_cap_in
;
13923 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13924 memory_order_relaxed
);
13925 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13926 memory_order_relaxed
);
13927 open_out
= atomic_load_explicit(&p
->open_out
,
13928 memory_order_relaxed
);
13930 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13931 notify_out
= atomic_load_explicit(&p
->notify_out
,
13932 memory_order_relaxed
);
13933 notify_in
= atomic_load_explicit(&p
->notify_in
,
13934 memory_order_relaxed
);
13935 update_out
= atomic_load_explicit(&p
->update_out
,
13936 memory_order_relaxed
);
13937 update_in
= atomic_load_explicit(&p
->update_in
,
13938 memory_order_relaxed
);
13939 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13940 memory_order_relaxed
);
13941 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13942 memory_order_relaxed
);
13943 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13944 memory_order_relaxed
);
13945 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13946 memory_order_relaxed
);
13947 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13948 memory_order_relaxed
);
13949 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13950 memory_order_relaxed
);
13952 /* Packet counts. */
13953 vty_out(vty
, " Message statistics:\n");
13954 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13955 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13956 vty_out(vty
, " Sent Rcvd\n");
13957 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13959 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13961 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13963 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13965 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13967 vty_out(vty
, " Capability: %10zu %10zu\n",
13968 dynamic_cap_out
, dynamic_cap_in
);
13969 vty_out(vty
, " Total: %10u %10u\n",
13970 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13974 /* advertisement-interval */
13975 json_object_int_add(json_neigh
,
13976 "minBtwnAdvertisementRunsTimerMsecs",
13977 p
->v_routeadv
* 1000);
13979 /* Update-source. */
13980 if (p
->update_if
|| p
->update_source
) {
13982 json_object_string_add(json_neigh
,
13985 else if (p
->update_source
)
13986 json_object_string_addf(json_neigh
,
13987 "updateSource", "%pSU",
13991 /* advertisement-interval */
13993 " Minimum time between advertisement runs is %d seconds\n",
13996 /* Update-source. */
13997 if (p
->update_if
|| p
->update_source
) {
13998 vty_out(vty
, " Update source is ");
14000 vty_out(vty
, "%s", p
->update_if
);
14001 else if (p
->update_source
)
14002 vty_out(vty
, "%pSU", p
->update_source
);
14003 vty_out(vty
, "\n");
14006 vty_out(vty
, "\n");
14009 /* Address Family Information */
14010 json_object
*json_hold
= NULL
;
14013 json_hold
= json_object_new_object();
14015 FOREACH_AFI_SAFI (afi
, safi
)
14016 if (p
->afc
[afi
][safi
])
14017 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14021 json_object_object_add(json_neigh
, "addressFamilyInfo",
14023 json_object_int_add(json_neigh
, "connectionsEstablished",
14025 json_object_int_add(json_neigh
, "connectionsDropped",
14028 vty_out(vty
, " Connections established %d; dropped %d\n",
14029 p
->established
, p
->dropped
);
14031 if (!p
->last_reset
) {
14033 json_object_string_add(json_neigh
, "lastReset",
14036 vty_out(vty
, " Last reset never\n");
14042 uptime
= bgp_clock();
14043 uptime
-= p
->resettime
;
14044 gmtime_r(&uptime
, &tm
);
14046 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14048 + (tm
.tm_min
* 60000)
14049 + (tm
.tm_hour
* 3600000));
14050 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14052 vty_out(vty
, " Last reset %s, ",
14053 peer_uptime(p
->resettime
, timebuf
,
14054 BGP_UPTIME_LEN
, 0, NULL
));
14056 bgp_show_peer_reset(vty
, p
, NULL
, false);
14057 if (p
->last_reset_cause_size
) {
14058 msg
= p
->last_reset_cause
;
14060 " Message received that caused BGP to send a NOTIFICATION:\n ");
14061 for (i
= 1; i
<= p
->last_reset_cause_size
;
14063 vty_out(vty
, "%02X", *msg
++);
14065 if (i
!= p
->last_reset_cause_size
) {
14067 vty_out(vty
, "\n ");
14068 } else if (i
% 4 == 0) {
14073 vty_out(vty
, "\n");
14078 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14080 json_object_boolean_true_add(json_neigh
,
14081 "prefixesConfigExceedMax");
14084 " Peer had exceeded the max. no. of prefixes configured.\n");
14086 if (p
->t_pmax_restart
) {
14088 json_object_boolean_true_add(
14089 json_neigh
, "reducePrefixNumFrom");
14090 json_object_int_add(json_neigh
,
14091 "restartInTimerMsec",
14092 thread_timer_remain_second(
14097 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14098 p
->host
, thread_timer_remain_second(
14099 p
->t_pmax_restart
));
14102 json_object_boolean_true_add(
14104 "reducePrefixNumAndClearIpBgp");
14107 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14112 /* EBGP Multihop and GTSM */
14113 if (p
->sort
!= BGP_PEER_IBGP
) {
14115 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14116 json_object_int_add(json_neigh
,
14117 "externalBgpNbrMaxHopsAway",
14120 json_object_int_add(json_neigh
,
14121 "externalBgpNbrMaxHopsAway",
14124 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14126 " External BGP neighbor may be up to %d hops away.\n",
14130 " External BGP neighbor may be up to %d hops away.\n",
14135 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14136 json_object_int_add(json_neigh
,
14137 "internalBgpNbrMaxHopsAway",
14140 json_object_int_add(json_neigh
,
14141 "internalBgpNbrMaxHopsAway",
14144 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14146 " Internal BGP neighbor may be up to %d hops away.\n",
14150 " Internal BGP neighbor may be up to %d hops away.\n",
14155 /* Local address. */
14158 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14160 json_object_int_add(json_neigh
, "portLocal",
14161 ntohs(p
->su_local
->sin
.sin_port
));
14163 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14164 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14167 json_object_string_add(json_neigh
, "hostLocal",
14169 json_object_int_add(json_neigh
, "portLocal", -1);
14173 /* Remote address. */
14174 if (p
->su_remote
) {
14176 json_object_string_addf(json_neigh
, "hostForeign",
14177 "%pSU", p
->su_remote
);
14178 json_object_int_add(json_neigh
, "portForeign",
14179 ntohs(p
->su_remote
->sin
.sin_port
));
14181 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14183 ntohs(p
->su_remote
->sin
.sin_port
));
14186 json_object_string_add(json_neigh
, "hostForeign",
14188 json_object_int_add(json_neigh
, "portForeign", -1);
14192 /* Nexthop display. */
14195 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14197 json_object_string_addf(json_neigh
, "nexthopGlobal",
14198 "%pI6", &p
->nexthop
.v6_global
);
14199 json_object_string_addf(json_neigh
, "nexthopLocal",
14200 "%pI6", &p
->nexthop
.v6_local
);
14201 if (p
->shared_network
)
14202 json_object_string_add(json_neigh
,
14206 json_object_string_add(json_neigh
,
14208 "nonSharedNetwork");
14210 vty_out(vty
, "Nexthop: %s\n",
14211 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14213 vty_out(vty
, "Nexthop global: %s\n",
14214 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14216 vty_out(vty
, "Nexthop local: %s\n",
14217 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14219 vty_out(vty
, "BGP connection: %s\n",
14220 p
->shared_network
? "shared network"
14221 : "non shared network");
14225 /* Timer information. */
14227 json_object_int_add(json_neigh
, "connectRetryTimer",
14229 if (peer_established(p
) && p
->rtt
)
14230 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14233 json_object_int_add(
14234 json_neigh
, "nextStartTimerDueInMsecs",
14235 thread_timer_remain_second(p
->t_start
) * 1000);
14237 json_object_int_add(
14238 json_neigh
, "nextConnectTimerDueInMsecs",
14239 thread_timer_remain_second(p
->t_connect
)
14241 if (p
->t_routeadv
) {
14242 json_object_int_add(json_neigh
, "mraiInterval",
14244 json_object_int_add(
14245 json_neigh
, "mraiTimerExpireInMsecs",
14246 thread_timer_remain_second(p
->t_routeadv
)
14250 json_object_int_add(json_neigh
, "authenticationEnabled",
14254 json_object_string_add(json_neigh
, "readThread", "on");
14256 json_object_string_add(json_neigh
, "readThread", "off");
14258 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14259 json_object_string_add(json_neigh
, "writeThread", "on");
14261 json_object_string_add(json_neigh
, "writeThread",
14264 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14266 if (peer_established(p
) && p
->rtt
)
14267 vty_out(vty
, "Estimated round trip time: %d ms\n",
14270 vty_out(vty
, "Next start timer due in %ld seconds\n",
14271 thread_timer_remain_second(p
->t_start
));
14273 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14274 thread_timer_remain_second(p
->t_connect
));
14277 "MRAI (interval %u) timer expires in %ld seconds\n",
14279 thread_timer_remain_second(p
->t_routeadv
));
14281 vty_out(vty
, "Peer Authentication Enabled\n");
14283 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14284 p
->t_read
? "on" : "off",
14285 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14290 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14291 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14292 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14295 vty_out(vty
, "\n");
14297 /* BFD information. */
14299 bgp_bfd_show_info(vty
, p
, json_neigh
);
14302 if (p
->conf_if
) /* Configured interface name. */
14303 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14304 else /* Configured IP address. */
14305 json_object_object_add(json
, p
->host
, json_neigh
);
14309 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14310 enum show_type type
,
14311 union sockunion
*su
,
14312 const char *conf_if
, afi_t afi
,
14315 struct listnode
*node
, *nnode
;
14318 safi_t safi
= SAFI_UNICAST
;
14319 json_object
*json
= NULL
;
14320 json_object
*json_neighbor
= NULL
;
14323 json
= json_object_new_object();
14324 json_neighbor
= json_object_new_object();
14327 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14329 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14332 if ((peer
->afc
[afi
][safi
]) == 0)
14335 if (type
== show_all
) {
14336 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14340 json_object_object_add(json
, peer
->host
,
14342 json_neighbor
= NULL
;
14345 } else if (type
== show_peer
) {
14348 && !strcmp(peer
->conf_if
, conf_if
))
14350 && !strcmp(peer
->hostname
, conf_if
))) {
14352 bgp_show_peer_gr_status(vty
, peer
,
14357 if (sockunion_same(&peer
->su
, su
)) {
14359 bgp_show_peer_gr_status(vty
, peer
,
14364 if (use_json
&& find
)
14365 json_object_object_add(json
, peer
->host
,
14370 json_neighbor
= NULL
;
14375 if (type
== show_peer
&& !find
) {
14377 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14379 vty_out(vty
, "%% No such neighbor\n");
14383 json_object_free(json_neighbor
);
14384 vty_json(vty
, json
);
14386 vty_out(vty
, "\n");
14389 return CMD_SUCCESS
;
14392 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14393 enum show_type type
, union sockunion
*su
,
14394 const char *conf_if
, bool use_json
,
14397 struct listnode
*node
, *nnode
;
14400 bool nbr_output
= false;
14401 afi_t afi
= AFI_MAX
;
14402 safi_t safi
= SAFI_MAX
;
14404 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14406 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14410 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14411 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14416 bgp_show_peer(vty
, peer
, use_json
, json
);
14422 && !strcmp(peer
->conf_if
, conf_if
))
14424 && !strcmp(peer
->hostname
, conf_if
))) {
14426 bgp_show_peer(vty
, peer
, use_json
,
14430 if (sockunion_same(&peer
->su
, su
)) {
14432 bgp_show_peer(vty
, peer
, use_json
,
14437 case show_ipv4_peer
:
14438 case show_ipv6_peer
:
14439 FOREACH_SAFI (safi
) {
14440 if (peer
->afc
[afi
][safi
]) {
14443 && !strcmp(peer
->conf_if
, conf_if
))
14445 && !strcmp(peer
->hostname
, conf_if
))) {
14447 bgp_show_peer(vty
, peer
, use_json
,
14452 if (sockunion_same(&peer
->su
, su
)) {
14454 bgp_show_peer(vty
, peer
, use_json
,
14462 case show_ipv4_all
:
14463 case show_ipv6_all
:
14464 FOREACH_SAFI (safi
) {
14465 if (peer
->afc
[afi
][safi
]) {
14466 bgp_show_peer(vty
, peer
, use_json
, json
);
14475 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14476 type
== show_ipv6_peer
) && !find
) {
14478 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14480 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14483 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14484 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14485 vty_out(vty
, "%% No BGP neighbors found\n");
14488 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14489 json
, JSON_C_TO_STRING_PRETTY
));
14491 vty_out(vty
, "\n");
14494 return CMD_SUCCESS
;
14497 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14498 enum show_type type
,
14499 const char *ip_str
,
14500 afi_t afi
, bool use_json
)
14505 union sockunion su
;
14507 bgp
= bgp_get_default();
14513 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14517 ret
= str2sockunion(ip_str
, &su
);
14519 bgp_show_neighbor_graceful_restart(
14520 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14522 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14523 NULL
, afi
, use_json
);
14525 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14529 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14530 enum show_type type
,
14531 const char *ip_str
,
14534 struct listnode
*node
, *nnode
;
14536 union sockunion su
;
14537 json_object
*json
= NULL
;
14538 int ret
, is_first
= 1;
14539 bool nbr_output
= false;
14542 vty_out(vty
, "{\n");
14544 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14547 if (!(json
= json_object_new_object())) {
14549 EC_BGP_JSON_MEM_ERROR
,
14550 "Unable to allocate memory for JSON object");
14552 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14556 json_object_int_add(json
, "vrfId",
14557 (bgp
->vrf_id
== VRF_UNKNOWN
)
14559 : (int64_t)bgp
->vrf_id
);
14560 json_object_string_add(
14562 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14567 vty_out(vty
, ",\n");
14571 vty_out(vty
, "\"%s\":",
14572 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14576 vty_out(vty
, "\nInstance %s:\n",
14577 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14582 if (type
== show_peer
|| type
== show_ipv4_peer
||
14583 type
== show_ipv6_peer
) {
14584 ret
= str2sockunion(ip_str
, &su
);
14586 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14589 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14592 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14595 json_object_free(json
);
14600 vty_out(vty
, "}\n");
14601 else if (!nbr_output
)
14602 vty_out(vty
, "%% BGP instance not found\n");
14605 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14606 enum show_type type
, const char *ip_str
,
14611 union sockunion su
;
14612 json_object
*json
= NULL
;
14615 if (strmatch(name
, "all")) {
14616 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14618 return CMD_SUCCESS
;
14620 bgp
= bgp_lookup_by_name(name
);
14623 json
= json_object_new_object();
14624 vty_json(vty
, json
);
14627 "%% BGP instance not found\n");
14629 return CMD_WARNING
;
14633 bgp
= bgp_get_default();
14637 json
= json_object_new_object();
14639 ret
= str2sockunion(ip_str
, &su
);
14641 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14644 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14647 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14650 json_object_free(json
);
14653 vty_out(vty
, "{}\n");
14655 vty_out(vty
, "%% BGP instance not found\n");
14658 return CMD_SUCCESS
;
14663 /* "show [ip] bgp neighbors graceful-restart" commands. */
14664 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14665 show_ip_bgp_neighbors_graceful_restart_cmd
,
14666 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14672 "Neighbor to display information about\n"
14673 "Neighbor to display information about\n"
14674 "Neighbor on BGP configured interface\n"
14678 char *sh_arg
= NULL
;
14679 enum show_type sh_type
;
14681 afi_t afi
= AFI_MAX
;
14682 bool uj
= use_json(argc
, argv
);
14684 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14689 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14690 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14691 || argv_find(argv
, argc
, "WORD", &idx
)) {
14692 sh_type
= show_peer
;
14693 sh_arg
= argv
[idx
]->arg
;
14695 sh_type
= show_all
;
14697 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14698 return CMD_SUCCESS
;
14701 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14705 /* "show [ip] bgp neighbors" commands. */
14706 DEFUN (show_ip_bgp_neighbors
,
14707 show_ip_bgp_neighbors_cmd
,
14708 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14712 BGP_INSTANCE_HELP_STR
14715 "Detailed information on TCP and BGP neighbor connections\n"
14716 "Neighbor to display information about\n"
14717 "Neighbor to display information about\n"
14718 "Neighbor on BGP configured interface\n"
14722 char *sh_arg
= NULL
;
14723 enum show_type sh_type
;
14724 afi_t afi
= AFI_MAX
;
14726 bool uj
= use_json(argc
, argv
);
14730 /* [<vrf> VIEWVRFNAME] */
14731 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14732 vrf
= argv
[idx
+ 1]->arg
;
14733 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14735 } else if (argv_find(argv
, argc
, "view", &idx
))
14736 /* [<view> VIEWVRFNAME] */
14737 vrf
= argv
[idx
+ 1]->arg
;
14741 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14742 sh_type
= show_ipv4_all
;
14744 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14745 sh_type
= show_ipv6_all
;
14748 sh_type
= show_all
;
14751 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14752 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14753 || argv_find(argv
, argc
, "WORD", &idx
)) {
14754 sh_type
= show_peer
;
14755 sh_arg
= argv
[idx
]->arg
;
14758 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14759 sh_type
= show_ipv4_peer
;
14760 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14761 sh_type
= show_ipv6_peer
;
14764 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14767 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14768 paths' and `show ip mbgp paths'. Those functions results are the
14770 DEFUN (show_ip_bgp_paths
,
14771 show_ip_bgp_paths_cmd
,
14772 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14777 "Path information\n")
14779 vty_out(vty
, "Address Refcnt Path\n");
14780 aspath_print_all_vty(vty
);
14781 return CMD_SUCCESS
;
14786 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14789 struct community
*com
;
14791 com
= (struct community
*)bucket
->data
;
14792 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14793 community_str(com
, false, false));
14796 /* Show BGP's community internal data. */
14797 DEFUN (show_ip_bgp_community_info
,
14798 show_ip_bgp_community_info_cmd
,
14799 "show [ip] bgp community-info",
14803 "List all bgp community information\n")
14805 vty_out(vty
, "Address Refcnt Community\n");
14807 hash_iterate(community_hash(),
14808 (void (*)(struct hash_bucket
*,
14809 void *))community_show_all_iterator
,
14812 return CMD_SUCCESS
;
14815 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14818 struct lcommunity
*lcom
;
14820 lcom
= (struct lcommunity
*)bucket
->data
;
14821 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14822 lcommunity_str(lcom
, false, false));
14825 /* Show BGP's community internal data. */
14826 DEFUN (show_ip_bgp_lcommunity_info
,
14827 show_ip_bgp_lcommunity_info_cmd
,
14828 "show ip bgp large-community-info",
14832 "List all bgp large-community information\n")
14834 vty_out(vty
, "Address Refcnt Large-community\n");
14836 hash_iterate(lcommunity_hash(),
14837 (void (*)(struct hash_bucket
*,
14838 void *))lcommunity_show_all_iterator
,
14841 return CMD_SUCCESS
;
14843 /* Graceful Restart */
14845 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14852 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14854 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14856 switch (bgp_global_gr_mode
) {
14858 case GLOBAL_HELPER
:
14859 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14863 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14866 case GLOBAL_DISABLE
:
14867 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14870 case GLOBAL_INVALID
:
14872 "Global BGP GR Mode Invalid\n");
14875 vty_out(vty
, "\n");
14878 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14879 enum show_type type
,
14880 const char *ip_str
,
14881 afi_t afi
, bool use_json
)
14883 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14886 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14888 bgp_show_neighbor_graceful_restart_vty(
14889 vty
, type
, ip_str
, afi
, use_json
);
14892 } else if (afi
!= AFI_MAX
) {
14893 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14896 return CMD_ERR_INCOMPLETE
;
14899 return CMD_SUCCESS
;
14901 /* Graceful Restart */
14903 DEFUN (show_ip_bgp_attr_info
,
14904 show_ip_bgp_attr_info_cmd
,
14905 "show [ip] bgp attribute-info",
14909 "List all bgp attribute information\n")
14911 attr_show_all(vty
);
14912 return CMD_SUCCESS
;
14915 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14916 afi_t afi
, safi_t safi
,
14917 bool use_json
, json_object
*json
)
14920 struct listnode
*node
;
14922 char buf1
[INET6_ADDRSTRLEN
];
14924 enum vpn_policy_direction dir
;
14927 json_object
*json_import_vrfs
= NULL
;
14928 json_object
*json_export_vrfs
= NULL
;
14930 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14933 vty_json(vty
, json
);
14935 return CMD_WARNING
;
14938 /* Provide context for the block */
14939 json_object_string_add(json
, "vrf", name
? name
: "default");
14940 json_object_string_add(json
, "afiSafi",
14941 get_afi_safi_str(afi
, safi
, true));
14943 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14944 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14945 json_object_string_add(json
, "importFromVrfs", "none");
14946 json_object_string_add(json
, "importRts", "none");
14948 json_import_vrfs
= json_object_new_array();
14950 for (ALL_LIST_ELEMENTS_RO(
14951 bgp
->vpn_policy
[afi
].import_vrf
,
14953 json_object_array_add(json_import_vrfs
,
14954 json_object_new_string(vname
));
14956 json_object_object_add(json
, "importFromVrfs",
14958 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14959 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14960 ecom_str
= ecommunity_ecom2str(
14961 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14962 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14963 json_object_string_add(json
, "importRts",
14965 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14967 json_object_string_add(json
, "importRts",
14971 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14972 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14973 json_object_string_add(json
, "exportToVrfs", "none");
14974 json_object_string_add(json
, "routeDistinguisher",
14976 json_object_string_add(json
, "exportRts", "none");
14978 json_export_vrfs
= json_object_new_array();
14980 for (ALL_LIST_ELEMENTS_RO(
14981 bgp
->vpn_policy
[afi
].export_vrf
,
14983 json_object_array_add(json_export_vrfs
,
14984 json_object_new_string(vname
));
14985 json_object_object_add(json
, "exportToVrfs",
14987 json_object_string_add(json
, "routeDistinguisher",
14988 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14989 buf1
, RD_ADDRSTRLEN
));
14991 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14992 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14993 ecom_str
= ecommunity_ecom2str(
14994 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14995 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14996 json_object_string_add(json
, "exportRts",
14998 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15000 json_object_string_add(json
, "exportRts",
15005 vty_json(vty
, json
);
15008 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15011 vty_out(vty
, "%% No such BGP instance exist\n");
15012 return CMD_WARNING
;
15015 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15016 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15018 "This VRF is not importing %s routes from any other VRF\n",
15019 get_afi_safi_str(afi
, safi
, false));
15022 "This VRF is importing %s routes from the following VRFs:\n",
15023 get_afi_safi_str(afi
, safi
, false));
15025 for (ALL_LIST_ELEMENTS_RO(
15026 bgp
->vpn_policy
[afi
].import_vrf
,
15028 vty_out(vty
, " %s\n", vname
);
15030 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15032 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15033 ecom_str
= ecommunity_ecom2str(
15034 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15035 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15036 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15038 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15040 vty_out(vty
, "Import RT(s):\n");
15043 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15044 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15046 "This VRF is not exporting %s routes to any other VRF\n",
15047 get_afi_safi_str(afi
, safi
, false));
15050 "This VRF is exporting %s routes to the following VRFs:\n",
15051 get_afi_safi_str(afi
, safi
, false));
15053 for (ALL_LIST_ELEMENTS_RO(
15054 bgp
->vpn_policy
[afi
].export_vrf
,
15056 vty_out(vty
, " %s\n", vname
);
15058 vty_out(vty
, "RD: %s\n",
15059 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15060 buf1
, RD_ADDRSTRLEN
));
15062 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15063 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15064 ecom_str
= ecommunity_ecom2str(
15065 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15066 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15067 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15068 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15070 vty_out(vty
, "Import RT(s):\n");
15074 return CMD_SUCCESS
;
15077 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15078 safi_t safi
, bool use_json
)
15080 struct listnode
*node
, *nnode
;
15082 char *vrf_name
= NULL
;
15083 json_object
*json
= NULL
;
15084 json_object
*json_vrf
= NULL
;
15085 json_object
*json_vrfs
= NULL
;
15088 json
= json_object_new_object();
15089 json_vrfs
= json_object_new_object();
15092 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15094 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15095 vrf_name
= bgp
->name
;
15098 json_vrf
= json_object_new_object();
15100 vty_out(vty
, "\nInstance %s:\n",
15101 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15102 ? VRF_DEFAULT_NAME
: bgp
->name
);
15104 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15106 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15107 json_object_object_add(json_vrfs
,
15108 VRF_DEFAULT_NAME
, json_vrf
);
15110 json_object_object_add(json_vrfs
, vrf_name
,
15116 json_object_object_add(json
, "vrfs", json_vrfs
);
15117 vty_json(vty
, json
);
15120 return CMD_SUCCESS
;
15123 /* "show [ip] bgp route-leak" command. */
15124 DEFUN (show_ip_bgp_route_leak
,
15125 show_ip_bgp_route_leak_cmd
,
15126 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15130 BGP_INSTANCE_HELP_STR
15133 "Route leaking information\n"
15137 afi_t afi
= AFI_MAX
;
15138 safi_t safi
= SAFI_MAX
;
15140 bool uj
= use_json(argc
, argv
);
15142 json_object
*json
= NULL
;
15144 /* show [ip] bgp */
15145 if (argv_find(argv
, argc
, "ip", &idx
)) {
15147 safi
= SAFI_UNICAST
;
15149 /* [vrf VIEWVRFNAME] */
15150 if (argv_find(argv
, argc
, "view", &idx
)) {
15152 "%% This command is not applicable to BGP views\n");
15153 return CMD_WARNING
;
15156 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15157 vrf
= argv
[idx
+ 1]->arg
;
15158 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15161 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15162 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15163 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15165 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15167 "%% This command is applicable only for unicast ipv4|ipv6\n");
15168 return CMD_WARNING
;
15171 if (vrf
&& strmatch(vrf
, "all"))
15172 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15175 json
= json_object_new_object();
15177 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15180 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15183 struct listnode
*node
, *nnode
;
15186 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15187 vty_out(vty
, "\nInstance %s:\n",
15188 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15191 update_group_show(bgp
, afi
, safi
, vty
, 0);
15195 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15196 int safi
, uint64_t subgrp_id
)
15201 if (strmatch(name
, "all")) {
15202 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15203 return CMD_SUCCESS
;
15205 bgp
= bgp_lookup_by_name(name
);
15208 bgp
= bgp_get_default();
15212 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15213 return CMD_SUCCESS
;
15216 DEFUN (show_ip_bgp_updgrps
,
15217 show_ip_bgp_updgrps_cmd
,
15218 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15222 BGP_INSTANCE_HELP_STR
15224 BGP_SAFI_WITH_LABEL_HELP_STR
15225 "Detailed info about dynamic update groups\n"
15226 "Specific subgroup to display detailed info for\n")
15229 afi_t afi
= AFI_IP6
;
15230 safi_t safi
= SAFI_UNICAST
;
15231 uint64_t subgrp_id
= 0;
15235 /* show [ip] bgp */
15236 if (argv_find(argv
, argc
, "ip", &idx
))
15238 /* [<vrf> VIEWVRFNAME] */
15239 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15240 vrf
= argv
[idx
+ 1]->arg
;
15241 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15243 } else if (argv_find(argv
, argc
, "view", &idx
))
15244 /* [<view> VIEWVRFNAME] */
15245 vrf
= argv
[idx
+ 1]->arg
;
15246 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15247 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15248 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15251 /* get subgroup id, if provided */
15253 if (argv
[idx
]->type
== VARIABLE_TKN
)
15254 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15256 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15259 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15260 show_bgp_instance_all_ipv6_updgrps_cmd
,
15261 "show [ip] bgp <view|vrf> all update-groups",
15265 BGP_INSTANCE_ALL_HELP_STR
15266 "Detailed info about dynamic update groups\n")
15268 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15269 return CMD_SUCCESS
;
15272 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15273 show_bgp_l2vpn_evpn_updgrps_cmd
,
15274 "show [ip] bgp l2vpn evpn update-groups",
15278 "l2vpn address family\n"
15279 "evpn sub-address family\n"
15280 "Detailed info about dynamic update groups\n")
15283 uint64_t subgrp_id
= 0;
15285 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15286 return CMD_SUCCESS
;
15289 DEFUN (show_bgp_updgrps_stats
,
15290 show_bgp_updgrps_stats_cmd
,
15291 "show [ip] bgp update-groups statistics",
15295 "Detailed info about dynamic update groups\n"
15300 bgp
= bgp_get_default();
15302 update_group_show_stats(bgp
, vty
);
15304 return CMD_SUCCESS
;
15307 DEFUN (show_bgp_instance_updgrps_stats
,
15308 show_bgp_instance_updgrps_stats_cmd
,
15309 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15313 BGP_INSTANCE_HELP_STR
15314 "Detailed info about dynamic update groups\n"
15320 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15322 update_group_show_stats(bgp
, vty
);
15324 return CMD_SUCCESS
;
15327 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15328 afi_t afi
, safi_t safi
,
15329 const char *what
, uint64_t subgrp_id
)
15334 bgp
= bgp_lookup_by_name(name
);
15336 bgp
= bgp_get_default();
15339 if (!strcmp(what
, "advertise-queue"))
15340 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15342 else if (!strcmp(what
, "advertised-routes"))
15343 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15345 else if (!strcmp(what
, "packet-queue"))
15346 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15351 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15352 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15353 "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",
15354 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15356 "Detailed info about dynamic update groups\n"
15357 "Specific subgroup to display info for\n"
15358 "Advertisement queue\n"
15359 "Announced routes\n"
15362 uint64_t subgrp_id
= 0;
15366 subgrp_id
= strtoull(sgid
, NULL
, 10);
15371 afiz
= bgp_vty_afi_from_str(afi
);
15375 afiz
= bgp_vty_afi_from_str(afi
);
15376 if (afiz
!= AFI_IP
)
15378 "%% Cannot specify both 'ip' and 'ipv6'\n");
15379 return CMD_WARNING
;
15382 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15384 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15385 return CMD_SUCCESS
;
15388 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15391 struct listnode
*node
, *nnode
;
15392 struct prefix
*range
;
15397 const char *peer_status
;
15401 json_object
*json_peer_group
= NULL
;
15402 json_object
*json_peer_group_afc
= NULL
;
15403 json_object
*json_peer_group_members
= NULL
;
15404 json_object
*json_peer_group_dynamic
= NULL
;
15405 json_object
*json_peer_group_dynamic_af
= NULL
;
15406 json_object
*json_peer_group_ranges
= NULL
;
15408 conf
= group
->conf
;
15411 json_peer_group
= json_object_new_object();
15412 json_peer_group_afc
= json_object_new_array();
15415 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15417 json_object_int_add(json_peer_group
, "remoteAs",
15420 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15421 group
->name
, conf
->as
);
15422 } else if (conf
->as_type
== AS_INTERNAL
) {
15424 json_object_int_add(json_peer_group
, "remoteAs",
15427 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15428 group
->name
, group
->bgp
->as
);
15431 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15434 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15436 json_object_string_add(json_peer_group
, "type",
15439 vty_out(vty
, " Peer-group type is internal\n");
15442 json_object_string_add(json_peer_group
, "type",
15445 vty_out(vty
, " Peer-group type is external\n");
15448 /* Display AFs configured. */
15450 vty_out(vty
, " Configured address-families:");
15452 FOREACH_AFI_SAFI (afi
, safi
) {
15453 if (conf
->afc
[afi
][safi
]) {
15456 json_object_array_add(
15457 json_peer_group_afc
,
15458 json_object_new_string(get_afi_safi_str(
15459 afi
, safi
, false)));
15461 vty_out(vty
, " %s;",
15462 get_afi_safi_str(afi
, safi
, false));
15467 json_object_object_add(json_peer_group
,
15468 "addressFamiliesConfigured",
15469 json_peer_group_afc
);
15472 vty_out(vty
, " none\n");
15474 vty_out(vty
, "\n");
15477 /* Display listen ranges (for dynamic neighbors), if any */
15478 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15479 lr_count
= listcount(group
->listen_range
[afi
]);
15482 if (!json_peer_group_dynamic
)
15483 json_peer_group_dynamic
=
15484 json_object_new_object();
15486 json_peer_group_dynamic_af
=
15487 json_object_new_object();
15488 json_peer_group_ranges
=
15489 json_object_new_array();
15490 json_object_int_add(json_peer_group_dynamic_af
,
15491 "count", lr_count
);
15493 vty_out(vty
, " %d %s listen range(s)\n",
15494 lr_count
, afi2str(afi
));
15497 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15502 snprintfrr(buf
, sizeof(buf
), "%pFX",
15505 json_object_array_add(
15506 json_peer_group_ranges
,
15507 json_object_new_string(buf
));
15509 vty_out(vty
, " %pFX\n", range
);
15514 json_object_object_add(
15515 json_peer_group_dynamic_af
, "ranges",
15516 json_peer_group_ranges
);
15518 json_object_object_add(
15519 json_peer_group_dynamic
, afi2str(afi
),
15520 json_peer_group_dynamic_af
);
15525 if (json_peer_group_dynamic
)
15526 json_object_object_add(json_peer_group
, "dynamicRanges",
15527 json_peer_group_dynamic
);
15529 /* Display group members and their status */
15530 if (listcount(group
->peer
)) {
15532 json_peer_group_members
= json_object_new_object();
15534 vty_out(vty
, " Peer-group members:\n");
15535 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15536 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15537 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15538 peer_status
= "Idle (Admin)";
15539 else if (CHECK_FLAG(peer
->sflags
,
15540 PEER_STATUS_PREFIX_OVERFLOW
))
15541 peer_status
= "Idle (PfxCt)";
15543 peer_status
= lookup_msg(bgp_status_msg
,
15544 peer
->status
, NULL
);
15546 dynamic
= peer_dynamic_neighbor(peer
);
15549 json_object
*json_peer_group_member
=
15550 json_object_new_object();
15552 json_object_string_add(json_peer_group_member
,
15553 "status", peer_status
);
15556 json_object_boolean_true_add(
15557 json_peer_group_member
,
15560 json_object_object_add(json_peer_group_members
,
15562 json_peer_group_member
);
15564 vty_out(vty
, " %s %s %s \n", peer
->host
,
15565 dynamic
? "(dynamic)" : "",
15570 json_object_object_add(json_peer_group
, "members",
15571 json_peer_group_members
);
15575 json_object_object_add(json
, group
->name
, json_peer_group
);
15577 return CMD_SUCCESS
;
15580 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15581 const char *group_name
, bool uj
)
15584 struct listnode
*node
, *nnode
;
15585 struct peer_group
*group
;
15586 bool found
= false;
15587 json_object
*json
= NULL
;
15590 json
= json_object_new_object();
15592 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15596 vty_json(vty
, json
);
15598 vty_out(vty
, "%% BGP instance not found\n");
15600 return CMD_WARNING
;
15603 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15605 if (strmatch(group
->name
, group_name
)) {
15606 bgp_show_one_peer_group(vty
, group
, json
);
15611 bgp_show_one_peer_group(vty
, group
, json
);
15615 if (group_name
&& !found
&& !uj
)
15616 vty_out(vty
, "%% No such peer-group\n");
15619 vty_json(vty
, json
);
15621 return CMD_SUCCESS
;
15624 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15625 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15626 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15627 "Detailed information on BGP peer groups\n"
15628 "Peer group name\n" JSON_STR
)
15632 bool uj
= use_json(argc
, argv
);
15634 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15636 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15638 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15642 /* Redistribute VTY commands. */
15644 DEFUN (bgp_redistribute_ipv4
,
15645 bgp_redistribute_ipv4_cmd
,
15646 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15647 "Redistribute information from another routing protocol\n"
15648 FRR_IP_REDIST_HELP_STR_BGPD
)
15650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15651 int idx_protocol
= 1;
15654 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15656 vty_out(vty
, "%% Invalid route type\n");
15657 return CMD_WARNING_CONFIG_FAILED
;
15660 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15661 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15665 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15666 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15667 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15669 DEFUN (bgp_redistribute_ipv4_rmap
,
15670 bgp_redistribute_ipv4_rmap_cmd
,
15671 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15672 "Redistribute information from another routing protocol\n"
15673 FRR_IP_REDIST_HELP_STR_BGPD
15674 "Route map reference\n"
15675 "Pointer to route-map entries\n")
15677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15678 int idx_protocol
= 1;
15681 struct bgp_redist
*red
;
15683 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15684 vty
, argv
[idx_word
]->arg
);
15686 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15688 vty_out(vty
, "%% Invalid route type\n");
15689 return CMD_WARNING_CONFIG_FAILED
;
15692 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15694 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15695 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15699 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15700 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15701 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15702 "Route map reference\n"
15703 "Pointer to route-map entries\n")
15705 DEFUN (bgp_redistribute_ipv4_metric
,
15706 bgp_redistribute_ipv4_metric_cmd
,
15707 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15708 "Redistribute information from another routing protocol\n"
15709 FRR_IP_REDIST_HELP_STR_BGPD
15710 "Metric for redistributed routes\n"
15711 "Default metric\n")
15713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15714 int idx_protocol
= 1;
15715 int idx_number
= 3;
15718 struct bgp_redist
*red
;
15721 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15723 vty_out(vty
, "%% Invalid route type\n");
15724 return CMD_WARNING_CONFIG_FAILED
;
15726 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15728 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15729 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15730 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15734 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15735 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15736 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15737 "Metric for redistributed routes\n"
15738 "Default metric\n")
15740 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15741 bgp_redistribute_ipv4_rmap_metric_cmd
,
15742 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15743 "Redistribute information from another routing protocol\n"
15744 FRR_IP_REDIST_HELP_STR_BGPD
15745 "Route map reference\n"
15746 "Pointer to route-map entries\n"
15747 "Metric for redistributed routes\n"
15748 "Default metric\n")
15750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15751 int idx_protocol
= 1;
15753 int idx_number
= 5;
15756 struct bgp_redist
*red
;
15758 struct route_map
*route_map
=
15759 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15761 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15763 vty_out(vty
, "%% Invalid route type\n");
15764 return CMD_WARNING_CONFIG_FAILED
;
15766 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15768 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15770 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15771 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15772 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15776 bgp_redistribute_ipv4_rmap_metric
,
15777 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15778 "redistribute " FRR_IP_REDIST_STR_BGPD
15779 " route-map RMAP_NAME metric (0-4294967295)",
15780 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15781 "Route map reference\n"
15782 "Pointer to route-map entries\n"
15783 "Metric for redistributed routes\n"
15784 "Default metric\n")
15786 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15787 bgp_redistribute_ipv4_metric_rmap_cmd
,
15788 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15789 "Redistribute information from another routing protocol\n"
15790 FRR_IP_REDIST_HELP_STR_BGPD
15791 "Metric for redistributed routes\n"
15793 "Route map reference\n"
15794 "Pointer to route-map entries\n")
15796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15797 int idx_protocol
= 1;
15798 int idx_number
= 3;
15802 struct bgp_redist
*red
;
15804 struct route_map
*route_map
=
15805 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15807 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15809 vty_out(vty
, "%% Invalid route type\n");
15810 return CMD_WARNING_CONFIG_FAILED
;
15812 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15814 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15815 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15817 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15818 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15822 bgp_redistribute_ipv4_metric_rmap
,
15823 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15824 "redistribute " FRR_IP_REDIST_STR_BGPD
15825 " metric (0-4294967295) route-map RMAP_NAME",
15826 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15827 "Metric for redistributed routes\n"
15829 "Route map reference\n"
15830 "Pointer to route-map entries\n")
15832 DEFUN (bgp_redistribute_ipv4_ospf
,
15833 bgp_redistribute_ipv4_ospf_cmd
,
15834 "redistribute <ospf|table> (1-65535)",
15835 "Redistribute information from another routing protocol\n"
15836 "Open Shortest Path First (OSPFv2)\n"
15837 "Non-main Kernel Routing Table\n"
15838 "Instance ID/Table ID\n")
15840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15841 int idx_ospf_table
= 1;
15842 int idx_number
= 2;
15843 unsigned short instance
;
15844 unsigned short protocol
;
15846 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15848 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15849 protocol
= ZEBRA_ROUTE_OSPF
;
15851 protocol
= ZEBRA_ROUTE_TABLE
;
15853 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15854 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15857 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15858 "redistribute <ospf|table> (1-65535)",
15859 "Redistribute information from another routing protocol\n"
15860 "Open Shortest Path First (OSPFv2)\n"
15861 "Non-main Kernel Routing Table\n"
15862 "Instance ID/Table ID\n")
15864 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15865 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15866 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15867 "Redistribute information from another routing protocol\n"
15868 "Open Shortest Path First (OSPFv2)\n"
15869 "Non-main Kernel Routing Table\n"
15870 "Instance ID/Table ID\n"
15871 "Route map reference\n"
15872 "Pointer to route-map entries\n")
15874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15875 int idx_ospf_table
= 1;
15876 int idx_number
= 2;
15878 struct bgp_redist
*red
;
15879 unsigned short instance
;
15882 struct route_map
*route_map
=
15883 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15885 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15886 protocol
= ZEBRA_ROUTE_OSPF
;
15888 protocol
= ZEBRA_ROUTE_TABLE
;
15890 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15891 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15893 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15894 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15897 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15898 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15899 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15900 "Redistribute information from another routing protocol\n"
15901 "Open Shortest Path First (OSPFv2)\n"
15902 "Non-main Kernel Routing Table\n"
15903 "Instance ID/Table ID\n"
15904 "Route map reference\n"
15905 "Pointer to route-map entries\n")
15907 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15908 bgp_redistribute_ipv4_ospf_metric_cmd
,
15909 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15910 "Redistribute information from another routing protocol\n"
15911 "Open Shortest Path First (OSPFv2)\n"
15912 "Non-main Kernel Routing Table\n"
15913 "Instance ID/Table ID\n"
15914 "Metric for redistributed routes\n"
15915 "Default metric\n")
15917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15918 int idx_ospf_table
= 1;
15919 int idx_number
= 2;
15920 int idx_number_2
= 4;
15922 struct bgp_redist
*red
;
15923 unsigned short instance
;
15927 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15928 protocol
= ZEBRA_ROUTE_OSPF
;
15930 protocol
= ZEBRA_ROUTE_TABLE
;
15932 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15933 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15935 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15936 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15938 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15941 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15942 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15943 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15944 "Redistribute information from another routing protocol\n"
15945 "Open Shortest Path First (OSPFv2)\n"
15946 "Non-main Kernel Routing Table\n"
15947 "Instance ID/Table ID\n"
15948 "Metric for redistributed routes\n"
15949 "Default metric\n")
15951 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15952 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15953 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15954 "Redistribute information from another routing protocol\n"
15955 "Open Shortest Path First (OSPFv2)\n"
15956 "Non-main Kernel Routing Table\n"
15957 "Instance ID/Table ID\n"
15958 "Route map reference\n"
15959 "Pointer to route-map entries\n"
15960 "Metric for redistributed routes\n"
15961 "Default metric\n")
15963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15964 int idx_ospf_table
= 1;
15965 int idx_number
= 2;
15967 int idx_number_2
= 6;
15969 struct bgp_redist
*red
;
15970 unsigned short instance
;
15973 struct route_map
*route_map
=
15974 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15976 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15977 protocol
= ZEBRA_ROUTE_OSPF
;
15979 protocol
= ZEBRA_ROUTE_TABLE
;
15981 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15982 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15984 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15986 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15987 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15989 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15993 bgp_redistribute_ipv4_ospf_rmap_metric
,
15994 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15995 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
15996 "Redistribute information from another routing protocol\n"
15997 "Open Shortest Path First (OSPFv2)\n"
15998 "Non-main Kernel Routing Table\n"
15999 "Instance ID/Table ID\n"
16000 "Route map reference\n"
16001 "Pointer to route-map entries\n"
16002 "Metric for redistributed routes\n"
16003 "Default metric\n")
16005 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16006 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16007 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16008 "Redistribute information from another routing protocol\n"
16009 "Open Shortest Path First (OSPFv2)\n"
16010 "Non-main Kernel Routing Table\n"
16011 "Instance ID/Table ID\n"
16012 "Metric for redistributed routes\n"
16014 "Route map reference\n"
16015 "Pointer to route-map entries\n")
16017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16018 int idx_ospf_table
= 1;
16019 int idx_number
= 2;
16020 int idx_number_2
= 4;
16023 struct bgp_redist
*red
;
16024 unsigned short instance
;
16027 struct route_map
*route_map
=
16028 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16030 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16031 protocol
= ZEBRA_ROUTE_OSPF
;
16033 protocol
= ZEBRA_ROUTE_TABLE
;
16035 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16036 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16038 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16039 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16042 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16043 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16047 bgp_redistribute_ipv4_ospf_metric_rmap
,
16048 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16049 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16050 "Redistribute information from another routing protocol\n"
16051 "Open Shortest Path First (OSPFv2)\n"
16052 "Non-main Kernel Routing Table\n"
16053 "Instance ID/Table ID\n"
16054 "Metric for redistributed routes\n"
16056 "Route map reference\n"
16057 "Pointer to route-map entries\n")
16059 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16060 no_bgp_redistribute_ipv4_ospf_cmd
,
16061 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16063 "Redistribute information from another routing protocol\n"
16064 "Open Shortest Path First (OSPFv2)\n"
16065 "Non-main Kernel Routing Table\n"
16066 "Instance ID/Table ID\n"
16067 "Metric for redistributed routes\n"
16069 "Route map reference\n"
16070 "Pointer to route-map entries\n")
16072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16073 int idx_ospf_table
= 2;
16074 int idx_number
= 3;
16075 unsigned short instance
;
16078 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16079 protocol
= ZEBRA_ROUTE_OSPF
;
16081 protocol
= ZEBRA_ROUTE_TABLE
;
16083 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16084 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16088 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16089 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16091 "Redistribute information from another routing protocol\n"
16092 "Open Shortest Path First (OSPFv2)\n"
16093 "Non-main Kernel Routing Table\n"
16094 "Instance ID/Table ID\n"
16095 "Metric for redistributed routes\n"
16097 "Route map reference\n"
16098 "Pointer to route-map entries\n")
16100 DEFUN (no_bgp_redistribute_ipv4
,
16101 no_bgp_redistribute_ipv4_cmd
,
16102 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16104 "Redistribute information from another routing protocol\n"
16105 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 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16112 int idx_protocol
= 2;
16115 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16117 vty_out(vty
, "%% Invalid route type\n");
16118 return CMD_WARNING_CONFIG_FAILED
;
16120 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16124 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16125 "no redistribute " FRR_IP_REDIST_STR_BGPD
16126 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16128 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16129 "Metric for redistributed routes\n"
16131 "Route map reference\n"
16132 "Pointer to route-map entries\n")
16134 DEFUN (bgp_redistribute_ipv6
,
16135 bgp_redistribute_ipv6_cmd
,
16136 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16137 "Redistribute information from another routing protocol\n"
16138 FRR_IP6_REDIST_HELP_STR_BGPD
)
16140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16141 int idx_protocol
= 1;
16144 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16146 vty_out(vty
, "%% Invalid route type\n");
16147 return CMD_WARNING_CONFIG_FAILED
;
16150 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16151 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16154 DEFUN (bgp_redistribute_ipv6_rmap
,
16155 bgp_redistribute_ipv6_rmap_cmd
,
16156 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16157 "Redistribute information from another routing protocol\n"
16158 FRR_IP6_REDIST_HELP_STR_BGPD
16159 "Route map reference\n"
16160 "Pointer to route-map entries\n")
16162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16163 int idx_protocol
= 1;
16166 struct bgp_redist
*red
;
16168 struct route_map
*route_map
=
16169 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16171 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16173 vty_out(vty
, "%% Invalid route type\n");
16174 return CMD_WARNING_CONFIG_FAILED
;
16177 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16179 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16180 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16183 DEFUN (bgp_redistribute_ipv6_metric
,
16184 bgp_redistribute_ipv6_metric_cmd
,
16185 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16186 "Redistribute information from another routing protocol\n"
16187 FRR_IP6_REDIST_HELP_STR_BGPD
16188 "Metric for redistributed routes\n"
16189 "Default metric\n")
16191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16192 int idx_protocol
= 1;
16193 int idx_number
= 3;
16196 struct bgp_redist
*red
;
16199 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16201 vty_out(vty
, "%% Invalid route type\n");
16202 return CMD_WARNING_CONFIG_FAILED
;
16204 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16206 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16207 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16208 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16211 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16212 bgp_redistribute_ipv6_rmap_metric_cmd
,
16213 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16214 "Redistribute information from another routing protocol\n"
16215 FRR_IP6_REDIST_HELP_STR_BGPD
16216 "Route map reference\n"
16217 "Pointer to route-map entries\n"
16218 "Metric for redistributed routes\n"
16219 "Default metric\n")
16221 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16222 int idx_protocol
= 1;
16224 int idx_number
= 5;
16227 struct bgp_redist
*red
;
16229 struct route_map
*route_map
=
16230 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16232 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16234 vty_out(vty
, "%% Invalid route type\n");
16235 return CMD_WARNING_CONFIG_FAILED
;
16237 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16239 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16241 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16242 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16244 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16247 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16248 bgp_redistribute_ipv6_metric_rmap_cmd
,
16249 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16250 "Redistribute information from another routing protocol\n"
16251 FRR_IP6_REDIST_HELP_STR_BGPD
16252 "Metric for redistributed routes\n"
16254 "Route map reference\n"
16255 "Pointer to route-map entries\n")
16257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16258 int idx_protocol
= 1;
16259 int idx_number
= 3;
16263 struct bgp_redist
*red
;
16265 struct route_map
*route_map
=
16266 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16268 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16270 vty_out(vty
, "%% Invalid route type\n");
16271 return CMD_WARNING_CONFIG_FAILED
;
16273 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16275 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16276 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16279 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16280 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16283 DEFUN (no_bgp_redistribute_ipv6
,
16284 no_bgp_redistribute_ipv6_cmd
,
16285 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16287 "Redistribute information from another routing protocol\n"
16288 FRR_IP6_REDIST_HELP_STR_BGPD
16289 "Metric for redistributed routes\n"
16291 "Route map reference\n"
16292 "Pointer to route-map entries\n")
16294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16295 int idx_protocol
= 2;
16298 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16300 vty_out(vty
, "%% Invalid route type\n");
16301 return CMD_WARNING_CONFIG_FAILED
;
16304 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16307 /* Neighbor update tcp-mss. */
16308 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16309 const char *tcp_mss_str
)
16312 uint32_t tcp_mss_val
= 0;
16314 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16316 return CMD_WARNING_CONFIG_FAILED
;
16319 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16320 peer_tcp_mss_set(peer
, tcp_mss_val
);
16322 peer_tcp_mss_unset(peer
);
16325 return CMD_SUCCESS
;
16328 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16329 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16330 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16331 "TCP max segment size\n"
16334 int peer_index
= 1;
16338 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16339 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16340 argv
[mss_index
]->arg
);
16343 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16344 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16345 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16346 "TCP max segment size\n"
16349 int peer_index
= 2;
16352 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16353 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16356 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16357 "[no$no] bgp retain route-target all",
16359 "Retain BGP updates\n"
16360 "Retain BGP updates based on route-target values\n"
16361 "Retain all BGP updates\n")
16364 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16366 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16367 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16368 if (check
!= !no
) {
16370 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16371 [bgp_node_safi(vty
)],
16372 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16374 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16375 [bgp_node_safi(vty
)],
16376 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16377 /* trigger a flush to re-sync with ADJ-RIB-in */
16378 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16379 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16381 return CMD_SUCCESS
;
16384 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16385 afi_t afi
, safi_t safi
)
16389 /* Unicast redistribution only. */
16390 if (safi
!= SAFI_UNICAST
)
16393 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16394 /* Redistribute BGP does not make sense. */
16395 if (i
!= ZEBRA_ROUTE_BGP
) {
16396 struct list
*red_list
;
16397 struct listnode
*node
;
16398 struct bgp_redist
*red
;
16400 red_list
= bgp
->redist
[afi
][i
];
16404 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16405 /* "redistribute" configuration. */
16406 vty_out(vty
, " redistribute %s",
16407 zebra_route_string(i
));
16409 vty_out(vty
, " %d", red
->instance
);
16410 if (red
->redist_metric_flag
)
16411 vty_out(vty
, " metric %u",
16412 red
->redist_metric
);
16413 if (red
->rmap
.name
)
16414 vty_out(vty
, " route-map %s",
16416 vty_out(vty
, "\n");
16422 /* peer-group helpers for config-write */
16424 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16426 if (!peer_group_active(peer
)) {
16427 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16428 return !CHECK_FLAG(peer
->flags
, flag
);
16430 return !!CHECK_FLAG(peer
->flags
, flag
);
16433 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16436 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16439 if (!peer_group_active(peer
)) {
16440 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16441 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16443 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16446 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16449 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16450 uint8_t type
, int direct
)
16452 struct bgp_filter
*filter
;
16454 if (peer_group_active(peer
))
16455 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16458 filter
= &peer
->filter
[afi
][safi
];
16460 case PEER_FT_DISTRIBUTE_LIST
:
16461 return !!(filter
->dlist
[direct
].name
);
16462 case PEER_FT_FILTER_LIST
:
16463 return !!(filter
->aslist
[direct
].name
);
16464 case PEER_FT_PREFIX_LIST
:
16465 return !!(filter
->plist
[direct
].name
);
16466 case PEER_FT_ROUTE_MAP
:
16467 return !!(filter
->map
[direct
].name
);
16468 case PEER_FT_UNSUPPRESS_MAP
:
16469 return !!(filter
->usmap
.name
);
16470 case PEER_FT_ADVERTISE_MAP
:
16471 return !!(filter
->advmap
.aname
16472 && ((filter
->advmap
.condition
== direct
)
16473 && filter
->advmap
.cname
));
16479 /* Return true if the addpath type is set for peer and different from
16482 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16485 enum bgp_addpath_strat type
, g_type
;
16487 type
= peer
->addpath_type
[afi
][safi
];
16489 if (type
!= BGP_ADDPATH_NONE
) {
16490 if (peer_group_active(peer
)) {
16491 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16493 if (type
!= g_type
)
16505 /* This is part of the address-family block (unicast only) */
16506 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16510 uint32_t tovpn_sid_index
= 0;
16512 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16513 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16514 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16515 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16516 bgp
->vpn_policy
[afi
]
16517 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16519 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16520 bgp
->vpn_policy
[afi
]
16521 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16523 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16524 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16525 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16526 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16529 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16530 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16532 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16535 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16536 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16537 bgp
->vpn_policy
[afi
].tovpn_label
);
16541 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16542 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16543 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16544 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16545 } else if (tovpn_sid_index
!= 0) {
16546 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16550 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16551 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16552 char buf
[RD_ADDRSTRLEN
];
16553 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16554 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16557 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16558 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16560 char buf
[PREFIX_STRLEN
];
16561 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16562 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16565 vty_out(vty
, "%*snexthop vpn export %s\n",
16569 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16570 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16572 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16573 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16575 char *b
= ecommunity_ecom2str(
16576 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16577 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16578 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16579 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16581 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16582 char *b
= ecommunity_ecom2str(
16583 bgp
->vpn_policy
[afi
]
16584 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16585 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16586 ECOMMUNITY_ROUTE_TARGET
);
16587 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16588 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16590 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16591 char *b
= ecommunity_ecom2str(
16592 bgp
->vpn_policy
[afi
]
16593 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16594 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16595 ECOMMUNITY_ROUTE_TARGET
);
16596 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16597 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16601 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16602 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16603 bgp
->vpn_policy
[afi
]
16604 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16606 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16607 char *b
= ecommunity_ecom2str(
16608 bgp
->vpn_policy
[afi
]
16609 .import_redirect_rtlist
,
16610 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16611 ECOMMUNITY_ROUTE_TARGET
);
16613 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16614 != ECOMMUNITY_SIZE
)
16615 vty_out(vty
, "%*srt6 redirect import %s\n",
16618 vty_out(vty
, "%*srt redirect import %s\n",
16620 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16624 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16625 afi_t afi
, safi_t safi
)
16627 struct bgp_filter
*filter
;
16631 filter
= &peer
->filter
[afi
][safi
];
16633 /* distribute-list. */
16634 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16636 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16637 filter
->dlist
[FILTER_IN
].name
);
16639 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16641 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16642 filter
->dlist
[FILTER_OUT
].name
);
16645 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16647 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16648 filter
->plist
[FILTER_IN
].name
);
16650 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16652 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16653 filter
->plist
[FILTER_OUT
].name
);
16656 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16657 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16658 filter
->map
[RMAP_IN
].name
);
16660 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16662 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16663 filter
->map
[RMAP_OUT
].name
);
16665 /* unsuppress-map */
16666 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16667 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16668 filter
->usmap
.name
);
16670 /* advertise-map : always applied in OUT direction*/
16671 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16672 CONDITION_NON_EXIST
))
16674 " neighbor %s advertise-map %s non-exist-map %s\n",
16675 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16677 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16679 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16680 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16683 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16685 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16686 filter
->aslist
[FILTER_IN
].name
);
16688 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16690 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16691 filter
->aslist
[FILTER_OUT
].name
);
16694 /* BGP peer configuration display function. */
16695 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16698 struct peer
*g_peer
= NULL
;
16700 int if_pg_printed
= false;
16701 int if_ras_printed
= false;
16703 /* Skip dynamic neighbors. */
16704 if (peer_dynamic_neighbor(peer
))
16708 addr
= peer
->conf_if
;
16712 /************************************
16713 ****** Global to the neighbor ******
16714 ************************************/
16715 if (peer
->conf_if
) {
16716 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16717 vty_out(vty
, " neighbor %s interface v6only", addr
);
16719 vty_out(vty
, " neighbor %s interface", addr
);
16721 if (peer_group_active(peer
)) {
16722 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16723 if_pg_printed
= true;
16724 } else if (peer
->as_type
== AS_SPECIFIED
) {
16725 vty_out(vty
, " remote-as %u", peer
->as
);
16726 if_ras_printed
= true;
16727 } else if (peer
->as_type
== AS_INTERNAL
) {
16728 vty_out(vty
, " remote-as internal");
16729 if_ras_printed
= true;
16730 } else if (peer
->as_type
== AS_EXTERNAL
) {
16731 vty_out(vty
, " remote-as external");
16732 if_ras_printed
= true;
16735 vty_out(vty
, "\n");
16738 /* remote-as and peer-group */
16739 /* peer is a member of a peer-group */
16740 if (peer_group_active(peer
)) {
16741 g_peer
= peer
->group
->conf
;
16743 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16744 if (peer
->as_type
== AS_SPECIFIED
) {
16745 vty_out(vty
, " neighbor %s remote-as %u\n",
16747 } else if (peer
->as_type
== AS_INTERNAL
) {
16749 " neighbor %s remote-as internal\n",
16751 } else if (peer
->as_type
== AS_EXTERNAL
) {
16753 " neighbor %s remote-as external\n",
16758 /* For swpX peers we displayed the peer-group
16759 * via 'neighbor swpX interface peer-group PGNAME' */
16760 if (!if_pg_printed
)
16761 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16762 peer
->group
->name
);
16765 /* peer is NOT a member of a peer-group */
16767 /* peer is a peer-group, declare the peer-group */
16768 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16769 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16772 if (!if_ras_printed
) {
16773 if (peer
->as_type
== AS_SPECIFIED
) {
16774 vty_out(vty
, " neighbor %s remote-as %u\n",
16776 } else if (peer
->as_type
== AS_INTERNAL
) {
16778 " neighbor %s remote-as internal\n",
16780 } else if (peer
->as_type
== AS_EXTERNAL
) {
16782 " neighbor %s remote-as external\n",
16789 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16790 vty_out(vty
, " neighbor %s local-as %u", addr
,
16791 peer
->change_local_as
);
16792 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16793 vty_out(vty
, " no-prepend");
16794 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16795 vty_out(vty
, " replace-as");
16796 vty_out(vty
, "\n");
16801 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16805 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16806 if (peer
->tx_shutdown_message
)
16807 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16808 peer
->tx_shutdown_message
);
16810 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16813 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16814 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16815 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16818 if (peer
->bfd_config
)
16819 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16822 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16823 vty_out(vty
, " neighbor %s password %s\n", addr
,
16826 /* neighbor solo */
16827 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16828 if (!peer_group_active(peer
)) {
16829 vty_out(vty
, " neighbor %s solo\n", addr
);
16834 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16835 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16838 /* Local interface name */
16839 if (peer
->ifname
) {
16840 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16843 /* TCP max segment size */
16844 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16845 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16848 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16849 vty_out(vty
, " neighbor %s passive\n", addr
);
16851 /* ebgp-multihop */
16852 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16853 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16854 && peer
->ttl
== MAXTTL
)) {
16855 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16856 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16862 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16863 peer
->local_role
!= ROLE_UNDEFINED
)
16864 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16865 bgp_get_name_by_role(peer
->local_role
),
16866 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16870 /* ttl-security hops */
16871 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16872 if (!peer_group_active(peer
)
16873 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16874 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16875 addr
, peer
->gtsm_hops
);
16879 /* disable-connected-check */
16880 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16881 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16883 /* link-bw-encoding-ieee */
16884 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16885 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16888 /* extended-optional-parameters */
16889 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16890 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16893 /* enforce-first-as */
16894 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16895 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16897 /* update-source */
16898 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16899 if (peer
->update_source
)
16900 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16901 peer
->update_source
);
16902 else if (peer
->update_if
)
16903 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16907 /* advertisement-interval */
16908 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16909 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16913 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16914 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16915 peer
->keepalive
, peer
->holdtime
);
16917 /* timers connect */
16918 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16919 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16921 /* need special-case handling for changed default values due to
16922 * config profile / version (because there is no "timers bgp connect"
16923 * command, we need to save this per-peer :/)
16925 else if (!peer_group_active(peer
) && !peer
->connect
&&
16926 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16927 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16928 peer
->bgp
->default_connect_retry
);
16930 /* timers delayopen */
16931 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16932 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16934 /* Save config even though flag is not set if default values have been
16937 else if (!peer_group_active(peer
) && !peer
->delayopen
16938 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16939 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16940 peer
->bgp
->default_delayopen
);
16942 /* capability dynamic */
16943 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16944 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16946 /* capability extended-nexthop */
16947 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16948 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
16951 " no neighbor %s capability extended-nexthop\n",
16953 else if (!peer
->conf_if
)
16955 " neighbor %s capability extended-nexthop\n",
16959 /* dont-capability-negotiation */
16960 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16961 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16963 /* override-capability */
16964 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16965 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16967 /* strict-capability-match */
16968 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16969 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16971 /* Sender side AS path loop detection. */
16972 if (peer
->as_path_loop_detection
)
16973 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16976 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16977 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16979 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16980 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16982 " neighbor %s graceful-restart-helper\n", addr
);
16983 } else if (CHECK_FLAG(
16984 peer
->peer_gr_new_status_flag
,
16985 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16987 " neighbor %s graceful-restart\n", addr
);
16989 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16990 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16992 peer
->peer_gr_new_status_flag
,
16993 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16994 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17000 /* BGP peer configuration display function. */
17001 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17002 struct peer
*peer
, afi_t afi
, safi_t safi
)
17004 struct peer
*g_peer
= NULL
;
17006 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17008 /* Skip dynamic neighbors. */
17009 if (peer_dynamic_neighbor(peer
))
17013 addr
= peer
->conf_if
;
17017 /************************************
17018 ****** Per AF to the neighbor ******
17019 ************************************/
17020 if (peer_group_active(peer
)) {
17021 g_peer
= peer
->group
->conf
;
17023 /* If the peer-group is active but peer is not, print a 'no
17025 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17026 vty_out(vty
, " no neighbor %s activate\n", addr
);
17029 /* If the peer-group is not active but peer is, print an
17031 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17032 vty_out(vty
, " neighbor %s activate\n", addr
);
17035 if (peer
->afc
[afi
][safi
]) {
17036 if (safi
== SAFI_ENCAP
)
17037 vty_out(vty
, " neighbor %s activate\n", addr
);
17038 else if (!bgp
->default_af
[afi
][safi
])
17039 vty_out(vty
, " neighbor %s activate\n", addr
);
17041 if (bgp
->default_af
[afi
][safi
])
17042 vty_out(vty
, " no neighbor %s activate\n",
17047 /* addpath TX knobs */
17048 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17049 switch (peer
->addpath_type
[afi
][safi
]) {
17050 case BGP_ADDPATH_ALL
:
17051 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17054 case BGP_ADDPATH_BEST_PER_AS
:
17056 " neighbor %s addpath-tx-bestpath-per-AS\n",
17059 case BGP_ADDPATH_MAX
:
17060 case BGP_ADDPATH_NONE
:
17065 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17066 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17068 /* ORF capability. */
17069 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17070 || peergroup_af_flag_check(peer
, afi
, safi
,
17071 PEER_FLAG_ORF_PREFIX_RM
)) {
17072 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17074 if (peergroup_af_flag_check(peer
, afi
, safi
,
17075 PEER_FLAG_ORF_PREFIX_SM
)
17076 && peergroup_af_flag_check(peer
, afi
, safi
,
17077 PEER_FLAG_ORF_PREFIX_RM
))
17078 vty_out(vty
, " both");
17079 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17080 PEER_FLAG_ORF_PREFIX_SM
))
17081 vty_out(vty
, " send");
17083 vty_out(vty
, " receive");
17084 vty_out(vty
, "\n");
17087 /* Route reflector client. */
17088 if (peergroup_af_flag_check(peer
, afi
, safi
,
17089 PEER_FLAG_REFLECTOR_CLIENT
)) {
17090 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17093 /* next-hop-self force */
17094 if (peergroup_af_flag_check(peer
, afi
, safi
,
17095 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17096 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17099 /* next-hop-self */
17100 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17101 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17104 /* remove-private-AS */
17105 if (peergroup_af_flag_check(peer
, afi
, safi
,
17106 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17107 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17111 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17112 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17113 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17117 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17118 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17119 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17122 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17123 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17124 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17128 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17129 vty_out(vty
, " neighbor %s as-override\n", addr
);
17132 /* send-community print. */
17133 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17134 PEER_FLAG_SEND_COMMUNITY
);
17135 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17136 PEER_FLAG_SEND_EXT_COMMUNITY
);
17137 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17138 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17140 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17141 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17144 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17147 " no neighbor %s send-community extended\n",
17151 vty_out(vty
, " no neighbor %s send-community large\n",
17155 /* Default information */
17156 if (peergroup_af_flag_check(peer
, afi
, safi
,
17157 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17158 vty_out(vty
, " neighbor %s default-originate", addr
);
17160 if (peer
->default_rmap
[afi
][safi
].name
)
17161 vty_out(vty
, " route-map %s",
17162 peer
->default_rmap
[afi
][safi
].name
);
17164 vty_out(vty
, "\n");
17167 /* Soft reconfiguration inbound. */
17168 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17169 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17173 /* maximum-prefix. */
17174 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17175 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17176 peer
->pmax
[afi
][safi
]);
17178 if (peer
->pmax_threshold
[afi
][safi
]
17179 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17180 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17181 if (peer_af_flag_check(peer
, afi
, safi
,
17182 PEER_FLAG_MAX_PREFIX_WARNING
))
17183 vty_out(vty
, " warning-only");
17184 if (peer
->pmax_restart
[afi
][safi
])
17185 vty_out(vty
, " restart %u",
17186 peer
->pmax_restart
[afi
][safi
]);
17187 if (peer_af_flag_check(peer
, afi
, safi
,
17188 PEER_FLAG_MAX_PREFIX_FORCE
))
17189 vty_out(vty
, " force");
17191 vty_out(vty
, "\n");
17194 /* maximum-prefix-out */
17195 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17196 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17197 addr
, peer
->pmax_out
[afi
][safi
]);
17199 /* Route server client. */
17200 if (peergroup_af_flag_check(peer
, afi
, safi
,
17201 PEER_FLAG_RSERVER_CLIENT
)) {
17202 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17205 /* Nexthop-local unchanged. */
17206 if (peergroup_af_flag_check(peer
, afi
, safi
,
17207 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17208 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17211 /* allowas-in <1-10> */
17212 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17213 if (peer_af_flag_check(peer
, afi
, safi
,
17214 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17215 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17216 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17217 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17219 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17220 peer
->allowas_in
[afi
][safi
]);
17225 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17226 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17227 peer
->weight
[afi
][safi
]);
17230 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17232 /* atribute-unchanged. */
17233 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17234 || (safi
!= SAFI_EVPN
17235 && peer_af_flag_check(peer
, afi
, safi
,
17236 PEER_FLAG_NEXTHOP_UNCHANGED
))
17237 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17239 if (!peer_group_active(peer
)
17240 || peergroup_af_flag_check(peer
, afi
, safi
,
17241 PEER_FLAG_AS_PATH_UNCHANGED
)
17242 || peergroup_af_flag_check(peer
, afi
, safi
,
17243 PEER_FLAG_NEXTHOP_UNCHANGED
)
17244 || peergroup_af_flag_check(peer
, afi
, safi
,
17245 PEER_FLAG_MED_UNCHANGED
)) {
17248 " neighbor %s attribute-unchanged%s%s%s\n",
17250 peer_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_AS_PATH_UNCHANGED
)
17254 peer_af_flag_check(peer
, afi
, safi
,
17255 PEER_FLAG_NEXTHOP_UNCHANGED
)
17258 peer_af_flag_check(peer
, afi
, safi
,
17259 PEER_FLAG_MED_UNCHANGED
)
17266 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17269 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17270 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17271 vty_out(vty
, " no bgp retain route-target all\n");
17274 /* Address family based peer configuration display. */
17275 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17279 struct peer_group
*group
;
17280 struct listnode
*node
, *nnode
;
17283 vty_frame(vty
, " !\n address-family ");
17284 if (afi
== AFI_IP
) {
17285 if (safi
== SAFI_UNICAST
)
17286 vty_frame(vty
, "ipv4 unicast");
17287 else if (safi
== SAFI_LABELED_UNICAST
)
17288 vty_frame(vty
, "ipv4 labeled-unicast");
17289 else if (safi
== SAFI_MULTICAST
)
17290 vty_frame(vty
, "ipv4 multicast");
17291 else if (safi
== SAFI_MPLS_VPN
)
17292 vty_frame(vty
, "ipv4 vpn");
17293 else if (safi
== SAFI_ENCAP
)
17294 vty_frame(vty
, "ipv4 encap");
17295 else if (safi
== SAFI_FLOWSPEC
)
17296 vty_frame(vty
, "ipv4 flowspec");
17297 } else if (afi
== AFI_IP6
) {
17298 if (safi
== SAFI_UNICAST
)
17299 vty_frame(vty
, "ipv6 unicast");
17300 else if (safi
== SAFI_LABELED_UNICAST
)
17301 vty_frame(vty
, "ipv6 labeled-unicast");
17302 else if (safi
== SAFI_MULTICAST
)
17303 vty_frame(vty
, "ipv6 multicast");
17304 else if (safi
== SAFI_MPLS_VPN
)
17305 vty_frame(vty
, "ipv6 vpn");
17306 else if (safi
== SAFI_ENCAP
)
17307 vty_frame(vty
, "ipv6 encap");
17308 else if (safi
== SAFI_FLOWSPEC
)
17309 vty_frame(vty
, "ipv6 flowspec");
17310 } else if (afi
== AFI_L2VPN
) {
17311 if (safi
== SAFI_EVPN
)
17312 vty_frame(vty
, "l2vpn evpn");
17314 vty_frame(vty
, "\n");
17316 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17318 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17320 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17322 /* BGP flag dampening. */
17323 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17324 bgp_config_write_damp(vty
, afi
, safi
);
17326 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17327 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17329 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17330 /* Do not display doppelganger peers */
17331 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17332 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17335 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17336 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17338 if (safi
== SAFI_EVPN
)
17339 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17341 if (safi
== SAFI_FLOWSPEC
)
17342 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17344 if (safi
== SAFI_MPLS_VPN
)
17345 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17347 if (safi
== SAFI_UNICAST
) {
17348 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17349 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17350 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17352 vty_out(vty
, " export vpn\n");
17354 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17355 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17357 vty_out(vty
, " import vpn\n");
17359 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17360 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17363 for (ALL_LIST_ELEMENTS_RO(
17364 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17366 vty_out(vty
, " import vrf %s\n", name
);
17370 vty_endframe(vty
, " exit-address-family\n");
17373 int bgp_config_write(struct vty
*vty
)
17376 struct peer_group
*group
;
17378 struct listnode
*node
, *nnode
;
17379 struct listnode
*mnode
, *mnnode
;
17383 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17384 vty_out(vty
, "bgp route-map delay-timer %u\n",
17385 bm
->rmap_update_timer
);
17387 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17388 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17389 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17390 vty_out(vty
, " %d", bm
->v_establish_wait
);
17391 vty_out(vty
, "\n");
17394 if (bm
->wait_for_fib
)
17395 vty_out(vty
, "bgp suppress-fib-pending\n");
17397 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17398 vty_out(vty
, "bgp graceful-shutdown\n");
17400 /* No-RIB (Zebra) option flag configuration */
17401 if (bgp_option_check(BGP_OPT_NO_FIB
))
17402 vty_out(vty
, "bgp no-rib\n");
17404 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17405 vty_out(vty
, "bgp send-extra-data zebra\n");
17407 /* BGP session DSCP value */
17408 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17409 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17411 /* BGP configuration. */
17412 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17414 /* skip all auto created vrf as they dont have user config */
17415 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17418 /* Router bgp ASN */
17419 vty_out(vty
, "router bgp %u", bgp
->as
);
17422 vty_out(vty
, " %s %s",
17423 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17424 ? "view" : "vrf", bgp
->name
);
17425 vty_out(vty
, "\n");
17427 /* BGP fast-external-failover. */
17428 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17429 vty_out(vty
, " no bgp fast-external-failover\n");
17431 /* BGP router ID. */
17432 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17433 vty_out(vty
, " bgp router-id %pI4\n",
17434 &bgp
->router_id_static
);
17436 /* Suppress fib pending */
17437 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17438 vty_out(vty
, " bgp suppress-fib-pending\n");
17440 /* BGP log-neighbor-changes. */
17441 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17442 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17443 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17444 CHECK_FLAG(bgp
->flags
,
17445 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17449 /* BGP configuration. */
17450 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17451 vty_out(vty
, " bgp always-compare-med\n");
17453 /* RFC8212 default eBGP policy. */
17454 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17455 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17456 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17457 CHECK_FLAG(bgp
->flags
,
17458 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17462 /* draft-ietf-idr-deprecate-as-set-confed-set */
17463 if (bgp
->reject_as_sets
)
17464 vty_out(vty
, " bgp reject-as-sets\n");
17466 /* Suppress duplicate updates if the route actually not changed
17468 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17469 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17470 vty_out(vty
, " %sbgp suppress-duplicates\n",
17471 CHECK_FLAG(bgp
->flags
,
17472 BGP_FLAG_SUPPRESS_DUPLICATES
)
17476 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17478 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17479 SAVE_BGP_HARD_ADMIN_RESET
)
17480 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17481 CHECK_FLAG(bgp
->flags
,
17482 BGP_FLAG_HARD_ADMIN_RESET
)
17486 /* BGP default <afi>-<safi> */
17487 FOREACH_AFI_SAFI (afi
, safi
) {
17488 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17489 if (!bgp
->default_af
[afi
][safi
])
17490 vty_out(vty
, " no bgp default %s\n",
17491 get_bgp_default_af_flag(afi
,
17493 } else if (bgp
->default_af
[afi
][safi
])
17494 vty_out(vty
, " bgp default %s\n",
17495 get_bgp_default_af_flag(afi
, safi
));
17498 /* BGP default local-preference. */
17499 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17500 vty_out(vty
, " bgp default local-preference %u\n",
17501 bgp
->default_local_pref
);
17503 /* BGP default show-hostname */
17504 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17505 != SAVE_BGP_SHOW_HOSTNAME
)
17506 vty_out(vty
, " %sbgp default show-hostname\n",
17507 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17511 /* BGP default show-nexthop-hostname */
17512 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17513 != SAVE_BGP_SHOW_HOSTNAME
)
17514 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17515 CHECK_FLAG(bgp
->flags
,
17516 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17520 /* BGP default subgroup-pkt-queue-max. */
17521 if (bgp
->default_subgroup_pkt_queue_max
17522 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17523 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17524 bgp
->default_subgroup_pkt_queue_max
);
17526 /* BGP client-to-client reflection. */
17527 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17528 vty_out(vty
, " no bgp client-to-client reflection\n");
17530 /* BGP cluster ID. */
17531 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17532 vty_out(vty
, " bgp cluster-id %pI4\n",
17535 /* Disable ebgp connected nexthop check */
17536 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17538 " bgp disable-ebgp-connected-route-check\n");
17540 /* Confederation identifier*/
17541 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17542 vty_out(vty
, " bgp confederation identifier %u\n",
17545 /* Confederation peer */
17546 if (bgp
->confed_peers_cnt
> 0) {
17549 vty_out(vty
, " bgp confederation peers");
17551 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17552 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17554 vty_out(vty
, "\n");
17557 /* BGP deterministic-med. */
17558 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17559 != SAVE_BGP_DETERMINISTIC_MED
)
17560 vty_out(vty
, " %sbgp deterministic-med\n",
17561 CHECK_FLAG(bgp
->flags
,
17562 BGP_FLAG_DETERMINISTIC_MED
)
17566 /* BGP update-delay. */
17567 bgp_config_write_update_delay(vty
, bgp
);
17569 if (bgp
->v_maxmed_onstartup
17570 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17571 vty_out(vty
, " bgp max-med on-startup %u",
17572 bgp
->v_maxmed_onstartup
);
17573 if (bgp
->maxmed_onstartup_value
17574 != BGP_MAXMED_VALUE_DEFAULT
)
17575 vty_out(vty
, " %u",
17576 bgp
->maxmed_onstartup_value
);
17577 vty_out(vty
, "\n");
17579 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17580 vty_out(vty
, " bgp max-med administrative");
17581 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17582 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17583 vty_out(vty
, "\n");
17587 bgp_config_write_wpkt_quanta(vty
, bgp
);
17589 bgp_config_write_rpkt_quanta(vty
, bgp
);
17591 /* coalesce time */
17592 bgp_config_write_coalesce_time(vty
, bgp
);
17594 /* BGP per-instance graceful-shutdown */
17595 /* BGP-wide settings and per-instance settings are mutually
17598 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17599 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17600 vty_out(vty
, " bgp graceful-shutdown\n");
17602 /* Long-lived Graceful Restart */
17603 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17605 " bgp long-lived-graceful-restart stale-time %u\n",
17606 bgp
->llgr_stale_time
);
17608 /* BGP graceful-restart. */
17609 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17611 " bgp graceful-restart stalepath-time %u\n",
17612 bgp
->stalepath_time
);
17614 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17615 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17616 bgp
->restart_time
);
17618 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17619 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17620 vty_out(vty
, " %sbgp graceful-restart notification\n",
17621 CHECK_FLAG(bgp
->flags
,
17622 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17626 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17628 " bgp graceful-restart select-defer-time %u\n",
17629 bgp
->select_defer_time
);
17631 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17632 vty_out(vty
, " bgp graceful-restart\n");
17634 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17635 vty_out(vty
, " bgp graceful-restart-disable\n");
17637 /* BGP graceful-restart Preserve State F bit. */
17638 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17640 " bgp graceful-restart preserve-fw-state\n");
17642 /* Stale timer for RIB */
17643 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17645 " bgp graceful-restart rib-stale-time %u\n",
17646 bgp
->rib_stale_time
);
17648 /* BGP bestpath method. */
17649 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17650 vty_out(vty
, " bgp bestpath as-path ignore\n");
17651 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17652 vty_out(vty
, " bgp bestpath as-path confed\n");
17654 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17655 if (CHECK_FLAG(bgp
->flags
,
17656 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17658 " bgp bestpath as-path multipath-relax as-set\n");
17661 " bgp bestpath as-path multipath-relax\n");
17665 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17667 " bgp route-reflector allow-outbound-policy\n");
17669 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17670 vty_out(vty
, " bgp bestpath compare-routerid\n");
17671 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17672 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17673 vty_out(vty
, " bgp bestpath med");
17674 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17675 vty_out(vty
, " confed");
17676 if (CHECK_FLAG(bgp
->flags
,
17677 BGP_FLAG_MED_MISSING_AS_WORST
))
17678 vty_out(vty
, " missing-as-worst");
17679 vty_out(vty
, "\n");
17682 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17684 " bgp bestpath peer-type multipath-relax\n");
17686 /* Link bandwidth handling. */
17687 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17688 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17689 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17690 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17691 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17692 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17694 /* BGP network import check. */
17695 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17696 != SAVE_BGP_IMPORT_CHECK
)
17697 vty_out(vty
, " %sbgp network import-check\n",
17698 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17702 /* BGP timers configuration. */
17703 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17704 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17705 vty_out(vty
, " timers bgp %u %u\n",
17706 bgp
->default_keepalive
, bgp
->default_holdtime
);
17708 /* BGP minimum holdtime configuration. */
17709 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17710 && bgp
->default_min_holdtime
!= 0)
17711 vty_out(vty
, " bgp minimum-holdtime %u\n",
17712 bgp
->default_min_holdtime
);
17714 /* Conditional advertisement timer configuration */
17715 if (bgp
->condition_check_period
17716 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17718 " bgp conditional-advertisement timer %u\n",
17719 bgp
->condition_check_period
);
17722 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17723 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17726 /* Normal neighbor configuration. */
17727 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17728 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17729 bgp_config_write_peer_global(vty
, bgp
, peer
);
17732 /* listen range and limit for dynamic BGP neighbors */
17733 bgp_config_write_listen(vty
, bgp
);
17736 * BGP default autoshutdown neighbors
17738 * This must be placed after any peer and peer-group
17739 * configuration, to avoid setting all peers to shutdown after
17740 * a daemon restart, which is undesired behavior. (see #2286)
17742 if (bgp
->autoshutdown
)
17743 vty_out(vty
, " bgp default shutdown\n");
17745 /* BGP instance administrative shutdown */
17746 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17747 vty_out(vty
, " bgp shutdown\n");
17749 if (bgp
->allow_martian
)
17750 vty_out(vty
, " bgp allow-martian-nexthop\n");
17752 if (bgp
->fast_convergence
)
17753 vty_out(vty
, " bgp fast-convergence\n");
17755 if (bgp
->srv6_enabled
) {
17756 vty_frame(vty
, " !\n segment-routing srv6\n");
17757 if (strlen(bgp
->srv6_locator_name
))
17758 vty_out(vty
, " locator %s\n",
17759 bgp
->srv6_locator_name
);
17760 vty_endframe(vty
, " exit\n");
17764 /* IPv4 unicast configuration. */
17765 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17767 /* IPv4 multicast configuration. */
17768 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17770 /* IPv4 labeled-unicast configuration. */
17771 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17773 /* IPv4 VPN configuration. */
17774 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17776 /* ENCAPv4 configuration. */
17777 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17779 /* FLOWSPEC v4 configuration. */
17780 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17782 /* IPv6 unicast configuration. */
17783 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17785 /* IPv6 multicast configuration. */
17786 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17788 /* IPv6 labeled-unicast configuration. */
17789 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17790 SAFI_LABELED_UNICAST
);
17792 /* IPv6 VPN configuration. */
17793 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17795 /* ENCAPv6 configuration. */
17796 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17798 /* FLOWSPEC v6 configuration. */
17799 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17801 /* EVPN configuration. */
17802 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17804 hook_call(bgp_inst_config_write
, bgp
, vty
);
17806 #ifdef ENABLE_BGP_VNC
17807 bgp_rfapi_cfg_write(vty
, bgp
);
17810 vty_out(vty
, "exit\n");
17811 vty_out(vty
, "!\n");
17817 /* BGP node structure. */
17818 static struct cmd_node bgp_node
= {
17821 .parent_node
= CONFIG_NODE
,
17822 .prompt
= "%s(config-router)# ",
17823 .config_write
= bgp_config_write
,
17826 static struct cmd_node bgp_ipv4_unicast_node
= {
17827 .name
= "bgp ipv4 unicast",
17828 .node
= BGP_IPV4_NODE
,
17829 .parent_node
= BGP_NODE
,
17830 .prompt
= "%s(config-router-af)# ",
17834 static struct cmd_node bgp_ipv4_multicast_node
= {
17835 .name
= "bgp ipv4 multicast",
17836 .node
= BGP_IPV4M_NODE
,
17837 .parent_node
= BGP_NODE
,
17838 .prompt
= "%s(config-router-af)# ",
17842 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17843 .name
= "bgp ipv4 labeled unicast",
17844 .node
= BGP_IPV4L_NODE
,
17845 .parent_node
= BGP_NODE
,
17846 .prompt
= "%s(config-router-af)# ",
17850 static struct cmd_node bgp_ipv6_unicast_node
= {
17851 .name
= "bgp ipv6 unicast",
17852 .node
= BGP_IPV6_NODE
,
17853 .parent_node
= BGP_NODE
,
17854 .prompt
= "%s(config-router-af)# ",
17858 static struct cmd_node bgp_ipv6_multicast_node
= {
17859 .name
= "bgp ipv6 multicast",
17860 .node
= BGP_IPV6M_NODE
,
17861 .parent_node
= BGP_NODE
,
17862 .prompt
= "%s(config-router-af)# ",
17866 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17867 .name
= "bgp ipv6 labeled unicast",
17868 .node
= BGP_IPV6L_NODE
,
17869 .parent_node
= BGP_NODE
,
17870 .prompt
= "%s(config-router-af)# ",
17874 static struct cmd_node bgp_vpnv4_node
= {
17875 .name
= "bgp vpnv4",
17876 .node
= BGP_VPNV4_NODE
,
17877 .parent_node
= BGP_NODE
,
17878 .prompt
= "%s(config-router-af)# ",
17882 static struct cmd_node bgp_vpnv6_node
= {
17883 .name
= "bgp vpnv6",
17884 .node
= BGP_VPNV6_NODE
,
17885 .parent_node
= BGP_NODE
,
17886 .prompt
= "%s(config-router-af-vpnv6)# ",
17890 static struct cmd_node bgp_evpn_node
= {
17891 .name
= "bgp evpn",
17892 .node
= BGP_EVPN_NODE
,
17893 .parent_node
= BGP_NODE
,
17894 .prompt
= "%s(config-router-evpn)# ",
17898 static struct cmd_node bgp_evpn_vni_node
= {
17899 .name
= "bgp evpn vni",
17900 .node
= BGP_EVPN_VNI_NODE
,
17901 .parent_node
= BGP_EVPN_NODE
,
17902 .prompt
= "%s(config-router-af-vni)# ",
17905 static struct cmd_node bgp_flowspecv4_node
= {
17906 .name
= "bgp ipv4 flowspec",
17907 .node
= BGP_FLOWSPECV4_NODE
,
17908 .parent_node
= BGP_NODE
,
17909 .prompt
= "%s(config-router-af)# ",
17913 static struct cmd_node bgp_flowspecv6_node
= {
17914 .name
= "bgp ipv6 flowspec",
17915 .node
= BGP_FLOWSPECV6_NODE
,
17916 .parent_node
= BGP_NODE
,
17917 .prompt
= "%s(config-router-af-vpnv6)# ",
17921 static struct cmd_node bgp_srv6_node
= {
17922 .name
= "bgp srv6",
17923 .node
= BGP_SRV6_NODE
,
17924 .parent_node
= BGP_NODE
,
17925 .prompt
= "%s(config-router-srv6)# ",
17928 static void community_list_vty(void);
17930 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17933 struct peer_group
*group
;
17934 struct listnode
*lnbgp
, *lnpeer
;
17936 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17937 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17939 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17943 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17947 struct listnode
*lnbgp
, *lnpeer
;
17949 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17950 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17951 /* only provide suggestions on the appropriate input
17953 * they'll otherwise show up multiple times */
17954 enum cmd_token_type match_type
;
17955 char *name
= peer
->host
;
17957 if (peer
->conf_if
) {
17958 match_type
= VARIABLE_TKN
;
17959 name
= peer
->conf_if
;
17960 } else if (strchr(peer
->host
, ':'))
17961 match_type
= IPV6_TKN
;
17963 match_type
= IPV4_TKN
;
17965 if (token
->type
!= match_type
)
17968 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17973 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17975 bgp_ac_peer(comps
, token
);
17977 if (token
->type
== VARIABLE_TKN
)
17978 bgp_ac_peergroup(comps
, token
);
17981 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17982 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17983 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17984 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17985 {.completions
= NULL
}};
17987 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17988 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17989 {.completions
= NULL
} };
17991 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
17993 static struct thread
*t_bgp_cfg
;
17995 bool bgp_config_inprocess(void)
17997 return thread_is_scheduled(t_bgp_cfg
);
18000 static void bgp_config_finish(struct thread
*t
)
18002 struct listnode
*node
;
18005 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18006 hook_call(bgp_config_end
, bgp
);
18009 static void bgp_config_start(void)
18011 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18012 THREAD_OFF(t_bgp_cfg
);
18013 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18014 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18017 /* When we receive a hook the configuration is read,
18018 * we start a timer to make sure we postpone sending
18019 * EoR before route-maps are processed.
18020 * This is especially valid if using `bgp route-map delay-timer`.
18022 static void bgp_config_end(void)
18024 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18025 uint32_t bgp_post_config_delay
=
18026 thread_is_scheduled(bm
->t_rmap_update
)
18027 ? thread_timer_remain_second(bm
->t_rmap_update
)
18028 : BGP_POST_CONFIG_DELAY_SECONDS
;
18030 /* If BGP config processing thread isn't running, then
18031 * we can return and rely it's properly handled.
18033 if (!bgp_config_inprocess())
18036 THREAD_OFF(t_bgp_cfg
);
18038 /* Start a new timer to make sure we don't send EoR
18039 * before route-maps are processed.
18041 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18042 bgp_post_config_delay
, &t_bgp_cfg
);
18045 void bgp_vty_init(void)
18047 cmd_variable_handler_register(bgp_var_neighbor
);
18048 cmd_variable_handler_register(bgp_var_peergroup
);
18050 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18052 /* Install bgp top node. */
18053 install_node(&bgp_node
);
18054 install_node(&bgp_ipv4_unicast_node
);
18055 install_node(&bgp_ipv4_multicast_node
);
18056 install_node(&bgp_ipv4_labeled_unicast_node
);
18057 install_node(&bgp_ipv6_unicast_node
);
18058 install_node(&bgp_ipv6_multicast_node
);
18059 install_node(&bgp_ipv6_labeled_unicast_node
);
18060 install_node(&bgp_vpnv4_node
);
18061 install_node(&bgp_vpnv6_node
);
18062 install_node(&bgp_evpn_node
);
18063 install_node(&bgp_evpn_vni_node
);
18064 install_node(&bgp_flowspecv4_node
);
18065 install_node(&bgp_flowspecv6_node
);
18066 install_node(&bgp_srv6_node
);
18068 /* Install default VTY commands to new nodes. */
18069 install_default(BGP_NODE
);
18070 install_default(BGP_IPV4_NODE
);
18071 install_default(BGP_IPV4M_NODE
);
18072 install_default(BGP_IPV4L_NODE
);
18073 install_default(BGP_IPV6_NODE
);
18074 install_default(BGP_IPV6M_NODE
);
18075 install_default(BGP_IPV6L_NODE
);
18076 install_default(BGP_VPNV4_NODE
);
18077 install_default(BGP_VPNV6_NODE
);
18078 install_default(BGP_FLOWSPECV4_NODE
);
18079 install_default(BGP_FLOWSPECV6_NODE
);
18080 install_default(BGP_EVPN_NODE
);
18081 install_default(BGP_EVPN_VNI_NODE
);
18082 install_default(BGP_SRV6_NODE
);
18084 /* "bgp local-mac" hidden commands. */
18085 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18086 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18088 /* "bgp suppress-fib-pending" global */
18089 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18091 /* bgp route-map delay-timer commands. */
18092 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18093 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18095 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18097 /* bgp fast-convergence command */
18098 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18099 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18101 /* global bgp update-delay command */
18102 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18103 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18105 /* global bgp graceful-shutdown command */
18106 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18107 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18109 /* Dummy commands (Currently not supported) */
18110 install_element(BGP_NODE
, &no_synchronization_cmd
);
18111 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18113 /* "router bgp" commands. */
18114 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18116 /* "no router bgp" commands. */
18117 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18119 /* "bgp session-dscp command */
18120 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18121 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18123 /* "bgp router-id" commands. */
18124 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18125 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18127 /* "bgp suppress-fib-pending" command */
18128 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18130 /* "bgp cluster-id" commands. */
18131 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18132 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18134 /* "bgp no-rib" commands. */
18135 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18136 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18138 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18140 /* "bgp confederation" commands. */
18141 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18142 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18144 /* "bgp confederation peers" commands. */
18145 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18146 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18148 /* bgp max-med command */
18149 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18150 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18151 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18152 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18153 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18155 /* "neighbor role" commands. */
18156 install_element(BGP_NODE
, &neighbor_role_cmd
);
18157 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18158 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18160 /* bgp disable-ebgp-connected-nh-check */
18161 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18162 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18164 /* bgp update-delay command */
18165 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18166 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18168 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18169 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18171 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18172 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18174 /* "maximum-paths" commands. */
18175 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18176 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18177 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18178 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18179 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18180 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18181 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18182 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18183 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18184 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18185 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18186 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18187 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18188 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18189 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18191 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18192 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18193 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18194 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18195 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18196 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18197 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18198 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18199 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18200 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18202 /* "timers bgp" commands. */
18203 install_element(BGP_NODE
, &bgp_timers_cmd
);
18204 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18206 /* "minimum-holdtime" commands. */
18207 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18208 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18210 /* route-map delay-timer commands - per instance for backwards compat.
18212 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18213 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18215 /* "bgp client-to-client reflection" commands */
18216 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18217 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18219 /* "bgp always-compare-med" commands */
18220 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18221 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18223 /* bgp ebgp-requires-policy */
18224 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18225 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18227 /* bgp suppress-duplicates */
18228 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18229 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18231 /* bgp reject-as-sets */
18232 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18233 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18235 /* "bgp deterministic-med" commands */
18236 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18237 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18239 /* "bgp graceful-restart" command */
18240 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18241 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18243 /* "bgp graceful-restart-disable" command */
18244 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18245 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18247 /* "neighbor a:b:c:d graceful-restart" command */
18248 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18249 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18251 /* "neighbor a:b:c:d graceful-restart-disable" command */
18252 install_element(BGP_NODE
,
18253 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18254 install_element(BGP_NODE
,
18255 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18257 /* "neighbor a:b:c:d graceful-restart-helper" command */
18258 install_element(BGP_NODE
,
18259 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18260 install_element(BGP_NODE
,
18261 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18263 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18264 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18265 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18266 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18267 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18268 install_element(BGP_NODE
,
18269 &no_bgp_graceful_restart_select_defer_time_cmd
);
18270 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18271 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18272 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18274 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18275 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18276 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18277 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18279 /* "bgp graceful-shutdown" commands */
18280 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18281 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18283 /* "bgp hard-administrative-reset" commands */
18284 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18286 /* "bgp long-lived-graceful-restart" commands */
18287 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18288 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18290 /* "bgp fast-external-failover" commands */
18291 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18292 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18294 /* "bgp bestpath compare-routerid" commands */
18295 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18296 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18298 /* "bgp bestpath as-path ignore" commands */
18299 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18300 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18302 /* "bgp bestpath as-path confed" commands */
18303 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18304 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18306 /* "bgp bestpath as-path multipath-relax" commands */
18307 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18308 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18310 /* "bgp bestpath peer-type multipath-relax" commands */
18311 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18312 install_element(BGP_NODE
,
18313 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18315 /* "bgp log-neighbor-changes" commands */
18316 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18317 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18319 /* "bgp bestpath med" commands */
18320 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18321 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18323 /* "bgp bestpath bandwidth" commands */
18324 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18325 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18327 /* "no bgp default <afi>-<safi>" commands. */
18328 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18330 /* "bgp network import-check" commands. */
18331 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18332 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18333 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18335 /* "bgp default local-preference" commands. */
18336 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18337 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18339 /* bgp default show-hostname */
18340 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18341 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18343 /* bgp default show-nexthop-hostname */
18344 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18345 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18347 /* "bgp default subgroup-pkt-queue-max" commands. */
18348 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18349 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18351 /* bgp ibgp-allow-policy-mods command */
18352 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18353 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18355 /* "bgp listen limit" commands. */
18356 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18357 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18359 /* "bgp listen range" commands. */
18360 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18361 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18363 /* "bgp default shutdown" command */
18364 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18366 /* "bgp shutdown" commands */
18367 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18368 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18369 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18370 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18372 /* "neighbor remote-as" commands. */
18373 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18374 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18375 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18376 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18377 install_element(BGP_NODE
,
18378 &neighbor_interface_v6only_config_remote_as_cmd
);
18379 install_element(BGP_NODE
, &no_neighbor_cmd
);
18380 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18382 /* "neighbor peer-group" commands. */
18383 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18384 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18385 install_element(BGP_NODE
,
18386 &no_neighbor_interface_peer_group_remote_as_cmd
);
18388 /* "neighbor local-as" commands. */
18389 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18390 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18391 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18392 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18394 /* "neighbor solo" commands. */
18395 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18396 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18398 /* "neighbor password" commands. */
18399 install_element(BGP_NODE
, &neighbor_password_cmd
);
18400 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18402 /* "neighbor activate" commands. */
18403 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18404 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18405 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18406 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18407 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18408 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18409 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18410 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18411 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18412 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18413 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18414 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18416 /* "no neighbor activate" commands. */
18417 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18418 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18419 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18420 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18421 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18422 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18423 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18424 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18425 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18426 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18427 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18428 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18430 /* "neighbor peer-group" set commands. */
18431 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18432 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18433 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18434 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18435 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18436 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18437 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18438 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18439 install_element(BGP_FLOWSPECV4_NODE
,
18440 &neighbor_set_peer_group_hidden_cmd
);
18441 install_element(BGP_FLOWSPECV6_NODE
,
18442 &neighbor_set_peer_group_hidden_cmd
);
18444 /* "no neighbor peer-group unset" commands. */
18445 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18446 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18447 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18448 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18449 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18450 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18451 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18452 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18453 install_element(BGP_FLOWSPECV4_NODE
,
18454 &no_neighbor_set_peer_group_hidden_cmd
);
18455 install_element(BGP_FLOWSPECV6_NODE
,
18456 &no_neighbor_set_peer_group_hidden_cmd
);
18458 /* "neighbor softreconfiguration inbound" commands.*/
18459 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18460 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18461 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18462 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18463 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18464 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18465 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18466 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18467 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18468 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18469 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18470 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18471 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18472 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18473 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18474 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18475 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18476 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18477 install_element(BGP_FLOWSPECV4_NODE
,
18478 &neighbor_soft_reconfiguration_cmd
);
18479 install_element(BGP_FLOWSPECV4_NODE
,
18480 &no_neighbor_soft_reconfiguration_cmd
);
18481 install_element(BGP_FLOWSPECV6_NODE
,
18482 &neighbor_soft_reconfiguration_cmd
);
18483 install_element(BGP_FLOWSPECV6_NODE
,
18484 &no_neighbor_soft_reconfiguration_cmd
);
18485 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18486 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18488 /* "neighbor attribute-unchanged" commands. */
18489 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18490 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18491 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18492 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18493 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18494 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18495 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18496 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18497 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18498 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18499 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18500 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18501 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18502 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18503 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18504 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18505 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18506 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18508 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18509 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18511 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18512 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18513 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18514 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18516 /* "nexthop-local unchanged" commands */
18517 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18518 install_element(BGP_IPV6_NODE
,
18519 &no_neighbor_nexthop_local_unchanged_cmd
);
18521 /* "neighbor next-hop-self" commands. */
18522 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18523 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18524 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18525 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18526 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18527 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18528 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18529 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18530 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18531 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18532 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18533 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18534 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18535 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18536 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18537 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18538 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18539 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18540 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18541 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18543 /* "neighbor next-hop-self force" commands. */
18544 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18545 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18546 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18547 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18548 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18549 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18550 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18551 install_element(BGP_IPV4_NODE
,
18552 &no_neighbor_nexthop_self_all_hidden_cmd
);
18553 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18554 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18555 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18556 install_element(BGP_IPV4M_NODE
,
18557 &no_neighbor_nexthop_self_all_hidden_cmd
);
18558 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18559 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18560 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18561 install_element(BGP_IPV4L_NODE
,
18562 &no_neighbor_nexthop_self_all_hidden_cmd
);
18563 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18564 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18565 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18566 install_element(BGP_IPV6_NODE
,
18567 &no_neighbor_nexthop_self_all_hidden_cmd
);
18568 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18569 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18570 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18571 install_element(BGP_IPV6M_NODE
,
18572 &no_neighbor_nexthop_self_all_hidden_cmd
);
18573 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18574 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18575 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18576 install_element(BGP_IPV6L_NODE
,
18577 &no_neighbor_nexthop_self_all_hidden_cmd
);
18578 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18579 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18580 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18581 install_element(BGP_VPNV4_NODE
,
18582 &no_neighbor_nexthop_self_all_hidden_cmd
);
18583 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18584 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18585 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18586 install_element(BGP_VPNV6_NODE
,
18587 &no_neighbor_nexthop_self_all_hidden_cmd
);
18588 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18589 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18591 /* "neighbor as-override" commands. */
18592 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18593 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18594 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18595 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18596 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18597 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18598 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18599 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18600 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18601 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18602 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18603 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18604 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18605 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18606 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18607 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18608 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18609 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18611 /* "neighbor remove-private-AS" commands. */
18612 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18613 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18614 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18615 install_element(BGP_NODE
,
18616 &no_neighbor_remove_private_as_all_hidden_cmd
);
18617 install_element(BGP_NODE
,
18618 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18619 install_element(BGP_NODE
,
18620 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18621 install_element(BGP_NODE
,
18622 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18625 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18626 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18627 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18628 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18629 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18630 install_element(BGP_IPV4_NODE
,
18631 &neighbor_remove_private_as_replace_as_cmd
);
18632 install_element(BGP_IPV4_NODE
,
18633 &no_neighbor_remove_private_as_replace_as_cmd
);
18634 install_element(BGP_IPV4_NODE
,
18635 &neighbor_remove_private_as_all_replace_as_cmd
);
18636 install_element(BGP_IPV4_NODE
,
18637 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18638 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18639 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18640 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18641 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18642 install_element(BGP_IPV4M_NODE
,
18643 &neighbor_remove_private_as_replace_as_cmd
);
18644 install_element(BGP_IPV4M_NODE
,
18645 &no_neighbor_remove_private_as_replace_as_cmd
);
18646 install_element(BGP_IPV4M_NODE
,
18647 &neighbor_remove_private_as_all_replace_as_cmd
);
18648 install_element(BGP_IPV4M_NODE
,
18649 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18650 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18651 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18652 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18653 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18654 install_element(BGP_IPV4L_NODE
,
18655 &neighbor_remove_private_as_replace_as_cmd
);
18656 install_element(BGP_IPV4L_NODE
,
18657 &no_neighbor_remove_private_as_replace_as_cmd
);
18658 install_element(BGP_IPV4L_NODE
,
18659 &neighbor_remove_private_as_all_replace_as_cmd
);
18660 install_element(BGP_IPV4L_NODE
,
18661 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18662 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18663 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18664 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18665 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18666 install_element(BGP_IPV6_NODE
,
18667 &neighbor_remove_private_as_replace_as_cmd
);
18668 install_element(BGP_IPV6_NODE
,
18669 &no_neighbor_remove_private_as_replace_as_cmd
);
18670 install_element(BGP_IPV6_NODE
,
18671 &neighbor_remove_private_as_all_replace_as_cmd
);
18672 install_element(BGP_IPV6_NODE
,
18673 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18674 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18675 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18676 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18677 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18678 install_element(BGP_IPV6M_NODE
,
18679 &neighbor_remove_private_as_replace_as_cmd
);
18680 install_element(BGP_IPV6M_NODE
,
18681 &no_neighbor_remove_private_as_replace_as_cmd
);
18682 install_element(BGP_IPV6M_NODE
,
18683 &neighbor_remove_private_as_all_replace_as_cmd
);
18684 install_element(BGP_IPV6M_NODE
,
18685 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18686 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18687 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18688 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18689 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18690 install_element(BGP_IPV6L_NODE
,
18691 &neighbor_remove_private_as_replace_as_cmd
);
18692 install_element(BGP_IPV6L_NODE
,
18693 &no_neighbor_remove_private_as_replace_as_cmd
);
18694 install_element(BGP_IPV6L_NODE
,
18695 &neighbor_remove_private_as_all_replace_as_cmd
);
18696 install_element(BGP_IPV6L_NODE
,
18697 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18698 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18699 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18700 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18701 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18702 install_element(BGP_VPNV4_NODE
,
18703 &neighbor_remove_private_as_replace_as_cmd
);
18704 install_element(BGP_VPNV4_NODE
,
18705 &no_neighbor_remove_private_as_replace_as_cmd
);
18706 install_element(BGP_VPNV4_NODE
,
18707 &neighbor_remove_private_as_all_replace_as_cmd
);
18708 install_element(BGP_VPNV4_NODE
,
18709 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18710 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18711 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18712 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18713 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18714 install_element(BGP_VPNV6_NODE
,
18715 &neighbor_remove_private_as_replace_as_cmd
);
18716 install_element(BGP_VPNV6_NODE
,
18717 &no_neighbor_remove_private_as_replace_as_cmd
);
18718 install_element(BGP_VPNV6_NODE
,
18719 &neighbor_remove_private_as_all_replace_as_cmd
);
18720 install_element(BGP_VPNV6_NODE
,
18721 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18723 /* "neighbor send-community" commands.*/
18724 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18725 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18726 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18727 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18728 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18729 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18730 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18731 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18732 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18733 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18734 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18735 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18736 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18737 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18738 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18739 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18740 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18741 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18742 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18743 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18744 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18745 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18746 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18747 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18748 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18749 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18750 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18751 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18752 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18753 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18754 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18755 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18756 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18757 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18758 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18761 /* "neighbor route-reflector" commands.*/
18762 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18763 install_element(BGP_NODE
,
18764 &no_neighbor_route_reflector_client_hidden_cmd
);
18765 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18766 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18767 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18768 install_element(BGP_IPV4M_NODE
,
18769 &no_neighbor_route_reflector_client_cmd
);
18770 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18771 install_element(BGP_IPV4L_NODE
,
18772 &no_neighbor_route_reflector_client_cmd
);
18773 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18774 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18775 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18776 install_element(BGP_IPV6M_NODE
,
18777 &no_neighbor_route_reflector_client_cmd
);
18778 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18779 install_element(BGP_IPV6L_NODE
,
18780 &no_neighbor_route_reflector_client_cmd
);
18781 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18782 install_element(BGP_VPNV4_NODE
,
18783 &no_neighbor_route_reflector_client_cmd
);
18784 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18785 install_element(BGP_VPNV6_NODE
,
18786 &no_neighbor_route_reflector_client_cmd
);
18787 install_element(BGP_FLOWSPECV4_NODE
,
18788 &neighbor_route_reflector_client_cmd
);
18789 install_element(BGP_FLOWSPECV4_NODE
,
18790 &no_neighbor_route_reflector_client_cmd
);
18791 install_element(BGP_FLOWSPECV6_NODE
,
18792 &neighbor_route_reflector_client_cmd
);
18793 install_element(BGP_FLOWSPECV6_NODE
,
18794 &no_neighbor_route_reflector_client_cmd
);
18795 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18796 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18798 /* "neighbor route-server" commands.*/
18799 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18800 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18801 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18802 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18803 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18804 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18805 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18806 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18807 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18808 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18809 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18810 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18811 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18812 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18813 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18814 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18815 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18816 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18817 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18818 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18819 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18820 install_element(BGP_FLOWSPECV4_NODE
,
18821 &no_neighbor_route_server_client_cmd
);
18822 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18823 install_element(BGP_FLOWSPECV6_NODE
,
18824 &no_neighbor_route_server_client_cmd
);
18826 /* "neighbor disable-addpath-rx" commands. */
18827 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18828 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18829 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18830 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18831 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18832 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18833 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18834 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18835 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18836 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18837 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18838 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18839 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18840 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18841 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18842 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18844 /* "neighbor addpath-tx-all-paths" commands.*/
18845 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18846 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18847 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18848 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18849 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18850 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18851 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18852 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18853 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18854 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18855 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18856 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18857 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18858 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18859 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18860 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18861 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18862 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18864 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18865 install_element(BGP_NODE
,
18866 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18867 install_element(BGP_NODE
,
18868 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18869 install_element(BGP_IPV4_NODE
,
18870 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18871 install_element(BGP_IPV4_NODE
,
18872 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18873 install_element(BGP_IPV4M_NODE
,
18874 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18875 install_element(BGP_IPV4M_NODE
,
18876 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18877 install_element(BGP_IPV4L_NODE
,
18878 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18879 install_element(BGP_IPV4L_NODE
,
18880 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18881 install_element(BGP_IPV6_NODE
,
18882 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18883 install_element(BGP_IPV6_NODE
,
18884 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18885 install_element(BGP_IPV6M_NODE
,
18886 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18887 install_element(BGP_IPV6M_NODE
,
18888 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18889 install_element(BGP_IPV6L_NODE
,
18890 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18891 install_element(BGP_IPV6L_NODE
,
18892 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18893 install_element(BGP_VPNV4_NODE
,
18894 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18895 install_element(BGP_VPNV4_NODE
,
18896 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18897 install_element(BGP_VPNV6_NODE
,
18898 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18899 install_element(BGP_VPNV6_NODE
,
18900 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18902 /* "neighbor sender-as-path-loop-detection" commands. */
18903 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18904 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18906 /* "neighbor passive" commands. */
18907 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18908 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18911 /* "neighbor shutdown" commands. */
18912 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18913 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18914 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18915 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18916 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18917 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18919 /* "neighbor capability extended-nexthop" commands.*/
18920 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18921 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18923 /* "neighbor capability orf prefix-list" commands.*/
18924 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18925 install_element(BGP_NODE
,
18926 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18927 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18928 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18929 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18930 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18931 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18932 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18933 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18934 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18935 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18936 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18937 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18938 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18940 /* "neighbor capability dynamic" commands.*/
18941 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18942 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18944 /* "neighbor dont-capability-negotiate" commands. */
18945 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18946 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18948 /* "neighbor ebgp-multihop" commands. */
18949 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18950 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18951 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18953 /* "neighbor disable-connected-check" commands. */
18954 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18955 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18957 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18958 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18959 install_element(BGP_NODE
,
18960 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18962 /* "neighbor extended-optional-parameters" commands. */
18963 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18964 install_element(BGP_NODE
,
18965 &no_neighbor_extended_optional_parameters_cmd
);
18967 /* "neighbor enforce-first-as" commands. */
18968 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18969 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18971 /* "neighbor description" commands. */
18972 install_element(BGP_NODE
, &neighbor_description_cmd
);
18973 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18974 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18976 /* "neighbor update-source" commands. "*/
18977 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18978 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18980 /* "neighbor default-originate" commands. */
18981 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18982 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18983 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18984 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18985 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18986 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18987 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18988 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18989 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18990 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18991 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18992 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18993 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18994 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18995 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18996 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18997 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18998 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18999 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19000 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19001 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19003 /* "neighbor port" commands. */
19004 install_element(BGP_NODE
, &neighbor_port_cmd
);
19005 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19007 /* "neighbor weight" commands. */
19008 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19009 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19011 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19012 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19013 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19014 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19015 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19016 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19017 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19018 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19019 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19020 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19021 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19022 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19023 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19024 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19025 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19026 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19028 /* "neighbor override-capability" commands. */
19029 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19030 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19032 /* "neighbor strict-capability-match" commands. */
19033 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19034 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19036 /* "neighbor timers" commands. */
19037 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19038 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19040 /* "neighbor timers connect" commands. */
19041 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19042 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19044 /* "neighbor timers delayopen" commands. */
19045 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19046 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19048 /* "neighbor advertisement-interval" commands. */
19049 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19050 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19052 /* "neighbor interface" commands. */
19053 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19054 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19056 /* "neighbor distribute" commands. */
19057 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19058 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19059 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19060 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19061 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19062 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19063 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19064 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19065 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19066 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19067 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19068 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19069 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19070 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19071 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19072 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19073 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19076 /* "neighbor prefix-list" commands. */
19077 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19078 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19079 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19080 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19081 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19082 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19083 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19084 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19085 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19086 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19087 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19088 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19089 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19090 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19091 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19092 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19093 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19094 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19095 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19096 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19097 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19098 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19100 /* "neighbor filter-list" commands. */
19101 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19102 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19103 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19104 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19105 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19106 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19107 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19108 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19109 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19110 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19111 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19112 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19113 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19114 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19115 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19116 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19117 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19118 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19119 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19120 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19121 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19122 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19124 /* "neighbor route-map" commands. */
19125 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19126 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19127 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19128 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19129 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19130 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19131 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19132 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19133 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19134 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19135 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19136 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19137 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19138 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19139 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19140 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19141 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19142 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19143 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19144 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19145 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19146 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19147 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19148 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19150 /* "neighbor unsuppress-map" commands. */
19151 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19152 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19153 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19154 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19155 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19156 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19157 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19158 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19159 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19160 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19161 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19162 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19163 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19164 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19165 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19166 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19167 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19168 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19170 /* "neighbor advertise-map" commands. */
19171 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19172 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19173 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19174 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19175 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19176 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19177 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19178 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19179 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19180 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19182 /* neighbor maximum-prefix-out commands. */
19183 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19184 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19185 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19186 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19187 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19188 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19189 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19190 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19191 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19192 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19193 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19194 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19195 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19196 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19197 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19198 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19199 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19200 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19202 /* "neighbor maximum-prefix" commands. */
19203 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19204 install_element(BGP_NODE
,
19205 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19206 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19207 install_element(BGP_NODE
,
19208 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19209 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19210 install_element(BGP_NODE
,
19211 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19212 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19213 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19214 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19215 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19216 install_element(BGP_IPV4_NODE
,
19217 &neighbor_maximum_prefix_threshold_warning_cmd
);
19218 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19219 install_element(BGP_IPV4_NODE
,
19220 &neighbor_maximum_prefix_threshold_restart_cmd
);
19221 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19222 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19223 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19224 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19225 install_element(BGP_IPV4M_NODE
,
19226 &neighbor_maximum_prefix_threshold_warning_cmd
);
19227 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19228 install_element(BGP_IPV4M_NODE
,
19229 &neighbor_maximum_prefix_threshold_restart_cmd
);
19230 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19231 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19232 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19233 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19234 install_element(BGP_IPV4L_NODE
,
19235 &neighbor_maximum_prefix_threshold_warning_cmd
);
19236 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19237 install_element(BGP_IPV4L_NODE
,
19238 &neighbor_maximum_prefix_threshold_restart_cmd
);
19239 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19240 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19241 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19242 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19243 install_element(BGP_IPV6_NODE
,
19244 &neighbor_maximum_prefix_threshold_warning_cmd
);
19245 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19246 install_element(BGP_IPV6_NODE
,
19247 &neighbor_maximum_prefix_threshold_restart_cmd
);
19248 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19249 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19250 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19251 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19252 install_element(BGP_IPV6M_NODE
,
19253 &neighbor_maximum_prefix_threshold_warning_cmd
);
19254 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19255 install_element(BGP_IPV6M_NODE
,
19256 &neighbor_maximum_prefix_threshold_restart_cmd
);
19257 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19258 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19259 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19260 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19261 install_element(BGP_IPV6L_NODE
,
19262 &neighbor_maximum_prefix_threshold_warning_cmd
);
19263 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19264 install_element(BGP_IPV6L_NODE
,
19265 &neighbor_maximum_prefix_threshold_restart_cmd
);
19266 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19267 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19268 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19269 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19270 install_element(BGP_VPNV4_NODE
,
19271 &neighbor_maximum_prefix_threshold_warning_cmd
);
19272 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19273 install_element(BGP_VPNV4_NODE
,
19274 &neighbor_maximum_prefix_threshold_restart_cmd
);
19275 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19276 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19277 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19278 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19279 install_element(BGP_VPNV6_NODE
,
19280 &neighbor_maximum_prefix_threshold_warning_cmd
);
19281 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19282 install_element(BGP_VPNV6_NODE
,
19283 &neighbor_maximum_prefix_threshold_restart_cmd
);
19284 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19286 /* "neighbor allowas-in" */
19287 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19288 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19289 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19290 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19291 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19292 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19293 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19294 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19295 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19296 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19297 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19298 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19299 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19300 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19301 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19302 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19303 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19304 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19305 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19306 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19308 /* address-family commands. */
19309 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19310 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19311 #ifdef KEEP_OLD_VPN_COMMANDS
19312 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19313 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19314 #endif /* KEEP_OLD_VPN_COMMANDS */
19316 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19318 /* "exit-address-family" command. */
19319 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19320 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19321 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19322 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19323 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19324 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19325 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19326 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19327 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19328 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19329 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19331 /* BGP retain all route-target */
19332 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19333 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19335 /* "clear ip bgp commands" */
19336 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19338 /* clear ip bgp prefix */
19339 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19340 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19341 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19343 /* "show [ip] bgp summary" commands. */
19344 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19345 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19346 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19347 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19348 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19349 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19350 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19352 /* "show [ip] bgp neighbors" commands. */
19353 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19355 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19357 /* "show [ip] bgp peer-group" commands. */
19358 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19360 /* "show [ip] bgp paths" commands. */
19361 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19363 /* "show [ip] bgp community" commands. */
19364 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19366 /* "show ip bgp large-community" commands. */
19367 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19368 /* "show [ip] bgp attribute-info" commands. */
19369 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19370 /* "show [ip] bgp route-leak" command */
19371 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19373 /* "redistribute" commands. */
19374 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19375 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19376 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19377 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19378 install_element(BGP_NODE
,
19379 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19380 install_element(BGP_NODE
,
19381 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19382 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19383 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19384 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19385 install_element(BGP_NODE
,
19386 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19387 install_element(BGP_NODE
,
19388 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19389 install_element(BGP_NODE
,
19390 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19391 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19392 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19393 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19394 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19395 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19396 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19397 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19398 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19399 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19400 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19401 install_element(BGP_IPV4_NODE
,
19402 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19403 install_element(BGP_IPV4_NODE
,
19404 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19405 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19406 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19407 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19408 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19409 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19410 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19412 /* import|export vpn [route-map RMAP_NAME] */
19413 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19414 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19416 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19417 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19419 /* ttl_security commands */
19420 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19421 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19423 /* "show [ip] bgp memory" commands. */
19424 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19426 /* "show bgp martian next-hop" */
19427 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19429 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19431 /* "show [ip] bgp views" commands. */
19432 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19434 /* "show [ip] bgp vrfs" commands. */
19435 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19437 /* Community-list. */
19438 community_list_vty();
19440 community_alias_vty();
19442 /* vpn-policy commands */
19443 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19444 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19445 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19446 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19447 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19448 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19449 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19450 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19451 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19452 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19453 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19454 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19456 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19457 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19459 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19460 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19461 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19462 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19463 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19464 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19465 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19466 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19467 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19468 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19470 /* tcp-mss command */
19471 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19472 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19474 /* srv6 commands */
19475 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19476 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19477 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19478 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19479 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19480 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19481 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19484 #include "memory.h"
19485 #include "bgp_regex.h"
19486 #include "bgp_clist.h"
19487 #include "bgp_ecommunity.h"
19489 /* VTY functions. */
19491 /* Direction value to string conversion. */
19492 static const char *community_direct_str(int direct
)
19495 case COMMUNITY_DENY
:
19497 case COMMUNITY_PERMIT
:
19504 /* Display error string. */
19505 static void community_list_perror(struct vty
*vty
, int ret
)
19508 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19509 vty_out(vty
, "%% Can't find community-list\n");
19511 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19512 vty_out(vty
, "%% Malformed community-list value\n");
19514 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19516 "%% Community name conflict, previously defined as standard community\n");
19518 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19520 "%% Community name conflict, previously defined as expanded community\n");
19525 /* "community-list" keyword help string. */
19526 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19528 /*community-list standard */
19529 DEFUN (community_list_standard
,
19530 bgp_community_list_standard_cmd
,
19531 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19534 "Community list number (standard)\n"
19535 "Add an standard community-list entry\n"
19536 "Community list name\n"
19537 "Sequence number of an entry\n"
19538 "Sequence number\n"
19539 "Specify community to reject\n"
19540 "Specify community to accept\n"
19543 char *cl_name_or_number
= NULL
;
19546 int style
= COMMUNITY_LIST_STANDARD
;
19549 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19550 seq
= argv
[idx
]->arg
;
19553 argv_find(argv
, argc
, "(1-99)", &idx
);
19554 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19555 cl_name_or_number
= argv
[idx
]->arg
;
19556 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19558 argv_find(argv
, argc
, "AA:NN", &idx
);
19559 char *str
= argv_concat(argv
, argc
, idx
);
19561 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19564 XFREE(MTYPE_TMP
, str
);
19567 /* Display error string. */
19568 community_list_perror(vty
, ret
);
19569 return CMD_WARNING_CONFIG_FAILED
;
19572 return CMD_SUCCESS
;
19575 DEFUN (no_community_list_standard_all
,
19576 no_bgp_community_list_standard_all_cmd
,
19577 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19581 "Community list number (standard)\n"
19582 "Add an standard community-list entry\n"
19583 "Community list name\n"
19584 "Sequence number of an entry\n"
19585 "Sequence number\n"
19586 "Specify community to reject\n"
19587 "Specify community to accept\n"
19590 char *cl_name_or_number
= NULL
;
19593 int style
= COMMUNITY_LIST_STANDARD
;
19597 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19598 seq
= argv
[idx
]->arg
;
19601 argv_find(argv
, argc
, "permit", &idx
);
19602 argv_find(argv
, argc
, "deny", &idx
);
19605 direct
= argv_find(argv
, argc
, "permit", &idx
)
19610 argv_find(argv
, argc
, "AA:NN", &idx
);
19611 str
= argv_concat(argv
, argc
, idx
);
19615 argv_find(argv
, argc
, "(1-99)", &idx
);
19616 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19617 cl_name_or_number
= argv
[idx
]->arg
;
19619 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19622 XFREE(MTYPE_TMP
, str
);
19625 community_list_perror(vty
, ret
);
19626 return CMD_WARNING_CONFIG_FAILED
;
19629 return CMD_SUCCESS
;
19632 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19633 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19634 NO_STR BGP_STR COMMUNITY_LIST_STR
19635 "Community list number (standard)\n"
19636 "Add an standard community-list entry\n"
19637 "Community list name\n")
19639 /*community-list expanded */
19640 DEFUN (community_list_expanded_all
,
19641 bgp_community_list_expanded_all_cmd
,
19642 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19645 "Community list number (expanded)\n"
19646 "Add an expanded community-list entry\n"
19647 "Community list name\n"
19648 "Sequence number of an entry\n"
19649 "Sequence number\n"
19650 "Specify community to reject\n"
19651 "Specify community to accept\n"
19654 char *cl_name_or_number
= NULL
;
19657 int style
= COMMUNITY_LIST_EXPANDED
;
19660 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19661 seq
= argv
[idx
]->arg
;
19665 argv_find(argv
, argc
, "(100-500)", &idx
);
19666 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19667 cl_name_or_number
= argv
[idx
]->arg
;
19668 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19670 argv_find(argv
, argc
, "AA:NN", &idx
);
19671 char *str
= argv_concat(argv
, argc
, idx
);
19673 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19676 XFREE(MTYPE_TMP
, str
);
19679 /* Display error string. */
19680 community_list_perror(vty
, ret
);
19681 return CMD_WARNING_CONFIG_FAILED
;
19684 return CMD_SUCCESS
;
19687 DEFUN (no_community_list_expanded_all
,
19688 no_bgp_community_list_expanded_all_cmd
,
19689 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19693 "Community list number (expanded)\n"
19694 "Add an expanded community-list entry\n"
19695 "Community list name\n"
19696 "Sequence number of an entry\n"
19697 "Sequence number\n"
19698 "Specify community to reject\n"
19699 "Specify community to accept\n"
19702 char *cl_name_or_number
= NULL
;
19706 int style
= COMMUNITY_LIST_EXPANDED
;
19709 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19710 seq
= argv
[idx
]->arg
;
19713 argv_find(argv
, argc
, "permit", &idx
);
19714 argv_find(argv
, argc
, "deny", &idx
);
19717 direct
= argv_find(argv
, argc
, "permit", &idx
)
19722 argv_find(argv
, argc
, "AA:NN", &idx
);
19723 str
= argv_concat(argv
, argc
, idx
);
19727 argv_find(argv
, argc
, "(100-500)", &idx
);
19728 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19729 cl_name_or_number
= argv
[idx
]->arg
;
19731 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19734 XFREE(MTYPE_TMP
, str
);
19737 community_list_perror(vty
, ret
);
19738 return CMD_WARNING_CONFIG_FAILED
;
19741 return CMD_SUCCESS
;
19744 ALIAS(no_community_list_expanded_all
,
19745 no_bgp_community_list_expanded_all_list_cmd
,
19746 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19747 NO_STR BGP_STR COMMUNITY_LIST_STR
19748 "Community list number (expanded)\n"
19749 "Add an expanded community-list entry\n"
19750 "Community list name\n")
19752 /* Return configuration string of community-list entry. */
19753 static const char *community_list_config_str(struct community_entry
*entry
)
19760 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19761 str
= community_str(entry
->u
.com
, false, false);
19762 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19763 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19765 str
= entry
->config
;
19770 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19772 struct community_entry
*entry
;
19774 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19775 if (entry
== list
->head
) {
19776 if (all_digit(list
->name
))
19777 vty_out(vty
, "Community %s list %s\n",
19778 entry
->style
== COMMUNITY_LIST_STANDARD
19780 : "(expanded) access",
19783 vty_out(vty
, "Named Community %s list %s\n",
19784 entry
->style
== COMMUNITY_LIST_STANDARD
19790 vty_out(vty
, " %s\n",
19791 community_direct_str(entry
->direct
));
19793 vty_out(vty
, " %s %s\n",
19794 community_direct_str(entry
->direct
),
19795 community_list_config_str(entry
));
19799 DEFUN (show_community_list
,
19800 show_bgp_community_list_cmd
,
19801 "show bgp community-list",
19804 "List community-list\n")
19806 struct community_list
*list
;
19807 struct community_list_master
*cm
;
19809 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19811 return CMD_SUCCESS
;
19813 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19814 community_list_show(vty
, list
);
19816 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19817 community_list_show(vty
, list
);
19819 return CMD_SUCCESS
;
19822 DEFUN (show_community_list_arg
,
19823 show_bgp_community_list_arg_cmd
,
19824 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19827 "List community-list\n"
19828 "Community-list number\n"
19829 "Community-list name\n"
19830 "Detailed information on community-list\n")
19832 int idx_comm_list
= 3;
19833 struct community_list
*list
;
19835 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19836 COMMUNITY_LIST_MASTER
);
19838 vty_out(vty
, "%% Can't find community-list\n");
19839 return CMD_WARNING
;
19842 community_list_show(vty
, list
);
19844 return CMD_SUCCESS
;
19848 * Large Community code.
19850 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19851 struct cmd_token
**argv
, int style
,
19852 int reject_all_digit_name
)
19861 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19862 seq
= argv
[idx
]->arg
;
19865 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19868 /* All digit name check. */
19870 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19871 argv_find(argv
, argc
, "(1-99)", &idx
);
19872 argv_find(argv
, argc
, "(100-500)", &idx
);
19873 cl_name
= argv
[idx
]->arg
;
19874 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19875 vty_out(vty
, "%% Community name cannot have all digits\n");
19876 return CMD_WARNING_CONFIG_FAILED
;
19880 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19881 argv_find(argv
, argc
, "LINE", &idx
);
19882 /* Concat community string argument. */
19884 str
= argv_concat(argv
, argc
, idx
);
19888 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19890 /* Free temporary community list string allocated by
19892 XFREE(MTYPE_TMP
, str
);
19895 community_list_perror(vty
, ret
);
19896 return CMD_WARNING_CONFIG_FAILED
;
19898 return CMD_SUCCESS
;
19901 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19902 struct cmd_token
**argv
, int style
)
19910 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19911 seq
= argv
[idx
]->arg
;
19914 argv_find(argv
, argc
, "permit", &idx
);
19915 argv_find(argv
, argc
, "deny", &idx
);
19918 /* Check the list direct. */
19919 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19920 direct
= COMMUNITY_PERMIT
;
19922 direct
= COMMUNITY_DENY
;
19925 argv_find(argv
, argc
, "LINE", &idx
);
19926 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19927 /* Concat community string argument. */
19928 str
= argv_concat(argv
, argc
, idx
);
19932 argv_find(argv
, argc
, "(1-99)", &idx
);
19933 argv_find(argv
, argc
, "(100-500)", &idx
);
19934 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19936 /* Unset community list. */
19937 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19940 /* Free temporary community list string allocated by
19942 XFREE(MTYPE_TMP
, str
);
19945 community_list_perror(vty
, ret
);
19946 return CMD_WARNING_CONFIG_FAILED
;
19949 return CMD_SUCCESS
;
19952 /* "large-community-list" keyword help string. */
19953 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19954 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19956 DEFUN (lcommunity_list_standard
,
19957 bgp_lcommunity_list_standard_cmd
,
19958 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19960 LCOMMUNITY_LIST_STR
19961 "Large Community list number (standard)\n"
19962 "Sequence number of an entry\n"
19963 "Sequence number\n"
19964 "Specify large community to reject\n"
19965 "Specify large community to accept\n"
19966 LCOMMUNITY_VAL_STR
)
19968 return lcommunity_list_set_vty(vty
, argc
, argv
,
19969 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19972 DEFUN (lcommunity_list_expanded
,
19973 bgp_lcommunity_list_expanded_cmd
,
19974 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19976 LCOMMUNITY_LIST_STR
19977 "Large Community list number (expanded)\n"
19978 "Sequence number of an entry\n"
19979 "Sequence number\n"
19980 "Specify large community to reject\n"
19981 "Specify large community to accept\n"
19982 "An ordered list as a regular-expression\n")
19984 return lcommunity_list_set_vty(vty
, argc
, argv
,
19985 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19988 DEFUN (lcommunity_list_name_standard
,
19989 bgp_lcommunity_list_name_standard_cmd
,
19990 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19992 LCOMMUNITY_LIST_STR
19993 "Specify standard large-community-list\n"
19994 "Large Community list name\n"
19995 "Sequence number of an entry\n"
19996 "Sequence number\n"
19997 "Specify large community to reject\n"
19998 "Specify large community to accept\n"
19999 LCOMMUNITY_VAL_STR
)
20001 return lcommunity_list_set_vty(vty
, argc
, argv
,
20002 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20005 DEFUN (lcommunity_list_name_expanded
,
20006 bgp_lcommunity_list_name_expanded_cmd
,
20007 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20009 LCOMMUNITY_LIST_STR
20010 "Specify expanded large-community-list\n"
20011 "Large Community list name\n"
20012 "Sequence number of an entry\n"
20013 "Sequence number\n"
20014 "Specify large community to reject\n"
20015 "Specify large community to accept\n"
20016 "An ordered list as a regular-expression\n")
20018 return lcommunity_list_set_vty(vty
, argc
, argv
,
20019 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20022 DEFUN (no_lcommunity_list_all
,
20023 no_bgp_lcommunity_list_all_cmd
,
20024 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20027 LCOMMUNITY_LIST_STR
20028 "Large Community list number (standard)\n"
20029 "Large Community list number (expanded)\n"
20030 "Large Community list name\n")
20032 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20033 LARGE_COMMUNITY_LIST_STANDARD
);
20036 DEFUN (no_lcommunity_list_name_standard_all
,
20037 no_bgp_lcommunity_list_name_standard_all_cmd
,
20038 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20041 LCOMMUNITY_LIST_STR
20042 "Specify standard large-community-list\n"
20043 "Large Community list name\n")
20045 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20046 LARGE_COMMUNITY_LIST_STANDARD
);
20049 DEFUN (no_lcommunity_list_name_expanded_all
,
20050 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20051 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20054 LCOMMUNITY_LIST_STR
20055 "Specify expanded large-community-list\n"
20056 "Large Community list name\n")
20058 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20059 LARGE_COMMUNITY_LIST_EXPANDED
);
20062 DEFUN (no_lcommunity_list_standard
,
20063 no_bgp_lcommunity_list_standard_cmd
,
20064 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20067 LCOMMUNITY_LIST_STR
20068 "Large Community list number (standard)\n"
20069 "Sequence number of an entry\n"
20070 "Sequence number\n"
20071 "Specify large community to reject\n"
20072 "Specify large community to accept\n"
20073 LCOMMUNITY_VAL_STR
)
20075 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20076 LARGE_COMMUNITY_LIST_STANDARD
);
20079 DEFUN (no_lcommunity_list_expanded
,
20080 no_bgp_lcommunity_list_expanded_cmd
,
20081 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20084 LCOMMUNITY_LIST_STR
20085 "Large Community list number (expanded)\n"
20086 "Sequence number of an entry\n"
20087 "Sequence number\n"
20088 "Specify large community to reject\n"
20089 "Specify large community to accept\n"
20090 "An ordered list as a regular-expression\n")
20092 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20093 LARGE_COMMUNITY_LIST_EXPANDED
);
20096 DEFUN (no_lcommunity_list_name_standard
,
20097 no_bgp_lcommunity_list_name_standard_cmd
,
20098 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20101 LCOMMUNITY_LIST_STR
20102 "Specify standard large-community-list\n"
20103 "Large Community list name\n"
20104 "Sequence number of an entry\n"
20105 "Sequence number\n"
20106 "Specify large community to reject\n"
20107 "Specify large community to accept\n"
20108 LCOMMUNITY_VAL_STR
)
20110 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20111 LARGE_COMMUNITY_LIST_STANDARD
);
20114 DEFUN (no_lcommunity_list_name_expanded
,
20115 no_bgp_lcommunity_list_name_expanded_cmd
,
20116 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20119 LCOMMUNITY_LIST_STR
20120 "Specify expanded large-community-list\n"
20121 "Large community list name\n"
20122 "Sequence number of an entry\n"
20123 "Sequence number\n"
20124 "Specify large community to reject\n"
20125 "Specify large community to accept\n"
20126 "An ordered list as a regular-expression\n")
20128 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20129 LARGE_COMMUNITY_LIST_EXPANDED
);
20132 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20134 struct community_entry
*entry
;
20136 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20137 if (entry
== list
->head
) {
20138 if (all_digit(list
->name
))
20139 vty_out(vty
, "Large community %s list %s\n",
20141 LARGE_COMMUNITY_LIST_STANDARD
20143 : "(expanded) access",
20147 "Named large community %s list %s\n",
20149 LARGE_COMMUNITY_LIST_STANDARD
20155 vty_out(vty
, " %s\n",
20156 community_direct_str(entry
->direct
));
20158 vty_out(vty
, " %s %s\n",
20159 community_direct_str(entry
->direct
),
20160 community_list_config_str(entry
));
20164 DEFUN (show_lcommunity_list
,
20165 show_bgp_lcommunity_list_cmd
,
20166 "show bgp large-community-list",
20169 "List large-community list\n")
20171 struct community_list
*list
;
20172 struct community_list_master
*cm
;
20174 cm
= community_list_master_lookup(bgp_clist
,
20175 LARGE_COMMUNITY_LIST_MASTER
);
20177 return CMD_SUCCESS
;
20179 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20180 lcommunity_list_show(vty
, list
);
20182 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20183 lcommunity_list_show(vty
, list
);
20185 return CMD_SUCCESS
;
20188 DEFUN (show_lcommunity_list_arg
,
20189 show_bgp_lcommunity_list_arg_cmd
,
20190 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20193 "List large-community list\n"
20194 "Large-community-list number\n"
20195 "Large-community-list name\n"
20196 "Detailed information on large-community-list\n")
20198 struct community_list
*list
;
20200 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20201 LARGE_COMMUNITY_LIST_MASTER
);
20203 vty_out(vty
, "%% Can't find large-community-list\n");
20204 return CMD_WARNING
;
20207 lcommunity_list_show(vty
, list
);
20209 return CMD_SUCCESS
;
20212 /* "extcommunity-list" keyword help string. */
20213 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20214 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20216 DEFUN (extcommunity_list_standard
,
20217 bgp_extcommunity_list_standard_cmd
,
20218 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20220 EXTCOMMUNITY_LIST_STR
20221 "Extended Community list number (standard)\n"
20222 "Specify standard extcommunity-list\n"
20223 "Community list name\n"
20224 "Sequence number of an entry\n"
20225 "Sequence number\n"
20226 "Specify community to reject\n"
20227 "Specify community to accept\n"
20228 EXTCOMMUNITY_VAL_STR
)
20230 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20232 char *cl_number_or_name
= NULL
;
20237 argv_find(argv
, argc
, "(1-99)", &idx
);
20238 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20239 cl_number_or_name
= argv
[idx
]->arg
;
20241 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20242 seq
= argv
[idx
]->arg
;
20244 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20246 argv_find(argv
, argc
, "AA:NN", &idx
);
20247 char *str
= argv_concat(argv
, argc
, idx
);
20249 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20252 XFREE(MTYPE_TMP
, str
);
20255 community_list_perror(vty
, ret
);
20256 return CMD_WARNING_CONFIG_FAILED
;
20259 return CMD_SUCCESS
;
20262 DEFUN (extcommunity_list_name_expanded
,
20263 bgp_extcommunity_list_name_expanded_cmd
,
20264 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20266 EXTCOMMUNITY_LIST_STR
20267 "Extended Community list number (expanded)\n"
20268 "Specify expanded extcommunity-list\n"
20269 "Extended Community list name\n"
20270 "Sequence number of an entry\n"
20271 "Sequence number\n"
20272 "Specify community to reject\n"
20273 "Specify community to accept\n"
20274 "An ordered list as a regular-expression\n")
20276 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20278 char *cl_number_or_name
= NULL
;
20282 argv_find(argv
, argc
, "(100-500)", &idx
);
20283 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20284 cl_number_or_name
= argv
[idx
]->arg
;
20286 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20287 seq
= argv
[idx
]->arg
;
20289 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20291 argv_find(argv
, argc
, "LINE", &idx
);
20292 char *str
= argv_concat(argv
, argc
, idx
);
20294 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20297 XFREE(MTYPE_TMP
, str
);
20300 community_list_perror(vty
, ret
);
20301 return CMD_WARNING_CONFIG_FAILED
;
20304 return CMD_SUCCESS
;
20307 DEFUN (no_extcommunity_list_standard_all
,
20308 no_bgp_extcommunity_list_standard_all_cmd
,
20309 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20312 EXTCOMMUNITY_LIST_STR
20313 "Extended Community list number (standard)\n"
20314 "Specify standard extcommunity-list\n"
20315 "Community list name\n"
20316 "Sequence number of an entry\n"
20317 "Sequence number\n"
20318 "Specify community to reject\n"
20319 "Specify community to accept\n"
20320 EXTCOMMUNITY_VAL_STR
)
20322 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20324 char *cl_number_or_name
= NULL
;
20329 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20330 seq
= argv
[idx
]->arg
;
20333 argv_find(argv
, argc
, "permit", &idx
);
20334 argv_find(argv
, argc
, "deny", &idx
);
20336 direct
= argv_find(argv
, argc
, "permit", &idx
)
20341 argv_find(argv
, argc
, "AA:NN", &idx
);
20342 str
= argv_concat(argv
, argc
, idx
);
20346 argv_find(argv
, argc
, "(1-99)", &idx
);
20347 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20348 cl_number_or_name
= argv
[idx
]->arg
;
20350 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20351 seq
, direct
, style
);
20353 XFREE(MTYPE_TMP
, str
);
20356 community_list_perror(vty
, ret
);
20357 return CMD_WARNING_CONFIG_FAILED
;
20360 return CMD_SUCCESS
;
20363 ALIAS(no_extcommunity_list_standard_all
,
20364 no_bgp_extcommunity_list_standard_all_list_cmd
,
20365 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20366 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20367 "Extended Community list number (standard)\n"
20368 "Specify standard extcommunity-list\n"
20369 "Community list name\n")
20371 DEFUN (no_extcommunity_list_expanded_all
,
20372 no_bgp_extcommunity_list_expanded_all_cmd
,
20373 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20376 EXTCOMMUNITY_LIST_STR
20377 "Extended Community list number (expanded)\n"
20378 "Specify expanded extcommunity-list\n"
20379 "Extended Community list name\n"
20380 "Sequence number of an entry\n"
20381 "Sequence number\n"
20382 "Specify community to reject\n"
20383 "Specify community to accept\n"
20384 "An ordered list as a regular-expression\n")
20386 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20388 char *cl_number_or_name
= NULL
;
20393 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20394 seq
= argv
[idx
]->arg
;
20397 argv_find(argv
, argc
, "permit", &idx
);
20398 argv_find(argv
, argc
, "deny", &idx
);
20401 direct
= argv_find(argv
, argc
, "permit", &idx
)
20406 argv_find(argv
, argc
, "LINE", &idx
);
20407 str
= argv_concat(argv
, argc
, idx
);
20411 argv_find(argv
, argc
, "(100-500)", &idx
);
20412 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20413 cl_number_or_name
= argv
[idx
]->arg
;
20415 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20416 seq
, direct
, style
);
20418 XFREE(MTYPE_TMP
, str
);
20421 community_list_perror(vty
, ret
);
20422 return CMD_WARNING_CONFIG_FAILED
;
20425 return CMD_SUCCESS
;
20428 ALIAS(no_extcommunity_list_expanded_all
,
20429 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20430 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20431 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20432 "Extended Community list number (expanded)\n"
20433 "Specify expanded extcommunity-list\n"
20434 "Extended Community list name\n")
20436 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20438 struct community_entry
*entry
;
20440 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20441 if (entry
== list
->head
) {
20442 if (all_digit(list
->name
))
20443 vty_out(vty
, "Extended community %s list %s\n",
20444 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20446 : "(expanded) access",
20450 "Named extended community %s list %s\n",
20451 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20457 vty_out(vty
, " %s\n",
20458 community_direct_str(entry
->direct
));
20460 vty_out(vty
, " %s %s\n",
20461 community_direct_str(entry
->direct
),
20462 community_list_config_str(entry
));
20466 DEFUN (show_extcommunity_list
,
20467 show_bgp_extcommunity_list_cmd
,
20468 "show bgp extcommunity-list",
20471 "List extended-community list\n")
20473 struct community_list
*list
;
20474 struct community_list_master
*cm
;
20476 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20478 return CMD_SUCCESS
;
20480 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20481 extcommunity_list_show(vty
, list
);
20483 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20484 extcommunity_list_show(vty
, list
);
20486 return CMD_SUCCESS
;
20489 DEFUN (show_extcommunity_list_arg
,
20490 show_bgp_extcommunity_list_arg_cmd
,
20491 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20494 "List extended-community list\n"
20495 "Extcommunity-list number\n"
20496 "Extcommunity-list name\n"
20497 "Detailed information on extcommunity-list\n")
20499 int idx_comm_list
= 3;
20500 struct community_list
*list
;
20502 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20503 EXTCOMMUNITY_LIST_MASTER
);
20505 vty_out(vty
, "%% Can't find extcommunity-list\n");
20506 return CMD_WARNING
;
20509 extcommunity_list_show(vty
, list
);
20511 return CMD_SUCCESS
;
20514 /* Display community-list and extcommunity-list configuration. */
20515 static int community_list_config_write(struct vty
*vty
)
20517 struct community_list
*list
;
20518 struct community_entry
*entry
;
20519 struct community_list_master
*cm
;
20522 /* Community-list. */
20523 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20525 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20526 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20528 "bgp community-list %s seq %" PRId64
" %s %s\n",
20529 list
->name
, entry
->seq
,
20530 community_direct_str(entry
->direct
),
20531 community_list_config_str(entry
));
20534 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20535 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20537 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20538 entry
->style
== COMMUNITY_LIST_STANDARD
20541 list
->name
, entry
->seq
,
20542 community_direct_str(entry
->direct
),
20543 community_list_config_str(entry
));
20547 /* Extcommunity-list. */
20548 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20550 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20551 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20553 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20554 list
->name
, entry
->seq
,
20555 community_direct_str(entry
->direct
),
20556 community_list_config_str(entry
));
20559 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20560 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20562 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20563 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20566 list
->name
, entry
->seq
,
20567 community_direct_str(entry
->direct
),
20568 community_list_config_str(entry
));
20573 /* lcommunity-list. */
20574 cm
= community_list_master_lookup(bgp_clist
,
20575 LARGE_COMMUNITY_LIST_MASTER
);
20577 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20578 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20580 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20581 list
->name
, entry
->seq
,
20582 community_direct_str(entry
->direct
),
20583 community_list_config_str(entry
));
20586 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20587 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20589 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20591 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20594 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20595 community_list_config_str(entry
));
20602 static int community_list_config_write(struct vty
*vty
);
20603 static struct cmd_node community_list_node
= {
20604 .name
= "community list",
20605 .node
= COMMUNITY_LIST_NODE
,
20607 .config_write
= community_list_config_write
,
20610 static void community_list_vty(void)
20612 install_node(&community_list_node
);
20614 /* Community-list. */
20615 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20616 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20617 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20618 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20619 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20620 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20621 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20622 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20624 /* Extcommunity-list. */
20625 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20626 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20627 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20628 install_element(CONFIG_NODE
,
20629 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20630 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20631 install_element(CONFIG_NODE
,
20632 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20633 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20634 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20636 /* Large Community List */
20637 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20638 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20639 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20640 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20641 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20642 install_element(CONFIG_NODE
,
20643 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20644 install_element(CONFIG_NODE
,
20645 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20646 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20647 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20648 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20649 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20650 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20651 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20653 bgp_community_list_command_completion_setup();
20656 static struct cmd_node community_alias_node
= {
20657 .name
= "community alias",
20658 .node
= COMMUNITY_ALIAS_NODE
,
20660 .config_write
= bgp_community_alias_write
,
20663 void community_alias_vty(void)
20665 install_node(&community_alias_node
);
20667 /* Community-list. */
20668 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20670 bgp_community_alias_command_completion_setup();