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 },
127 DEFINE_HOOK(bgp_inst_config_write
,
128 (struct bgp
*bgp
, struct vty
*vty
),
130 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
131 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
133 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
134 struct prefix
*range
, int exact
);
136 /* Show BGP peer's information. */
146 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
147 struct prefix
*range
, int exact
);
149 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
154 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
157 afi_t afi
, bool use_json
);
159 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
165 return BGP_IPV4_NODE
;
167 return BGP_IPV4M_NODE
;
168 case SAFI_LABELED_UNICAST
:
169 return BGP_IPV4L_NODE
;
171 return BGP_VPNV4_NODE
;
173 return BGP_FLOWSPECV4_NODE
;
176 return BGP_IPV4_NODE
;
181 return BGP_IPV6_NODE
;
183 return BGP_IPV6M_NODE
;
184 case SAFI_LABELED_UNICAST
:
185 return BGP_IPV6L_NODE
;
187 return BGP_VPNV6_NODE
;
189 return BGP_FLOWSPECV6_NODE
;
192 return BGP_IPV4_NODE
;
195 return BGP_EVPN_NODE
;
198 // We should never be here but to clarify the switch statement..
199 return BGP_IPV4_NODE
;
202 // Impossible to happen
203 return BGP_IPV4_NODE
;
206 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
209 if (safi
== SAFI_UNICAST
)
210 return "IPv4 Unicast";
211 if (safi
== SAFI_MULTICAST
)
212 return "IPv4 Multicast";
213 if (safi
== SAFI_LABELED_UNICAST
)
214 return "IPv4 Labeled Unicast";
215 if (safi
== SAFI_MPLS_VPN
)
217 if (safi
== SAFI_ENCAP
)
219 if (safi
== SAFI_FLOWSPEC
)
220 return "IPv4 Flowspec";
221 } else if (afi
== AFI_IP6
) {
222 if (safi
== SAFI_UNICAST
)
223 return "IPv6 Unicast";
224 if (safi
== SAFI_MULTICAST
)
225 return "IPv6 Multicast";
226 if (safi
== SAFI_LABELED_UNICAST
)
227 return "IPv6 Labeled Unicast";
228 if (safi
== SAFI_MPLS_VPN
)
230 if (safi
== SAFI_ENCAP
)
232 if (safi
== SAFI_FLOWSPEC
)
233 return "IPv6 Flowspec";
234 } else if (afi
== AFI_L2VPN
) {
235 if (safi
== SAFI_EVPN
)
243 * Please note that we have intentionally camelCased
244 * the return strings here. So if you want
245 * to use this function, please ensure you
246 * are doing this within json output
248 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
251 if (safi
== SAFI_UNICAST
)
252 return "ipv4Unicast";
253 if (safi
== SAFI_MULTICAST
)
254 return "ipv4Multicast";
255 if (safi
== SAFI_LABELED_UNICAST
)
256 return "ipv4LabeledUnicast";
257 if (safi
== SAFI_MPLS_VPN
)
259 if (safi
== SAFI_ENCAP
)
261 if (safi
== SAFI_FLOWSPEC
)
262 return "ipv4Flowspec";
263 } else if (afi
== AFI_IP6
) {
264 if (safi
== SAFI_UNICAST
)
265 return "ipv6Unicast";
266 if (safi
== SAFI_MULTICAST
)
267 return "ipv6Multicast";
268 if (safi
== SAFI_LABELED_UNICAST
)
269 return "ipv6LabeledUnicast";
270 if (safi
== SAFI_MPLS_VPN
)
272 if (safi
== SAFI_ENCAP
)
274 if (safi
== SAFI_FLOWSPEC
)
275 return "ipv6Flowspec";
276 } else if (afi
== AFI_L2VPN
) {
277 if (safi
== SAFI_EVPN
)
284 /* unset srv6 locator */
285 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
288 struct listnode
*node
, *nnode
;
289 struct srv6_locator_chunk
*chunk
;
290 struct bgp_srv6_function
*func
;
292 struct in6_addr
*tovpn_sid
;
294 /* release chunk notification via ZAPI */
295 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
296 bgp
->srv6_locator_name
);
301 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
))
302 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
304 /* refresh functions */
305 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
))
306 listnode_delete(bgp
->srv6_functions
, func
);
308 /* refresh tovpn_sid */
309 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
310 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
313 /* refresh vpnv4 tovpn_sid */
314 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
;
316 XFREE(MTYPE_BGP_SRV6_SID
,
317 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
319 /* refresh vpnv6 tovpn_sid */
320 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
;
322 XFREE(MTYPE_BGP_SRV6_SID
,
323 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
326 /* update vpn bgp processes */
327 vpn_leak_postchange_all();
329 /* clear locator name */
330 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
335 /* Utility function to get address family from current node. */
336 afi_t
bgp_node_afi(struct vty
*vty
)
344 case BGP_FLOWSPECV6_NODE
:
357 /* Utility function to get subsequent address family from current
359 safi_t
bgp_node_safi(struct vty
*vty
)
365 safi
= SAFI_MPLS_VPN
;
369 safi
= SAFI_MULTICAST
;
376 safi
= SAFI_LABELED_UNICAST
;
378 case BGP_FLOWSPECV4_NODE
:
379 case BGP_FLOWSPECV6_NODE
:
380 safi
= SAFI_FLOWSPEC
;
390 * Converts an AFI in string form to afi_t
392 * @param afi string, one of
396 * @return the corresponding afi_t
398 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
400 afi_t afi
= AFI_MAX
; /* unknown */
401 if (strmatch(afi_str
, "ipv4"))
403 else if (strmatch(afi_str
, "ipv6"))
405 else if (strmatch(afi_str
, "l2vpn"))
410 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
414 if (argv_find(argv
, argc
, "ipv4", index
)) {
418 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
422 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
430 /* supports <unicast|multicast|vpn|labeled-unicast> */
431 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
433 safi_t safi
= SAFI_MAX
; /* unknown */
434 if (strmatch(safi_str
, "multicast"))
435 safi
= SAFI_MULTICAST
;
436 else if (strmatch(safi_str
, "unicast"))
438 else if (strmatch(safi_str
, "vpn"))
439 safi
= SAFI_MPLS_VPN
;
440 else if (strmatch(safi_str
, "evpn"))
442 else if (strmatch(safi_str
, "labeled-unicast"))
443 safi
= SAFI_LABELED_UNICAST
;
444 else if (strmatch(safi_str
, "flowspec"))
445 safi
= SAFI_FLOWSPEC
;
449 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
453 if (argv_find(argv
, argc
, "unicast", index
)) {
456 *safi
= SAFI_UNICAST
;
457 } else if (argv_find(argv
, argc
, "multicast", index
)) {
460 *safi
= SAFI_MULTICAST
;
461 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
464 *safi
= SAFI_LABELED_UNICAST
;
465 } else if (argv_find(argv
, argc
, "vpn", index
)) {
468 *safi
= SAFI_MPLS_VPN
;
469 } else if (argv_find(argv
, argc
, "evpn", index
)) {
473 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
476 *safi
= SAFI_FLOWSPEC
;
482 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
485 * address-family identifier
488 * subsequent address-family identifier
491 * default_af string corresponding to the supplied afi/safi pair.
492 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
495 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
501 return "ipv4-unicast";
503 return "ipv4-multicast";
508 case SAFI_LABELED_UNICAST
:
509 return "ipv4-labeled-unicast";
511 return "ipv4-flowspec";
513 return "unknown-afi/safi";
519 return "ipv6-unicast";
521 return "ipv6-multicast";
526 case SAFI_LABELED_UNICAST
:
527 return "ipv6-labeled-unicast";
529 return "ipv6-flowspec";
531 return "unknown-afi/safi";
539 return "unknown-afi/safi";
543 return "unknown-afi/safi";
545 /* all AFIs are accounted for above, so this shouldn't happen */
546 return "unknown-afi/safi";
549 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
550 enum bgp_instance_type inst_type
)
552 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
554 if (ret
== BGP_CREATED
) {
555 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
556 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
558 if (DFLT_BGP_IMPORT_CHECK
)
559 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
560 if (DFLT_BGP_SHOW_HOSTNAME
)
561 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
562 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
563 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
564 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
565 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
566 if (DFLT_BGP_DETERMINISTIC_MED
)
567 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
568 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
569 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
570 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
571 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
579 * bgp_vty_find_and_parse_afi_safi_bgp
581 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
582 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
583 * to appropriate values for the calling function. This is to allow the
584 * calling function to make decisions appropriate for the show command
585 * that is being parsed.
587 * The show commands are generally of the form:
588 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
589 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
591 * Since we use argv_find if the show command in particular doesn't have:
593 * [<view|vrf> VIEWVRFNAME]
594 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
595 * The command parsing should still be ok.
597 * vty -> The vty for the command so we can output some useful data in
598 * the event of a parse error in the vrf.
599 * argv -> The command tokens
600 * argc -> How many command tokens we have
601 * idx -> The current place in the command, generally should be 0 for this
603 * afi -> The parsed afi if it was included in the show command, returned here
604 * safi -> The parsed safi if it was included in the show command, returned here
605 * bgp -> Pointer to the bgp data structure we need to fill in.
606 * use_json -> json is configured or not
608 * The function returns the correct location in the parse tree for the
611 * Returns 0 for failure to parse correctly, else the idx position of where
612 * it found the last token.
614 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
615 struct cmd_token
**argv
, int argc
,
616 int *idx
, afi_t
*afi
, safi_t
*safi
,
617 struct bgp
**bgp
, bool use_json
)
619 char *vrf_name
= NULL
;
625 if (argv_find(argv
, argc
, "ip", idx
))
628 if (argv_find(argv
, argc
, "view", idx
))
629 vrf_name
= argv
[*idx
+ 1]->arg
;
630 else if (argv_find(argv
, argc
, "vrf", idx
)) {
631 vrf_name
= argv
[*idx
+ 1]->arg
;
632 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
636 if (strmatch(vrf_name
, "all"))
639 *bgp
= bgp_lookup_by_name(vrf_name
);
642 json_object
*json
= NULL
;
643 json
= json_object_new_object();
644 json_object_string_add(
646 "View/Vrf is unknown");
650 vty_out(vty
, "View/Vrf %s is unknown\n",
657 *bgp
= bgp_get_default();
660 json_object
*json
= NULL
;
661 json
= json_object_new_object();
662 json_object_string_add(
664 "Default BGP instance not found");
669 "Default BGP instance not found\n");
675 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
676 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
682 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
684 struct interface
*ifp
= NULL
;
685 struct listnode
*node
;
686 struct bgp_listener
*listener
;
687 union sockunion all_su
;
689 if (su
->sa
.sa_family
== AF_INET
) {
690 (void)str2sockunion("0.0.0.0", &all_su
);
691 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
692 } else if (su
->sa
.sa_family
== AF_INET6
) {
693 (void)str2sockunion("::", &all_su
);
694 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
695 su
->sin6
.sin6_scope_id
,
700 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
701 if (sockunion_family(su
) !=
702 sockunion_family(&listener
->su
))
705 /* If 0.0.0.0/:: is a listener, then treat as self and
708 if (!sockunion_cmp(&listener
->su
, su
) ||
709 !sockunion_cmp(&listener
->su
, &all_su
))
717 /* Utility function for looking up peer from VTY. */
718 /* This is used only for configuration, so disallow if attempted on
719 * a dynamic neighbor.
721 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
723 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
732 ret
= str2sockunion(ip_str
, &su
);
734 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
736 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
739 "%% Malformed address or name: %s\n",
745 peer
= peer_lookup(bgp
, &su
);
748 "%% Specify remote-as or peer-group commands first\n");
751 if (peer_dynamic_neighbor(peer
)) {
753 "%% Operation not allowed on a dynamic neighbor\n");
760 /* Utility function for looking up peer or peer group. */
761 /* This is used only for configuration, so disallow if attempted on
762 * a dynamic neighbor.
764 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
766 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
769 struct peer
*peer
= NULL
;
770 struct peer_group
*group
= NULL
;
776 ret
= str2sockunion(peer_str
, &su
);
778 /* IP address, locate peer. */
779 peer
= peer_lookup(bgp
, &su
);
781 /* Not IP, could match either peer configured on interface or a
783 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
785 group
= peer_group_lookup(bgp
, peer_str
);
789 if (peer_dynamic_neighbor(peer
)) {
791 "%% Operation not allowed on a dynamic neighbor\n");
801 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
806 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
808 const char *str
= NULL
;
813 case BGP_GR_NO_OPERATION
:
815 case BGP_ERR_INVALID_VALUE
:
816 str
= "Invalid value";
818 case BGP_ERR_INVALID_FLAG
:
819 str
= "Invalid flag";
821 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
822 str
= "Peer-group has been shutdown. Activate the peer-group first";
824 case BGP_ERR_PEER_FLAG_CONFLICT
:
825 str
= "Can't set override-capability and strict-capability-match at the same time";
827 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
828 str
= "Specify remote-as or peer-group remote AS first";
830 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
831 str
= "Cannot change the peer-group. Deconfigure first";
833 case BGP_ERR_PEER_GROUP_MISMATCH
:
834 str
= "Peer is not a member of this peer-group";
836 case BGP_ERR_PEER_FILTER_CONFLICT
:
837 str
= "Prefix/distribute list can not co-exist";
839 case BGP_ERR_NOT_INTERNAL_PEER
:
840 str
= "Invalid command. Not an internal neighbor";
842 case BGP_ERR_REMOVE_PRIVATE_AS
:
843 str
= "remove-private-AS cannot be configured for IBGP peers";
845 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
846 str
= "Local-AS allowed only for EBGP peers";
848 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
849 str
= "Cannot have local-as same as BGP AS number";
851 case BGP_ERR_TCPSIG_FAILED
:
852 str
= "Error while applying TCP-Sig to session(s)";
854 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
855 str
= "ebgp-multihop and ttl-security cannot be configured together";
857 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
858 str
= "ttl-security only allowed for EBGP peers";
860 case BGP_ERR_AS_OVERRIDE
:
861 str
= "as-override cannot be configured for IBGP peers";
863 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
864 str
= "Invalid limit for number of dynamic neighbors";
866 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
867 str
= "Dynamic neighbor listen range already exists";
869 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
870 str
= "Operation not allowed on a dynamic neighbor";
872 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
873 str
= "Operation not allowed on a directly connected neighbor";
875 case BGP_ERR_PEER_SAFI_CONFLICT
:
876 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
878 case BGP_ERR_GR_INVALID_CMD
:
879 str
= "The Graceful Restart command used is not valid at this moment.";
881 case BGP_ERR_GR_OPERATION_FAILED
:
882 str
= "The Graceful Restart Operation failed due to an err.";
884 case BGP_ERR_PEER_GROUP_MEMBER
:
885 str
= "Peer-group member cannot override remote-as of peer-group.";
887 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
888 str
= "Peer-group members must be all internal or all external.";
890 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
891 str
= "Range specified cannot be deleted because it is not part of current config.";
893 case BGP_ERR_INSTANCE_MISMATCH
:
894 str
= "Instance specified does not match the current instance.";
896 case BGP_ERR_NO_INTERFACE_CONFIG
:
897 str
= "Interface specified is not being used for interface based peer.";
899 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
900 str
= "No configuration already specified for soft reconfiguration.";
902 case BGP_ERR_AS_MISMATCH
:
903 str
= "BGP is already running.";
905 case BGP_ERR_AF_UNCONFIGURED
:
906 str
= "AFI/SAFI specified is not currently configured.";
908 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS
:
909 str
= "AS specified for local as is the same as the remote as and this is not allowed.";
911 case BGP_ERR_INVALID_AS
:
912 str
= "Confederation AS specified is the same AS as our AS.";
916 vty_out(vty
, "%% %s\n", str
);
917 return CMD_WARNING_CONFIG_FAILED
;
922 /* BGP clear sort. */
931 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
932 safi_t safi
, int error
)
935 case BGP_ERR_AF_UNCONFIGURED
:
937 "%% BGP: Enable %s address family for the neighbor %s\n",
938 get_afi_safi_str(afi
, safi
, false), peer
->host
);
940 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
942 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
950 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
951 struct listnode
**nnode
, enum bgp_clear_type stype
)
956 /* if afi/.safi not specified, spin thru all of them */
957 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
960 enum bgp_af_index index
;
962 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
963 paf
= peer
->peer_af_array
[index
];
967 if (paf
&& paf
->subgroup
)
968 SET_FLAG(paf
->subgroup
->sflags
,
969 SUBGRP_STATUS_FORCE_UPDATES
);
972 tmp_safi
= paf
->safi
;
973 if (!peer
->afc
[tmp_afi
][tmp_safi
])
976 if (stype
== BGP_CLEAR_SOFT_NONE
)
977 ret
= peer_clear(peer
, nnode
);
979 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
982 /* if afi specified and safi not, spin thru safis on this afi */
983 } else if (safi
== SAFI_UNSPEC
) {
986 for (tmp_safi
= SAFI_UNICAST
;
987 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
988 if (!peer
->afc
[afi
][tmp_safi
])
991 paf
= peer_af_find(peer
, afi
, tmp_safi
);
992 if (paf
&& paf
->subgroup
)
993 SET_FLAG(paf
->subgroup
->sflags
,
994 SUBGRP_STATUS_FORCE_UPDATES
);
996 if (stype
== BGP_CLEAR_SOFT_NONE
)
997 ret
= peer_clear(peer
, nnode
);
999 ret
= peer_clear_soft(peer
, afi
,
1002 /* both afi/safi specified, let the caller know if not defined */
1004 if (!peer
->afc
[afi
][safi
])
1007 paf
= peer_af_find(peer
, afi
, safi
);
1008 if (paf
&& paf
->subgroup
)
1009 SET_FLAG(paf
->subgroup
->sflags
,
1010 SUBGRP_STATUS_FORCE_UPDATES
);
1012 if (stype
== BGP_CLEAR_SOFT_NONE
)
1013 ret
= peer_clear(peer
, nnode
);
1015 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1021 /* `clear ip bgp' functions. */
1022 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1023 enum clear_sort sort
, enum bgp_clear_type stype
,
1030 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1032 /* Clear all neighbors. */
1034 * Pass along pointer to next node to peer_clear() when walking all
1035 * nodes on the BGP instance as that may get freed if it is a
1038 if (sort
== clear_all
) {
1039 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1041 bgp_peer_gr_flags_update(peer
);
1043 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1044 gr_router_detected
= true;
1046 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1050 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1053 if (gr_router_detected
1054 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1055 bgp_zebra_send_capabilities(bgp
, false);
1056 } else if (!gr_router_detected
1057 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1058 bgp_zebra_send_capabilities(bgp
, true);
1061 /* This is to apply read-only mode on this clear. */
1062 if (stype
== BGP_CLEAR_SOFT_NONE
)
1063 bgp
->update_delay_over
= 0;
1068 /* Clear specified neighbor. */
1069 if (sort
== clear_peer
) {
1072 /* Make sockunion for lookup. */
1073 ret
= str2sockunion(arg
, &su
);
1075 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1077 peer
= peer_lookup_by_hostname(bgp
, arg
);
1080 "Malformed address or name: %s\n",
1086 peer
= peer_lookup(bgp
, &su
);
1089 "%% BGP: Unknown neighbor - \"%s\"\n",
1095 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1096 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1098 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1100 /* if afi/safi not defined for this peer, let caller know */
1102 ret
= BGP_ERR_AF_UNCONFIGURED
;
1105 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1110 /* Clear all neighbors belonging to a specific peer-group. */
1111 if (sort
== clear_group
) {
1112 struct peer_group
*group
;
1114 group
= peer_group_lookup(bgp
, arg
);
1116 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1120 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1121 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1124 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1131 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1132 get_afi_safi_str(afi
, safi
, false), arg
);
1137 /* Clear all external (eBGP) neighbors. */
1138 if (sort
== clear_external
) {
1139 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1140 if (peer
->sort
== BGP_PEER_IBGP
)
1143 bgp_peer_gr_flags_update(peer
);
1145 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1146 gr_router_detected
= true;
1148 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1151 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1156 if (gr_router_detected
1157 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1158 bgp_zebra_send_capabilities(bgp
, false);
1159 } else if (!gr_router_detected
1160 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1161 bgp_zebra_send_capabilities(bgp
, true);
1166 "%% BGP: No external %s peer is configured\n",
1167 get_afi_safi_str(afi
, safi
, false));
1172 /* Clear all neighbors belonging to a specific AS. */
1173 if (sort
== clear_as
) {
1174 as_t as
= strtoul(arg
, NULL
, 10);
1176 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1180 bgp_peer_gr_flags_update(peer
);
1182 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1183 gr_router_detected
= true;
1185 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1188 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1193 if (gr_router_detected
1194 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1195 bgp_zebra_send_capabilities(bgp
, false);
1196 } else if (!gr_router_detected
1197 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1198 bgp_zebra_send_capabilities(bgp
, true);
1203 "%% BGP: No %s peer is configured with AS %s\n",
1204 get_afi_safi_str(afi
, safi
, false), arg
);
1212 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1213 safi_t safi
, enum clear_sort sort
,
1214 enum bgp_clear_type stype
, const char *arg
)
1218 /* BGP structure lookup. */
1220 bgp
= bgp_lookup_by_name(name
);
1222 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1226 bgp
= bgp_get_default();
1228 vty_out(vty
, "No BGP process is configured\n");
1233 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1236 /* clear soft inbound */
1237 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1242 FOREACH_AFI_SAFI (afi
, safi
)
1243 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1244 BGP_CLEAR_SOFT_IN
, NULL
);
1247 /* clear soft outbound */
1248 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1253 FOREACH_AFI_SAFI (afi
, safi
)
1254 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1255 BGP_CLEAR_SOFT_OUT
, NULL
);
1259 #ifndef VTYSH_EXTRACT_PL
1260 #include "bgpd/bgp_vty_clippy.c"
1263 DEFUN_HIDDEN (bgp_local_mac
,
1265 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1267 "Local MAC config\n"
1268 "VxLAN Network Identifier\n"
1272 "mac-mobility sequence\n"
1282 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1283 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1284 vty_out(vty
, "%% Malformed MAC address\n");
1287 memset(&ip
, 0, sizeof(ip
));
1288 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1290 bgp
= bgp_get_default();
1292 vty_out(vty
, "Default BGP instance is not there\n");
1296 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1299 vty_out(vty
, "Internal error\n");
1306 DEFUN_HIDDEN (no_bgp_local_mac
,
1307 no_bgp_local_mac_cmd
,
1308 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1311 "Local MAC config\n"
1312 "VxLAN Network Identifier\n"
1323 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1324 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1325 vty_out(vty
, "%% Malformed MAC address\n");
1328 memset(&ip
, 0, sizeof(ip
));
1330 bgp
= bgp_get_default();
1332 vty_out(vty
, "Default BGP instance is not there\n");
1336 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1338 vty_out(vty
, "Internal error\n");
1345 DEFUN (no_synchronization
,
1346 no_synchronization_cmd
,
1347 "no synchronization",
1349 "Perform IGP synchronization\n")
1354 DEFUN (no_auto_summary
,
1355 no_auto_summary_cmd
,
1358 "Enable automatic network number summarization\n")
1363 /* "router bgp" commands. */
1364 DEFUN_NOSH (router_bgp
,
1366 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1370 BGP_INSTANCE_HELP_STR
)
1373 int idx_view_vrf
= 3;
1379 const char *name
= NULL
;
1380 enum bgp_instance_type inst_type
;
1382 // "router bgp" without an ASN
1384 // Pending: Make VRF option available for ASN less config
1385 bgp
= bgp_get_default();
1388 vty_out(vty
, "%% No BGP process is configured\n");
1389 return CMD_WARNING_CONFIG_FAILED
;
1392 if (listcount(bm
->bgp
) > 1) {
1393 vty_out(vty
, "%% Please specify ASN and VRF\n");
1394 return CMD_WARNING_CONFIG_FAILED
;
1400 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1402 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1403 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1404 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1406 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1408 name
= argv
[idx_vrf
]->arg
;
1410 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1411 if (strmatch(name
, VRF_DEFAULT_NAME
))
1414 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1415 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1416 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1419 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1420 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1422 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1424 case BGP_ERR_AS_MISMATCH
:
1425 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1426 return CMD_WARNING_CONFIG_FAILED
;
1427 case BGP_ERR_INSTANCE_MISMATCH
:
1429 "BGP instance name and AS number mismatch\n");
1431 "BGP instance is already running; AS is %u\n",
1433 return CMD_WARNING_CONFIG_FAILED
;
1437 * If we just instantiated the default instance, complete
1438 * any pending VRF-VPN leaking that was configured via
1439 * earlier "router bgp X vrf FOO" blocks.
1441 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1442 vpn_leak_postchange_all();
1444 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1445 bgp_vpn_leak_export(bgp
);
1446 /* Pending: handle when user tries to change a view to vrf n vv.
1450 /* unset the auto created flag as the user config is now present */
1451 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1452 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1457 /* "no router bgp" commands. */
1458 DEFUN (no_router_bgp
,
1460 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1465 BGP_INSTANCE_HELP_STR
)
1471 const char *name
= NULL
;
1473 // "no router bgp" without an ASN
1475 // Pending: Make VRF option available for ASN less config
1476 bgp
= bgp_get_default();
1479 vty_out(vty
, "%% No BGP process is configured\n");
1480 return CMD_WARNING_CONFIG_FAILED
;
1483 if (listcount(bm
->bgp
) > 1) {
1484 vty_out(vty
, "%% Please specify ASN and VRF\n");
1485 return CMD_WARNING_CONFIG_FAILED
;
1489 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1491 return CMD_WARNING_CONFIG_FAILED
;
1494 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1497 name
= argv
[idx_vrf
]->arg
;
1498 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1499 && strmatch(name
, VRF_DEFAULT_NAME
))
1503 /* Lookup bgp structure. */
1504 bgp
= bgp_lookup(as
, name
);
1506 vty_out(vty
, "%% Can't find BGP instance\n");
1507 return CMD_WARNING_CONFIG_FAILED
;
1511 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1513 return CMD_WARNING_CONFIG_FAILED
;
1516 /* Cannot delete default instance if vrf instances exist */
1517 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1518 struct listnode
*node
;
1519 struct bgp
*tmp_bgp
;
1521 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1522 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1524 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1525 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1526 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1527 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1528 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1529 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1530 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1531 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1532 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1533 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1534 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1535 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1536 (bgp
== bgp_get_evpn() &&
1537 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1538 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1539 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1540 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1541 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1542 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1543 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1544 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1545 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1547 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1548 return CMD_WARNING_CONFIG_FAILED
;
1560 /* BGP router-id. */
1562 DEFPY (bgp_router_id
,
1564 "bgp router-id A.B.C.D",
1566 "Override configured router identifier\n"
1567 "Manually configured router identifier\n")
1569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1570 bgp_router_id_static_set(bgp
, router_id
);
1574 DEFPY (no_bgp_router_id
,
1575 no_bgp_router_id_cmd
,
1576 "no bgp router-id [A.B.C.D]",
1579 "Override configured router identifier\n"
1580 "Manually configured router identifier\n")
1582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1584 if (router_id_str
) {
1585 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1586 vty_out(vty
, "%% BGP router-id doesn't match\n");
1587 return CMD_WARNING_CONFIG_FAILED
;
1591 router_id
.s_addr
= 0;
1592 bgp_router_id_static_set(bgp
, router_id
);
1597 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1598 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1600 "Add community specific parameters\n"
1601 "Create an alias for a community\n"
1602 "Community (AA:BB or AA:BB:CC)\n"
1605 struct community_alias ca1
;
1606 struct community_alias ca2
;
1607 struct community_alias
*lookup_community
;
1608 struct community_alias
*lookup_alias
;
1610 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1611 vty_out(vty
, "Invalid community format\n");
1615 memset(&ca1
, 0, sizeof(ca1
));
1616 memset(&ca2
, 0, sizeof(ca2
));
1617 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1618 strlcpy(ca1
.alias
, alias_name
, sizeof(ca1
.alias
));
1620 lookup_community
= bgp_ca_community_lookup(&ca1
);
1621 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1624 bgp_ca_alias_delete(&ca1
);
1625 bgp_ca_community_delete(&ca1
);
1628 /* Lookup if community hash table has an item
1629 * with the same alias name.
1631 strlcpy(ca2
.community
, lookup_alias
->community
,
1632 sizeof(ca2
.community
));
1633 if (bgp_ca_community_lookup(&ca2
)) {
1635 "community (%s) already has this alias (%s)\n",
1636 lookup_alias
->community
,
1637 lookup_alias
->alias
);
1640 bgp_ca_alias_delete(&ca1
);
1643 if (lookup_community
)
1644 bgp_ca_community_delete(&ca1
);
1646 bgp_ca_alias_insert(&ca1
);
1647 bgp_ca_community_insert(&ca1
);
1653 DEFPY (bgp_global_suppress_fib_pending
,
1654 bgp_global_suppress_fib_pending_cmd
,
1655 "[no] bgp suppress-fib-pending",
1658 "Advertise only routes that are programmed in kernel to peers globally\n")
1660 bm_wait_for_fib_set(!no
);
1665 DEFPY (bgp_suppress_fib_pending
,
1666 bgp_suppress_fib_pending_cmd
,
1667 "[no] bgp suppress-fib-pending",
1670 "Advertise only routes that are programmed in kernel to peers\n")
1672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1674 bgp_suppress_fib_pending_set(bgp
, !no
);
1679 /* BGP Cluster ID. */
1680 DEFUN (bgp_cluster_id
,
1682 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1684 "Configure Route-Reflector Cluster-id\n"
1685 "Route-Reflector Cluster-id in IP address format\n"
1686 "Route-Reflector Cluster-id as 32 bit quantity\n")
1688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1691 struct in_addr cluster
;
1693 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1695 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1696 return CMD_WARNING_CONFIG_FAILED
;
1699 bgp_cluster_id_set(bgp
, &cluster
);
1700 bgp_clear_star_soft_out(vty
, bgp
->name
);
1705 DEFUN (no_bgp_cluster_id
,
1706 no_bgp_cluster_id_cmd
,
1707 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1710 "Configure Route-Reflector Cluster-id\n"
1711 "Route-Reflector Cluster-id in IP address format\n"
1712 "Route-Reflector Cluster-id as 32 bit quantity\n")
1714 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1715 bgp_cluster_id_unset(bgp
);
1716 bgp_clear_star_soft_out(vty
, bgp
->name
);
1725 "Disable BGP route installation to RIB (Zebra)\n")
1727 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1729 "%% No-RIB option is already set, nothing to do here.\n");
1733 bgp_option_norib_set_runtime();
1738 DEFPY (no_bgp_norib
,
1743 "Disable BGP route installation to RIB (Zebra)\n")
1745 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1747 "%% No-RIB option is not set, nothing to do here.\n");
1751 bgp_option_norib_unset_runtime();
1756 DEFPY (no_bgp_send_extra_data
,
1757 no_bgp_send_extra_data_cmd
,
1758 "[no] bgp send-extra-data zebra",
1761 "Extra data to Zebra for display/use\n"
1765 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1767 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1772 DEFUN (bgp_confederation_identifier
,
1773 bgp_confederation_identifier_cmd
,
1774 "bgp confederation identifier (1-4294967295)",
1776 "AS confederation parameters\n"
1778 "Set routing domain confederation AS\n")
1780 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1784 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1786 bgp_confederation_id_set(bgp
, as
);
1791 DEFUN (no_bgp_confederation_identifier
,
1792 no_bgp_confederation_identifier_cmd
,
1793 "no bgp confederation identifier [(1-4294967295)]",
1796 "AS confederation parameters\n"
1798 "Set routing domain confederation AS\n")
1800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1801 bgp_confederation_id_unset(bgp
);
1806 DEFUN (bgp_confederation_peers
,
1807 bgp_confederation_peers_cmd
,
1808 "bgp confederation peers (1-4294967295)...",
1810 "AS confederation parameters\n"
1811 "Peer ASs in BGP confederation\n"
1814 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1819 for (i
= idx_asn
; i
< argc
; i
++) {
1820 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1822 if (bgp
->as
== as
) {
1824 "%% Local member-AS not allowed in confed peer list\n");
1828 bgp_confederation_peers_add(bgp
, as
);
1833 DEFUN (no_bgp_confederation_peers
,
1834 no_bgp_confederation_peers_cmd
,
1835 "no bgp confederation peers (1-4294967295)...",
1838 "AS confederation parameters\n"
1839 "Peer ASs in BGP confederation\n"
1842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1847 for (i
= idx_asn
; i
< argc
; i
++) {
1848 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1850 bgp_confederation_peers_remove(bgp
, as
);
1856 * Central routine for maximum-paths configuration.
1857 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1858 * @set: 1 for setting values, 0 for removing the max-paths config.
1860 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1861 const char *mpaths
, uint16_t options
,
1864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1865 uint16_t maxpaths
= 0;
1870 afi
= bgp_node_afi(vty
);
1871 safi
= bgp_node_safi(vty
);
1874 maxpaths
= strtol(mpaths
, NULL
, 10);
1875 if (maxpaths
> multipath_num
) {
1877 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1878 maxpaths
, multipath_num
);
1879 return CMD_WARNING_CONFIG_FAILED
;
1881 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1884 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1888 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1889 (set
== 1) ? "" : "un",
1890 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1891 maxpaths
, afi
, safi
);
1892 return CMD_WARNING_CONFIG_FAILED
;
1895 bgp_recalculate_all_bestpaths(bgp
);
1900 DEFUN (bgp_maxmed_admin
,
1901 bgp_maxmed_admin_cmd
,
1902 "bgp max-med administrative ",
1904 "Advertise routes with max-med\n"
1905 "Administratively applied, for an indefinite period\n")
1907 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1909 bgp
->v_maxmed_admin
= 1;
1910 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1912 bgp_maxmed_update(bgp
);
1917 DEFUN (bgp_maxmed_admin_medv
,
1918 bgp_maxmed_admin_medv_cmd
,
1919 "bgp max-med administrative (0-4294967295)",
1921 "Advertise routes with max-med\n"
1922 "Administratively applied, for an indefinite period\n"
1923 "Max MED value to be used\n")
1925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1928 bgp
->v_maxmed_admin
= 1;
1929 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1931 bgp_maxmed_update(bgp
);
1936 DEFUN (no_bgp_maxmed_admin
,
1937 no_bgp_maxmed_admin_cmd
,
1938 "no bgp max-med administrative [(0-4294967295)]",
1941 "Advertise routes with max-med\n"
1942 "Administratively applied, for an indefinite period\n"
1943 "Max MED value to be used\n")
1945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1946 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1947 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1948 bgp_maxmed_update(bgp
);
1953 DEFUN (bgp_maxmed_onstartup
,
1954 bgp_maxmed_onstartup_cmd
,
1955 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1957 "Advertise routes with max-med\n"
1958 "Effective on a startup\n"
1959 "Time (seconds) period for max-med\n"
1960 "Max MED value to be used\n")
1962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 argv_find(argv
, argc
, "(5-86400)", &idx
);
1966 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1967 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1968 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1970 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1972 bgp_maxmed_update(bgp
);
1977 DEFUN (no_bgp_maxmed_onstartup
,
1978 no_bgp_maxmed_onstartup_cmd
,
1979 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1982 "Advertise routes with max-med\n"
1983 "Effective on a startup\n"
1984 "Time (seconds) period for max-med\n"
1985 "Max MED value to be used\n")
1987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1989 /* Cancel max-med onstartup if its on */
1990 if (bgp
->t_maxmed_onstartup
) {
1991 thread_cancel(&bgp
->t_maxmed_onstartup
);
1992 bgp
->maxmed_onstartup_over
= 1;
1995 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1996 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1998 bgp_maxmed_update(bgp
);
2003 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2004 uint16_t update_delay
,
2005 uint16_t establish_wait
)
2007 struct listnode
*node
, *nnode
;
2009 bool vrf_cfg
= false;
2012 * See if update-delay is set per-vrf and warn user to delete it
2013 * Note that we only need to check this if this is the first time
2014 * setting the global config.
2016 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2017 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2018 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2020 "%% update-delay configuration found in vrf %s\n",
2021 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2031 "%%Failed: global update-delay config not permitted\n");
2035 if (!establish_wait
) { /* update-delay <delay> */
2036 bm
->v_update_delay
= update_delay
;
2037 bm
->v_establish_wait
= bm
->v_update_delay
;
2039 /* update-delay <delay> <establish-wait> */
2040 if (update_delay
< establish_wait
) {
2042 "%%Failed: update-delay less than the establish-wait!\n");
2043 return CMD_WARNING_CONFIG_FAILED
;
2046 bm
->v_update_delay
= update_delay
;
2047 bm
->v_establish_wait
= establish_wait
;
2050 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2051 bgp
->v_update_delay
= bm
->v_update_delay
;
2052 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2058 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2060 struct listnode
*node
, *nnode
;
2063 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2064 bm
->v_establish_wait
= bm
->v_update_delay
;
2066 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2067 bgp
->v_update_delay
= bm
->v_update_delay
;
2068 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2074 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2075 uint16_t establish_wait
)
2077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 /* if configured globally, per-instance config is not allowed */
2080 if (bm
->v_update_delay
) {
2082 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2083 return CMD_WARNING_CONFIG_FAILED
;
2087 if (!establish_wait
) /* update-delay <delay> */
2089 bgp
->v_update_delay
= update_delay
;
2090 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2094 /* update-delay <delay> <establish-wait> */
2095 if (update_delay
< establish_wait
) {
2097 "%%Failed: update-delay less than the establish-wait!\n");
2098 return CMD_WARNING_CONFIG_FAILED
;
2101 bgp
->v_update_delay
= update_delay
;
2102 bgp
->v_establish_wait
= establish_wait
;
2107 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2111 /* If configured globally, cannot remove from one bgp instance */
2112 if (bm
->v_update_delay
) {
2114 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2115 return CMD_WARNING_CONFIG_FAILED
;
2117 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2118 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2123 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2125 /* If configured globally, no need to display per-instance value */
2126 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2127 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2128 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2129 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2134 /* Global update-delay configuration */
2135 DEFPY (bgp_global_update_delay
,
2136 bgp_global_update_delay_cmd
,
2137 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2139 "Force initial delay for best-path and updates for all bgp instances\n"
2140 "Max delay in seconds\n"
2141 "Establish wait in seconds\n")
2143 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2146 /* Global update-delay deconfiguration */
2147 DEFPY (no_bgp_global_update_delay
,
2148 no_bgp_global_update_delay_cmd
,
2149 "no bgp update-delay [(0-3600) [(1-3600)]]",
2152 "Force initial delay for best-path and updates\n"
2153 "Max delay in seconds\n"
2154 "Establish wait in seconds\n")
2156 return bgp_global_update_delay_deconfig_vty(vty
);
2159 /* Update-delay configuration */
2161 DEFPY (bgp_update_delay
,
2162 bgp_update_delay_cmd
,
2163 "update-delay (0-3600)$delay [(1-3600)$wait]",
2164 "Force initial delay for best-path and updates\n"
2165 "Max delay in seconds\n"
2166 "Establish wait in seconds\n")
2168 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2171 /* Update-delay deconfiguration */
2172 DEFPY (no_bgp_update_delay
,
2173 no_bgp_update_delay_cmd
,
2174 "no update-delay [(0-3600) [(1-3600)]]",
2176 "Force initial delay for best-path and updates\n"
2177 "Max delay in seconds\n"
2178 "Establish wait in seconds\n")
2180 return bgp_update_delay_deconfig_vty(vty
);
2184 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2189 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2190 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2195 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2200 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2201 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2206 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2209 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2210 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2211 vty_out(vty
, " write-quanta %d\n", quanta
);
2214 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2217 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2218 if (quanta
!= BGP_READ_PACKET_MAX
)
2219 vty_out(vty
, " read-quanta %d\n", quanta
);
2222 /* Packet quanta configuration
2224 * XXX: The value set here controls the size of a stack buffer in the IO
2225 * thread. When changing these limits be careful to prevent stack overflow.
2227 * Furthermore, the maximums used here should correspond to
2228 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2230 DEFPY (bgp_wpkt_quanta
,
2231 bgp_wpkt_quanta_cmd
,
2232 "[no] write-quanta (1-64)$quanta",
2234 "How many packets to write to peer socket per run\n"
2235 "Number of packets\n")
2237 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2240 DEFPY (bgp_rpkt_quanta
,
2241 bgp_rpkt_quanta_cmd
,
2242 "[no] read-quanta (1-10)$quanta",
2244 "How many packets to read from peer socket per I/O cycle\n"
2245 "Number of packets\n")
2247 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2250 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2252 if (!bgp
->heuristic_coalesce
)
2253 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2257 DEFUN (bgp_coalesce_time
,
2258 bgp_coalesce_time_cmd
,
2259 "coalesce-time (0-4294967295)",
2260 "Subgroup coalesce timer\n"
2261 "Subgroup coalesce timer value (in ms)\n")
2263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2266 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2267 bgp
->heuristic_coalesce
= false;
2268 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2272 DEFUN (no_bgp_coalesce_time
,
2273 no_bgp_coalesce_time_cmd
,
2274 "no coalesce-time (0-4294967295)",
2276 "Subgroup coalesce timer\n"
2277 "Subgroup coalesce timer value (in ms)\n")
2279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2281 bgp
->heuristic_coalesce
= true;
2282 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2286 /* Maximum-paths configuration */
2287 DEFUN (bgp_maxpaths
,
2289 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2290 "Forward packets over multiple paths\n"
2291 "Number of paths\n")
2294 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2295 argv
[idx_number
]->arg
, 0, 1);
2298 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2299 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2300 "Forward packets over multiple paths\n"
2301 "Number of paths\n")
2303 DEFUN (bgp_maxpaths_ibgp
,
2304 bgp_maxpaths_ibgp_cmd
,
2305 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2306 "Forward packets over multiple paths\n"
2308 "Number of paths\n")
2311 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2312 argv
[idx_number
]->arg
, 0, 1);
2315 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2316 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2317 "Forward packets over multiple paths\n"
2319 "Number of paths\n")
2321 DEFUN (bgp_maxpaths_ibgp_cluster
,
2322 bgp_maxpaths_ibgp_cluster_cmd
,
2323 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2324 "Forward packets over multiple paths\n"
2327 "Match the cluster length\n")
2330 return bgp_maxpaths_config_vty(
2331 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
2332 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
2335 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2336 "maximum-paths ibgp " CMD_RANGE_STR(
2337 1, MULTIPATH_NUM
) " equal-cluster-length",
2338 "Forward packets over multiple paths\n"
2341 "Match the cluster length\n")
2343 DEFUN (no_bgp_maxpaths
,
2344 no_bgp_maxpaths_cmd
,
2345 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2347 "Forward packets over multiple paths\n"
2348 "Number of paths\n")
2350 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2353 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2354 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2355 "Forward packets over multiple paths\n"
2356 "Number of paths\n")
2358 DEFUN (no_bgp_maxpaths_ibgp
,
2359 no_bgp_maxpaths_ibgp_cmd
,
2360 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2362 "Forward packets over multiple paths\n"
2365 "Match the cluster length\n")
2367 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2370 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2371 "no maximum-paths ibgp [" CMD_RANGE_STR(
2372 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2374 "Forward packets over multiple paths\n"
2377 "Match the cluster length\n")
2379 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2380 afi_t afi
, safi_t safi
)
2382 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2383 vty_out(vty
, " maximum-paths %d\n",
2384 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2387 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2388 vty_out(vty
, " maximum-paths ibgp %d",
2389 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2390 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2391 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2392 vty_out(vty
, " equal-cluster-length");
2401 "timers bgp (0-65535) (0-65535)",
2402 "Adjust routing timers\n"
2404 "Keepalive interval\n"
2407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2409 int idx_number_2
= 3;
2410 unsigned long keepalive
= 0;
2411 unsigned long holdtime
= 0;
2413 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2414 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2416 /* Holdtime value check. */
2417 if (holdtime
< 3 && holdtime
!= 0) {
2419 "%% hold time value must be either 0 or greater than 3\n");
2420 return CMD_WARNING_CONFIG_FAILED
;
2423 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2424 BGP_DEFAULT_DELAYOPEN
);
2429 DEFUN (no_bgp_timers
,
2431 "no timers bgp [(0-65535) (0-65535)]",
2433 "Adjust routing timers\n"
2435 "Keepalive interval\n"
2438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2439 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2440 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2445 /* BGP minimum holdtime. */
2447 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2448 "bgp minimum-holdtime (1-65535)",
2449 "BGP specific commands\n"
2450 "BGP minimum holdtime\n"
2453 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2455 unsigned long min_holdtime
;
2457 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2459 bgp
->default_min_holdtime
= min_holdtime
;
2464 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2465 "no bgp minimum-holdtime [(1-65535)]",
2467 "BGP specific commands\n"
2468 "BGP minimum holdtime\n"
2471 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2473 bgp
->default_min_holdtime
= 0;
2478 DEFUN (bgp_client_to_client_reflection
,
2479 bgp_client_to_client_reflection_cmd
,
2480 "bgp client-to-client reflection",
2482 "Configure client to client route reflection\n"
2483 "reflection of routes allowed\n")
2485 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2487 bgp_clear_star_soft_out(vty
, bgp
->name
);
2492 DEFUN (no_bgp_client_to_client_reflection
,
2493 no_bgp_client_to_client_reflection_cmd
,
2494 "no bgp client-to-client reflection",
2497 "Configure client to client route reflection\n"
2498 "reflection of routes allowed\n")
2500 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2501 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2502 bgp_clear_star_soft_out(vty
, bgp
->name
);
2507 /* "bgp always-compare-med" configuration. */
2508 DEFUN (bgp_always_compare_med
,
2509 bgp_always_compare_med_cmd
,
2510 "bgp always-compare-med",
2512 "Allow comparing MED from different neighbors\n")
2514 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2515 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2516 bgp_recalculate_all_bestpaths(bgp
);
2521 DEFUN (no_bgp_always_compare_med
,
2522 no_bgp_always_compare_med_cmd
,
2523 "no bgp always-compare-med",
2526 "Allow comparing MED from different neighbors\n")
2528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2529 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2530 bgp_recalculate_all_bestpaths(bgp
);
2536 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2537 "bgp ebgp-requires-policy",
2539 "Require in and out policy for eBGP peers (RFC8212)\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2546 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2547 "no bgp ebgp-requires-policy",
2550 "Require in and out policy for eBGP peers (RFC8212)\n")
2552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2553 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2557 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2558 "bgp suppress-duplicates",
2560 "Suppress duplicate updates if the route actually not changed\n")
2562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2563 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2567 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2568 "no bgp suppress-duplicates",
2571 "Suppress duplicate updates if the route actually not changed\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2574 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2578 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2579 "bgp reject-as-sets",
2581 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2584 struct listnode
*node
, *nnode
;
2587 bgp
->reject_as_sets
= true;
2589 /* Reset existing BGP sessions to reject routes
2590 * with aspath containing AS_SET or AS_CONFED_SET.
2592 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2593 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2594 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2595 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2596 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2603 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2604 "no bgp reject-as-sets",
2607 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2610 struct listnode
*node
, *nnode
;
2613 bgp
->reject_as_sets
= false;
2615 /* Reset existing BGP sessions to reject routes
2616 * with aspath containing AS_SET or AS_CONFED_SET.
2618 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2619 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2620 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2621 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2622 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2629 /* "bgp deterministic-med" configuration. */
2630 DEFUN (bgp_deterministic_med
,
2631 bgp_deterministic_med_cmd
,
2632 "bgp deterministic-med",
2634 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2638 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2639 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2640 bgp_recalculate_all_bestpaths(bgp
);
2646 DEFUN (no_bgp_deterministic_med
,
2647 no_bgp_deterministic_med_cmd
,
2648 "no bgp deterministic-med",
2651 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2654 int bestpath_per_as_used
;
2658 struct listnode
*node
, *nnode
;
2660 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2661 bestpath_per_as_used
= 0;
2663 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2664 FOREACH_AFI_SAFI (afi
, safi
)
2665 if (bgp_addpath_dmed_required(
2666 peer
->addpath_type
[afi
][safi
])) {
2667 bestpath_per_as_used
= 1;
2671 if (bestpath_per_as_used
)
2675 if (bestpath_per_as_used
) {
2677 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2678 return CMD_WARNING_CONFIG_FAILED
;
2680 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2681 bgp_recalculate_all_bestpaths(bgp
);
2688 /* "bgp graceful-restart mode" configuration. */
2689 DEFUN (bgp_graceful_restart
,
2690 bgp_graceful_restart_cmd
,
2691 "bgp graceful-restart",
2696 int ret
= BGP_GR_FAILURE
;
2698 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2699 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2703 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2705 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2708 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2709 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2711 "Graceful restart configuration changed, reset all peers to take effect\n");
2712 return bgp_vty_return(vty
, ret
);
2715 DEFUN (no_bgp_graceful_restart
,
2716 no_bgp_graceful_restart_cmd
,
2717 "no bgp graceful-restart",
2723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2726 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2728 int ret
= BGP_GR_FAILURE
;
2730 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2732 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2735 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2736 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2738 "Graceful restart configuration changed, reset all peers to take effect\n");
2740 return bgp_vty_return(vty
, ret
);
2743 DEFUN (bgp_graceful_restart_stalepath_time
,
2744 bgp_graceful_restart_stalepath_time_cmd
,
2745 "bgp graceful-restart stalepath-time (1-4095)",
2747 "Graceful restart capability parameters\n"
2748 "Set the max time to hold onto restarting peer's stale paths\n"
2749 "Delay value (seconds)\n")
2751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2755 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2756 bgp
->stalepath_time
= stalepath
;
2760 DEFUN (bgp_graceful_restart_restart_time
,
2761 bgp_graceful_restart_restart_time_cmd
,
2762 "bgp graceful-restart restart-time (0-4095)",
2764 "Graceful restart capability parameters\n"
2765 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2766 "Delay value (seconds)\n")
2768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2772 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2773 bgp
->restart_time
= restart
;
2777 DEFUN (bgp_graceful_restart_select_defer_time
,
2778 bgp_graceful_restart_select_defer_time_cmd
,
2779 "bgp graceful-restart select-defer-time (0-3600)",
2781 "Graceful restart capability parameters\n"
2782 "Set the time to defer the BGP route selection after restart\n"
2783 "Delay value (seconds, 0 - disable)\n")
2785 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2787 uint32_t defer_time
;
2789 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2790 bgp
->select_defer_time
= defer_time
;
2791 if (defer_time
== 0)
2792 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2794 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2799 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2800 no_bgp_graceful_restart_stalepath_time_cmd
,
2801 "no bgp graceful-restart stalepath-time [(1-4095)]",
2804 "Graceful restart capability parameters\n"
2805 "Set the max time to hold onto restarting peer's stale paths\n"
2806 "Delay value (seconds)\n")
2808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2810 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2814 DEFUN (no_bgp_graceful_restart_restart_time
,
2815 no_bgp_graceful_restart_restart_time_cmd
,
2816 "no bgp graceful-restart restart-time [(0-4095)]",
2819 "Graceful restart capability parameters\n"
2820 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2821 "Delay value (seconds)\n")
2823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2825 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2829 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2830 no_bgp_graceful_restart_select_defer_time_cmd
,
2831 "no bgp graceful-restart select-defer-time [(0-3600)]",
2834 "Graceful restart capability parameters\n"
2835 "Set the time to defer the BGP route selection after restart\n"
2836 "Delay value (seconds)\n")
2838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2841 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2846 DEFUN (bgp_graceful_restart_preserve_fw
,
2847 bgp_graceful_restart_preserve_fw_cmd
,
2848 "bgp graceful-restart preserve-fw-state",
2850 "Graceful restart capability parameters\n"
2851 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2854 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2858 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2859 no_bgp_graceful_restart_preserve_fw_cmd
,
2860 "no bgp graceful-restart preserve-fw-state",
2863 "Graceful restart capability parameters\n"
2864 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2867 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2871 DEFUN (bgp_graceful_restart_disable
,
2872 bgp_graceful_restart_disable_cmd
,
2873 "bgp graceful-restart-disable",
2877 int ret
= BGP_GR_FAILURE
;
2879 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2881 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2885 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2887 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2890 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2892 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2894 "Graceful restart configuration changed, reset all peers to take effect\n");
2896 return bgp_vty_return(vty
, ret
);
2899 DEFUN (no_bgp_graceful_restart_disable
,
2900 no_bgp_graceful_restart_disable_cmd
,
2901 "no bgp graceful-restart-disable",
2907 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2909 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2911 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2913 int ret
= BGP_GR_FAILURE
;
2915 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2917 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2920 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2922 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2924 "Graceful restart configuration changed, reset all peers to take effect\n");
2926 return bgp_vty_return(vty
, ret
);
2929 DEFUN (bgp_neighbor_graceful_restart_set
,
2930 bgp_neighbor_graceful_restart_set_cmd
,
2931 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2939 int ret
= BGP_GR_FAILURE
;
2941 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2943 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2945 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2947 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2949 return CMD_WARNING_CONFIG_FAILED
;
2951 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2953 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2954 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2956 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2958 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2960 "Graceful restart configuration changed, reset this peer to take effect\n");
2962 return bgp_vty_return(vty
, ret
);
2965 DEFUN (no_bgp_neighbor_graceful_restart
,
2966 no_bgp_neighbor_graceful_restart_set_cmd
,
2967 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2975 int ret
= BGP_GR_FAILURE
;
2978 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2980 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2982 return CMD_WARNING_CONFIG_FAILED
;
2984 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2986 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2988 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2990 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2991 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2993 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2995 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2997 "Graceful restart configuration changed, reset this peer to take effect\n");
2999 return bgp_vty_return(vty
, ret
);
3002 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3003 bgp_neighbor_graceful_restart_helper_set_cmd
,
3004 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3007 GR_NEIGHBOR_HELPER_CMD
3012 int ret
= BGP_GR_FAILURE
;
3014 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3016 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3018 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3020 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3023 return CMD_WARNING_CONFIG_FAILED
;
3026 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3028 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3029 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3031 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3033 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3035 "Graceful restart configuration changed, reset this peer to take effect\n");
3037 return bgp_vty_return(vty
, ret
);
3040 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3041 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3042 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3046 NO_GR_NEIGHBOR_HELPER_CMD
3050 int ret
= BGP_GR_FAILURE
;
3053 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3055 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3057 return CMD_WARNING_CONFIG_FAILED
;
3059 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3061 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3063 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3065 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3066 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3068 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3070 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3072 "Graceful restart configuration changed, reset this peer to take effect\n");
3074 return bgp_vty_return(vty
, ret
);
3077 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3078 bgp_neighbor_graceful_restart_disable_set_cmd
,
3079 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3082 GR_NEIGHBOR_DISABLE_CMD
3087 int ret
= BGP_GR_FAILURE
;
3089 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3091 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3093 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3095 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3097 return CMD_WARNING_CONFIG_FAILED
;
3099 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3101 if (peer
->bgp
->t_startup
)
3102 bgp_peer_gr_flags_update(peer
);
3104 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3105 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3107 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3109 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3111 "Graceful restart configuration changed, reset this peer to take effect\n");
3113 return bgp_vty_return(vty
, ret
);
3116 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3117 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3118 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3122 NO_GR_NEIGHBOR_DISABLE_CMD
3126 int ret
= BGP_GR_FAILURE
;
3129 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3131 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3133 return CMD_WARNING_CONFIG_FAILED
;
3135 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3137 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3139 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3141 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3142 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3144 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3146 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3148 "Graceful restart configuration changed, reset this peer to take effect\n");
3150 return bgp_vty_return(vty
, ret
);
3153 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3154 bgp_graceful_restart_disable_eor_cmd
,
3155 "bgp graceful-restart disable-eor",
3157 "Graceful restart configuration parameters\n"
3158 "Disable EOR Check\n")
3160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3161 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3166 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3167 no_bgp_graceful_restart_disable_eor_cmd
,
3168 "no bgp graceful-restart disable-eor",
3171 "Graceful restart configuration parameters\n"
3172 "Disable EOR Check\n")
3174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3175 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3180 DEFUN (bgp_graceful_restart_rib_stale_time
,
3181 bgp_graceful_restart_rib_stale_time_cmd
,
3182 "bgp graceful-restart rib-stale-time (1-3600)",
3184 "Graceful restart configuration parameters\n"
3185 "Specify the stale route removal timer in rib\n"
3186 "Delay value (seconds)\n")
3188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3190 uint32_t stale_time
;
3192 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3193 bgp
->rib_stale_time
= stale_time
;
3194 /* Send the stale timer update message to RIB */
3195 if (bgp_zebra_stale_timer_update(bgp
))
3201 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3202 no_bgp_graceful_restart_rib_stale_time_cmd
,
3203 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3206 "Graceful restart configuration parameters\n"
3207 "Specify the stale route removal timer in rib\n"
3208 "Delay value (seconds)\n")
3210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3212 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3213 /* Send the stale timer update message to RIB */
3214 if (bgp_zebra_stale_timer_update(bgp
))
3220 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3221 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3223 "Enable Long-lived Graceful Restart\n"
3224 "Specifies maximum time to wait before purging long-lived stale routes\n"
3225 "Stale time value (seconds)\n")
3227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3229 uint32_t llgr_stale_time
;
3231 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3232 bgp
->llgr_stale_time
= llgr_stale_time
;
3237 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3238 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3240 "Enable Long-lived Graceful Restart\n"
3241 "Specifies maximum time to wait before purging long-lived stale routes\n"
3242 "Stale time value (seconds)\n")
3244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3246 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3251 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3254 bgp_static_redo_import_check(bgp
);
3255 bgp_redistribute_redo(bgp
);
3256 bgp_clear_star_soft_out(vty
, bgp
->name
);
3257 bgp_clear_star_soft_in(vty
, bgp
->name
);
3260 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3262 struct listnode
*node
, *nnode
;
3264 bool vrf_cfg
= false;
3266 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3269 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3270 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3271 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3273 "%% graceful-shutdown configuration found in vrf %s\n",
3274 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3275 VRF_DEFAULT_NAME
: bgp
->name
);
3282 "%%Failed: global graceful-shutdown not permitted\n");
3286 /* Set flag globally */
3287 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3289 /* Initiate processing for all BGP instances. */
3290 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3291 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3296 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3298 struct listnode
*node
, *nnode
;
3301 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3304 /* Unset flag globally */
3305 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3307 /* Initiate processing for all BGP instances. */
3308 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3309 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3314 /* "bgp graceful-shutdown" configuration */
3315 DEFUN (bgp_graceful_shutdown
,
3316 bgp_graceful_shutdown_cmd
,
3317 "bgp graceful-shutdown",
3319 "Graceful shutdown parameters\n")
3321 if (vty
->node
== CONFIG_NODE
)
3322 return bgp_global_graceful_shutdown_config_vty(vty
);
3324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3326 /* if configured globally, per-instance config is not allowed */
3327 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3329 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3330 return CMD_WARNING_CONFIG_FAILED
;
3333 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3334 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3335 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3341 DEFUN (no_bgp_graceful_shutdown
,
3342 no_bgp_graceful_shutdown_cmd
,
3343 "no bgp graceful-shutdown",
3346 "Graceful shutdown parameters\n")
3348 if (vty
->node
== CONFIG_NODE
)
3349 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3353 /* If configured globally, cannot remove from one bgp instance */
3354 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3356 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3357 return CMD_WARNING_CONFIG_FAILED
;
3360 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3361 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3362 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3368 /* "bgp fast-external-failover" configuration. */
3369 DEFUN (bgp_fast_external_failover
,
3370 bgp_fast_external_failover_cmd
,
3371 "bgp fast-external-failover",
3373 "Immediately reset session if a link to a directly connected external peer goes down\n")
3375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3376 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3380 DEFUN (no_bgp_fast_external_failover
,
3381 no_bgp_fast_external_failover_cmd
,
3382 "no bgp fast-external-failover",
3385 "Immediately reset session if a link to a directly connected external peer goes down\n")
3387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3388 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3392 /* "bgp bestpath compare-routerid" configuration. */
3393 DEFUN (bgp_bestpath_compare_router_id
,
3394 bgp_bestpath_compare_router_id_cmd
,
3395 "bgp bestpath compare-routerid",
3397 "Change the default bestpath selection\n"
3398 "Compare router-id for identical EBGP paths\n")
3400 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3401 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3402 bgp_recalculate_all_bestpaths(bgp
);
3407 DEFUN (no_bgp_bestpath_compare_router_id
,
3408 no_bgp_bestpath_compare_router_id_cmd
,
3409 "no bgp bestpath compare-routerid",
3412 "Change the default bestpath selection\n"
3413 "Compare router-id for identical EBGP paths\n")
3415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3416 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3417 bgp_recalculate_all_bestpaths(bgp
);
3422 /* "bgp bestpath as-path ignore" configuration. */
3423 DEFUN (bgp_bestpath_aspath_ignore
,
3424 bgp_bestpath_aspath_ignore_cmd
,
3425 "bgp bestpath as-path ignore",
3427 "Change the default bestpath selection\n"
3428 "AS-path attribute\n"
3429 "Ignore as-path length in selecting a route\n")
3431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3432 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3433 bgp_recalculate_all_bestpaths(bgp
);
3438 DEFUN (no_bgp_bestpath_aspath_ignore
,
3439 no_bgp_bestpath_aspath_ignore_cmd
,
3440 "no bgp bestpath as-path ignore",
3443 "Change the default bestpath selection\n"
3444 "AS-path attribute\n"
3445 "Ignore as-path length in selecting a route\n")
3447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3448 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3449 bgp_recalculate_all_bestpaths(bgp
);
3454 /* "bgp bestpath as-path confed" configuration. */
3455 DEFUN (bgp_bestpath_aspath_confed
,
3456 bgp_bestpath_aspath_confed_cmd
,
3457 "bgp bestpath as-path confed",
3459 "Change the default bestpath selection\n"
3460 "AS-path attribute\n"
3461 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3464 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3465 bgp_recalculate_all_bestpaths(bgp
);
3470 DEFUN (no_bgp_bestpath_aspath_confed
,
3471 no_bgp_bestpath_aspath_confed_cmd
,
3472 "no bgp bestpath as-path confed",
3475 "Change the default bestpath selection\n"
3476 "AS-path attribute\n"
3477 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3480 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3481 bgp_recalculate_all_bestpaths(bgp
);
3486 /* "bgp bestpath as-path multipath-relax" configuration. */
3487 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3488 bgp_bestpath_aspath_multipath_relax_cmd
,
3489 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3491 "Change the default bestpath selection\n"
3492 "AS-path attribute\n"
3493 "Allow load sharing across routes that have different AS paths (but same length)\n"
3494 "Generate an AS_SET\n"
3495 "Do not generate an AS_SET\n")
3497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3499 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3501 /* no-as-set is now the default behavior so we can silently
3503 if (argv_find(argv
, argc
, "as-set", &idx
))
3504 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3506 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3508 bgp_recalculate_all_bestpaths(bgp
);
3513 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3514 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3515 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3518 "Change the default bestpath selection\n"
3519 "AS-path attribute\n"
3520 "Allow load sharing across routes that have different AS paths (but same length)\n"
3521 "Generate an AS_SET\n"
3522 "Do not generate an AS_SET\n")
3524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3525 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3526 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3527 bgp_recalculate_all_bestpaths(bgp
);
3532 /* "bgp bestpath peer-type multipath-relax" configuration. */
3533 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3534 bgp_bestpath_peer_type_multipath_relax_cmd
,
3535 "bgp bestpath peer-type multipath-relax",
3537 "Change the default bestpath selection\n"
3539 "Allow load sharing across routes learned from different peer types\n")
3541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3542 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3543 bgp_recalculate_all_bestpaths(bgp
);
3548 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3549 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3550 "no bgp bestpath peer-type multipath-relax",
3552 "Change the default bestpath selection\n"
3554 "Allow load sharing across routes learned from different peer types\n")
3556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3557 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3558 bgp_recalculate_all_bestpaths(bgp
);
3563 /* "bgp log-neighbor-changes" configuration. */
3564 DEFUN (bgp_log_neighbor_changes
,
3565 bgp_log_neighbor_changes_cmd
,
3566 "bgp log-neighbor-changes",
3568 "Log neighbor up/down and reset reason\n")
3570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3571 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3575 DEFUN (no_bgp_log_neighbor_changes
,
3576 no_bgp_log_neighbor_changes_cmd
,
3577 "no bgp log-neighbor-changes",
3580 "Log neighbor up/down and reset reason\n")
3582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3583 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3587 /* "bgp bestpath med" configuration. */
3588 DEFUN (bgp_bestpath_med
,
3589 bgp_bestpath_med_cmd
,
3590 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3592 "Change the default bestpath selection\n"
3594 "Compare MED among confederation paths\n"
3595 "Treat missing MED as the least preferred one\n"
3596 "Treat missing MED as the least preferred one\n"
3597 "Compare MED among confederation paths\n")
3599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3602 if (argv_find(argv
, argc
, "confed", &idx
))
3603 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3605 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3606 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3608 bgp_recalculate_all_bestpaths(bgp
);
3613 DEFUN (no_bgp_bestpath_med
,
3614 no_bgp_bestpath_med_cmd
,
3615 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3618 "Change the default bestpath selection\n"
3620 "Compare MED among confederation paths\n"
3621 "Treat missing MED as the least preferred one\n"
3622 "Treat missing MED as the least preferred one\n"
3623 "Compare MED among confederation paths\n")
3625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3628 if (argv_find(argv
, argc
, "confed", &idx
))
3629 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3631 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3632 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3634 bgp_recalculate_all_bestpaths(bgp
);
3639 /* "bgp bestpath bandwidth" configuration. */
3640 DEFPY (bgp_bestpath_bw
,
3641 bgp_bestpath_bw_cmd
,
3642 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3644 "Change the default bestpath selection\n"
3645 "Link Bandwidth attribute\n"
3646 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3647 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3648 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3655 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3656 return CMD_ERR_INCOMPLETE
;
3658 if (!strcmp(bw_cfg
, "ignore"))
3659 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3660 else if (!strcmp(bw_cfg
, "skip-missing"))
3661 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3662 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3663 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3665 return CMD_ERR_NO_MATCH
;
3667 /* This config is used in route install, so redo that. */
3668 FOREACH_AFI_SAFI (afi
, safi
) {
3669 if (!bgp_fibupd_safi(safi
))
3671 bgp_zebra_announce_table(bgp
, afi
, safi
);
3677 DEFPY (no_bgp_bestpath_bw
,
3678 no_bgp_bestpath_bw_cmd
,
3679 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3682 "Change the default bestpath selection\n"
3683 "Link Bandwidth attribute\n"
3684 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3685 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3686 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3692 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3694 /* This config is used in route install, so redo that. */
3695 FOREACH_AFI_SAFI (afi
, safi
) {
3696 if (!bgp_fibupd_safi(safi
))
3698 bgp_zebra_announce_table(bgp
, afi
, safi
);
3703 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3704 "[no] bgp default <ipv4-unicast|"
3707 "ipv4-labeled-unicast|"
3712 "ipv6-labeled-unicast|"
3714 "l2vpn-evpn>$afi_safi",
3717 "Configure BGP defaults\n"
3718 "Activate ipv4-unicast for a peer by default\n"
3719 "Activate ipv4-multicast for a peer by default\n"
3720 "Activate ipv4-vpn for a peer by default\n"
3721 "Activate ipv4-labeled-unicast for a peer by default\n"
3722 "Activate ipv4-flowspec for a peer by default\n"
3723 "Activate ipv6-unicast for a peer by default\n"
3724 "Activate ipv6-multicast for a peer by default\n"
3725 "Activate ipv6-vpn for a peer by default\n"
3726 "Activate ipv6-labeled-unicast for a peer by default\n"
3727 "Activate ipv6-flowspec for a peer by default\n"
3728 "Activate l2vpn-evpn for a peer by default\n")
3730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3731 char afi_safi_str
[strlen(afi_safi
) + 1];
3732 char *afi_safi_str_tok
;
3734 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3735 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3736 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3737 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3740 if (strmatch(safi_str
, "labeled"))
3741 safi
= bgp_vty_safi_from_str("labeled-unicast");
3743 safi
= bgp_vty_safi_from_str(safi_str
);
3746 bgp
->default_af
[afi
][safi
] = false;
3748 if ((safi
== SAFI_LABELED_UNICAST
3749 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3750 || (safi
== SAFI_UNICAST
3751 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3752 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3754 bgp
->default_af
[afi
][safi
] = true;
3760 /* Display hostname in certain command outputs */
3761 DEFUN (bgp_default_show_hostname
,
3762 bgp_default_show_hostname_cmd
,
3763 "bgp default show-hostname",
3765 "Configure BGP defaults\n"
3766 "Show hostname in certain command outputs\n")
3768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3769 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3773 DEFUN (no_bgp_default_show_hostname
,
3774 no_bgp_default_show_hostname_cmd
,
3775 "no bgp default show-hostname",
3778 "Configure BGP defaults\n"
3779 "Show hostname in certain command outputs\n")
3781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3782 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3786 /* Display hostname in certain command outputs */
3787 DEFUN (bgp_default_show_nexthop_hostname
,
3788 bgp_default_show_nexthop_hostname_cmd
,
3789 "bgp default show-nexthop-hostname",
3791 "Configure BGP defaults\n"
3792 "Show hostname for nexthop in certain command outputs\n")
3794 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3795 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3799 DEFUN (no_bgp_default_show_nexthop_hostname
,
3800 no_bgp_default_show_nexthop_hostname_cmd
,
3801 "no bgp default show-nexthop-hostname",
3804 "Configure BGP defaults\n"
3805 "Show hostname for nexthop in certain command outputs\n")
3807 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3808 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3812 /* "bgp network import-check" configuration. */
3813 DEFUN (bgp_network_import_check
,
3814 bgp_network_import_check_cmd
,
3815 "bgp network import-check",
3817 "BGP network command\n"
3818 "Check BGP network route exists in IGP\n")
3820 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3821 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3822 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3823 bgp_static_redo_import_check(bgp
);
3829 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3830 "bgp network import-check exact",
3832 "BGP network command\n"
3833 "Check BGP network route exists in IGP\n"
3834 "Match route precisely\n")
3836 DEFUN (no_bgp_network_import_check
,
3837 no_bgp_network_import_check_cmd
,
3838 "no bgp network import-check",
3841 "BGP network command\n"
3842 "Check BGP network route exists in IGP\n")
3844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3845 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3846 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3847 bgp_static_redo_import_check(bgp
);
3853 DEFUN (bgp_default_local_preference
,
3854 bgp_default_local_preference_cmd
,
3855 "bgp default local-preference (0-4294967295)",
3857 "Configure BGP defaults\n"
3858 "local preference (higher=more preferred)\n"
3859 "Configure default local preference value\n")
3861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3863 uint32_t local_pref
;
3865 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3867 bgp_default_local_preference_set(bgp
, local_pref
);
3868 bgp_clear_star_soft_in(vty
, bgp
->name
);
3873 DEFUN (no_bgp_default_local_preference
,
3874 no_bgp_default_local_preference_cmd
,
3875 "no bgp default local-preference [(0-4294967295)]",
3878 "Configure BGP defaults\n"
3879 "local preference (higher=more preferred)\n"
3880 "Configure default local preference value\n")
3882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3883 bgp_default_local_preference_unset(bgp
);
3884 bgp_clear_star_soft_in(vty
, bgp
->name
);
3890 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3891 bgp_default_subgroup_pkt_queue_max_cmd
,
3892 "bgp default subgroup-pkt-queue-max (20-100)",
3894 "Configure BGP defaults\n"
3895 "subgroup-pkt-queue-max\n"
3896 "Configure subgroup packet queue max\n")
3898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3902 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3904 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3909 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3910 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3911 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3914 "Configure BGP defaults\n"
3915 "subgroup-pkt-queue-max\n"
3916 "Configure subgroup packet queue max\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3919 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3924 DEFUN (bgp_rr_allow_outbound_policy
,
3925 bgp_rr_allow_outbound_policy_cmd
,
3926 "bgp route-reflector allow-outbound-policy",
3928 "Allow modifications made by out route-map\n"
3929 "on ibgp neighbors\n")
3931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3933 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3934 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3935 update_group_announce_rrclients(bgp
);
3936 bgp_clear_star_soft_out(vty
, bgp
->name
);
3942 DEFUN (no_bgp_rr_allow_outbound_policy
,
3943 no_bgp_rr_allow_outbound_policy_cmd
,
3944 "no bgp route-reflector allow-outbound-policy",
3947 "Allow modifications made by out route-map\n"
3948 "on ibgp neighbors\n")
3950 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3952 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3953 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3954 update_group_announce_rrclients(bgp
);
3955 bgp_clear_star_soft_out(vty
, bgp
->name
);
3961 DEFUN (bgp_listen_limit
,
3962 bgp_listen_limit_cmd
,
3963 "bgp listen limit (1-65535)",
3965 "BGP Dynamic Neighbors listen commands\n"
3966 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3967 "Configure Dynamic Neighbors listen limit value\n")
3969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3973 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3975 bgp_listen_limit_set(bgp
, listen_limit
);
3980 DEFUN (no_bgp_listen_limit
,
3981 no_bgp_listen_limit_cmd
,
3982 "no bgp listen limit [(1-65535)]",
3985 "BGP Dynamic Neighbors listen commands\n"
3986 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3987 "Configure Dynamic Neighbors listen limit value\n")
3989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3990 bgp_listen_limit_unset(bgp
);
3996 * Check if this listen range is already configured. Check for exact
3997 * match or overlap based on input.
3999 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4000 struct prefix
*range
, int exact
)
4002 struct listnode
*node
, *nnode
;
4003 struct listnode
*node1
, *nnode1
;
4004 struct peer_group
*group
;
4009 afi
= family2afi(range
->family
);
4010 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4011 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4014 match
= prefix_same(range
, lr
);
4016 match
= (prefix_match(range
, lr
)
4017 || prefix_match(lr
, range
));
4026 DEFUN (bgp_listen_range
,
4027 bgp_listen_range_cmd
,
4028 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4030 "Configure BGP dynamic neighbors listen range\n"
4031 "Configure BGP dynamic neighbors listen range\n"
4033 "Member of the peer-group\n"
4034 "Peer-group name\n")
4036 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4037 struct prefix range
;
4038 struct peer_group
*group
, *existing_group
;
4043 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4044 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4045 char *prefix
= argv
[idx
]->arg
;
4046 argv_find(argv
, argc
, "PGNAME", &idx
);
4047 char *peergroup
= argv
[idx
]->arg
;
4049 /* Convert IP prefix string to struct prefix. */
4050 ret
= str2prefix(prefix
, &range
);
4052 vty_out(vty
, "%% Malformed listen range\n");
4053 return CMD_WARNING_CONFIG_FAILED
;
4056 afi
= family2afi(range
.family
);
4058 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4060 "%% Malformed listen range (link-local address)\n");
4061 return CMD_WARNING_CONFIG_FAILED
;
4066 /* Check if same listen range is already configured. */
4067 existing_group
= listen_range_exists(bgp
, &range
, 1);
4068 if (existing_group
) {
4069 if (strcmp(existing_group
->name
, peergroup
) == 0)
4073 "%% Same listen range is attached to peer-group %s\n",
4074 existing_group
->name
);
4075 return CMD_WARNING_CONFIG_FAILED
;
4079 /* Check if an overlapping listen range exists. */
4080 if (listen_range_exists(bgp
, &range
, 0)) {
4082 "%% Listen range overlaps with existing listen range\n");
4083 return CMD_WARNING_CONFIG_FAILED
;
4086 group
= peer_group_lookup(bgp
, peergroup
);
4088 vty_out(vty
, "%% Configure the peer-group first\n");
4089 return CMD_WARNING_CONFIG_FAILED
;
4092 ret
= peer_group_listen_range_add(group
, &range
);
4093 return bgp_vty_return(vty
, ret
);
4096 DEFUN (no_bgp_listen_range
,
4097 no_bgp_listen_range_cmd
,
4098 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4101 "Unconfigure BGP dynamic neighbors listen range\n"
4102 "Unconfigure BGP dynamic neighbors listen range\n"
4104 "Member of the peer-group\n"
4105 "Peer-group name\n")
4107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4108 struct prefix range
;
4109 struct peer_group
*group
;
4114 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4115 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4116 char *prefix
= argv
[idx
]->arg
;
4117 argv_find(argv
, argc
, "PGNAME", &idx
);
4118 char *peergroup
= argv
[idx
]->arg
;
4120 /* Convert IP prefix string to struct prefix. */
4121 ret
= str2prefix(prefix
, &range
);
4123 vty_out(vty
, "%% Malformed listen range\n");
4124 return CMD_WARNING_CONFIG_FAILED
;
4127 afi
= family2afi(range
.family
);
4129 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4131 "%% Malformed listen range (link-local address)\n");
4132 return CMD_WARNING_CONFIG_FAILED
;
4137 group
= peer_group_lookup(bgp
, peergroup
);
4139 vty_out(vty
, "%% Peer-group does not exist\n");
4140 return CMD_WARNING_CONFIG_FAILED
;
4143 ret
= peer_group_listen_range_del(group
, &range
);
4144 return bgp_vty_return(vty
, ret
);
4147 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4149 struct peer_group
*group
;
4150 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4151 struct prefix
*range
;
4154 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4155 vty_out(vty
, " bgp listen limit %d\n",
4156 bgp
->dynamic_neighbors_limit
);
4158 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4159 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4160 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4163 " bgp listen range %pFX peer-group %s\n",
4164 range
, group
->name
);
4171 DEFUN (bgp_disable_connected_route_check
,
4172 bgp_disable_connected_route_check_cmd
,
4173 "bgp disable-ebgp-connected-route-check",
4175 "Disable checking if nexthop is connected on ebgp sessions\n")
4177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4178 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4179 bgp_clear_star_soft_in(vty
, bgp
->name
);
4184 DEFUN (no_bgp_disable_connected_route_check
,
4185 no_bgp_disable_connected_route_check_cmd
,
4186 "no bgp disable-ebgp-connected-route-check",
4189 "Disable checking if nexthop is connected on ebgp sessions\n")
4191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4192 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4193 bgp_clear_star_soft_in(vty
, bgp
->name
);
4199 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4205 int as_type
= AS_SPECIFIED
;
4208 if (as_str
[0] == 'i') {
4210 as_type
= AS_INTERNAL
;
4211 } else if (as_str
[0] == 'e') {
4213 as_type
= AS_EXTERNAL
;
4215 /* Get AS number. */
4216 as
= strtoul(as_str
, NULL
, 10);
4219 /* If peer is peer group or interface peer, call proper function. */
4220 ret
= str2sockunion(peer_str
, &su
);
4224 /* Check if existing interface peer */
4225 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4227 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4229 /* if not interface peer, check peer-group settings */
4230 if (ret
< 0 && !peer
) {
4231 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4234 "%% Create the peer-group or interface first\n");
4235 return CMD_WARNING_CONFIG_FAILED
;
4240 if (peer_address_self_check(bgp
, &su
)) {
4242 "%% Can not configure the local system as neighbor\n");
4243 return CMD_WARNING_CONFIG_FAILED
;
4245 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4248 return bgp_vty_return(vty
, ret
);
4251 DEFUN (bgp_default_shutdown
,
4252 bgp_default_shutdown_cmd
,
4253 "[no] bgp default shutdown",
4256 "Configure BGP defaults\n"
4257 "Apply administrative shutdown to newly configured peers\n")
4259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4260 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4264 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4266 "Administrative shutdown of the BGP instance\n"
4267 "Add a shutdown message (RFC 8203)\n"
4268 "Shutdown message\n")
4270 char *msgstr
= NULL
;
4272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4275 msgstr
= argv_concat(argv
, argc
, 3);
4277 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4278 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4279 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4280 return CMD_WARNING_CONFIG_FAILED
;
4283 bgp_shutdown_enable(bgp
, msgstr
);
4284 XFREE(MTYPE_TMP
, msgstr
);
4289 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4290 BGP_STR
"Administrative shutdown of the BGP instance\n")
4292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4294 bgp_shutdown_enable(bgp
, NULL
);
4299 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4300 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4304 bgp_shutdown_disable(bgp
);
4309 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4310 "no bgp shutdown message MSG...", NO_STR BGP_STR
4311 "Administrative shutdown of the BGP instance\n"
4312 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4314 DEFUN (neighbor_remote_as
,
4315 neighbor_remote_as_cmd
,
4316 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4319 "Specify a BGP neighbor\n"
4321 "Internal BGP peer\n"
4322 "External BGP peer\n")
4325 int idx_remote_as
= 3;
4326 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4327 argv
[idx_remote_as
]->arg
);
4329 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4330 * sessions do not wait for hold timer expiry to bring down the sessions
4331 * when nexthop becomes unreachable
4333 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4334 BGP_STR
"Fast convergence for bgp sessions\n")
4336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4337 bgp
->fast_convergence
= true;
4342 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4343 "no bgp fast-convergence",
4344 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4347 bgp
->fast_convergence
= false;
4352 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4354 const char *peer_group_name
,
4357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4359 int as_type
= AS_UNSPECIFIED
;
4361 struct peer_group
*group
;
4364 group
= peer_group_lookup(bgp
, conf_if
);
4367 vty_out(vty
, "%% Name conflict with peer-group \n");
4368 return CMD_WARNING_CONFIG_FAILED
;
4372 if (as_str
[0] == 'i') {
4373 as_type
= AS_INTERNAL
;
4374 } else if (as_str
[0] == 'e') {
4375 as_type
= AS_EXTERNAL
;
4377 /* Get AS number. */
4378 as
= strtoul(as_str
, NULL
, 10);
4379 as_type
= AS_SPECIFIED
;
4383 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4386 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4388 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4392 vty_out(vty
, "%% BGP failed to create peer\n");
4393 return CMD_WARNING_CONFIG_FAILED
;
4397 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4399 /* Request zebra to initiate IPv6 RAs on this interface. We do
4401 * any unnumbered peer in order to not worry about run-time
4403 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4405 * gets deleted later etc.)
4408 bgp_zebra_initiate_radv(bgp
, peer
);
4411 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4412 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4414 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4416 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4418 /* v6only flag changed. Reset bgp seesion */
4419 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4420 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4421 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4422 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4424 bgp_session_reset(peer
);
4427 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4428 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4429 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4430 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4433 if (peer_group_name
) {
4434 group
= peer_group_lookup(bgp
, peer_group_name
);
4436 vty_out(vty
, "%% Configure the peer-group first\n");
4437 return CMD_WARNING_CONFIG_FAILED
;
4440 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4443 return bgp_vty_return(vty
, ret
);
4446 DEFUN (neighbor_interface_config
,
4447 neighbor_interface_config_cmd
,
4448 "neighbor WORD interface [peer-group PGNAME]",
4450 "Interface name or neighbor tag\n"
4451 "Enable BGP on interface\n"
4452 "Member of the peer-group\n"
4453 "Peer-group name\n")
4456 int idx_peer_group_word
= 4;
4458 if (argc
> idx_peer_group_word
)
4459 return peer_conf_interface_get(
4460 vty
, argv
[idx_word
]->arg
, 0,
4461 argv
[idx_peer_group_word
]->arg
, NULL
);
4463 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4467 DEFUN (neighbor_interface_config_v6only
,
4468 neighbor_interface_config_v6only_cmd
,
4469 "neighbor WORD interface v6only [peer-group PGNAME]",
4471 "Interface name or neighbor tag\n"
4472 "Enable BGP on interface\n"
4473 "Enable BGP with v6 link-local only\n"
4474 "Member of the peer-group\n"
4475 "Peer-group name\n")
4478 int idx_peer_group_word
= 5;
4480 if (argc
> idx_peer_group_word
)
4481 return peer_conf_interface_get(
4482 vty
, argv
[idx_word
]->arg
, 1,
4483 argv
[idx_peer_group_word
]->arg
, NULL
);
4485 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4489 DEFUN (neighbor_interface_config_remote_as
,
4490 neighbor_interface_config_remote_as_cmd
,
4491 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4493 "Interface name or neighbor tag\n"
4494 "Enable BGP on interface\n"
4495 "Specify a BGP neighbor\n"
4497 "Internal BGP peer\n"
4498 "External BGP peer\n")
4501 int idx_remote_as
= 4;
4502 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4503 argv
[idx_remote_as
]->arg
);
4506 DEFUN (neighbor_interface_v6only_config_remote_as
,
4507 neighbor_interface_v6only_config_remote_as_cmd
,
4508 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4510 "Interface name or neighbor tag\n"
4511 "Enable BGP with v6 link-local only\n"
4512 "Enable BGP on interface\n"
4513 "Specify a BGP neighbor\n"
4515 "Internal BGP peer\n"
4516 "External BGP peer\n")
4519 int idx_remote_as
= 5;
4520 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4521 argv
[idx_remote_as
]->arg
);
4524 DEFUN (neighbor_peer_group
,
4525 neighbor_peer_group_cmd
,
4526 "neighbor WORD peer-group",
4528 "Interface name or neighbor tag\n"
4529 "Configure peer-group\n")
4531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4534 struct peer_group
*group
;
4536 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4538 vty_out(vty
, "%% Name conflict with interface: \n");
4539 return CMD_WARNING_CONFIG_FAILED
;
4542 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4544 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4545 return CMD_WARNING_CONFIG_FAILED
;
4553 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4557 "Specify a BGP neighbor\n"
4559 "Internal BGP peer\n"
4560 "External BGP peer\n")
4562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4566 struct peer_group
*group
;
4570 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4572 /* look up for neighbor by interface name config. */
4573 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4575 /* Request zebra to terminate IPv6 RAs on this
4578 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4579 peer_notify_unconfig(peer
);
4584 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4586 peer_group_notify_unconfig(group
);
4587 peer_group_delete(group
);
4589 vty_out(vty
, "%% Create the peer-group first\n");
4590 return CMD_WARNING_CONFIG_FAILED
;
4593 peer
= peer_lookup(bgp
, &su
);
4595 if (peer_dynamic_neighbor(peer
)) {
4597 "%% Operation not allowed on a dynamic neighbor\n");
4598 return CMD_WARNING_CONFIG_FAILED
;
4601 other
= peer
->doppelganger
;
4603 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4604 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4606 peer_notify_unconfig(peer
);
4608 if (other
&& other
->status
!= Deleted
) {
4609 peer_notify_unconfig(other
);
4618 DEFUN (no_neighbor_interface_config
,
4619 no_neighbor_interface_config_cmd
,
4620 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4624 "Configure BGP on interface\n"
4625 "Enable BGP with v6 link-local only\n"
4626 "Member of the peer-group\n"
4628 "Specify a BGP neighbor\n"
4630 "Internal BGP peer\n"
4631 "External BGP peer\n")
4633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4637 /* look up for neighbor by interface name config. */
4638 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4640 /* Request zebra to terminate IPv6 RAs on this interface. */
4642 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4643 peer_notify_unconfig(peer
);
4646 vty_out(vty
, "%% Create the bgp interface first\n");
4647 return CMD_WARNING_CONFIG_FAILED
;
4652 DEFUN (no_neighbor_peer_group
,
4653 no_neighbor_peer_group_cmd
,
4654 "no neighbor WORD peer-group",
4658 "Configure peer-group\n")
4660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4662 struct peer_group
*group
;
4664 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4666 peer_group_notify_unconfig(group
);
4667 peer_group_delete(group
);
4669 vty_out(vty
, "%% Create the peer-group first\n");
4670 return CMD_WARNING_CONFIG_FAILED
;
4675 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4676 no_neighbor_interface_peer_group_remote_as_cmd
,
4677 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4680 "Interface name or neighbor tag\n"
4681 "Specify a BGP neighbor\n"
4683 "Internal BGP peer\n"
4684 "External BGP peer\n")
4686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4688 struct peer_group
*group
;
4691 /* look up for neighbor by interface name config. */
4692 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4694 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4698 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4700 peer_group_remote_as_delete(group
);
4702 vty_out(vty
, "%% Create the peer-group or interface first\n");
4703 return CMD_WARNING_CONFIG_FAILED
;
4708 DEFUN (neighbor_local_as
,
4709 neighbor_local_as_cmd
,
4710 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4713 "Specify a local-as number\n"
4714 "AS number used as local AS\n")
4722 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4724 return CMD_WARNING_CONFIG_FAILED
;
4726 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4727 ret
= peer_local_as_set(peer
, as
, 0, 0);
4728 return bgp_vty_return(vty
, ret
);
4731 DEFUN (neighbor_local_as_no_prepend
,
4732 neighbor_local_as_no_prepend_cmd
,
4733 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4736 "Specify a local-as number\n"
4737 "AS number used as local AS\n"
4738 "Do not prepend local-as to updates from ebgp peers\n")
4746 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4748 return CMD_WARNING_CONFIG_FAILED
;
4750 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4751 ret
= peer_local_as_set(peer
, as
, 1, 0);
4752 return bgp_vty_return(vty
, ret
);
4755 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4756 neighbor_local_as_no_prepend_replace_as_cmd
,
4757 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4760 "Specify a local-as number\n"
4761 "AS number used as local AS\n"
4762 "Do not prepend local-as to updates from ebgp peers\n"
4763 "Do not prepend local-as to updates from ibgp peers\n")
4771 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4773 return CMD_WARNING_CONFIG_FAILED
;
4775 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4776 ret
= peer_local_as_set(peer
, as
, 1, 1);
4777 return bgp_vty_return(vty
, ret
);
4780 DEFUN (no_neighbor_local_as
,
4781 no_neighbor_local_as_cmd
,
4782 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4786 "Specify a local-as number\n"
4787 "AS number used as local AS\n"
4788 "Do not prepend local-as to updates from ebgp peers\n"
4789 "Do not prepend local-as to updates from ibgp peers\n")
4795 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4797 return CMD_WARNING_CONFIG_FAILED
;
4799 ret
= peer_local_as_unset(peer
);
4800 return bgp_vty_return(vty
, ret
);
4804 DEFUN (neighbor_solo
,
4806 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4809 "Solo peer - part of its own update group\n")
4815 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4817 return CMD_WARNING_CONFIG_FAILED
;
4819 ret
= update_group_adjust_soloness(peer
, 1);
4820 return bgp_vty_return(vty
, ret
);
4823 DEFUN (no_neighbor_solo
,
4824 no_neighbor_solo_cmd
,
4825 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4829 "Solo peer - part of its own update group\n")
4835 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4837 return CMD_WARNING_CONFIG_FAILED
;
4839 ret
= update_group_adjust_soloness(peer
, 0);
4840 return bgp_vty_return(vty
, ret
);
4843 DEFUN (neighbor_password
,
4844 neighbor_password_cmd
,
4845 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4856 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4858 return CMD_WARNING_CONFIG_FAILED
;
4860 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4861 return bgp_vty_return(vty
, ret
);
4864 DEFUN (no_neighbor_password
,
4865 no_neighbor_password_cmd
,
4866 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4877 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4879 return CMD_WARNING_CONFIG_FAILED
;
4881 ret
= peer_password_unset(peer
);
4882 return bgp_vty_return(vty
, ret
);
4885 DEFUN (neighbor_activate
,
4886 neighbor_activate_cmd
,
4887 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4890 "Enable the Address Family for this Neighbor\n")
4896 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4898 return CMD_WARNING_CONFIG_FAILED
;
4900 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4901 return bgp_vty_return(vty
, ret
);
4904 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4905 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4906 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4907 "Enable the Address Family for this Neighbor\n")
4909 DEFUN (no_neighbor_activate
,
4910 no_neighbor_activate_cmd
,
4911 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4915 "Enable the Address Family for this Neighbor\n")
4922 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4924 return CMD_WARNING_CONFIG_FAILED
;
4926 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4927 return bgp_vty_return(vty
, ret
);
4930 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4931 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4932 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4933 "Enable the Address Family for this Neighbor\n")
4935 DEFUN (neighbor_set_peer_group
,
4936 neighbor_set_peer_group_cmd
,
4937 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4940 "Member of the peer-group\n"
4941 "Peer-group name\n")
4943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4950 struct peer_group
*group
;
4952 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4954 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4956 vty_out(vty
, "%% Malformed address or name: %s\n",
4957 argv
[idx_peer
]->arg
);
4958 return CMD_WARNING_CONFIG_FAILED
;
4961 if (peer_address_self_check(bgp
, &su
)) {
4963 "%% Can not configure the local system as neighbor\n");
4964 return CMD_WARNING_CONFIG_FAILED
;
4967 /* Disallow for dynamic neighbor. */
4968 peer
= peer_lookup(bgp
, &su
);
4969 if (peer
&& peer_dynamic_neighbor(peer
)) {
4971 "%% Operation not allowed on a dynamic neighbor\n");
4972 return CMD_WARNING_CONFIG_FAILED
;
4976 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4978 vty_out(vty
, "%% Configure the peer-group first\n");
4979 return CMD_WARNING_CONFIG_FAILED
;
4982 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4984 return bgp_vty_return(vty
, ret
);
4987 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4988 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4989 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4990 "Member of the peer-group\n"
4991 "Peer-group name\n")
4993 DEFUN (no_neighbor_set_peer_group
,
4994 no_neighbor_set_peer_group_cmd
,
4995 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4999 "Member of the peer-group\n"
5000 "Peer-group name\n")
5002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5007 struct peer_group
*group
;
5009 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5011 return CMD_WARNING_CONFIG_FAILED
;
5013 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5015 vty_out(vty
, "%% Configure the peer-group first\n");
5016 return CMD_WARNING_CONFIG_FAILED
;
5019 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5020 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5022 peer_notify_unconfig(peer
);
5023 ret
= peer_delete(peer
);
5025 return bgp_vty_return(vty
, ret
);
5028 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5029 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5031 "Member of the peer-group\n"
5032 "Peer-group name\n")
5034 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5035 uint32_t flag
, int set
)
5040 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5042 return CMD_WARNING_CONFIG_FAILED
;
5045 * If 'neighbor <interface>', then this is for directly connected peers,
5046 * we should not accept disable-connected-check.
5048 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5050 "%s is directly connected peer, cannot accept disable-connected-check\n",
5052 return CMD_WARNING_CONFIG_FAILED
;
5055 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5056 peer_tx_shutdown_message_unset(peer
);
5059 ret
= peer_flag_set(peer
, flag
);
5061 ret
= peer_flag_unset(peer
, flag
);
5063 return bgp_vty_return(vty
, ret
);
5066 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5068 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5071 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5074 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5077 /* neighbor passive. */
5078 DEFUN (neighbor_passive
,
5079 neighbor_passive_cmd
,
5080 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5083 "Don't send open messages to this neighbor\n")
5086 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5089 DEFUN (no_neighbor_passive
,
5090 no_neighbor_passive_cmd
,
5091 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5095 "Don't send open messages to this neighbor\n")
5098 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5101 /* neighbor shutdown. */
5102 DEFUN (neighbor_shutdown_msg
,
5103 neighbor_shutdown_msg_cmd
,
5104 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5107 "Administratively shut down this neighbor\n"
5108 "Add a shutdown message (RFC 8203)\n"
5109 "Shutdown message\n")
5115 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5119 return CMD_WARNING_CONFIG_FAILED
;
5120 message
= argv_concat(argv
, argc
, 4);
5121 peer_tx_shutdown_message_set(peer
, message
);
5122 XFREE(MTYPE_TMP
, message
);
5125 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5128 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5129 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5130 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5131 "Administratively shut down this neighbor\n")
5133 DEFUN (no_neighbor_shutdown_msg
,
5134 no_neighbor_shutdown_msg_cmd
,
5135 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5139 "Administratively shut down this neighbor\n"
5140 "Remove a shutdown message (RFC 8203)\n"
5141 "Shutdown message\n")
5145 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5146 PEER_FLAG_SHUTDOWN
);
5149 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5150 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5152 "Administratively shut down this neighbor\n")
5154 DEFUN(neighbor_shutdown_rtt
,
5155 neighbor_shutdown_rtt_cmd
,
5156 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5159 "Administratively shut down this neighbor\n"
5160 "Shutdown if round-trip-time is higher than expected\n"
5161 "Round-trip-time in milliseconds\n"
5162 "Specify the number of keepalives before shutdown\n"
5163 "The number of keepalives with higher RTT to shutdown\n")
5170 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5173 return CMD_WARNING_CONFIG_FAILED
;
5175 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5177 if (argv_find(argv
, argc
, "count", &idx_count
))
5178 peer
->rtt_keepalive_conf
=
5179 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5181 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5182 PEER_FLAG_RTT_SHUTDOWN
);
5185 DEFUN(no_neighbor_shutdown_rtt
,
5186 no_neighbor_shutdown_rtt_cmd
,
5187 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5191 "Administratively shut down this neighbor\n"
5192 "Shutdown if round-trip-time is higher than expected\n"
5193 "Round-trip-time in milliseconds\n"
5194 "Specify the number of keepalives before shutdown\n"
5195 "The number of keepalives with higher RTT to shutdown\n")
5200 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5203 return CMD_WARNING_CONFIG_FAILED
;
5205 peer
->rtt_expected
= 0;
5206 peer
->rtt_keepalive_conf
= 1;
5208 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5209 PEER_FLAG_RTT_SHUTDOWN
);
5212 /* neighbor capability dynamic. */
5213 DEFUN (neighbor_capability_dynamic
,
5214 neighbor_capability_dynamic_cmd
,
5215 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5218 "Advertise capability to the peer\n"
5219 "Advertise dynamic capability to this neighbor\n")
5222 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5223 PEER_FLAG_DYNAMIC_CAPABILITY
);
5226 DEFUN (no_neighbor_capability_dynamic
,
5227 no_neighbor_capability_dynamic_cmd
,
5228 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5232 "Advertise capability to the peer\n"
5233 "Advertise dynamic capability to this neighbor\n")
5236 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5237 PEER_FLAG_DYNAMIC_CAPABILITY
);
5240 /* neighbor dont-capability-negotiate */
5241 DEFUN (neighbor_dont_capability_negotiate
,
5242 neighbor_dont_capability_negotiate_cmd
,
5243 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5246 "Do not perform capability negotiation\n")
5249 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5250 PEER_FLAG_DONT_CAPABILITY
);
5253 DEFUN (no_neighbor_dont_capability_negotiate
,
5254 no_neighbor_dont_capability_negotiate_cmd
,
5255 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5259 "Do not perform capability negotiation\n")
5262 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5263 PEER_FLAG_DONT_CAPABILITY
);
5266 /* neighbor capability extended next hop encoding */
5267 DEFUN (neighbor_capability_enhe
,
5268 neighbor_capability_enhe_cmd
,
5269 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5272 "Advertise capability to the peer\n"
5273 "Advertise extended next-hop capability to the peer\n")
5276 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5277 PEER_FLAG_CAPABILITY_ENHE
);
5280 DEFUN (no_neighbor_capability_enhe
,
5281 no_neighbor_capability_enhe_cmd
,
5282 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5286 "Advertise capability to the peer\n"
5287 "Advertise extended next-hop capability to the peer\n")
5290 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5291 PEER_FLAG_CAPABILITY_ENHE
);
5294 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5295 afi_t afi
, safi_t safi
, uint32_t flag
,
5301 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5303 return CMD_WARNING_CONFIG_FAILED
;
5306 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5308 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5310 return bgp_vty_return(vty
, ret
);
5313 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5314 afi_t afi
, safi_t safi
, uint32_t flag
)
5316 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5319 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5320 afi_t afi
, safi_t safi
, uint32_t flag
)
5322 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5325 /* neighbor capability orf prefix-list. */
5326 DEFUN (neighbor_capability_orf_prefix
,
5327 neighbor_capability_orf_prefix_cmd
,
5328 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5331 "Advertise capability to the peer\n"
5332 "Advertise ORF capability to the peer\n"
5333 "Advertise prefixlist ORF capability to this neighbor\n"
5334 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5335 "Capability to RECEIVE the ORF from this neighbor\n"
5336 "Capability to SEND the ORF to this neighbor\n")
5338 int idx_send_recv
= 5;
5339 char *peer_str
= argv
[1]->arg
;
5341 afi_t afi
= bgp_node_afi(vty
);
5342 safi_t safi
= bgp_node_safi(vty
);
5344 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5346 return CMD_WARNING_CONFIG_FAILED
;
5348 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5349 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5350 PEER_FLAG_ORF_PREFIX_SM
);
5352 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5353 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5354 PEER_FLAG_ORF_PREFIX_RM
);
5356 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5357 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5358 PEER_FLAG_ORF_PREFIX_SM
)
5359 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5360 PEER_FLAG_ORF_PREFIX_RM
);
5362 return CMD_WARNING_CONFIG_FAILED
;
5366 neighbor_capability_orf_prefix
,
5367 neighbor_capability_orf_prefix_hidden_cmd
,
5368 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5369 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5370 "Advertise capability to the peer\n"
5371 "Advertise ORF capability to the peer\n"
5372 "Advertise prefixlist ORF capability to this neighbor\n"
5373 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5374 "Capability to RECEIVE the ORF from this neighbor\n"
5375 "Capability to SEND the ORF to this neighbor\n")
5377 DEFUN (no_neighbor_capability_orf_prefix
,
5378 no_neighbor_capability_orf_prefix_cmd
,
5379 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5383 "Advertise capability to the peer\n"
5384 "Advertise ORF capability to the peer\n"
5385 "Advertise prefixlist ORF capability to this neighbor\n"
5386 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5387 "Capability to RECEIVE the ORF from this neighbor\n"
5388 "Capability to SEND the ORF to this neighbor\n")
5390 int idx_send_recv
= 6;
5391 char *peer_str
= argv
[2]->arg
;
5393 afi_t afi
= bgp_node_afi(vty
);
5394 safi_t safi
= bgp_node_safi(vty
);
5396 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5398 return CMD_WARNING_CONFIG_FAILED
;
5400 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5401 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5402 PEER_FLAG_ORF_PREFIX_SM
);
5404 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5405 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5406 PEER_FLAG_ORF_PREFIX_RM
);
5408 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5409 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5410 PEER_FLAG_ORF_PREFIX_SM
)
5411 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5412 PEER_FLAG_ORF_PREFIX_RM
);
5414 return CMD_WARNING_CONFIG_FAILED
;
5418 no_neighbor_capability_orf_prefix
,
5419 no_neighbor_capability_orf_prefix_hidden_cmd
,
5420 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5421 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5422 "Advertise capability to the peer\n"
5423 "Advertise ORF capability to the peer\n"
5424 "Advertise prefixlist ORF capability to this neighbor\n"
5425 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5426 "Capability to RECEIVE the ORF from this neighbor\n"
5427 "Capability to SEND the ORF to this neighbor\n")
5429 /* neighbor next-hop-self. */
5430 DEFUN (neighbor_nexthop_self
,
5431 neighbor_nexthop_self_cmd
,
5432 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5435 "Disable the next hop calculation for this neighbor\n")
5438 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5439 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5442 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5443 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5444 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5445 "Disable the next hop calculation for this neighbor\n")
5447 /* neighbor next-hop-self. */
5448 DEFUN (neighbor_nexthop_self_force
,
5449 neighbor_nexthop_self_force_cmd
,
5450 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5453 "Disable the next hop calculation for this neighbor\n"
5454 "Set the next hop to self for reflected routes\n")
5457 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5459 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5462 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5463 neighbor_nexthop_self_force_hidden_cmd
,
5464 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5465 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5466 "Disable the next hop calculation for this neighbor\n"
5467 "Set the next hop to self for reflected routes\n")
5469 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5470 neighbor_nexthop_self_all_hidden_cmd
,
5471 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5472 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5473 "Disable the next hop calculation for this neighbor\n"
5474 "Set the next hop to self for reflected routes\n")
5476 DEFUN (no_neighbor_nexthop_self
,
5477 no_neighbor_nexthop_self_cmd
,
5478 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5482 "Disable the next hop calculation for this neighbor\n")
5485 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5486 bgp_node_afi(vty
), bgp_node_safi(vty
),
5487 PEER_FLAG_NEXTHOP_SELF
);
5490 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5491 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5492 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5493 "Disable the next hop calculation for this neighbor\n")
5495 DEFUN (no_neighbor_nexthop_self_force
,
5496 no_neighbor_nexthop_self_force_cmd
,
5497 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5501 "Disable the next hop calculation for this neighbor\n"
5502 "Set the next hop to self for reflected routes\n")
5505 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5506 bgp_node_afi(vty
), bgp_node_safi(vty
),
5507 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5510 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5511 no_neighbor_nexthop_self_force_hidden_cmd
,
5512 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5513 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5514 "Disable the next hop calculation for this neighbor\n"
5515 "Set the next hop to self for reflected routes\n")
5517 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5518 no_neighbor_nexthop_self_all_hidden_cmd
,
5519 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5520 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5521 "Disable the next hop calculation for this neighbor\n"
5522 "Set the next hop to self for reflected routes\n")
5524 /* neighbor as-override */
5525 DEFUN (neighbor_as_override
,
5526 neighbor_as_override_cmd
,
5527 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5530 "Override ASNs in outbound updates if aspath equals remote-as\n")
5533 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5534 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5537 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5538 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5539 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5540 "Override ASNs in outbound updates if aspath equals remote-as\n")
5542 DEFUN (no_neighbor_as_override
,
5543 no_neighbor_as_override_cmd
,
5544 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5548 "Override ASNs in outbound updates if aspath equals remote-as\n")
5551 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5552 bgp_node_afi(vty
), bgp_node_safi(vty
),
5553 PEER_FLAG_AS_OVERRIDE
);
5556 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5557 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5558 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5559 "Override ASNs in outbound updates if aspath equals remote-as\n")
5561 /* neighbor remove-private-AS. */
5562 DEFUN (neighbor_remove_private_as
,
5563 neighbor_remove_private_as_cmd
,
5564 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5567 "Remove private ASNs in outbound updates\n")
5570 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5572 PEER_FLAG_REMOVE_PRIVATE_AS
);
5575 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5576 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5578 "Remove private ASNs in outbound updates\n")
5580 DEFUN (neighbor_remove_private_as_all
,
5581 neighbor_remove_private_as_all_cmd
,
5582 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5585 "Remove private ASNs in outbound updates\n"
5586 "Apply to all AS numbers\n")
5589 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5591 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5594 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5595 neighbor_remove_private_as_all_hidden_cmd
,
5596 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5597 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5598 "Remove private ASNs in outbound updates\n"
5599 "Apply to all AS numbers")
5601 DEFUN (neighbor_remove_private_as_replace_as
,
5602 neighbor_remove_private_as_replace_as_cmd
,
5603 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5606 "Remove private ASNs in outbound updates\n"
5607 "Replace private ASNs with our ASN in outbound updates\n")
5610 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5612 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5615 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5616 neighbor_remove_private_as_replace_as_hidden_cmd
,
5617 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5618 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5619 "Remove private ASNs in outbound updates\n"
5620 "Replace private ASNs with our ASN in outbound updates\n")
5622 DEFUN (neighbor_remove_private_as_all_replace_as
,
5623 neighbor_remove_private_as_all_replace_as_cmd
,
5624 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5627 "Remove private ASNs in outbound updates\n"
5628 "Apply to all AS numbers\n"
5629 "Replace private ASNs with our ASN in outbound updates\n")
5632 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5634 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5638 neighbor_remove_private_as_all_replace_as
,
5639 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5640 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5641 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5642 "Remove private ASNs in outbound updates\n"
5643 "Apply to all AS numbers\n"
5644 "Replace private ASNs with our ASN in outbound updates\n")
5646 DEFUN (no_neighbor_remove_private_as
,
5647 no_neighbor_remove_private_as_cmd
,
5648 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5652 "Remove private ASNs in outbound updates\n")
5655 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5656 bgp_node_afi(vty
), bgp_node_safi(vty
),
5657 PEER_FLAG_REMOVE_PRIVATE_AS
);
5660 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5661 no_neighbor_remove_private_as_hidden_cmd
,
5662 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5663 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5664 "Remove private ASNs in outbound updates\n")
5666 DEFUN (no_neighbor_remove_private_as_all
,
5667 no_neighbor_remove_private_as_all_cmd
,
5668 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5672 "Remove private ASNs in outbound updates\n"
5673 "Apply to all AS numbers\n")
5676 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5677 bgp_node_afi(vty
), bgp_node_safi(vty
),
5678 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5681 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5682 no_neighbor_remove_private_as_all_hidden_cmd
,
5683 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5684 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5685 "Remove private ASNs in outbound updates\n"
5686 "Apply to all AS numbers\n")
5688 DEFUN (no_neighbor_remove_private_as_replace_as
,
5689 no_neighbor_remove_private_as_replace_as_cmd
,
5690 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5694 "Remove private ASNs in outbound updates\n"
5695 "Replace private ASNs with our ASN in outbound updates\n")
5698 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5699 bgp_node_afi(vty
), bgp_node_safi(vty
),
5700 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5703 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5704 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5705 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5706 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5707 "Remove private ASNs in outbound updates\n"
5708 "Replace private ASNs with our ASN in outbound updates\n")
5710 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5711 no_neighbor_remove_private_as_all_replace_as_cmd
,
5712 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5716 "Remove private ASNs in outbound updates\n"
5717 "Apply to all AS numbers\n"
5718 "Replace private ASNs with our ASN in outbound updates\n")
5721 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5722 bgp_node_afi(vty
), bgp_node_safi(vty
),
5723 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5727 no_neighbor_remove_private_as_all_replace_as
,
5728 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5729 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5730 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5731 "Remove private ASNs in outbound updates\n"
5732 "Apply to all AS numbers\n"
5733 "Replace private ASNs with our ASN in outbound updates\n")
5736 /* neighbor send-community. */
5737 DEFUN (neighbor_send_community
,
5738 neighbor_send_community_cmd
,
5739 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5742 "Send Community attribute to this neighbor\n")
5746 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5748 PEER_FLAG_SEND_COMMUNITY
);
5751 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5752 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5753 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5754 "Send Community attribute to this neighbor\n")
5756 DEFUN (no_neighbor_send_community
,
5757 no_neighbor_send_community_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5762 "Send Community attribute to this neighbor\n")
5766 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5767 bgp_node_afi(vty
), bgp_node_safi(vty
),
5768 PEER_FLAG_SEND_COMMUNITY
);
5771 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5772 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5773 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5774 "Send Community attribute to this neighbor\n")
5776 /* neighbor send-community extended. */
5777 DEFUN (neighbor_send_community_type
,
5778 neighbor_send_community_type_cmd
,
5779 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5782 "Send Community attribute to this neighbor\n"
5783 "Send Standard and Extended Community attributes\n"
5784 "Send Standard, Large and Extended Community attributes\n"
5785 "Send Extended Community attributes\n"
5786 "Send Standard Community attributes\n"
5787 "Send Large Community attributes\n")
5789 const char *type
= argv
[argc
- 1]->text
;
5790 char *peer_str
= argv
[1]->arg
;
5792 afi_t afi
= bgp_node_afi(vty
);
5793 safi_t safi
= bgp_node_safi(vty
);
5795 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5797 return CMD_WARNING_CONFIG_FAILED
;
5799 if (strmatch(type
, "standard"))
5800 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5801 PEER_FLAG_SEND_COMMUNITY
);
5803 if (strmatch(type
, "extended"))
5804 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5805 PEER_FLAG_SEND_EXT_COMMUNITY
);
5807 if (strmatch(type
, "large"))
5808 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5809 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5811 if (strmatch(type
, "both")) {
5812 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5813 PEER_FLAG_SEND_COMMUNITY
)
5814 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5815 PEER_FLAG_SEND_EXT_COMMUNITY
);
5817 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5818 PEER_FLAG_SEND_COMMUNITY
)
5819 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5820 PEER_FLAG_SEND_EXT_COMMUNITY
)
5821 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5822 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5826 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5827 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5828 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5829 "Send Community attribute to this neighbor\n"
5830 "Send Standard and Extended Community attributes\n"
5831 "Send Standard, Large and Extended Community attributes\n"
5832 "Send Extended Community attributes\n"
5833 "Send Standard Community attributes\n"
5834 "Send Large Community attributes\n")
5836 DEFUN (no_neighbor_send_community_type
,
5837 no_neighbor_send_community_type_cmd
,
5838 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5842 "Send Community attribute to this neighbor\n"
5843 "Send Standard and Extended Community attributes\n"
5844 "Send Standard, Large and Extended Community attributes\n"
5845 "Send Extended Community attributes\n"
5846 "Send Standard Community attributes\n"
5847 "Send Large Community attributes\n")
5849 const char *type
= argv
[argc
- 1]->text
;
5850 char *peer_str
= argv
[2]->arg
;
5852 afi_t afi
= bgp_node_afi(vty
);
5853 safi_t safi
= bgp_node_safi(vty
);
5855 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5857 return CMD_WARNING_CONFIG_FAILED
;
5859 if (strmatch(type
, "standard"))
5860 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5861 PEER_FLAG_SEND_COMMUNITY
);
5863 if (strmatch(type
, "extended"))
5864 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5865 PEER_FLAG_SEND_EXT_COMMUNITY
);
5867 if (strmatch(type
, "large"))
5868 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5869 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5871 if (strmatch(type
, "both")) {
5873 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5874 PEER_FLAG_SEND_COMMUNITY
)
5875 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5876 PEER_FLAG_SEND_EXT_COMMUNITY
);
5879 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5880 PEER_FLAG_SEND_COMMUNITY
)
5881 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5882 PEER_FLAG_SEND_EXT_COMMUNITY
)
5883 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5884 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5888 no_neighbor_send_community_type
,
5889 no_neighbor_send_community_type_hidden_cmd
,
5890 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5891 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5892 "Send Community attribute to this neighbor\n"
5893 "Send Standard and Extended Community attributes\n"
5894 "Send Standard, Large and Extended Community attributes\n"
5895 "Send Extended Community attributes\n"
5896 "Send Standard Community attributes\n"
5897 "Send Large Community attributes\n")
5899 /* neighbor soft-reconfig. */
5900 DEFUN (neighbor_soft_reconfiguration
,
5901 neighbor_soft_reconfiguration_cmd
,
5902 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5905 "Per neighbor soft reconfiguration\n"
5906 "Allow inbound soft reconfiguration for this neighbor\n")
5909 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5911 PEER_FLAG_SOFT_RECONFIG
);
5914 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
5915 neighbor_soft_reconfiguration_hidden_cmd
,
5916 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5918 "Per neighbor soft reconfiguration\n"
5919 "Allow inbound soft reconfiguration for this neighbor\n")
5921 DEFUN (no_neighbor_soft_reconfiguration
,
5922 no_neighbor_soft_reconfiguration_cmd
,
5923 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5927 "Per neighbor soft reconfiguration\n"
5928 "Allow inbound soft reconfiguration for this neighbor\n")
5931 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5932 bgp_node_afi(vty
), bgp_node_safi(vty
),
5933 PEER_FLAG_SOFT_RECONFIG
);
5936 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5937 no_neighbor_soft_reconfiguration_hidden_cmd
,
5938 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5939 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5940 "Per neighbor soft reconfiguration\n"
5941 "Allow inbound soft reconfiguration for this neighbor\n")
5943 DEFUN (neighbor_route_reflector_client
,
5944 neighbor_route_reflector_client_cmd
,
5945 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5948 "Configure a neighbor as Route Reflector client\n")
5954 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5956 return CMD_WARNING_CONFIG_FAILED
;
5958 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5960 PEER_FLAG_REFLECTOR_CLIENT
);
5963 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5964 neighbor_route_reflector_client_hidden_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5966 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5967 "Configure a neighbor as Route Reflector client\n")
5969 DEFUN (no_neighbor_route_reflector_client
,
5970 no_neighbor_route_reflector_client_cmd
,
5971 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5975 "Configure a neighbor as Route Reflector client\n")
5978 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5979 bgp_node_afi(vty
), bgp_node_safi(vty
),
5980 PEER_FLAG_REFLECTOR_CLIENT
);
5983 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5984 no_neighbor_route_reflector_client_hidden_cmd
,
5985 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5986 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5987 "Configure a neighbor as Route Reflector client\n")
5989 /* neighbor route-server-client. */
5990 DEFUN (neighbor_route_server_client
,
5991 neighbor_route_server_client_cmd
,
5992 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5995 "Configure a neighbor as Route Server client\n")
6000 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6002 return CMD_WARNING_CONFIG_FAILED
;
6003 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6005 PEER_FLAG_RSERVER_CLIENT
);
6008 ALIAS_HIDDEN(neighbor_route_server_client
,
6009 neighbor_route_server_client_hidden_cmd
,
6010 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6011 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6012 "Configure a neighbor as Route Server client\n")
6014 DEFUN (no_neighbor_route_server_client
,
6015 no_neighbor_route_server_client_cmd
,
6016 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6020 "Configure a neighbor as Route Server client\n")
6023 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6024 bgp_node_afi(vty
), bgp_node_safi(vty
),
6025 PEER_FLAG_RSERVER_CLIENT
);
6028 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6029 no_neighbor_route_server_client_hidden_cmd
,
6030 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6031 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6032 "Configure a neighbor as Route Server client\n")
6034 DEFUN (neighbor_nexthop_local_unchanged
,
6035 neighbor_nexthop_local_unchanged_cmd
,
6036 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6039 "Configure treatment of outgoing link-local nexthop attribute\n"
6040 "Leave link-local nexthop unchanged for this peer\n")
6043 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6045 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6048 DEFUN (no_neighbor_nexthop_local_unchanged
,
6049 no_neighbor_nexthop_local_unchanged_cmd
,
6050 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6054 "Configure treatment of outgoing link-local-nexthop attribute\n"
6055 "Leave link-local nexthop unchanged for this peer\n")
6058 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6059 bgp_node_afi(vty
), bgp_node_safi(vty
),
6060 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6063 DEFUN (neighbor_attr_unchanged
,
6064 neighbor_attr_unchanged_cmd
,
6065 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6068 "BGP attribute is propagated unchanged to this neighbor\n"
6069 "As-path attribute\n"
6070 "Nexthop attribute\n"
6074 char *peer_str
= argv
[1]->arg
;
6076 bool aspath
= false;
6077 bool nexthop
= false;
6079 afi_t afi
= bgp_node_afi(vty
);
6080 safi_t safi
= bgp_node_safi(vty
);
6083 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6085 return CMD_WARNING_CONFIG_FAILED
;
6087 if (argv_find(argv
, argc
, "as-path", &idx
))
6091 if (argv_find(argv
, argc
, "next-hop", &idx
))
6095 if (argv_find(argv
, argc
, "med", &idx
))
6098 /* no flags means all of them! */
6099 if (!aspath
&& !nexthop
&& !med
) {
6100 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6101 PEER_FLAG_AS_PATH_UNCHANGED
);
6102 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6103 PEER_FLAG_NEXTHOP_UNCHANGED
);
6104 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6105 PEER_FLAG_MED_UNCHANGED
);
6108 if (peer_af_flag_check(peer
, afi
, safi
,
6109 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6110 ret
|= peer_af_flag_unset_vty(
6111 vty
, peer_str
, afi
, safi
,
6112 PEER_FLAG_AS_PATH_UNCHANGED
);
6115 ret
|= peer_af_flag_set_vty(
6116 vty
, peer_str
, afi
, safi
,
6117 PEER_FLAG_AS_PATH_UNCHANGED
);
6120 if (peer_af_flag_check(peer
, afi
, safi
,
6121 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6122 ret
|= peer_af_flag_unset_vty(
6123 vty
, peer_str
, afi
, safi
,
6124 PEER_FLAG_NEXTHOP_UNCHANGED
);
6127 ret
|= peer_af_flag_set_vty(
6128 vty
, peer_str
, afi
, safi
,
6129 PEER_FLAG_NEXTHOP_UNCHANGED
);
6132 if (peer_af_flag_check(peer
, afi
, safi
,
6133 PEER_FLAG_MED_UNCHANGED
)) {
6134 ret
|= peer_af_flag_unset_vty(
6135 vty
, peer_str
, afi
, safi
,
6136 PEER_FLAG_MED_UNCHANGED
);
6139 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6140 PEER_FLAG_MED_UNCHANGED
);
6147 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6148 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6150 "BGP attribute is propagated unchanged to this neighbor\n"
6151 "As-path attribute\n"
6152 "Nexthop attribute\n"
6155 DEFUN (no_neighbor_attr_unchanged
,
6156 no_neighbor_attr_unchanged_cmd
,
6157 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6161 "BGP attribute is propagated unchanged to this neighbor\n"
6162 "As-path attribute\n"
6163 "Nexthop attribute\n"
6167 char *peer_str
= argv
[2]->arg
;
6169 bool aspath
= false;
6170 bool nexthop
= false;
6172 afi_t afi
= bgp_node_afi(vty
);
6173 safi_t safi
= bgp_node_safi(vty
);
6176 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6178 return CMD_WARNING_CONFIG_FAILED
;
6180 if (argv_find(argv
, argc
, "as-path", &idx
))
6184 if (argv_find(argv
, argc
, "next-hop", &idx
))
6188 if (argv_find(argv
, argc
, "med", &idx
))
6191 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6192 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6193 PEER_FLAG_AS_PATH_UNCHANGED
)
6194 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6195 PEER_FLAG_NEXTHOP_UNCHANGED
)
6196 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6197 PEER_FLAG_MED_UNCHANGED
);
6200 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6201 PEER_FLAG_AS_PATH_UNCHANGED
);
6204 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6205 PEER_FLAG_NEXTHOP_UNCHANGED
);
6208 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6209 PEER_FLAG_MED_UNCHANGED
);
6215 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6216 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6217 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6218 "BGP attribute is propagated unchanged to this neighbor\n"
6219 "As-path attribute\n"
6220 "Nexthop attribute\n"
6223 /* EBGP multihop configuration. */
6224 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6225 const char *ttl_str
)
6230 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6232 return CMD_WARNING_CONFIG_FAILED
;
6235 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6240 ttl
= strtoul(ttl_str
, NULL
, 10);
6242 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6245 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6249 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6251 return CMD_WARNING_CONFIG_FAILED
;
6253 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6256 /* neighbor ebgp-multihop. */
6257 DEFUN (neighbor_ebgp_multihop
,
6258 neighbor_ebgp_multihop_cmd
,
6259 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6262 "Allow EBGP neighbors not on directly connected networks\n")
6265 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6268 DEFUN (neighbor_ebgp_multihop_ttl
,
6269 neighbor_ebgp_multihop_ttl_cmd
,
6270 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6273 "Allow EBGP neighbors not on directly connected networks\n"
6274 "maximum hop count\n")
6278 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6279 argv
[idx_number
]->arg
);
6282 DEFUN (no_neighbor_ebgp_multihop
,
6283 no_neighbor_ebgp_multihop_cmd
,
6284 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6288 "Allow EBGP neighbors not on directly connected networks\n"
6289 "maximum hop count\n")
6292 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6296 /* disable-connected-check */
6297 DEFUN (neighbor_disable_connected_check
,
6298 neighbor_disable_connected_check_cmd
,
6299 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6302 "one-hop away EBGP peer using loopback address\n"
6303 "Enforce EBGP neighbors perform multihop\n")
6306 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6307 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6310 DEFUN (no_neighbor_disable_connected_check
,
6311 no_neighbor_disable_connected_check_cmd
,
6312 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6316 "one-hop away EBGP peer using loopback address\n"
6317 "Enforce EBGP neighbors perform multihop\n")
6320 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6321 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6324 /* disable-link-bw-encoding-ieee */
6325 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6326 neighbor_disable_link_bw_encoding_ieee_cmd
,
6327 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6328 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6329 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6333 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6334 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6337 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6338 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6339 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6340 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6341 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6345 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6346 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6349 /* extended-optional-parameters */
6350 DEFUN(neighbor_extended_optional_parameters
,
6351 neighbor_extended_optional_parameters_cmd
,
6352 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6353 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6354 "Force the extended optional parameters format for OPEN messages\n")
6358 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6359 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6362 DEFUN(no_neighbor_extended_optional_parameters
,
6363 no_neighbor_extended_optional_parameters_cmd
,
6364 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6365 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6366 "Force the extended optional parameters format for OPEN messages\n")
6370 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6371 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6374 /* enforce-first-as */
6375 DEFUN (neighbor_enforce_first_as
,
6376 neighbor_enforce_first_as_cmd
,
6377 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6380 "Enforce the first AS for EBGP routes\n")
6384 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6385 PEER_FLAG_ENFORCE_FIRST_AS
);
6388 DEFUN (no_neighbor_enforce_first_as
,
6389 no_neighbor_enforce_first_as_cmd
,
6390 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6394 "Enforce the first AS for EBGP routes\n")
6398 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6399 PEER_FLAG_ENFORCE_FIRST_AS
);
6403 DEFUN (neighbor_description
,
6404 neighbor_description_cmd
,
6405 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6408 "Neighbor specific description\n"
6409 "Up to 80 characters describing this neighbor\n")
6416 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6418 return CMD_WARNING_CONFIG_FAILED
;
6420 str
= argv_concat(argv
, argc
, idx_line
);
6422 peer_description_set(peer
, str
);
6424 XFREE(MTYPE_TMP
, str
);
6429 DEFUN (no_neighbor_description
,
6430 no_neighbor_description_cmd
,
6431 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6435 "Neighbor specific description\n")
6440 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6442 return CMD_WARNING_CONFIG_FAILED
;
6444 peer_description_unset(peer
);
6449 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6450 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6451 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6452 "Neighbor specific description\n"
6453 "Up to 80 characters describing this neighbor\n")
6455 /* Neighbor update-source. */
6456 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6457 const char *source_str
)
6463 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6465 return CMD_WARNING_CONFIG_FAILED
;
6471 if (str2sockunion(source_str
, &su
) == 0)
6472 peer_update_source_addr_set(peer
, &su
);
6474 if (str2prefix(source_str
, &p
)) {
6476 "%% Invalid update-source, remove prefix length \n");
6477 return CMD_WARNING_CONFIG_FAILED
;
6479 peer_update_source_if_set(peer
, source_str
);
6482 peer_update_source_unset(peer
);
6487 #define BGP_UPDATE_SOURCE_HELP_STR \
6490 "Interface name (requires zebra to be running)\n"
6492 DEFUN (neighbor_update_source
,
6493 neighbor_update_source_cmd
,
6494 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6497 "Source of routing updates\n"
6498 BGP_UPDATE_SOURCE_HELP_STR
)
6502 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6503 argv
[idx_peer_2
]->arg
);
6506 DEFUN (no_neighbor_update_source
,
6507 no_neighbor_update_source_cmd
,
6508 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6512 "Source of routing updates\n"
6513 BGP_UPDATE_SOURCE_HELP_STR
)
6516 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6519 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6520 afi_t afi
, safi_t safi
,
6521 const char *rmap
, int set
)
6525 struct route_map
*route_map
= NULL
;
6527 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6529 return CMD_WARNING_CONFIG_FAILED
;
6533 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6534 ret
= peer_default_originate_set(peer
, afi
, safi
,
6537 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6539 return bgp_vty_return(vty
, ret
);
6542 /* neighbor default-originate. */
6543 DEFUN (neighbor_default_originate
,
6544 neighbor_default_originate_cmd
,
6545 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6548 "Originate default route to this neighbor\n")
6551 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6553 bgp_node_safi(vty
), NULL
, 1);
6556 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6557 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6558 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6559 "Originate default route to this neighbor\n")
6561 DEFUN (neighbor_default_originate_rmap
,
6562 neighbor_default_originate_rmap_cmd
,
6563 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6566 "Originate default route to this neighbor\n"
6567 "Route-map to specify criteria to originate default\n"
6572 return peer_default_originate_set_vty(
6573 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6574 argv
[idx_word
]->arg
, 1);
6578 neighbor_default_originate_rmap
,
6579 neighbor_default_originate_rmap_hidden_cmd
,
6580 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6582 "Originate default route to this neighbor\n"
6583 "Route-map to specify criteria to originate default\n"
6586 DEFUN (no_neighbor_default_originate
,
6587 no_neighbor_default_originate_cmd
,
6588 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6592 "Originate default route to this neighbor\n"
6593 "Route-map to specify criteria to originate default\n"
6597 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6599 bgp_node_safi(vty
), NULL
, 0);
6603 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6604 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6605 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6606 "Originate default route to this neighbor\n"
6607 "Route-map to specify criteria to originate default\n"
6611 /* Set neighbor's BGP port. */
6612 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6613 const char *port_str
)
6619 peer
= peer_lookup_vty(vty
, ip_str
);
6621 return CMD_WARNING_CONFIG_FAILED
;
6624 sp
= getservbyname("bgp", "tcp");
6625 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6627 port
= strtoul(port_str
, NULL
, 10);
6630 peer_port_set(peer
, port
);
6635 /* Set specified peer's BGP port. */
6636 DEFUN (neighbor_port
,
6638 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6641 "Neighbor's BGP port\n"
6642 "TCP port number\n")
6646 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6647 argv
[idx_number
]->arg
);
6650 DEFUN (no_neighbor_port
,
6651 no_neighbor_port_cmd
,
6652 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6656 "Neighbor's BGP port\n"
6657 "TCP port number\n")
6660 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6664 /* neighbor weight. */
6665 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6666 safi_t safi
, const char *weight_str
)
6670 unsigned long weight
;
6672 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6674 return CMD_WARNING_CONFIG_FAILED
;
6676 weight
= strtoul(weight_str
, NULL
, 10);
6678 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6679 return bgp_vty_return(vty
, ret
);
6682 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6688 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6690 return CMD_WARNING_CONFIG_FAILED
;
6692 ret
= peer_weight_unset(peer
, afi
, safi
);
6693 return bgp_vty_return(vty
, ret
);
6696 DEFUN (neighbor_weight
,
6697 neighbor_weight_cmd
,
6698 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6701 "Set default weight for routes from this neighbor\n"
6706 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6707 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6710 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6711 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6712 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6713 "Set default weight for routes from this neighbor\n"
6716 DEFUN (no_neighbor_weight
,
6717 no_neighbor_weight_cmd
,
6718 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6722 "Set default weight for routes from this neighbor\n"
6726 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6727 bgp_node_afi(vty
), bgp_node_safi(vty
));
6730 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6731 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6732 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6733 "Set default weight for routes from this neighbor\n"
6737 /* Override capability negotiation. */
6738 DEFUN (neighbor_override_capability
,
6739 neighbor_override_capability_cmd
,
6740 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6743 "Override capability negotiation result\n")
6746 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6747 PEER_FLAG_OVERRIDE_CAPABILITY
);
6750 DEFUN (no_neighbor_override_capability
,
6751 no_neighbor_override_capability_cmd
,
6752 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6756 "Override capability negotiation result\n")
6759 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6760 PEER_FLAG_OVERRIDE_CAPABILITY
);
6763 DEFUN (neighbor_strict_capability
,
6764 neighbor_strict_capability_cmd
,
6765 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6768 "Strict capability negotiation match\n")
6772 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6773 PEER_FLAG_STRICT_CAP_MATCH
);
6776 DEFUN (no_neighbor_strict_capability
,
6777 no_neighbor_strict_capability_cmd
,
6778 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6782 "Strict capability negotiation match\n")
6786 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6787 PEER_FLAG_STRICT_CAP_MATCH
);
6790 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6791 const char *keep_str
, const char *hold_str
)
6798 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6800 return CMD_WARNING_CONFIG_FAILED
;
6802 keepalive
= strtoul(keep_str
, NULL
, 10);
6803 holdtime
= strtoul(hold_str
, NULL
, 10);
6805 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6807 return bgp_vty_return(vty
, ret
);
6810 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6815 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6817 return CMD_WARNING_CONFIG_FAILED
;
6819 ret
= peer_timers_unset(peer
);
6821 return bgp_vty_return(vty
, ret
);
6824 DEFUN (neighbor_timers
,
6825 neighbor_timers_cmd
,
6826 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6829 "BGP per neighbor timers\n"
6830 "Keepalive interval\n"
6835 int idx_number_2
= 4;
6836 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6837 argv
[idx_number
]->arg
,
6838 argv
[idx_number_2
]->arg
);
6841 DEFUN (no_neighbor_timers
,
6842 no_neighbor_timers_cmd
,
6843 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6847 "BGP per neighbor timers\n"
6848 "Keepalive interval\n"
6852 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6856 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6857 const char *time_str
)
6863 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6865 return CMD_WARNING_CONFIG_FAILED
;
6867 connect
= strtoul(time_str
, NULL
, 10);
6869 ret
= peer_timers_connect_set(peer
, connect
);
6871 return bgp_vty_return(vty
, ret
);
6874 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6879 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6881 return CMD_WARNING_CONFIG_FAILED
;
6883 ret
= peer_timers_connect_unset(peer
);
6885 return bgp_vty_return(vty
, ret
);
6888 DEFUN (neighbor_timers_connect
,
6889 neighbor_timers_connect_cmd
,
6890 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6893 "BGP per neighbor timers\n"
6894 "BGP connect timer\n"
6899 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6900 argv
[idx_number
]->arg
);
6903 DEFUN (no_neighbor_timers_connect
,
6904 no_neighbor_timers_connect_cmd
,
6905 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6909 "BGP per neighbor timers\n"
6910 "BGP connect timer\n"
6914 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
6917 DEFPY (neighbor_timers_delayopen
,
6918 neighbor_timers_delayopen_cmd
,
6919 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
6922 "BGP per neighbor timers\n"
6923 "RFC 4271 DelayOpenTimer\n"
6924 "DelayOpenTime timer interval\n")
6928 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6930 return CMD_WARNING_CONFIG_FAILED
;
6933 if (peer_timers_delayopen_unset(peer
))
6934 return CMD_WARNING_CONFIG_FAILED
;
6936 if (peer_timers_delayopen_set(peer
, interval
))
6937 return CMD_WARNING_CONFIG_FAILED
;
6943 DEFPY (no_neighbor_timers_delayopen
,
6944 no_neighbor_timers_delayopen_cmd
,
6945 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
6949 "BGP per neighbor timers\n"
6950 "RFC 4271 DelayOpenTimer\n"
6951 "DelayOpenTime timer interval\n")
6955 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6957 return CMD_WARNING_CONFIG_FAILED
;
6959 if (peer_timers_delayopen_unset(peer
))
6960 return CMD_WARNING_CONFIG_FAILED
;
6965 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
6966 const char *time_str
, int set
)
6970 uint32_t routeadv
= 0;
6972 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6974 return CMD_WARNING_CONFIG_FAILED
;
6977 routeadv
= strtoul(time_str
, NULL
, 10);
6980 ret
= peer_advertise_interval_set(peer
, routeadv
);
6982 ret
= peer_advertise_interval_unset(peer
);
6984 return bgp_vty_return(vty
, ret
);
6987 DEFUN (neighbor_advertise_interval
,
6988 neighbor_advertise_interval_cmd
,
6989 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
6992 "Minimum interval between sending BGP routing updates\n"
6993 "time in seconds\n")
6997 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
6998 argv
[idx_number
]->arg
, 1);
7001 DEFUN (no_neighbor_advertise_interval
,
7002 no_neighbor_advertise_interval_cmd
,
7003 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7007 "Minimum interval between sending BGP routing updates\n"
7008 "time in seconds\n")
7011 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7015 /* Time to wait before processing route-map updates */
7016 DEFUN (bgp_set_route_map_delay_timer
,
7017 bgp_set_route_map_delay_timer_cmd
,
7018 "bgp route-map delay-timer (0-600)",
7020 "BGP route-map delay timer\n"
7021 "Time in secs to wait before processing route-map changes\n"
7022 "0 disables the timer, no route updates happen when route-maps change\n")
7025 uint32_t rmap_delay_timer
;
7027 if (argv
[idx_number
]->arg
) {
7028 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7029 bm
->rmap_update_timer
= rmap_delay_timer
;
7031 /* if the dynamic update handling is being disabled, and a timer
7033 * running, stop the timer and act as if the timer has already
7036 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7037 BGP_TIMER_OFF(bm
->t_rmap_update
);
7038 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7043 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7044 return CMD_WARNING_CONFIG_FAILED
;
7048 DEFUN (no_bgp_set_route_map_delay_timer
,
7049 no_bgp_set_route_map_delay_timer_cmd
,
7050 "no bgp route-map delay-timer [(0-600)]",
7053 "Default BGP route-map delay timer\n"
7054 "Reset to default time to wait for processing route-map changes\n"
7055 "0 disables the timer, no route updates happen when route-maps change\n")
7058 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7063 /* neighbor interface */
7064 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7069 peer
= peer_lookup_vty(vty
, ip_str
);
7070 if (!peer
|| peer
->conf_if
) {
7071 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7072 return CMD_WARNING_CONFIG_FAILED
;
7076 peer_interface_set(peer
, str
);
7078 peer_interface_unset(peer
);
7083 DEFUN (neighbor_interface
,
7084 neighbor_interface_cmd
,
7085 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7094 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7097 DEFUN (no_neighbor_interface
,
7098 no_neighbor_interface_cmd
,
7099 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7108 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7111 DEFUN (neighbor_distribute_list
,
7112 neighbor_distribute_list_cmd
,
7113 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7116 "Filter updates to/from this neighbor\n"
7117 "IP Access-list name\n"
7118 "Filter incoming updates\n"
7119 "Filter outgoing updates\n")
7126 const char *pstr
= argv
[idx_peer
]->arg
;
7127 const char *acl
= argv
[idx_acl
]->arg
;
7128 const char *inout
= argv
[argc
- 1]->text
;
7130 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7132 return CMD_WARNING_CONFIG_FAILED
;
7134 /* Check filter direction. */
7135 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7136 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7139 return bgp_vty_return(vty
, ret
);
7143 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7144 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7145 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7146 "Filter updates to/from this neighbor\n"
7147 "IP Access-list name\n"
7148 "Filter incoming updates\n"
7149 "Filter outgoing updates\n")
7151 DEFUN (no_neighbor_distribute_list
,
7152 no_neighbor_distribute_list_cmd
,
7153 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7157 "Filter updates to/from this neighbor\n"
7158 "IP Access-list name\n"
7159 "Filter incoming updates\n"
7160 "Filter outgoing updates\n")
7166 const char *pstr
= argv
[idx_peer
]->arg
;
7167 const char *inout
= argv
[argc
- 1]->text
;
7169 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7171 return CMD_WARNING_CONFIG_FAILED
;
7173 /* Check filter direction. */
7174 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7175 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7178 return bgp_vty_return(vty
, ret
);
7182 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7183 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7185 "Filter updates to/from this neighbor\n"
7186 "IP Access-list name\n"
7187 "Filter incoming updates\n"
7188 "Filter outgoing updates\n")
7190 /* Set prefix list to the peer. */
7191 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7192 afi_t afi
, safi_t safi
,
7193 const char *name_str
,
7194 const char *direct_str
)
7197 int direct
= FILTER_IN
;
7200 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7202 return CMD_WARNING_CONFIG_FAILED
;
7204 /* Check filter direction. */
7205 if (strncmp(direct_str
, "i", 1) == 0)
7207 else if (strncmp(direct_str
, "o", 1) == 0)
7208 direct
= FILTER_OUT
;
7210 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7212 return bgp_vty_return(vty
, ret
);
7215 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7216 afi_t afi
, safi_t safi
,
7217 const char *direct_str
)
7221 int direct
= FILTER_IN
;
7223 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7225 return CMD_WARNING_CONFIG_FAILED
;
7227 /* Check filter direction. */
7228 if (strncmp(direct_str
, "i", 1) == 0)
7230 else if (strncmp(direct_str
, "o", 1) == 0)
7231 direct
= FILTER_OUT
;
7233 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7235 return bgp_vty_return(vty
, ret
);
7238 DEFUN (neighbor_prefix_list
,
7239 neighbor_prefix_list_cmd
,
7240 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7243 "Filter updates to/from this neighbor\n"
7244 "Name of a prefix list\n"
7245 "Filter incoming updates\n"
7246 "Filter outgoing updates\n")
7251 return peer_prefix_list_set_vty(
7252 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7253 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7256 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7257 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7258 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7259 "Filter updates to/from this neighbor\n"
7260 "Name of a prefix list\n"
7261 "Filter incoming updates\n"
7262 "Filter outgoing updates\n")
7264 DEFUN (no_neighbor_prefix_list
,
7265 no_neighbor_prefix_list_cmd
,
7266 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7270 "Filter updates to/from this neighbor\n"
7271 "Name of a prefix list\n"
7272 "Filter incoming updates\n"
7273 "Filter outgoing updates\n")
7277 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7278 bgp_node_afi(vty
), bgp_node_safi(vty
),
7279 argv
[idx_in_out
]->arg
);
7282 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7283 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7284 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7285 "Filter updates to/from this neighbor\n"
7286 "Name of a prefix list\n"
7287 "Filter incoming updates\n"
7288 "Filter outgoing updates\n")
7290 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7291 safi_t safi
, const char *name_str
,
7292 const char *direct_str
)
7296 int direct
= FILTER_IN
;
7298 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7300 return CMD_WARNING_CONFIG_FAILED
;
7302 /* Check filter direction. */
7303 if (strncmp(direct_str
, "i", 1) == 0)
7305 else if (strncmp(direct_str
, "o", 1) == 0)
7306 direct
= FILTER_OUT
;
7308 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7310 return bgp_vty_return(vty
, ret
);
7313 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7314 safi_t safi
, const char *direct_str
)
7318 int direct
= FILTER_IN
;
7320 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7322 return CMD_WARNING_CONFIG_FAILED
;
7324 /* Check filter direction. */
7325 if (strncmp(direct_str
, "i", 1) == 0)
7327 else if (strncmp(direct_str
, "o", 1) == 0)
7328 direct
= FILTER_OUT
;
7330 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7332 return bgp_vty_return(vty
, ret
);
7335 DEFUN (neighbor_filter_list
,
7336 neighbor_filter_list_cmd
,
7337 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7340 "Establish BGP filters\n"
7341 "AS path access-list name\n"
7342 "Filter incoming routes\n"
7343 "Filter outgoing routes\n")
7348 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7349 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7350 argv
[idx_in_out
]->arg
);
7353 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7354 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7355 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7356 "Establish BGP filters\n"
7357 "AS path access-list name\n"
7358 "Filter incoming routes\n"
7359 "Filter outgoing routes\n")
7361 DEFUN (no_neighbor_filter_list
,
7362 no_neighbor_filter_list_cmd
,
7363 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7367 "Establish BGP filters\n"
7368 "AS path access-list name\n"
7369 "Filter incoming routes\n"
7370 "Filter outgoing routes\n")
7374 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7375 bgp_node_afi(vty
), bgp_node_safi(vty
),
7376 argv
[idx_in_out
]->arg
);
7379 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7380 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7381 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7382 "Establish BGP filters\n"
7383 "AS path access-list name\n"
7384 "Filter incoming routes\n"
7385 "Filter outgoing routes\n")
7387 /* Set advertise-map to the peer. */
7388 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7389 afi_t afi
, safi_t safi
,
7390 const char *advertise_str
,
7391 const char *condition_str
, bool condition
,
7394 int ret
= CMD_WARNING_CONFIG_FAILED
;
7396 struct route_map
*advertise_map
;
7397 struct route_map
*condition_map
;
7399 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7403 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7404 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7407 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7408 advertise_map
, condition_str
,
7409 condition_map
, condition
);
7411 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7412 advertise_map
, condition_str
,
7413 condition_map
, condition
);
7415 return bgp_vty_return(vty
, ret
);
7418 DEFPY (bgp_condadv_period
,
7419 bgp_condadv_period_cmd
,
7420 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7423 "Conditional advertisement settings\n"
7424 "Set period to rescan BGP table to check if condition is met\n"
7425 "Period between BGP table scans, in seconds; default 60\n")
7427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7429 bgp
->condition_check_period
=
7430 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7435 DEFPY (neighbor_advertise_map
,
7436 neighbor_advertise_map_cmd
,
7437 "[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",
7441 "Route-map to conditionally advertise routes\n"
7442 "Name of advertise map\n"
7443 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7444 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7445 "Name of the exist or non exist map\n")
7447 bool condition
= CONDITION_EXIST
;
7449 if (!strcmp(exist
, "non-exist-map"))
7450 condition
= CONDITION_NON_EXIST
;
7452 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7453 bgp_node_safi(vty
), advertise_str
,
7454 condition_str
, condition
, !no
);
7457 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7458 "[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",
7459 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7460 "Route-map to conditionally advertise routes\n"
7461 "Name of advertise map\n"
7462 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7463 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7464 "Name of the exist or non exist map\n")
7466 /* Set route-map to the peer. */
7467 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7468 afi_t afi
, safi_t safi
, const char *name_str
,
7469 const char *direct_str
)
7473 int direct
= RMAP_IN
;
7474 struct route_map
*route_map
;
7476 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7478 return CMD_WARNING_CONFIG_FAILED
;
7480 /* Check filter direction. */
7481 if (strncmp(direct_str
, "in", 2) == 0)
7483 else if (strncmp(direct_str
, "o", 1) == 0)
7486 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7487 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7489 return bgp_vty_return(vty
, ret
);
7492 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7493 afi_t afi
, safi_t safi
,
7494 const char *direct_str
)
7498 int direct
= RMAP_IN
;
7500 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7502 return CMD_WARNING_CONFIG_FAILED
;
7504 /* Check filter direction. */
7505 if (strncmp(direct_str
, "in", 2) == 0)
7507 else if (strncmp(direct_str
, "o", 1) == 0)
7510 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7512 return bgp_vty_return(vty
, ret
);
7515 DEFUN (neighbor_route_map
,
7516 neighbor_route_map_cmd
,
7517 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7520 "Apply route map to neighbor\n"
7521 "Name of route map\n"
7522 "Apply map to incoming routes\n"
7523 "Apply map to outbound routes\n")
7528 return peer_route_map_set_vty(
7529 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7530 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7533 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7534 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7535 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7536 "Apply route map to neighbor\n"
7537 "Name of route map\n"
7538 "Apply map to incoming routes\n"
7539 "Apply map to outbound routes\n")
7541 DEFUN (no_neighbor_route_map
,
7542 no_neighbor_route_map_cmd
,
7543 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7547 "Apply route map to neighbor\n"
7548 "Name of route map\n"
7549 "Apply map to incoming routes\n"
7550 "Apply map to outbound routes\n")
7554 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7555 bgp_node_afi(vty
), bgp_node_safi(vty
),
7556 argv
[idx_in_out
]->arg
);
7559 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7560 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7561 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7562 "Apply route map to neighbor\n"
7563 "Name of route map\n"
7564 "Apply map to incoming routes\n"
7565 "Apply map to outbound routes\n")
7567 /* Set unsuppress-map to the peer. */
7568 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7569 afi_t afi
, safi_t safi
,
7570 const char *name_str
)
7574 struct route_map
*route_map
;
7576 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7578 return CMD_WARNING_CONFIG_FAILED
;
7580 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7581 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7583 return bgp_vty_return(vty
, ret
);
7586 /* Unset route-map from the peer. */
7587 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7588 afi_t afi
, safi_t safi
)
7593 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7595 return CMD_WARNING_CONFIG_FAILED
;
7597 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7599 return bgp_vty_return(vty
, ret
);
7602 DEFUN (neighbor_unsuppress_map
,
7603 neighbor_unsuppress_map_cmd
,
7604 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7607 "Route-map to selectively unsuppress suppressed routes\n"
7608 "Name of route map\n")
7612 return peer_unsuppress_map_set_vty(
7613 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7614 argv
[idx_word
]->arg
);
7617 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7618 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7619 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7620 "Route-map to selectively unsuppress suppressed routes\n"
7621 "Name of route map\n")
7623 DEFUN (no_neighbor_unsuppress_map
,
7624 no_neighbor_unsuppress_map_cmd
,
7625 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7629 "Route-map to selectively unsuppress suppressed routes\n"
7630 "Name of route map\n")
7633 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7635 bgp_node_safi(vty
));
7638 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7639 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7640 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7641 "Route-map to selectively unsuppress suppressed routes\n"
7642 "Name of route map\n")
7644 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7645 afi_t afi
, safi_t safi
,
7646 const char *num_str
,
7647 const char *threshold_str
, int warning
,
7648 const char *restart_str
,
7649 const char *force_str
)
7657 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7659 return CMD_WARNING_CONFIG_FAILED
;
7661 max
= strtoul(num_str
, NULL
, 10);
7663 threshold
= atoi(threshold_str
);
7665 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7668 restart
= atoi(restart_str
);
7672 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7673 restart
, force_str
? true : false);
7675 return bgp_vty_return(vty
, ret
);
7678 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7679 afi_t afi
, safi_t safi
)
7684 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7686 return CMD_WARNING_CONFIG_FAILED
;
7688 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7690 return bgp_vty_return(vty
, ret
);
7693 /* Maximum number of prefix to be sent to the neighbor. */
7694 DEFUN(neighbor_maximum_prefix_out
,
7695 neighbor_maximum_prefix_out_cmd
,
7696 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7699 "Maximum number of prefixes to be sent to this peer\n"
7700 "Maximum no. of prefix limit\n")
7707 afi_t afi
= bgp_node_afi(vty
);
7708 safi_t safi
= bgp_node_safi(vty
);
7710 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7712 return CMD_WARNING_CONFIG_FAILED
;
7714 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7716 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7718 return bgp_vty_return(vty
, ret
);
7721 DEFUN(no_neighbor_maximum_prefix_out
,
7722 no_neighbor_maximum_prefix_out_cmd
,
7723 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7727 "Maximum number of prefixes to be sent to this peer\n"
7728 "Maximum no. of prefix limit\n")
7733 afi_t afi
= bgp_node_afi(vty
);
7734 safi_t safi
= bgp_node_safi(vty
);
7736 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7738 return CMD_WARNING_CONFIG_FAILED
;
7740 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
7742 return bgp_vty_return(vty
, ret
);
7745 /* Maximum number of prefix configuration. Prefix count is different
7746 for each peer configuration. So this configuration can be set for
7747 each peer configuration. */
7748 DEFUN (neighbor_maximum_prefix
,
7749 neighbor_maximum_prefix_cmd
,
7750 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7753 "Maximum number of prefix accept from this peer\n"
7754 "maximum no. of prefix limit\n"
7755 "Force checking all received routes not only accepted\n")
7762 if (argv_find(argv
, argc
, "force", &idx_force
))
7763 force
= argv
[idx_force
]->arg
;
7765 return peer_maximum_prefix_set_vty(
7766 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7767 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7770 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7771 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7772 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7773 "Maximum number of prefix accept from this peer\n"
7774 "maximum no. of prefix limit\n"
7775 "Force checking all received routes not only accepted\n")
7777 DEFUN (neighbor_maximum_prefix_threshold
,
7778 neighbor_maximum_prefix_threshold_cmd
,
7779 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7782 "Maximum number of prefix accept from this peer\n"
7783 "maximum no. of prefix limit\n"
7784 "Threshold value (%) at which to generate a warning msg\n"
7785 "Force checking all received routes not only accepted\n")
7789 int idx_number_2
= 4;
7793 if (argv_find(argv
, argc
, "force", &idx_force
))
7794 force
= argv
[idx_force
]->arg
;
7796 return peer_maximum_prefix_set_vty(
7797 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7798 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
7802 neighbor_maximum_prefix_threshold
,
7803 neighbor_maximum_prefix_threshold_hidden_cmd
,
7804 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7805 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7806 "Maximum number of prefix accept from this peer\n"
7807 "maximum no. of prefix limit\n"
7808 "Threshold value (%) at which to generate a warning msg\n"
7809 "Force checking all received routes not only accepted\n")
7811 DEFUN (neighbor_maximum_prefix_warning
,
7812 neighbor_maximum_prefix_warning_cmd
,
7813 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7816 "Maximum number of prefix accept from this peer\n"
7817 "maximum no. of prefix limit\n"
7818 "Only give warning message when limit is exceeded\n"
7819 "Force checking all received routes not only accepted\n")
7826 if (argv_find(argv
, argc
, "force", &idx_force
))
7827 force
= argv
[idx_force
]->arg
;
7829 return peer_maximum_prefix_set_vty(
7830 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7831 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
7835 neighbor_maximum_prefix_warning
,
7836 neighbor_maximum_prefix_warning_hidden_cmd
,
7837 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7838 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7839 "Maximum number of prefix accept from this peer\n"
7840 "maximum no. of prefix limit\n"
7841 "Only give warning message when limit is exceeded\n"
7842 "Force checking all received routes not only accepted\n")
7844 DEFUN (neighbor_maximum_prefix_threshold_warning
,
7845 neighbor_maximum_prefix_threshold_warning_cmd
,
7846 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7849 "Maximum number of prefix accept from this peer\n"
7850 "maximum no. of prefix limit\n"
7851 "Threshold value (%) at which to generate a warning msg\n"
7852 "Only give warning message when limit is exceeded\n"
7853 "Force checking all received routes not only accepted\n")
7857 int idx_number_2
= 4;
7861 if (argv_find(argv
, argc
, "force", &idx_force
))
7862 force
= argv
[idx_force
]->arg
;
7864 return peer_maximum_prefix_set_vty(
7865 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7866 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
7870 neighbor_maximum_prefix_threshold_warning
,
7871 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
7872 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7873 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7874 "Maximum number of prefix accept from this peer\n"
7875 "maximum no. of prefix limit\n"
7876 "Threshold value (%) at which to generate a warning msg\n"
7877 "Only give warning message when limit is exceeded\n"
7878 "Force checking all received routes not only accepted\n")
7880 DEFUN (neighbor_maximum_prefix_restart
,
7881 neighbor_maximum_prefix_restart_cmd
,
7882 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7885 "Maximum number of prefix accept from this peer\n"
7886 "maximum no. of prefix limit\n"
7887 "Restart bgp connection after limit is exceeded\n"
7888 "Restart interval in minutes\n"
7889 "Force checking all received routes not only accepted\n")
7893 int idx_number_2
= 5;
7897 if (argv_find(argv
, argc
, "force", &idx_force
))
7898 force
= argv
[idx_force
]->arg
;
7900 return peer_maximum_prefix_set_vty(
7901 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7902 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7906 neighbor_maximum_prefix_restart
,
7907 neighbor_maximum_prefix_restart_hidden_cmd
,
7908 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7909 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7910 "Maximum number of prefix accept from this peer\n"
7911 "maximum no. of prefix limit\n"
7912 "Restart bgp connection after limit is exceeded\n"
7913 "Restart interval in minutes\n"
7914 "Force checking all received routes not only accepted\n")
7916 DEFUN (neighbor_maximum_prefix_threshold_restart
,
7917 neighbor_maximum_prefix_threshold_restart_cmd
,
7918 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7921 "Maximum number of prefixes to accept from this peer\n"
7922 "maximum no. of prefix limit\n"
7923 "Threshold value (%) at which to generate a warning msg\n"
7924 "Restart bgp connection after limit is exceeded\n"
7925 "Restart interval in minutes\n"
7926 "Force checking all received routes not only accepted\n")
7930 int idx_number_2
= 4;
7931 int idx_number_3
= 6;
7935 if (argv_find(argv
, argc
, "force", &idx_force
))
7936 force
= argv
[idx_force
]->arg
;
7938 return peer_maximum_prefix_set_vty(
7939 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7940 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
7941 argv
[idx_number_3
]->arg
, force
);
7945 neighbor_maximum_prefix_threshold_restart
,
7946 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
7947 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7948 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7949 "Maximum number of prefixes to accept from this peer\n"
7950 "maximum no. of prefix limit\n"
7951 "Threshold value (%) at which to generate a warning msg\n"
7952 "Restart bgp connection after limit is exceeded\n"
7953 "Restart interval in minutes\n"
7954 "Force checking all received routes not only accepted\n")
7956 DEFUN (no_neighbor_maximum_prefix
,
7957 no_neighbor_maximum_prefix_cmd
,
7958 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7962 "Maximum number of prefixes to accept from this peer\n"
7963 "maximum no. of prefix limit\n"
7964 "Threshold value (%) at which to generate a warning msg\n"
7965 "Restart bgp connection after limit is exceeded\n"
7966 "Restart interval in minutes\n"
7967 "Only give warning message when limit is exceeded\n"
7968 "Force checking all received routes not only accepted\n")
7971 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
7973 bgp_node_safi(vty
));
7977 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
7978 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7979 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7980 "Maximum number of prefixes to accept from this peer\n"
7981 "maximum no. of prefix limit\n"
7982 "Threshold value (%) at which to generate a warning msg\n"
7983 "Restart bgp connection after limit is exceeded\n"
7984 "Restart interval in minutes\n"
7985 "Only give warning message when limit is exceeded\n"
7986 "Force checking all received routes not only accepted\n")
7989 /* "neighbor allowas-in" */
7990 DEFUN (neighbor_allowas_in
,
7991 neighbor_allowas_in_cmd
,
7992 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7995 "Accept as-path with my AS present in it\n"
7996 "Number of occurrences of AS number\n"
7997 "Only accept my AS in the as-path if the route was originated in my AS\n")
8000 int idx_number_origin
= 3;
8006 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8008 return CMD_WARNING_CONFIG_FAILED
;
8010 if (argc
<= idx_number_origin
)
8013 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8016 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8019 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8022 return bgp_vty_return(vty
, ret
);
8026 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8027 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8028 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8029 "Accept as-path with my AS present in it\n"
8030 "Number of occurrences of AS number\n"
8031 "Only accept my AS in the as-path if the route was originated in my AS\n")
8033 DEFUN (no_neighbor_allowas_in
,
8034 no_neighbor_allowas_in_cmd
,
8035 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8039 "allow local ASN appears in aspath attribute\n"
8040 "Number of occurrences of AS number\n"
8041 "Only accept my AS in the as-path if the route was originated in my AS\n")
8047 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8049 return CMD_WARNING_CONFIG_FAILED
;
8051 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8052 bgp_node_safi(vty
));
8054 return bgp_vty_return(vty
, ret
);
8058 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8059 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8060 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8061 "allow local ASN appears in aspath attribute\n"
8062 "Number of occurrences of AS number\n"
8063 "Only accept my AS in the as-path if the route was originated in my AS\n")
8065 DEFUN (neighbor_ttl_security
,
8066 neighbor_ttl_security_cmd
,
8067 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8070 "BGP ttl-security parameters\n"
8071 "Specify the maximum number of hops to the BGP peer\n"
8072 "Number of hops to BGP peer\n")
8079 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8081 return CMD_WARNING_CONFIG_FAILED
;
8083 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8086 * If 'neighbor swpX', then this is for directly connected peers,
8087 * we should not accept a ttl-security hops value greater than 1.
8089 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8091 "%s is directly connected peer, hops cannot exceed 1\n",
8092 argv
[idx_peer
]->arg
);
8093 return CMD_WARNING_CONFIG_FAILED
;
8096 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8099 DEFUN (no_neighbor_ttl_security
,
8100 no_neighbor_ttl_security_cmd
,
8101 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8105 "BGP ttl-security parameters\n"
8106 "Specify the maximum number of hops to the BGP peer\n"
8107 "Number of hops to BGP peer\n")
8112 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8114 return CMD_WARNING_CONFIG_FAILED
;
8116 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8119 /* disable-addpath-rx */
8120 DEFUN(neighbor_disable_addpath_rx
,
8121 neighbor_disable_addpath_rx_cmd
,
8122 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8125 "Do not accept additional paths\n")
8127 char *peer_str
= argv
[1]->arg
;
8129 afi_t afi
= bgp_node_afi(vty
);
8130 safi_t safi
= bgp_node_safi(vty
);
8132 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8134 return CMD_WARNING_CONFIG_FAILED
;
8136 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8137 PEER_FLAG_DISABLE_ADDPATH_RX
);
8140 DEFUN(no_neighbor_disable_addpath_rx
,
8141 no_neighbor_disable_addpath_rx_cmd
,
8142 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8146 "Do not accept additional paths\n")
8148 char *peer_str
= argv
[2]->arg
;
8150 afi_t afi
= bgp_node_afi(vty
);
8151 safi_t safi
= bgp_node_safi(vty
);
8153 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8155 return CMD_WARNING_CONFIG_FAILED
;
8157 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8158 PEER_FLAG_DISABLE_ADDPATH_RX
);
8161 DEFUN (neighbor_addpath_tx_all_paths
,
8162 neighbor_addpath_tx_all_paths_cmd
,
8163 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8166 "Use addpath to advertise all paths to a neighbor\n")
8171 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8173 return CMD_WARNING_CONFIG_FAILED
;
8175 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8180 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8181 neighbor_addpath_tx_all_paths_hidden_cmd
,
8182 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8183 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8184 "Use addpath to advertise all paths to a neighbor\n")
8186 DEFUN (no_neighbor_addpath_tx_all_paths
,
8187 no_neighbor_addpath_tx_all_paths_cmd
,
8188 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8192 "Use addpath to advertise all paths to a neighbor\n")
8197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8199 return CMD_WARNING_CONFIG_FAILED
;
8201 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8202 != BGP_ADDPATH_ALL
) {
8204 "%% Peer not currently configured to transmit all paths.");
8205 return CMD_WARNING_CONFIG_FAILED
;
8208 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8214 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8215 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8216 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8217 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8218 "Use addpath to advertise all paths to a neighbor\n")
8220 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8221 neighbor_addpath_tx_bestpath_per_as_cmd
,
8222 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8225 "Use addpath to advertise the bestpath per each neighboring AS\n")
8230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8232 return CMD_WARNING_CONFIG_FAILED
;
8234 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8235 BGP_ADDPATH_BEST_PER_AS
);
8240 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8241 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8242 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8243 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8244 "Use addpath to advertise the bestpath per each neighboring AS\n")
8246 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8247 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8248 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8252 "Use addpath to advertise the bestpath per each neighboring AS\n")
8257 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8259 return CMD_WARNING_CONFIG_FAILED
;
8261 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8262 != BGP_ADDPATH_BEST_PER_AS
) {
8264 "%% Peer not currently configured to transmit all best path per as.");
8265 return CMD_WARNING_CONFIG_FAILED
;
8268 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8274 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8275 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8276 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8277 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8278 "Use addpath to advertise the bestpath per each neighboring AS\n")
8281 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8282 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8285 "Detect AS loops before sending to neighbor\n")
8289 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8291 return CMD_WARNING_CONFIG_FAILED
;
8293 peer
->as_path_loop_detection
= true;
8299 no_neighbor_aspath_loop_detection
,
8300 no_neighbor_aspath_loop_detection_cmd
,
8301 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8305 "Detect AS loops before sending to neighbor\n")
8309 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8311 return CMD_WARNING_CONFIG_FAILED
;
8313 peer
->as_path_loop_detection
= false;
8318 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8319 struct ecommunity
**list
, bool is_rt6
)
8321 struct ecommunity
*ecom
= NULL
;
8322 struct ecommunity
*ecomadd
;
8324 for (; argc
; --argc
, ++argv
) {
8326 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8327 ECOMMUNITY_ROUTE_TARGET
,
8330 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8331 ECOMMUNITY_ROUTE_TARGET
,
8334 vty_out(vty
, "Malformed community-list value\n");
8336 ecommunity_free(&ecom
);
8337 return CMD_WARNING_CONFIG_FAILED
;
8341 ecommunity_merge(ecom
, ecomadd
);
8342 ecommunity_free(&ecomadd
);
8349 ecommunity_free(&*list
);
8357 * v2vimport is true if we are handling a `import vrf ...` command
8359 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8363 switch (vty
->node
) {
8372 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8377 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8378 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8379 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8380 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8382 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8386 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8387 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8388 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8389 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8391 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8398 DEFPY (af_rd_vpn_export
,
8399 af_rd_vpn_export_cmd
,
8400 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8402 "Specify route distinguisher\n"
8403 "Between current address-family and vpn\n"
8404 "For routes leaked from current address-family to vpn\n"
8405 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8408 struct prefix_rd prd
;
8414 if (argv_find(argv
, argc
, "no", &idx
))
8418 ret
= str2prefix_rd(rd_str
, &prd
);
8420 vty_out(vty
, "%% Malformed rd\n");
8421 return CMD_WARNING_CONFIG_FAILED
;
8425 afi
= vpn_policy_getafi(vty
, bgp
, false);
8427 return CMD_WARNING_CONFIG_FAILED
;
8430 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8432 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8433 bgp_get_default(), bgp
);
8436 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8437 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8438 BGP_VPN_POLICY_TOVPN_RD_SET
);
8440 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8441 BGP_VPN_POLICY_TOVPN_RD_SET
);
8444 /* post-change: re-export vpn routes */
8445 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8446 bgp_get_default(), bgp
);
8451 ALIAS (af_rd_vpn_export
,
8452 af_no_rd_vpn_export_cmd
,
8455 "Specify route distinguisher\n"
8456 "Between current address-family and vpn\n"
8457 "For routes leaked from current address-family to vpn\n")
8459 DEFPY (af_label_vpn_export
,
8460 af_label_vpn_export_cmd
,
8461 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8463 "label value for VRF\n"
8464 "Between current address-family and vpn\n"
8465 "For routes leaked from current address-family to vpn\n"
8466 "Label Value <0-1048575>\n"
8467 "Automatically assign a label\n")
8469 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8470 mpls_label_t label
= MPLS_LABEL_NONE
;
8475 if (argv_find(argv
, argc
, "no", &idx
))
8478 /* If "no ...", squash trailing parameter */
8484 label
= label_val
; /* parser should force unsigned */
8487 afi
= vpn_policy_getafi(vty
, bgp
, false);
8489 return CMD_WARNING_CONFIG_FAILED
;
8492 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8493 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8498 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8500 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8501 bgp_get_default(), bgp
);
8503 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8504 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8506 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8509 * label has previously been automatically
8510 * assigned by labelpool: release it
8512 * NB if tovpn_label == MPLS_LABEL_NONE it
8513 * means the automatic assignment is in flight
8514 * and therefore the labelpool callback must
8515 * detect that the auto label is not needed.
8518 bgp_lp_release(LP_TYPE_VRF
,
8519 &bgp
->vpn_policy
[afi
],
8520 bgp
->vpn_policy
[afi
].tovpn_label
);
8522 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8523 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8526 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8528 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8529 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8530 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8531 vpn_leak_label_callback
);
8534 /* post-change: re-export vpn routes */
8535 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8536 bgp_get_default(), bgp
);
8538 hook_call(bgp_snmp_update_last_changed
, bgp
);
8542 DEFPY (af_sid_vpn_export
,
8543 af_sid_vpn_export_cmd
,
8544 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8546 "sid value for VRF\n"
8547 "Between current address-family and vpn\n"
8548 "For routes leaked from current address-family to vpn\n"
8549 "Sid allocation index\n"
8550 "Automatically assign a label\n")
8552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8558 if (argv_find(argv
, argc
, "no", &idx
))
8560 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8561 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8563 afi
= vpn_policy_getafi(vty
, bgp
, false);
8565 return CMD_WARNING_CONFIG_FAILED
;
8569 vty_out(vty
, "It's not implemented\n");
8570 return CMD_WARNING_CONFIG_FAILED
;
8573 /* skip when it's already configured */
8574 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8575 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8576 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8580 * mode change between sid_idx and sid_auto isn't supported.
8581 * user must negate sid vpn export when they want to change the mode
8583 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8584 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8585 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8586 vty_out(vty
, "it's already configured as %s.\n",
8587 sid_auto
? "auto-mode" : "idx-mode");
8588 return CMD_WARNING_CONFIG_FAILED
;
8592 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8593 bgp_get_default(), bgp
);
8596 /* SID allocation auto-mode */
8598 zlog_debug("%s: auto sid alloc.", __func__
);
8599 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8600 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8602 /* SID allocation index-mode */
8604 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8605 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8609 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8610 bgp_get_default(), bgp
);
8614 ALIAS (af_label_vpn_export
,
8615 af_no_label_vpn_export_cmd
,
8616 "no label vpn export",
8618 "label value for VRF\n"
8619 "Between current address-family and vpn\n"
8620 "For routes leaked from current address-family to vpn\n")
8622 DEFPY (af_nexthop_vpn_export
,
8623 af_nexthop_vpn_export_cmd
,
8624 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8626 "Specify next hop to use for VRF advertised prefixes\n"
8627 "Between current address-family and vpn\n"
8628 "For routes leaked from current address-family to vpn\n"
8632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8638 vty_out(vty
, "%% Nexthop required\n");
8639 return CMD_WARNING_CONFIG_FAILED
;
8641 if (!sockunion2hostprefix(nexthop_su
, &p
))
8642 return CMD_WARNING_CONFIG_FAILED
;
8645 afi
= vpn_policy_getafi(vty
, bgp
, false);
8647 return CMD_WARNING_CONFIG_FAILED
;
8650 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8652 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8653 bgp_get_default(), bgp
);
8656 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8657 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8658 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8660 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8661 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8664 /* post-change: re-export vpn routes */
8665 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8666 bgp_get_default(), bgp
);
8671 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8673 if (!strcmp(dstr
, "import")) {
8674 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8675 } else if (!strcmp(dstr
, "export")) {
8676 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8677 } else if (!strcmp(dstr
, "both")) {
8678 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8679 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8681 vty_out(vty
, "%% direction parse error\n");
8682 return CMD_WARNING_CONFIG_FAILED
;
8687 DEFPY (af_rt_vpn_imexport
,
8688 af_rt_vpn_imexport_cmd
,
8689 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8691 "Specify route target list\n"
8692 "Specify route target list\n"
8693 "Between current address-family and vpn\n"
8694 "For routes leaked from vpn to current address-family: match any\n"
8695 "For routes leaked from current address-family to vpn: set\n"
8696 "both import: match any and export: set\n"
8697 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8701 struct ecommunity
*ecom
= NULL
;
8702 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8703 enum vpn_policy_direction dir
;
8708 if (argv_find(argv
, argc
, "no", &idx
))
8711 afi
= vpn_policy_getafi(vty
, bgp
, false);
8713 return CMD_WARNING_CONFIG_FAILED
;
8715 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8716 if (ret
!= CMD_SUCCESS
)
8720 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8721 vty_out(vty
, "%% Missing RTLIST\n");
8722 return CMD_WARNING_CONFIG_FAILED
;
8724 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8725 if (ret
!= CMD_SUCCESS
) {
8730 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8734 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8737 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8739 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8740 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8741 ecommunity_dup(ecom
);
8743 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8745 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8746 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8749 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8753 ecommunity_free(&ecom
);
8758 ALIAS (af_rt_vpn_imexport
,
8759 af_no_rt_vpn_imexport_cmd
,
8760 "no <rt|route-target> vpn <import|export|both>$direction_str",
8762 "Specify route target list\n"
8763 "Specify route target list\n"
8764 "Between current address-family and vpn\n"
8765 "For routes leaked from vpn to current address-family\n"
8766 "For routes leaked from current address-family to vpn\n"
8767 "both import and export\n")
8769 DEFPY (af_route_map_vpn_imexport
,
8770 af_route_map_vpn_imexport_cmd
,
8771 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8772 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8774 "Specify route map\n"
8775 "Between current address-family and vpn\n"
8776 "For routes leaked from vpn to current address-family\n"
8777 "For routes leaked from current address-family to vpn\n"
8778 "name of route-map\n")
8780 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8782 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8783 enum vpn_policy_direction dir
;
8788 if (argv_find(argv
, argc
, "no", &idx
))
8791 afi
= vpn_policy_getafi(vty
, bgp
, false);
8793 return CMD_WARNING_CONFIG_FAILED
;
8795 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8796 if (ret
!= CMD_SUCCESS
)
8799 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8803 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8806 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8807 XFREE(MTYPE_ROUTE_MAP_NAME
,
8808 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8809 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
8810 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8811 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8812 route_map_lookup_warn_noexist(vty
, rmap_str
);
8813 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8816 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8817 XFREE(MTYPE_ROUTE_MAP_NAME
,
8818 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8819 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8820 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8823 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8829 ALIAS (af_route_map_vpn_imexport
,
8830 af_no_route_map_vpn_imexport_cmd
,
8831 "no route-map vpn <import|export>$direction_str",
8833 "Specify route map\n"
8834 "Between current address-family and vpn\n"
8835 "For routes leaked from vpn to current address-family\n"
8836 "For routes leaked from current address-family to vpn\n")
8838 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
8839 "import vrf route-map RMAP$rmap_str",
8840 "Import routes from another VRF\n"
8841 "Vrf routes being filtered\n"
8842 "Specify route map\n"
8843 "name of route-map\n")
8845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8846 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8848 struct bgp
*bgp_default
;
8850 afi
= vpn_policy_getafi(vty
, bgp
, true);
8852 return CMD_WARNING_CONFIG_FAILED
;
8854 bgp_default
= bgp_get_default();
8859 /* Auto-create assuming the same AS */
8860 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8861 BGP_INSTANCE_TYPE_DEFAULT
);
8865 "VRF default is not configured as a bgp instance\n");
8870 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8872 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8873 XFREE(MTYPE_ROUTE_MAP_NAME
,
8874 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8875 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
8876 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8877 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8878 route_map_lookup_warn_noexist(vty
, rmap_str
);
8879 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8882 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8883 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8885 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8890 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
8891 "no import vrf route-map [RMAP$rmap_str]",
8893 "Import routes from another VRF\n"
8894 "Vrf routes being filtered\n"
8895 "Specify route map\n"
8896 "name of route-map\n")
8898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8899 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8902 afi
= vpn_policy_getafi(vty
, bgp
, true);
8904 return CMD_WARNING_CONFIG_FAILED
;
8906 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8908 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8909 XFREE(MTYPE_ROUTE_MAP_NAME
,
8910 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8911 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8912 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8914 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
8915 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8916 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8918 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8923 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
8924 "[no] import vrf VIEWVRFNAME$import_name",
8926 "Import routes from another VRF\n"
8927 "VRF to import from\n"
8928 "The name of the VRF\n")
8930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8931 struct listnode
*node
;
8932 struct bgp
*vrf_bgp
, *bgp_default
;
8935 bool remove
= false;
8938 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
8942 if (import_name
== NULL
) {
8943 vty_out(vty
, "%% Missing import name\n");
8947 if (strcmp(import_name
, "route-map") == 0) {
8948 vty_out(vty
, "%% Must include route-map name\n");
8952 if (argv_find(argv
, argc
, "no", &idx
))
8955 afi
= vpn_policy_getafi(vty
, bgp
, true);
8957 return CMD_WARNING_CONFIG_FAILED
;
8959 safi
= bgp_node_safi(vty
);
8961 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
8962 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
8963 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
8964 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
8965 remove
? "unimport" : "import", import_name
);
8969 bgp_default
= bgp_get_default();
8971 /* Auto-create assuming the same AS */
8972 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8973 BGP_INSTANCE_TYPE_DEFAULT
);
8977 "VRF default is not configured as a bgp instance\n");
8982 vrf_bgp
= bgp_lookup_by_name(import_name
);
8984 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
8985 vrf_bgp
= bgp_default
;
8987 /* Auto-create assuming the same AS */
8988 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
8992 "VRF %s is not configured as a bgp instance\n",
8999 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9001 /* Already importing from "import_vrf"? */
9002 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9004 if (strcmp(vname
, import_name
) == 0)
9008 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9014 /* This command is valid only in a bgp vrf instance or the default instance */
9015 DEFPY (bgp_imexport_vpn
,
9016 bgp_imexport_vpn_cmd
,
9017 "[no] <import|export>$direction_str vpn",
9019 "Import routes to this address-family\n"
9020 "Export routes from this address-family\n"
9021 "to/from default instance VPN RIB\n")
9023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9030 enum vpn_policy_direction dir
;
9032 if (argv_find(argv
, argc
, "no", &idx
))
9035 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9036 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9038 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9039 return CMD_WARNING_CONFIG_FAILED
;
9042 afi
= bgp_node_afi(vty
);
9043 safi
= bgp_node_safi(vty
);
9044 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9045 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9046 return CMD_WARNING_CONFIG_FAILED
;
9049 if (!strcmp(direction_str
, "import")) {
9050 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9051 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9052 } else if (!strcmp(direction_str
, "export")) {
9053 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9054 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9056 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9057 return CMD_WARNING_CONFIG_FAILED
;
9060 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9063 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9064 if (!previous_state
) {
9065 /* trigger export current vrf */
9066 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9069 if (previous_state
) {
9070 /* trigger un-export current vrf */
9071 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9073 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9076 hook_call(bgp_snmp_init_stats
, bgp
);
9081 DEFPY (af_routetarget_import
,
9082 af_routetarget_import_cmd
,
9083 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9085 "Specify route target list\n"
9086 "Specify route target list\n"
9087 "Specify route target list\n"
9088 "Specify route target list\n"
9089 "Flow-spec redirect type route target\n"
9090 "Import routes to this address-family\n"
9091 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9095 struct ecommunity
*ecom
= NULL
;
9097 int idx
= 0, idx_unused
= 0;
9101 if (argv_find(argv
, argc
, "no", &idx
))
9104 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9105 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9108 afi
= vpn_policy_getafi(vty
, bgp
, false);
9110 return CMD_WARNING_CONFIG_FAILED
;
9112 if (rt6
&& afi
!= AFI_IP6
)
9113 return CMD_WARNING_CONFIG_FAILED
;
9116 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9117 vty_out(vty
, "%% Missing RTLIST\n");
9118 return CMD_WARNING_CONFIG_FAILED
;
9120 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9121 if (ret
!= CMD_SUCCESS
)
9126 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9127 ecommunity_free(&bgp
->vpn_policy
[afi
]
9128 .import_redirect_rtlist
);
9129 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9130 ecommunity_dup(ecom
);
9132 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9133 ecommunity_free(&bgp
->vpn_policy
[afi
]
9134 .import_redirect_rtlist
);
9135 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9139 ecommunity_free(&ecom
);
9144 DEFUN_NOSH (address_family_ipv4_safi
,
9145 address_family_ipv4_safi_cmd
,
9146 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9147 "Enter Address Family command mode\n"
9149 BGP_SAFI_WITH_LABEL_HELP_STR
)
9153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9154 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9155 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9156 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9157 && safi
!= SAFI_EVPN
) {
9159 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9160 return CMD_WARNING_CONFIG_FAILED
;
9162 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9164 vty
->node
= BGP_IPV4_NODE
;
9169 DEFUN_NOSH (address_family_ipv6_safi
,
9170 address_family_ipv6_safi_cmd
,
9171 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9172 "Enter Address Family command mode\n"
9174 BGP_SAFI_WITH_LABEL_HELP_STR
)
9177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9178 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9179 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9180 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9181 && safi
!= SAFI_EVPN
) {
9183 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9184 return CMD_WARNING_CONFIG_FAILED
;
9186 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9188 vty
->node
= BGP_IPV6_NODE
;
9193 #ifdef KEEP_OLD_VPN_COMMANDS
9194 DEFUN_NOSH (address_family_vpnv4
,
9195 address_family_vpnv4_cmd
,
9196 "address-family vpnv4 [unicast]",
9197 "Enter Address Family command mode\n"
9199 "Address Family modifier\n")
9201 vty
->node
= BGP_VPNV4_NODE
;
9205 DEFUN_NOSH (address_family_vpnv6
,
9206 address_family_vpnv6_cmd
,
9207 "address-family vpnv6 [unicast]",
9208 "Enter Address Family command mode\n"
9210 "Address Family modifier\n")
9212 vty
->node
= BGP_VPNV6_NODE
;
9215 #endif /* KEEP_OLD_VPN_COMMANDS */
9217 DEFUN_NOSH (address_family_evpn
,
9218 address_family_evpn_cmd
,
9219 "address-family l2vpn evpn",
9220 "Enter Address Family command mode\n"
9222 "Address Family modifier\n")
9224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9225 vty
->node
= BGP_EVPN_NODE
;
9229 DEFUN_NOSH (bgp_segment_routing_srv6
,
9230 bgp_segment_routing_srv6_cmd
,
9231 "segment-routing srv6",
9232 "Segment-Routing configuration\n"
9233 "Segment-Routing SRv6 configuration\n")
9235 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9236 bgp
->srv6_enabled
= true;
9237 vty
->node
= BGP_SRV6_NODE
;
9241 DEFUN (no_bgp_segment_routing_srv6
,
9242 no_bgp_segment_routing_srv6_cmd
,
9243 "no segment-routing srv6",
9245 "Segment-Routing configuration\n"
9246 "Segment-Routing SRv6 configuration\n")
9248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9250 if (strlen(bgp
->srv6_locator_name
) > 0)
9251 if (bgp_srv6_locator_unset(bgp
) < 0)
9252 return CMD_WARNING_CONFIG_FAILED
;
9254 bgp
->srv6_enabled
= false;
9258 DEFPY (bgp_srv6_locator
,
9259 bgp_srv6_locator_cmd
,
9260 "locator NAME$name",
9261 "Specify SRv6 locator\n"
9262 "Specify SRv6 locator\n")
9264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9267 if (strlen(bgp
->srv6_locator_name
) > 0
9268 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9269 vty_out(vty
, "srv6 locator is already configured\n");
9270 return CMD_WARNING_CONFIG_FAILED
;
9273 snprintf(bgp
->srv6_locator_name
,
9274 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9276 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9278 return CMD_WARNING_CONFIG_FAILED
;
9283 DEFPY (no_bgp_srv6_locator
,
9284 no_bgp_srv6_locator_cmd
,
9285 "no locator NAME$name",
9287 "Specify SRv6 locator\n"
9288 "Specify SRv6 locator\n")
9290 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9292 /* when locator isn't configured, do nothing */
9293 if (strlen(bgp
->srv6_locator_name
) < 1)
9296 /* name validation */
9297 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9298 vty_out(vty
, "%% No srv6 locator is configured\n");
9299 return CMD_WARNING_CONFIG_FAILED
;
9303 if (bgp_srv6_locator_unset(bgp
) < 0)
9304 return CMD_WARNING_CONFIG_FAILED
;
9309 DEFPY (show_bgp_srv6
,
9311 "show bgp segment-routing srv6",
9314 "BGP Segment Routing\n"
9315 "BGP Segment Routing SRv6\n")
9318 struct listnode
*node
;
9319 struct srv6_locator_chunk
*chunk
;
9320 struct bgp_srv6_function
*func
;
9321 struct in6_addr
*tovpn4_sid
;
9322 struct in6_addr
*tovpn6_sid
;
9324 char buf_tovpn4_sid
[256];
9325 char buf_tovpn6_sid
[256];
9327 bgp
= bgp_get_default();
9331 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9332 vty_out(vty
, "locator_chunks:\n");
9333 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9334 prefix2str(&chunk
->prefix
, buf
, sizeof(buf
));
9335 vty_out(vty
, "- %s\n", buf
);
9338 vty_out(vty
, "functions:\n");
9339 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9340 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9341 vty_out(vty
, "- sid: %s\n", buf
);
9342 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9345 vty_out(vty
, "bgps:\n");
9346 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9347 vty_out(vty
, "- name: %s\n",
9348 bgp
->name
? bgp
->name
: "default");
9350 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9351 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9353 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9354 sizeof(buf_tovpn4_sid
));
9356 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9357 sizeof(buf_tovpn6_sid
));
9359 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9360 tovpn4_sid
? buf_tovpn4_sid
: "none");
9361 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9362 tovpn6_sid
? buf_tovpn6_sid
: "none");
9368 DEFUN_NOSH (exit_address_family
,
9369 exit_address_family_cmd
,
9370 "exit-address-family",
9371 "Exit from Address Family configuration mode\n")
9373 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9374 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9375 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9376 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9377 || vty
->node
== BGP_EVPN_NODE
9378 || vty
->node
== BGP_FLOWSPECV4_NODE
9379 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9380 vty
->node
= BGP_NODE
;
9384 /* Recalculate bestpath and re-advertise a prefix */
9385 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9386 const char *ip_str
, afi_t afi
, safi_t safi
,
9387 struct prefix_rd
*prd
)
9390 struct prefix match
;
9391 struct bgp_dest
*dest
;
9392 struct bgp_dest
*rm
;
9394 struct bgp_table
*table
;
9395 struct bgp_table
*rib
;
9397 /* BGP structure lookup. */
9399 bgp
= bgp_lookup_by_name(view_name
);
9401 vty_out(vty
, "%% Can't find BGP instance %s\n",
9406 bgp
= bgp_get_default();
9408 vty_out(vty
, "%% No BGP process is configured\n");
9413 /* Check IP address argument. */
9414 ret
= str2prefix(ip_str
, &match
);
9416 vty_out(vty
, "%% address is malformed\n");
9420 match
.family
= afi2family(afi
);
9421 rib
= bgp
->rib
[afi
][safi
];
9423 if (safi
== SAFI_MPLS_VPN
) {
9424 for (dest
= bgp_table_top(rib
); dest
;
9425 dest
= bgp_route_next(dest
)) {
9426 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9428 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9431 table
= bgp_dest_get_bgp_table_info(dest
);
9435 rm
= bgp_node_match(table
, &match
);
9437 const struct prefix
*rm_p
=
9438 bgp_dest_get_prefix(rm
);
9440 if (rm_p
->prefixlen
== match
.prefixlen
) {
9442 BGP_NODE_USER_CLEAR
);
9443 bgp_process(bgp
, rm
, afi
, safi
);
9445 bgp_dest_unlock_node(rm
);
9449 dest
= bgp_node_match(rib
, &match
);
9451 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9453 if (dest_p
->prefixlen
== match
.prefixlen
) {
9454 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9455 bgp_process(bgp
, dest
, afi
, safi
);
9457 bgp_dest_unlock_node(dest
);
9464 /* one clear bgp command to rule them all */
9465 DEFUN (clear_ip_bgp_all
,
9466 clear_ip_bgp_all_cmd
,
9467 "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>]",
9471 BGP_INSTANCE_HELP_STR
9474 BGP_SAFI_WITH_LABEL_HELP_STR
9475 "Address Family modifier\n"
9477 "BGP IPv4 neighbor to clear\n"
9478 "BGP IPv6 neighbor to clear\n"
9479 "BGP neighbor on interface to clear\n"
9480 "Clear peers with the AS number\n"
9481 "Clear all external peers\n"
9482 "Clear all members of peer-group\n"
9483 "BGP peer-group name\n"
9488 "Push out prefix-list ORF and do inbound soft reconfig\n"
9490 "Reset message statistics\n")
9494 afi_t afi
= AFI_UNSPEC
;
9495 safi_t safi
= SAFI_UNSPEC
;
9496 enum clear_sort clr_sort
= clear_peer
;
9497 enum bgp_clear_type clr_type
;
9498 char *clr_arg
= NULL
;
9502 /* clear [ip] bgp */
9503 if (argv_find(argv
, argc
, "ip", &idx
))
9506 /* [<vrf> VIEWVRFNAME] */
9507 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9508 vrf
= argv
[idx
+ 1]->arg
;
9510 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9512 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9513 /* [<view> VIEWVRFNAME] */
9514 vrf
= argv
[idx
+ 1]->arg
;
9517 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9518 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9519 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9521 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9522 if (argv_find(argv
, argc
, "*", &idx
)) {
9523 clr_sort
= clear_all
;
9524 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9525 clr_sort
= clear_peer
;
9526 clr_arg
= argv
[idx
]->arg
;
9527 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9528 clr_sort
= clear_peer
;
9529 clr_arg
= argv
[idx
]->arg
;
9530 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9531 clr_sort
= clear_group
;
9533 clr_arg
= argv
[idx
]->arg
;
9534 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9535 clr_sort
= clear_peer
;
9536 clr_arg
= argv
[idx
]->arg
;
9537 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9538 clr_sort
= clear_peer
;
9539 clr_arg
= argv
[idx
]->arg
;
9540 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9541 clr_sort
= clear_as
;
9542 clr_arg
= argv
[idx
]->arg
;
9543 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9544 clr_sort
= clear_external
;
9547 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9548 if (argv_find(argv
, argc
, "soft", &idx
)) {
9549 if (argv_find(argv
, argc
, "in", &idx
)
9550 || argv_find(argv
, argc
, "out", &idx
))
9551 clr_type
= strmatch(argv
[idx
]->text
, "in")
9553 : BGP_CLEAR_SOFT_OUT
;
9555 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9556 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9557 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9558 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9559 : BGP_CLEAR_SOFT_IN
;
9560 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9561 clr_type
= BGP_CLEAR_SOFT_OUT
;
9562 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9563 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9565 clr_type
= BGP_CLEAR_SOFT_NONE
;
9567 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9570 DEFUN (clear_ip_bgp_prefix
,
9571 clear_ip_bgp_prefix_cmd
,
9572 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9576 BGP_INSTANCE_HELP_STR
9577 "Clear bestpath and re-advertise\n"
9581 char *prefix
= NULL
;
9585 /* [<view|vrf> VIEWVRFNAME] */
9586 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9587 vrf
= argv
[idx
+ 1]->arg
;
9589 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9591 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9592 /* [<view> VIEWVRFNAME] */
9593 vrf
= argv
[idx
+ 1]->arg
;
9597 prefix
= argv
[argc
- 1]->arg
;
9599 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9602 DEFUN (clear_bgp_ipv6_safi_prefix
,
9603 clear_bgp_ipv6_safi_prefix_cmd
,
9604 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9610 "Clear bestpath and re-advertise\n"
9614 int idx_ipv6_prefix
= 0;
9615 safi_t safi
= SAFI_UNICAST
;
9616 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9617 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9619 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9620 return bgp_clear_prefix(
9621 vty
, NULL
, prefix
, AFI_IP6
,
9625 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9626 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9627 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9631 BGP_INSTANCE_HELP_STR
9634 "Clear bestpath and re-advertise\n"
9638 int idx_vrfview
= 0;
9639 int idx_ipv6_prefix
= 0;
9640 safi_t safi
= SAFI_UNICAST
;
9641 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9642 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9643 char *vrfview
= NULL
;
9645 /* [<view|vrf> VIEWVRFNAME] */
9646 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9647 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9648 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9650 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9651 /* [<view> VIEWVRFNAME] */
9652 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9654 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9656 return bgp_clear_prefix(
9657 vty
, vrfview
, prefix
,
9658 AFI_IP6
, safi
, NULL
);
9661 DEFUN (show_bgp_views
,
9663 "show [ip] bgp views",
9667 "Show the defined BGP views\n")
9669 struct list
*inst
= bm
->bgp
;
9670 struct listnode
*node
;
9673 vty_out(vty
, "Defined BGP views:\n");
9674 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9676 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9678 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9685 DEFUN (show_bgp_vrfs
,
9687 "show [ip] bgp vrfs [json]",
9694 char buf
[ETHER_ADDR_STRLEN
];
9695 struct list
*inst
= bm
->bgp
;
9696 struct listnode
*node
;
9698 bool uj
= use_json(argc
, argv
);
9699 json_object
*json
= NULL
;
9700 json_object
*json_vrfs
= NULL
;
9704 json
= json_object_new_object();
9705 json_vrfs
= json_object_new_object();
9708 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9709 const char *name
, *type
;
9711 struct listnode
*node2
, *nnode2
;
9712 int peers_cfg
, peers_estb
;
9713 json_object
*json_vrf
= NULL
;
9716 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9720 if (!uj
&& count
== 1) {
9722 "%4s %-5s %-16s %9s %10s %-37s\n",
9723 "Type", "Id", "routerId", "#PeersCfg",
9724 "#PeersEstb", "Name");
9725 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9726 "L3-VNI", "RouterMAC", "Interface");
9729 peers_cfg
= peers_estb
= 0;
9731 json_vrf
= json_object_new_object();
9734 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9735 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9738 if (peer_established(peer
))
9742 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9743 name
= VRF_DEFAULT_NAME
;
9752 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9754 : (int64_t)bgp
->vrf_id
;
9755 char buf
[BUFSIZ
] = {0};
9757 json_object_string_add(json_vrf
, "type", type
);
9758 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9759 json_object_string_addf(json_vrf
, "routerId", "%pI4",
9761 json_object_int_add(json_vrf
, "numConfiguredPeers",
9763 json_object_int_add(json_vrf
, "numEstablishedPeers",
9766 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9767 json_object_string_add(
9769 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9770 json_object_string_add(json_vrf
, "interface",
9771 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9773 json_object_object_add(json_vrfs
, name
, json_vrf
);
9775 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
9777 bgp
->vrf_id
== VRF_UNKNOWN
? -1
9779 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
9780 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
9782 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
9783 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9789 json_object_object_add(json
, "vrfs", json_vrfs
);
9791 json_object_int_add(json
, "totalVrfs", count
);
9793 vty_json(vty
, json
);
9797 "\nTotal number of VRFs (including default): %d\n",
9804 DEFUN (show_bgp_mac_hash
,
9805 show_bgp_mac_hash_cmd
,
9806 "show bgp mac hash",
9810 "Mac Address database\n")
9812 bgp_mac_dump_table(vty
);
9817 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
9819 struct vty
*vty
= (struct vty
*)args
;
9820 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
9822 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
9825 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
9827 vty_out(vty
, "self nexthop database:\n");
9828 bgp_nexthop_show_address_hash(vty
, bgp
);
9830 vty_out(vty
, "Tunnel-ip database:\n");
9831 hash_iterate(bgp
->tip_hash
,
9832 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
9836 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
9837 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
9838 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
9839 "martian next-hops\n"
9840 "martian next-hop database\n")
9842 struct bgp
*bgp
= NULL
;
9846 /* [<vrf> VIEWVRFNAME] */
9847 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9848 name
= argv
[idx
+ 1]->arg
;
9849 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
9851 } else if (argv_find(argv
, argc
, "view", &idx
))
9852 /* [<view> VIEWVRFNAME] */
9853 name
= argv
[idx
+ 1]->arg
;
9855 bgp
= bgp_lookup_by_name(name
);
9857 bgp
= bgp_get_default();
9860 vty_out(vty
, "%% No BGP process is configured\n");
9863 bgp_show_martian_nexthops(vty
, bgp
);
9868 DEFUN (show_bgp_memory
,
9869 show_bgp_memory_cmd
,
9870 "show [ip] bgp memory",
9874 "Global BGP memory statistics\n")
9876 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9877 unsigned long count
;
9879 /* RIB related usage stats */
9880 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
9881 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
9882 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9883 count
* sizeof(struct bgp_dest
)));
9885 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
9886 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
9887 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9888 count
* sizeof(struct bgp_path_info
)));
9889 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
9890 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
9893 memstrbuf
, sizeof(memstrbuf
),
9894 count
* sizeof(struct bgp_path_info_extra
)));
9896 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
9897 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
9898 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9899 count
* sizeof(struct bgp_static
)));
9901 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
9902 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
9903 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9904 count
* sizeof(struct bpacket
)));
9907 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
9908 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
9909 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9910 count
* sizeof(struct bgp_adj_in
)));
9911 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
9912 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
9913 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9914 count
* sizeof(struct bgp_adj_out
)));
9916 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
9917 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
9919 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9920 count
* sizeof(struct bgp_nexthop_cache
)));
9922 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
9923 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
9925 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9926 count
* sizeof(struct bgp_damp_info
)));
9929 count
= attr_count();
9930 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
9931 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9932 count
* sizeof(struct attr
)));
9934 if ((count
= attr_unknown_count()))
9935 vty_out(vty
, "%ld unknown attributes\n", count
);
9937 /* AS_PATH attributes */
9938 count
= aspath_count();
9939 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
9940 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9941 count
* sizeof(struct aspath
)));
9943 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
9944 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
9945 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9946 count
* sizeof(struct assegment
)));
9948 /* Other attributes */
9949 if ((count
= community_count()))
9950 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9951 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9952 count
* sizeof(struct community
)));
9953 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
9954 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9955 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9956 count
* sizeof(struct ecommunity
)));
9957 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
9959 "%ld BGP large-community entries, using %s of memory\n",
9960 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9961 count
* sizeof(struct lcommunity
)));
9963 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
9964 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
9965 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9966 count
* sizeof(struct cluster_list
)));
9968 /* Peer related usage */
9969 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
9970 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
9971 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9972 count
* sizeof(struct peer
)));
9974 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
9975 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
9976 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9977 count
* sizeof(struct peer_group
)));
9980 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
9981 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
9982 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9983 count
* sizeof(regex_t
)));
9987 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
9989 json_object
*bestpath
= json_object_new_object();
9991 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
9992 json_object_string_add(bestpath
, "asPath", "ignore");
9994 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
9995 json_object_string_add(bestpath
, "asPath", "confed");
9997 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
9998 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
9999 json_object_string_add(bestpath
, "multiPathRelax",
10002 json_object_string_add(bestpath
, "multiPathRelax",
10005 json_object_string_add(bestpath
, "multiPathRelax", "false");
10007 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10008 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10010 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10011 json_object_string_add(bestpath
, "compareRouterId", "true");
10012 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10013 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10014 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10015 json_object_string_add(bestpath
, "med", "confed");
10016 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10017 json_object_string_add(bestpath
, "med",
10018 "missing-as-worst");
10020 json_object_string_add(bestpath
, "med", "true");
10023 json_object_object_add(json
, "bestPath", bestpath
);
10026 /* Print the error code/subcode for why the peer is down */
10027 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10028 json_object
*json_peer
, bool use_json
)
10030 const char *code_str
;
10031 const char *subcode_str
;
10034 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10035 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10036 char errorcodesubcode_hexstr
[5];
10037 char errorcodesubcode_str
[256];
10039 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10040 subcode_str
= bgp_notify_subcode_str(
10042 peer
->notify
.subcode
);
10044 snprintf(errorcodesubcode_hexstr
,
10045 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10046 peer
->notify
.code
, peer
->notify
.subcode
);
10047 json_object_string_add(json_peer
,
10048 "lastErrorCodeSubcode",
10049 errorcodesubcode_hexstr
);
10050 snprintf(errorcodesubcode_str
, 255, "%s%s",
10051 code_str
, subcode_str
);
10052 json_object_string_add(json_peer
,
10053 "lastNotificationReason",
10054 errorcodesubcode_str
);
10055 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10056 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10057 && (peer
->notify
.subcode
10058 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10059 || peer
->notify
.subcode
10060 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10061 && peer
->notify
.length
) {
10063 const char *msg_str
;
10065 msg_str
= bgp_notify_admin_message(
10066 msgbuf
, sizeof(msgbuf
),
10067 (uint8_t *)peer
->notify
.data
,
10068 peer
->notify
.length
);
10070 json_object_string_add(
10072 "lastShutdownDescription",
10077 json_object_string_add(json_peer
, "lastResetDueTo",
10078 peer_down_str
[(int)peer
->last_reset
]);
10079 json_object_int_add(json_peer
, "lastResetCode",
10082 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10083 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10084 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10086 bgp_notify_subcode_str(peer
->notify
.code
,
10087 peer
->notify
.subcode
);
10088 vty_out(vty
, " Notification %s (%s%s)\n",
10089 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10092 code_str
, subcode_str
);
10094 vty_out(vty
, " %s\n",
10095 peer_down_str
[(int)peer
->last_reset
]);
10100 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10103 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10106 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10107 struct peer
*peer
, json_object
*json_peer
,
10108 int max_neighbor_width
, bool use_json
)
10110 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10114 if (peer_dynamic_neighbor(peer
))
10115 json_object_boolean_true_add(json_peer
,
10117 if (peer
->hostname
)
10118 json_object_string_add(json_peer
, "hostname",
10121 if (peer
->domainname
)
10122 json_object_string_add(json_peer
, "domainname",
10124 json_object_int_add(json_peer
, "connectionsEstablished",
10125 peer
->established
);
10126 json_object_int_add(json_peer
, "connectionsDropped",
10128 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10129 use_json
, json_peer
);
10130 if (peer_established(peer
))
10131 json_object_string_add(json_peer
, "lastResetDueTo",
10132 "AFI/SAFI Not Negotiated");
10134 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10137 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10139 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10140 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10141 peer
->hostname
, peer
->host
);
10143 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10145 /* pad the neighbor column with spaces */
10146 if (len
< max_neighbor_width
)
10147 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10149 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10151 peer_uptime(peer
->uptime
, timebuf
,
10152 BGP_UPTIME_LEN
, 0, NULL
));
10153 if (peer_established(peer
))
10154 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10156 bgp_show_peer_reset(vty
, peer
, NULL
,
10161 /* Strip peer's description to the given size. */
10162 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10164 static char stripped
[BUFSIZ
];
10165 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10167 strlcpy(stripped
, desc
, len
+ 1);
10172 /* Determine whether var peer should be filtered out of the summary. */
10173 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10174 struct peer
*fpeer
, int as_type
,
10178 /* filter neighbor XXXX */
10179 if (fpeer
&& fpeer
!= peer
)
10182 /* filter remote-as (internal|external) */
10183 if (as_type
!= AS_UNSPECIFIED
) {
10184 if (peer
->as_type
== AS_SPECIFIED
) {
10185 if (as_type
== AS_INTERNAL
) {
10186 if (peer
->as
!= peer
->local_as
)
10188 } else if (peer
->as
== peer
->local_as
)
10190 } else if (as_type
!= peer
->as_type
)
10192 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10198 /* Show BGP peer's summary information.
10200 * Peer's description is stripped according to if `wide` option is given
10203 * When adding new columns to `show bgp summary` output, please make
10204 * sure `Desc` is the lastest column to show because it can contain
10205 * whitespaces and the whole output will be tricky.
10207 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10208 struct peer
*fpeer
, int as_type
, as_t as
,
10209 uint16_t show_flags
)
10212 struct listnode
*node
, *nnode
;
10213 unsigned int count
= 0, dn_count
= 0;
10214 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10215 char neighbor_buf
[VTY_BUFSIZ
];
10216 int neighbor_col_default_width
= 16;
10217 int len
, failed_count
= 0;
10218 unsigned int filtered_count
= 0;
10219 int max_neighbor_width
= 0;
10221 json_object
*json
= NULL
;
10222 json_object
*json_peer
= NULL
;
10223 json_object
*json_peers
= NULL
;
10224 struct peer_af
*paf
;
10225 struct bgp_filter
*filter
;
10226 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10227 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10228 bool show_established
=
10229 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10230 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10231 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10233 /* labeled-unicast routes are installed in the unicast table so in order
10235 * display the correct PfxRcd value we must look at SAFI_UNICAST
10238 if (safi
== SAFI_LABELED_UNICAST
)
10239 pfx_rcd_safi
= SAFI_UNICAST
;
10241 pfx_rcd_safi
= safi
;
10244 json
= json_object_new_object();
10245 json_peers
= json_object_new_object();
10246 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10247 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10254 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10257 if (peer
->afc
[afi
][safi
]) {
10258 /* See if we have at least a single failed peer */
10259 if (bgp_has_peer_failed(peer
, afi
, safi
))
10263 if (peer_dynamic_neighbor(peer
))
10268 /* Loop over all neighbors that will be displayed to determine
10270 * characters are needed for the Neighbor column
10272 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10273 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10280 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10283 if (peer
->afc
[afi
][safi
]) {
10284 memset(dn_flag
, '\0', sizeof(dn_flag
));
10285 if (peer_dynamic_neighbor(peer
))
10289 && CHECK_FLAG(bgp
->flags
,
10290 BGP_FLAG_SHOW_HOSTNAME
))
10291 snprintf(neighbor_buf
,
10292 sizeof(neighbor_buf
),
10293 "%s%s(%s) ", dn_flag
,
10294 peer
->hostname
, peer
->host
);
10296 snprintf(neighbor_buf
,
10297 sizeof(neighbor_buf
), "%s%s ",
10298 dn_flag
, peer
->host
);
10300 len
= strlen(neighbor_buf
);
10302 if (len
> max_neighbor_width
)
10303 max_neighbor_width
= len
;
10305 /* See if we have at least a single failed peer */
10306 if (bgp_has_peer_failed(peer
, afi
, safi
))
10312 /* Originally we displayed the Neighbor column as 16
10313 * characters wide so make that the default
10315 if (max_neighbor_width
< neighbor_col_default_width
)
10316 max_neighbor_width
= neighbor_col_default_width
;
10319 if (show_failed
&& !failed_count
) {
10321 json_object_int_add(json
, "failedPeersCount", 0);
10322 json_object_int_add(json
, "dynamicPeers", dn_count
);
10323 json_object_int_add(json
, "totalPeers", count
);
10325 vty_json(vty
, json
);
10327 vty_out(vty
, "%% No failed BGP neighbors found\n");
10329 return CMD_SUCCESS
;
10332 count
= 0; /* Reset the value as its used again */
10333 filtered_count
= 0;
10335 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10336 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10339 if (!peer
->afc
[afi
][safi
])
10343 unsigned long ents
;
10344 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10347 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10349 : (int64_t)bgp
->vrf_id
;
10351 /* Usage summary and header */
10353 json_object_string_addf(json
, "routerId",
10356 json_object_int_add(json
, "as", bgp
->as
);
10357 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10358 json_object_string_add(
10361 == BGP_INSTANCE_TYPE_DEFAULT
)
10366 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10367 &bgp
->router_id
, bgp
->as
,
10368 bgp
->vrf_id
== VRF_UNKNOWN
10370 : (int)bgp
->vrf_id
);
10371 vty_out(vty
, "\n");
10374 if (bgp_update_delay_configured(bgp
)) {
10376 json_object_int_add(
10377 json
, "updateDelayLimit",
10378 bgp
->v_update_delay
);
10380 if (bgp
->v_update_delay
10381 != bgp
->v_establish_wait
)
10382 json_object_int_add(
10384 "updateDelayEstablishWait",
10385 bgp
->v_establish_wait
);
10387 if (bgp_update_delay_active(bgp
)) {
10388 json_object_string_add(
10390 "updateDelayFirstNeighbor",
10391 bgp
->update_delay_begin_time
);
10392 json_object_boolean_true_add(
10394 "updateDelayInProgress");
10396 if (bgp
->update_delay_over
) {
10397 json_object_string_add(
10399 "updateDelayFirstNeighbor",
10400 bgp
->update_delay_begin_time
);
10401 json_object_string_add(
10403 "updateDelayBestpathResumed",
10404 bgp
->update_delay_end_time
);
10405 json_object_string_add(
10407 "updateDelayZebraUpdateResume",
10408 bgp
->update_delay_zebra_resume_time
);
10409 json_object_string_add(
10411 "updateDelayPeerUpdateResume",
10412 bgp
->update_delay_peers_resume_time
);
10417 "Read-only mode update-delay limit: %d seconds\n",
10418 bgp
->v_update_delay
);
10419 if (bgp
->v_update_delay
10420 != bgp
->v_establish_wait
)
10422 " Establish wait: %d seconds\n",
10423 bgp
->v_establish_wait
);
10425 if (bgp_update_delay_active(bgp
)) {
10427 " First neighbor established: %s\n",
10428 bgp
->update_delay_begin_time
);
10430 " Delay in progress\n");
10432 if (bgp
->update_delay_over
) {
10434 " First neighbor established: %s\n",
10435 bgp
->update_delay_begin_time
);
10437 " Best-paths resumed: %s\n",
10438 bgp
->update_delay_end_time
);
10440 " zebra update resumed: %s\n",
10441 bgp
->update_delay_zebra_resume_time
);
10443 " peers update resumed: %s\n",
10444 bgp
->update_delay_peers_resume_time
);
10451 if (bgp_maxmed_onstartup_configured(bgp
)
10452 && bgp
->maxmed_active
)
10453 json_object_boolean_true_add(
10454 json
, "maxMedOnStartup");
10455 if (bgp
->v_maxmed_admin
)
10456 json_object_boolean_true_add(
10457 json
, "maxMedAdministrative");
10459 json_object_int_add(
10460 json
, "tableVersion",
10461 bgp_table_version(bgp
->rib
[afi
][safi
]));
10463 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10464 json_object_int_add(json
, "ribCount", ents
);
10465 json_object_int_add(
10467 ents
* sizeof(struct bgp_dest
));
10469 ents
= bgp
->af_peer_count
[afi
][safi
];
10470 json_object_int_add(json
, "peerCount", ents
);
10471 json_object_int_add(json
, "peerMemory",
10472 ents
* sizeof(struct peer
));
10474 if ((ents
= listcount(bgp
->group
))) {
10475 json_object_int_add(
10476 json
, "peerGroupCount", ents
);
10477 json_object_int_add(
10478 json
, "peerGroupMemory",
10479 ents
* sizeof(struct
10483 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10484 BGP_CONFIG_DAMPENING
))
10485 json_object_boolean_true_add(
10486 json
, "dampeningEnabled");
10489 if (bgp_maxmed_onstartup_configured(bgp
)
10490 && bgp
->maxmed_active
)
10492 "Max-med on-startup active\n");
10493 if (bgp
->v_maxmed_admin
)
10495 "Max-med administrative active\n");
10498 "BGP table version %" PRIu64
10501 bgp
->rib
[afi
][safi
]));
10503 ents
= bgp_table_count(
10504 bgp
->rib
[afi
][safi
]);
10506 "RIB entries %ld, using %s of memory\n",
10516 /* Peer related usage */
10517 ents
= bgp
->af_peer_count
[afi
][safi
];
10519 "Peers %ld, using %s of memory\n",
10529 if ((ents
= listcount(bgp
->group
)))
10531 "Peer groups %ld, using %s of memory\n",
10541 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10542 BGP_CONFIG_DAMPENING
))
10544 "Dampening enabled.\n");
10547 vty_out(vty
, "\n");
10549 /* Subtract 8 here because 'Neighbor' is
10551 vty_out(vty
, "Neighbor");
10552 vty_out(vty
, "%*s",
10553 max_neighbor_width
- 8, " ");
10555 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10560 paf
= peer_af_find(peer
, afi
, safi
);
10561 filter
= &peer
->filter
[afi
][safi
];
10564 /* Works for both failed & successful cases */
10565 if (peer_dynamic_neighbor(peer
))
10570 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10576 bgp_has_peer_failed(peer
, afi
, safi
)) {
10577 json_peer
= json_object_new_object();
10578 bgp_show_failed_summary(vty
, bgp
, peer
,
10579 json_peer
, 0, use_json
);
10580 } else if (!show_failed
) {
10581 if (show_established
10582 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10587 json_peer
= json_object_new_object();
10588 if (peer_dynamic_neighbor(peer
)) {
10589 json_object_boolean_true_add(json_peer
,
10593 if (peer
->hostname
)
10594 json_object_string_add(json_peer
, "hostname",
10597 if (peer
->domainname
)
10598 json_object_string_add(json_peer
, "domainname",
10601 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10602 json_object_int_add(
10603 json_peer
, "localAs",
10604 peer
->change_local_as
10605 ? peer
->change_local_as
10607 json_object_int_add(json_peer
, "version", 4);
10608 json_object_int_add(json_peer
, "msgRcvd",
10609 PEER_TOTAL_RX(peer
));
10610 json_object_int_add(json_peer
, "msgSent",
10611 PEER_TOTAL_TX(peer
));
10613 atomic_size_t outq_count
, inq_count
;
10614 outq_count
= atomic_load_explicit(
10615 &peer
->obuf
->count
,
10616 memory_order_relaxed
);
10617 inq_count
= atomic_load_explicit(
10618 &peer
->ibuf
->count
,
10619 memory_order_relaxed
);
10621 json_object_int_add(json_peer
, "tableVersion",
10622 peer
->version
[afi
][safi
]);
10623 json_object_int_add(json_peer
, "outq",
10625 json_object_int_add(json_peer
, "inq",
10627 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10628 use_json
, json_peer
);
10630 json_object_int_add(json_peer
, "pfxRcd",
10631 peer
->pcount
[afi
][pfx_rcd_safi
]);
10633 if (paf
&& PAF_SUBGRP(paf
))
10634 json_object_int_add(
10635 json_peer
, "pfxSnt",
10636 (PAF_SUBGRP(paf
))->scount
);
10638 json_object_int_add(json_peer
, "pfxSnt",
10641 /* BGP FSM state */
10642 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10643 || CHECK_FLAG(peer
->bgp
->flags
,
10644 BGP_FLAG_SHUTDOWN
))
10645 json_object_string_add(json_peer
,
10648 else if (peer
->afc_recv
[afi
][safi
])
10649 json_object_string_add(
10650 json_peer
, "state",
10651 lookup_msg(bgp_status_msg
,
10652 peer
->status
, NULL
));
10653 else if (CHECK_FLAG(
10655 PEER_STATUS_PREFIX_OVERFLOW
))
10656 json_object_string_add(json_peer
,
10660 json_object_string_add(
10661 json_peer
, "state",
10662 lookup_msg(bgp_status_msg
,
10663 peer
->status
, NULL
));
10665 /* BGP peer state */
10666 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10667 || CHECK_FLAG(peer
->bgp
->flags
,
10668 BGP_FLAG_SHUTDOWN
))
10669 json_object_string_add(json_peer
,
10672 else if (CHECK_FLAG(
10674 PEER_STATUS_PREFIX_OVERFLOW
))
10675 json_object_string_add(json_peer
,
10678 else if (CHECK_FLAG(peer
->flags
,
10679 PEER_FLAG_PASSIVE
))
10680 json_object_string_add(json_peer
,
10683 else if (CHECK_FLAG(peer
->sflags
,
10684 PEER_STATUS_NSF_WAIT
))
10685 json_object_string_add(json_peer
,
10688 else if (CHECK_FLAG(
10690 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10691 && (!bgp_inbound_policy_exists(peer
,
10693 || !bgp_outbound_policy_exists(
10695 json_object_string_add(json_peer
,
10699 json_object_string_add(
10700 json_peer
, "peerState", "OK");
10702 json_object_int_add(json_peer
, "connectionsEstablished",
10703 peer
->established
);
10704 json_object_int_add(json_peer
, "connectionsDropped",
10707 json_object_string_add(
10708 json_peer
, "desc", peer
->desc
);
10710 /* Avoid creating empty peer dicts in JSON */
10711 if (json_peer
== NULL
)
10715 json_object_string_add(json_peer
, "idType",
10717 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10718 json_object_string_add(json_peer
, "idType",
10720 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10721 json_object_string_add(json_peer
, "idType",
10723 json_object_object_add(json_peers
, peer
->host
,
10726 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10732 bgp_has_peer_failed(peer
, afi
, safi
)) {
10733 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10734 max_neighbor_width
,
10736 } else if (!show_failed
) {
10737 if (show_established
10738 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10743 if ((count
- filtered_count
) == 1) {
10744 /* display headline before the first
10746 vty_out(vty
, "\n");
10748 /* Subtract 8 here because 'Neighbor' is
10750 vty_out(vty
, "Neighbor");
10751 vty_out(vty
, "%*s",
10752 max_neighbor_width
- 8, " ");
10755 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10756 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10759 memset(dn_flag
, '\0', sizeof(dn_flag
));
10760 if (peer_dynamic_neighbor(peer
)) {
10765 && CHECK_FLAG(bgp
->flags
,
10766 BGP_FLAG_SHOW_HOSTNAME
))
10767 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10771 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10773 /* pad the neighbor column with spaces */
10774 if (len
< max_neighbor_width
)
10775 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10778 atomic_size_t outq_count
, inq_count
;
10779 outq_count
= atomic_load_explicit(
10780 &peer
->obuf
->count
,
10781 memory_order_relaxed
);
10782 inq_count
= atomic_load_explicit(
10783 &peer
->ibuf
->count
,
10784 memory_order_relaxed
);
10788 "4 %10u %10u %9u %9u %8" PRIu64
10791 peer
->change_local_as
10792 ? peer
->change_local_as
10794 PEER_TOTAL_RX(peer
),
10795 PEER_TOTAL_TX(peer
),
10796 peer
->version
[afi
][safi
],
10797 inq_count
, outq_count
,
10798 peer_uptime(peer
->uptime
,
10803 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
10805 peer
->as
, PEER_TOTAL_RX(peer
),
10806 PEER_TOTAL_TX(peer
),
10807 peer
->version
[afi
][safi
],
10808 inq_count
, outq_count
,
10809 peer_uptime(peer
->uptime
,
10814 if (peer_established(peer
)) {
10815 if (peer
->afc_recv
[afi
][safi
]) {
10818 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10819 && !bgp_inbound_policy_exists(
10821 vty_out(vty
, " %12s",
10830 vty_out(vty
, " NoNeg");
10833 if (paf
&& PAF_SUBGRP(paf
)) {
10836 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10837 && !bgp_outbound_policy_exists(
10839 vty_out(vty
, " %8s",
10848 vty_out(vty
, " NoNeg");
10851 if (CHECK_FLAG(peer
->flags
,
10852 PEER_FLAG_SHUTDOWN
)
10853 || CHECK_FLAG(peer
->bgp
->flags
,
10854 BGP_FLAG_SHUTDOWN
))
10855 vty_out(vty
, " Idle (Admin)");
10856 else if (CHECK_FLAG(
10858 PEER_STATUS_PREFIX_OVERFLOW
))
10859 vty_out(vty
, " Idle (PfxCt)");
10861 vty_out(vty
, " %12s",
10862 lookup_msg(bgp_status_msg
,
10863 peer
->status
, NULL
));
10865 vty_out(vty
, " %8u", 0);
10867 /* Make sure `Desc` column is the lastest in
10871 vty_out(vty
, " %s",
10872 bgp_peer_description_stripped(
10874 show_wide
? 64 : 20));
10876 vty_out(vty
, " N/A");
10877 vty_out(vty
, "\n");
10884 json_object_object_add(json
, "peers", json_peers
);
10885 json_object_int_add(json
, "failedPeers", failed_count
);
10886 json_object_int_add(json
, "displayedPeers",
10887 count
- filtered_count
);
10888 json_object_int_add(json
, "totalPeers", count
);
10889 json_object_int_add(json
, "dynamicPeers", dn_count
);
10892 bgp_show_bestpath_json(bgp
, json
);
10894 vty_json(vty
, json
);
10897 if (filtered_count
== count
)
10898 vty_out(vty
, "\n%% No matching neighbor\n");
10901 vty_out(vty
, "\nDisplayed neighbors %d",
10903 else if (as_type
!= AS_UNSPECIFIED
|| as
10904 || fpeer
|| show_established
)
10905 vty_out(vty
, "\nDisplayed neighbors %d",
10906 count
- filtered_count
);
10908 vty_out(vty
, "\nTotal number of neighbors %d\n",
10912 vty_out(vty
, "No %s neighbor is configured\n",
10913 get_afi_safi_str(afi
, safi
, false));
10917 vty_out(vty
, "* - dynamic neighbor\n");
10918 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
10919 dn_count
, bgp
->dynamic_neighbors_limit
);
10923 return CMD_SUCCESS
;
10926 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
10927 int safi
, struct peer
*fpeer
, int as_type
,
10928 as_t as
, uint16_t show_flags
)
10931 int afi_wildcard
= (afi
== AFI_MAX
);
10932 int safi_wildcard
= (safi
== SAFI_MAX
);
10933 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
10934 bool nbr_output
= false;
10935 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10937 if (use_json
&& is_wildcard
)
10938 vty_out(vty
, "{\n");
10940 afi
= 1; /* AFI_IP */
10941 while (afi
< AFI_MAX
) {
10943 safi
= 1; /* SAFI_UNICAST */
10944 while (safi
< SAFI_MAX
) {
10945 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
10950 * So limit output to those afi/safi
10952 * actualy have something interesting in
10957 vty_out(vty
, ",\n");
10961 vty_out(vty
, "\"%s\":",
10962 get_afi_safi_str(afi
,
10967 "\n%s Summary (%s):\n",
10968 get_afi_safi_str(afi
,
10974 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
10975 as_type
, as
, show_flags
);
10978 if (!safi_wildcard
)
10986 if (use_json
&& is_wildcard
)
10987 vty_out(vty
, "}\n");
10988 else if (!nbr_output
) {
10990 vty_out(vty
, "{}\n");
10992 vty_out(vty
, "%% No BGP neighbors found in %s\n",
10997 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
10999 const char *neighbor
,
11000 int as_type
, as_t as
,
11001 uint16_t show_flags
)
11003 struct listnode
*node
, *nnode
;
11005 struct peer
*fpeer
= NULL
;
11007 bool nbr_output
= false;
11008 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11011 vty_out(vty
, "{\n");
11013 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11017 vty_out(vty
, ",\n");
11021 vty_out(vty
, "\"%s\":",
11022 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11027 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11032 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11037 vty_out(vty
, "}\n");
11038 else if (!nbr_output
)
11039 vty_out(vty
, "%% BGP instance not found\n");
11042 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11043 safi_t safi
, const char *neighbor
, int as_type
,
11044 as_t as
, uint16_t show_flags
)
11047 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11048 struct peer
*fpeer
= NULL
;
11051 if (strmatch(name
, "all")) {
11052 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11055 return CMD_SUCCESS
;
11057 bgp
= bgp_lookup_by_name(name
);
11061 vty_out(vty
, "{}\n");
11064 "%% BGP instance not found\n");
11065 return CMD_WARNING
;
11069 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11072 return CMD_WARNING
;
11074 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11075 as_type
, as
, show_flags
);
11076 return CMD_SUCCESS
;
11080 bgp
= bgp_get_default();
11084 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11087 return CMD_WARNING
;
11089 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11093 vty_out(vty
, "{}\n");
11095 vty_out(vty
, "%% BGP instance not found\n");
11096 return CMD_WARNING
;
11099 return CMD_SUCCESS
;
11102 /* `show [ip] bgp summary' commands. */
11103 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11104 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11105 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11106 "]] [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]",
11107 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11108 BGP_SAFI_WITH_LABEL_HELP_STR
11109 "Display the entries for all address families\n"
11110 "Summary of BGP neighbor status\n"
11111 "Show only sessions in Established state\n"
11112 "Show only sessions not in Established state\n"
11113 "Show only the specified neighbor session\n"
11114 "Neighbor to display information about\n"
11115 "Neighbor to display information about\n"
11116 "Neighbor on BGP configured interface\n"
11117 "Show only the specified remote AS sessions\n"
11119 "Internal (iBGP) AS sessions\n"
11120 "External (eBGP) AS sessions\n"
11121 "Shorten the information on BGP instances\n"
11122 "Increase table width for longer output\n" JSON_STR
)
11125 afi_t afi
= AFI_MAX
;
11126 safi_t safi
= SAFI_MAX
;
11127 as_t as
= 0; /* 0 means AS filter not set */
11128 int as_type
= AS_UNSPECIFIED
;
11129 uint16_t show_flags
= 0;
11133 /* show [ip] bgp */
11134 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11136 /* [<vrf> VIEWVRFNAME] */
11137 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11138 vrf
= argv
[idx
+ 1]->arg
;
11139 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11141 } else if (argv_find(argv
, argc
, "view", &idx
))
11142 /* [<view> VIEWVRFNAME] */
11143 vrf
= argv
[idx
+ 1]->arg
;
11144 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11145 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11146 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11149 if (argv_find(argv
, argc
, "failed", &idx
))
11150 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11152 if (argv_find(argv
, argc
, "established", &idx
))
11153 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11155 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11156 if (argv
[idx
+ 1]->arg
[0] == 'i')
11157 as_type
= AS_INTERNAL
;
11158 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11159 as_type
= AS_EXTERNAL
;
11161 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11164 if (argv_find(argv
, argc
, "terse", &idx
))
11165 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11167 if (argv_find(argv
, argc
, "wide", &idx
))
11168 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11170 if (argv_find(argv
, argc
, "json", &idx
))
11171 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11173 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11177 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11180 return get_afi_safi_json_str(afi
, safi
);
11182 return get_afi_safi_vty_str(afi
, safi
);
11186 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11187 afi_t afi
, safi_t safi
,
11188 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11189 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11190 bool use_json
, json_object
*json_pref
)
11193 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11194 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11196 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11197 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11198 json_object_string_add(json_pref
, "sendMode",
11199 "advertisedAndReceived");
11200 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11201 json_object_string_add(json_pref
, "sendMode",
11203 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11204 json_object_string_add(json_pref
, "sendMode",
11207 vty_out(vty
, " Send-mode: ");
11208 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11209 vty_out(vty
, "advertised");
11210 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11211 vty_out(vty
, "%sreceived",
11212 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11216 vty_out(vty
, "\n");
11221 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11222 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11224 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11225 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11226 json_object_string_add(json_pref
, "recvMode",
11227 "advertisedAndReceived");
11228 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11229 json_object_string_add(json_pref
, "recvMode",
11231 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11232 json_object_string_add(json_pref
, "recvMode",
11235 vty_out(vty
, " Receive-mode: ");
11236 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11237 vty_out(vty
, "advertised");
11238 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11239 vty_out(vty
, "%sreceived",
11240 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11244 vty_out(vty
, "\n");
11249 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11254 bool rbit_status
= false;
11257 vty_out(vty
, "\n R bit: ");
11259 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11260 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11261 && (peer_established(p
))) {
11263 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11264 rbit_status
= true;
11266 rbit_status
= false;
11271 json_object_boolean_true_add(json
, "rBit");
11273 vty_out(vty
, "True\n");
11276 json_object_boolean_false_add(json
, "rBit");
11278 vty_out(vty
, "False\n");
11282 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11287 const char *mode
= "NotApplicable";
11290 vty_out(vty
, "\n Remote GR Mode: ");
11292 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11293 && (peer_established(peer
))) {
11295 if ((peer
->nsf_af_count
== 0)
11296 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11300 } else if (peer
->nsf_af_count
== 0
11301 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11305 } else if (peer
->nsf_af_count
!= 0
11306 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11313 json_object_string_add(json
, "remoteGrMode", mode
);
11315 vty_out(vty
, mode
, "\n");
11318 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11323 const char *mode
= "Invalid";
11326 vty_out(vty
, " Local GR Mode: ");
11328 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11330 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11332 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11334 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11335 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11337 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11339 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11346 json_object_string_add(json
, "localGrMode", mode
);
11348 vty_out(vty
, mode
, "\n");
11352 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11353 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11357 json_object
*json_afi_safi
= NULL
;
11358 json_object
*json_timer
= NULL
;
11359 json_object
*json_endofrib_status
= NULL
;
11360 bool eor_flag
= false;
11362 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11363 if (!peer
->afc
[afi
][safi
])
11366 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11367 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11371 json_afi_safi
= json_object_new_object();
11372 json_endofrib_status
= json_object_new_object();
11373 json_timer
= json_object_new_object();
11376 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11382 vty_out(vty
, " %s:\n",
11383 get_afi_safi_str(afi
, safi
, false));
11385 vty_out(vty
, " F bit: ");
11388 if (peer
->nsf
[afi
][safi
] &&
11389 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11390 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11393 json_object_boolean_true_add(json_afi_safi
,
11396 vty_out(vty
, "True\n");
11399 json_object_boolean_false_add(json_afi_safi
,
11402 vty_out(vty
, "False\n");
11406 vty_out(vty
, " End-of-RIB sent: ");
11408 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11409 PEER_STATUS_EOR_SEND
)) {
11411 json_object_boolean_true_add(
11412 json_endofrib_status
, "endOfRibSend");
11414 PRINT_EOR_JSON(eor_flag
);
11416 vty_out(vty
, "Yes\n");
11418 " End-of-RIB sent after update: ");
11420 PRINT_EOR(eor_flag
);
11424 json_object_boolean_false_add(
11425 json_endofrib_status
, "endOfRibSend");
11426 json_object_boolean_false_add(
11427 json_endofrib_status
,
11428 "endOfRibSentAfterUpdate");
11430 vty_out(vty
, "No\n");
11432 " End-of-RIB sent after update: ");
11433 vty_out(vty
, "No\n");
11438 vty_out(vty
, " End-of-RIB received: ");
11440 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11441 PEER_STATUS_EOR_RECEIVED
)) {
11443 json_object_boolean_true_add(
11444 json_endofrib_status
, "endOfRibRecv");
11446 vty_out(vty
, "Yes\n");
11449 json_object_boolean_false_add(
11450 json_endofrib_status
, "endOfRibRecv");
11452 vty_out(vty
, "No\n");
11456 json_object_int_add(json_timer
, "stalePathTimer",
11457 peer
->bgp
->stalepath_time
);
11459 if (peer
->t_gr_stale
!= NULL
) {
11460 json_object_int_add(json_timer
,
11461 "stalePathTimerRemaining",
11462 thread_timer_remain_second(
11463 peer
->t_gr_stale
));
11466 /* Display Configured Selection
11467 * Deferral only when when
11468 * Gr mode is enabled.
11470 if (CHECK_FLAG(peer
->flags
,
11471 PEER_FLAG_GRACEFUL_RESTART
)) {
11472 json_object_int_add(json_timer
,
11473 "selectionDeferralTimer",
11474 peer
->bgp
->stalepath_time
);
11477 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11480 json_object_int_add(
11482 "selectionDeferralTimerRemaining",
11483 thread_timer_remain_second(
11484 peer
->bgp
->gr_info
[afi
][safi
]
11485 .t_select_deferral
));
11488 vty_out(vty
, " Timers:\n");
11490 " Configured Stale Path Time(sec): %u\n",
11491 peer
->bgp
->stalepath_time
);
11493 if (peer
->t_gr_stale
!= NULL
)
11495 " Stale Path Remaining(sec): %ld\n",
11496 thread_timer_remain_second(
11497 peer
->t_gr_stale
));
11498 /* Display Configured Selection
11499 * Deferral only when when
11500 * Gr mode is enabled.
11502 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11504 " Configured Selection Deferral Time(sec): %u\n",
11505 peer
->bgp
->select_defer_time
);
11507 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11510 " Selection Deferral Time Remaining(sec): %ld\n",
11511 thread_timer_remain_second(
11512 peer
->bgp
->gr_info
[afi
][safi
]
11513 .t_select_deferral
));
11516 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11517 json_endofrib_status
);
11518 json_object_object_add(json_afi_safi
, "timers",
11520 json_object_object_add(
11521 json
, get_afi_safi_str(afi
, safi
, true),
11527 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11533 json_object
*json_timer
= NULL
;
11535 json_timer
= json_object_new_object();
11537 json_object_int_add(json_timer
, "configuredRestartTimer",
11538 p
->bgp
->restart_time
);
11540 json_object_int_add(json_timer
, "receivedRestartTimer",
11543 if (p
->t_gr_restart
!= NULL
)
11544 json_object_int_add(
11545 json_timer
, "restartTimerRemaining",
11546 thread_timer_remain_second(p
->t_gr_restart
));
11548 json_object_object_add(json
, "timers", json_timer
);
11551 vty_out(vty
, " Timers:\n");
11552 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11553 p
->bgp
->restart_time
);
11555 vty_out(vty
, " Received Restart Time(sec): %u\n",
11557 if (p
->t_gr_restart
!= NULL
)
11558 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11559 thread_timer_remain_second(p
->t_gr_restart
));
11560 if (p
->t_gr_restart
!= NULL
) {
11561 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11562 thread_timer_remain_second(p
->t_gr_restart
));
11567 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11568 bool use_json
, json_object
*json
)
11570 char buf
[SU_ADDRSTRLEN
] = {0};
11571 char dn_flag
[2] = {0};
11572 /* '*' + v6 address of neighbor */
11573 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11575 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11580 json_object_string_add(
11581 json
, "neighborAddr",
11582 BGP_PEER_SU_UNSPEC(p
)
11584 : sockunion2str(&p
->su
, buf
,
11587 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11588 BGP_PEER_SU_UNSPEC(p
)
11590 : sockunion2str(&p
->su
, buf
,
11593 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11597 json_object_string_add(json
, "neighborAddr",
11600 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11603 /* more gr info in new format */
11604 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11607 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11608 safi_t safi
, bool use_json
,
11609 json_object
*json_neigh
)
11611 struct bgp_filter
*filter
;
11612 struct peer_af
*paf
;
11613 char orf_pfx_name
[BUFSIZ
];
11615 json_object
*json_af
= NULL
;
11616 json_object
*json_prefA
= NULL
;
11617 json_object
*json_prefB
= NULL
;
11618 json_object
*json_addr
= NULL
;
11619 json_object
*json_advmap
= NULL
;
11622 json_addr
= json_object_new_object();
11623 json_af
= json_object_new_object();
11624 filter
= &p
->filter
[afi
][safi
];
11626 if (peer_group_active(p
))
11627 json_object_string_add(json_addr
, "peerGroupMember",
11630 paf
= peer_af_find(p
, afi
, safi
);
11631 if (paf
&& PAF_SUBGRP(paf
)) {
11632 json_object_int_add(json_addr
, "updateGroupId",
11633 PAF_UPDGRP(paf
)->id
);
11634 json_object_int_add(json_addr
, "subGroupId",
11635 PAF_SUBGRP(paf
)->id
);
11636 json_object_int_add(json_addr
, "packetQueueLength",
11637 bpacket_queue_virtual_length(paf
));
11640 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11641 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11642 PEER_CAP_ORF_PREFIX_SM_RCV
)
11643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11644 PEER_CAP_ORF_PREFIX_RM_ADV
)
11645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11646 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11647 json_object_int_add(json_af
, "orfType",
11649 json_prefA
= json_object_new_object();
11650 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11651 PEER_CAP_ORF_PREFIX_SM_ADV
,
11652 PEER_CAP_ORF_PREFIX_RM_ADV
,
11653 PEER_CAP_ORF_PREFIX_SM_RCV
,
11654 PEER_CAP_ORF_PREFIX_RM_RCV
,
11655 use_json
, json_prefA
);
11656 json_object_object_add(json_af
, "orfPrefixList",
11660 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11661 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11662 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11664 PEER_CAP_ORF_PREFIX_RM_ADV
)
11665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11666 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11667 json_object_int_add(json_af
, "orfOldType",
11668 ORF_TYPE_PREFIX_OLD
);
11669 json_prefB
= json_object_new_object();
11670 bgp_show_peer_afi_orf_cap(
11671 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11672 PEER_CAP_ORF_PREFIX_RM_ADV
,
11673 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11674 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11676 json_object_object_add(json_af
, "orfOldPrefixList",
11680 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11681 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11682 PEER_CAP_ORF_PREFIX_SM_RCV
)
11683 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11684 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11686 PEER_CAP_ORF_PREFIX_RM_ADV
)
11687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11688 PEER_CAP_ORF_PREFIX_RM_RCV
)
11689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11690 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11691 json_object_object_add(json_addr
, "afDependentCap",
11694 json_object_free(json_af
);
11696 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11697 p
->host
, afi
, safi
);
11698 orf_pfx_count
= prefix_bgp_show_prefix_list(
11699 NULL
, afi
, orf_pfx_name
, use_json
);
11701 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11702 PEER_STATUS_ORF_PREFIX_SEND
)
11703 || orf_pfx_count
) {
11704 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11705 PEER_STATUS_ORF_PREFIX_SEND
))
11706 json_object_boolean_true_add(json_neigh
,
11709 json_object_int_add(json_addr
, "orfRecvCounter",
11712 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11713 PEER_STATUS_ORF_WAIT_REFRESH
))
11714 json_object_string_add(
11715 json_addr
, "orfFirstUpdate",
11716 "deferredUntilORFOrRouteRefreshRecvd");
11718 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11719 PEER_FLAG_REFLECTOR_CLIENT
))
11720 json_object_boolean_true_add(json_addr
,
11721 "routeReflectorClient");
11722 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11723 PEER_FLAG_RSERVER_CLIENT
))
11724 json_object_boolean_true_add(json_addr
,
11725 "routeServerClient");
11726 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11727 json_object_boolean_true_add(json_addr
,
11728 "inboundSoftConfigPermit");
11730 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11731 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11732 json_object_boolean_true_add(
11734 "privateAsNumsAllReplacedInUpdatesToNbr");
11735 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11736 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11737 json_object_boolean_true_add(
11739 "privateAsNumsReplacedInUpdatesToNbr");
11740 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11741 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11742 json_object_boolean_true_add(
11744 "privateAsNumsAllRemovedInUpdatesToNbr");
11745 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11746 PEER_FLAG_REMOVE_PRIVATE_AS
))
11747 json_object_boolean_true_add(
11749 "privateAsNumsRemovedInUpdatesToNbr");
11751 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11752 json_object_boolean_true_add(
11754 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11757 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11758 json_object_string_add(json_addr
,
11759 "overrideASNsInOutboundUpdates",
11760 "ifAspathEqualRemoteAs");
11762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11763 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11764 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11765 json_object_boolean_true_add(json_addr
,
11766 "routerAlwaysNextHop");
11767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11768 PEER_FLAG_AS_PATH_UNCHANGED
))
11769 json_object_boolean_true_add(
11770 json_addr
, "unchangedAsPathPropogatedToNbr");
11771 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11772 PEER_FLAG_NEXTHOP_UNCHANGED
))
11773 json_object_boolean_true_add(
11774 json_addr
, "unchangedNextHopPropogatedToNbr");
11775 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11776 json_object_boolean_true_add(
11777 json_addr
, "unchangedMedPropogatedToNbr");
11778 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11779 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11780 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11781 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11782 PEER_FLAG_SEND_COMMUNITY
)
11783 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11784 PEER_FLAG_SEND_EXT_COMMUNITY
))
11785 json_object_string_add(json_addr
,
11786 "commAttriSentToNbr",
11787 "extendedAndStandard");
11788 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11789 PEER_FLAG_SEND_EXT_COMMUNITY
))
11790 json_object_string_add(json_addr
,
11791 "commAttriSentToNbr",
11794 json_object_string_add(json_addr
,
11795 "commAttriSentToNbr",
11798 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11799 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11800 if (p
->default_rmap
[afi
][safi
].name
)
11801 json_object_string_add(
11802 json_addr
, "defaultRouteMap",
11803 p
->default_rmap
[afi
][safi
].name
);
11805 if (paf
&& PAF_SUBGRP(paf
)
11806 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11807 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11808 json_object_boolean_true_add(json_addr
,
11811 json_object_boolean_true_add(json_addr
,
11815 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11816 if (is_evpn_enabled())
11817 json_object_boolean_true_add(
11818 json_addr
, "advertiseAllVnis");
11821 if (filter
->plist
[FILTER_IN
].name
11822 || filter
->dlist
[FILTER_IN
].name
11823 || filter
->aslist
[FILTER_IN
].name
11824 || filter
->map
[RMAP_IN
].name
)
11825 json_object_boolean_true_add(json_addr
,
11826 "inboundPathPolicyConfig");
11827 if (filter
->plist
[FILTER_OUT
].name
11828 || filter
->dlist
[FILTER_OUT
].name
11829 || filter
->aslist
[FILTER_OUT
].name
11830 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11831 json_object_boolean_true_add(
11832 json_addr
, "outboundPathPolicyConfig");
11835 if (filter
->plist
[FILTER_IN
].name
)
11836 json_object_string_add(json_addr
,
11837 "incomingUpdatePrefixFilterList",
11838 filter
->plist
[FILTER_IN
].name
);
11839 if (filter
->plist
[FILTER_OUT
].name
)
11840 json_object_string_add(json_addr
,
11841 "outgoingUpdatePrefixFilterList",
11842 filter
->plist
[FILTER_OUT
].name
);
11844 /* distribute-list */
11845 if (filter
->dlist
[FILTER_IN
].name
)
11846 json_object_string_add(
11847 json_addr
, "incomingUpdateNetworkFilterList",
11848 filter
->dlist
[FILTER_IN
].name
);
11849 if (filter
->dlist
[FILTER_OUT
].name
)
11850 json_object_string_add(
11851 json_addr
, "outgoingUpdateNetworkFilterList",
11852 filter
->dlist
[FILTER_OUT
].name
);
11855 if (filter
->aslist
[FILTER_IN
].name
)
11856 json_object_string_add(json_addr
,
11857 "incomingUpdateAsPathFilterList",
11858 filter
->aslist
[FILTER_IN
].name
);
11859 if (filter
->aslist
[FILTER_OUT
].name
)
11860 json_object_string_add(json_addr
,
11861 "outgoingUpdateAsPathFilterList",
11862 filter
->aslist
[FILTER_OUT
].name
);
11865 if (filter
->map
[RMAP_IN
].name
)
11866 json_object_string_add(
11867 json_addr
, "routeMapForIncomingAdvertisements",
11868 filter
->map
[RMAP_IN
].name
);
11869 if (filter
->map
[RMAP_OUT
].name
)
11870 json_object_string_add(
11871 json_addr
, "routeMapForOutgoingAdvertisements",
11872 filter
->map
[RMAP_OUT
].name
);
11874 /* ebgp-requires-policy (inbound) */
11875 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11876 && !bgp_inbound_policy_exists(p
, filter
))
11877 json_object_string_add(
11878 json_addr
, "inboundEbgpRequiresPolicy",
11879 "Inbound updates discarded due to missing policy");
11881 /* ebgp-requires-policy (outbound) */
11882 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11883 && (!bgp_outbound_policy_exists(p
, filter
)))
11884 json_object_string_add(
11885 json_addr
, "outboundEbgpRequiresPolicy",
11886 "Outbound updates discarded due to missing policy");
11888 /* unsuppress-map */
11889 if (filter
->usmap
.name
)
11890 json_object_string_add(json_addr
,
11891 "selectiveUnsuppressRouteMap",
11892 filter
->usmap
.name
);
11894 /* advertise-map */
11895 if (filter
->advmap
.aname
) {
11896 json_advmap
= json_object_new_object();
11897 json_object_string_add(json_advmap
, "condition",
11898 filter
->advmap
.condition
11901 json_object_string_add(json_advmap
, "conditionMap",
11902 filter
->advmap
.cname
);
11903 json_object_string_add(json_advmap
, "advertiseMap",
11904 filter
->advmap
.aname
);
11905 json_object_string_add(json_advmap
, "advertiseStatus",
11906 filter
->advmap
.update_type
11910 json_object_object_add(json_addr
, "advertiseMap",
11914 /* Receive prefix count */
11915 json_object_int_add(json_addr
, "acceptedPrefixCounter",
11916 p
->pcount
[afi
][safi
]);
11917 if (paf
&& PAF_SUBGRP(paf
))
11918 json_object_int_add(json_addr
, "sentPrefixCounter",
11919 (PAF_SUBGRP(paf
))->scount
);
11921 /* Maximum prefix */
11922 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
11923 json_object_int_add(json_addr
, "prefixOutAllowedMax",
11924 p
->pmax_out
[afi
][safi
]);
11926 /* Maximum prefix */
11927 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11928 json_object_int_add(json_addr
, "prefixAllowedMax",
11929 p
->pmax
[afi
][safi
]);
11930 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11931 PEER_FLAG_MAX_PREFIX_WARNING
))
11932 json_object_boolean_true_add(
11933 json_addr
, "prefixAllowedMaxWarning");
11934 json_object_int_add(json_addr
,
11935 "prefixAllowedWarningThresh",
11936 p
->pmax_threshold
[afi
][safi
]);
11937 if (p
->pmax_restart
[afi
][safi
])
11938 json_object_int_add(
11940 "prefixAllowedRestartIntervalMsecs",
11941 p
->pmax_restart
[afi
][safi
] * 60000);
11943 json_object_object_add(json_neigh
,
11944 get_afi_safi_str(afi
, safi
, true),
11948 filter
= &p
->filter
[afi
][safi
];
11950 vty_out(vty
, " For address family: %s\n",
11951 get_afi_safi_str(afi
, safi
, false));
11953 if (peer_group_active(p
))
11954 vty_out(vty
, " %s peer-group member\n",
11957 paf
= peer_af_find(p
, afi
, safi
);
11958 if (paf
&& PAF_SUBGRP(paf
)) {
11959 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
11960 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
11961 vty_out(vty
, " Packet Queue length %d\n",
11962 bpacket_queue_virtual_length(paf
));
11964 vty_out(vty
, " Not part of any update group\n");
11966 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11967 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11968 PEER_CAP_ORF_PREFIX_SM_RCV
)
11969 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11970 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11971 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11972 PEER_CAP_ORF_PREFIX_RM_ADV
)
11973 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11974 PEER_CAP_ORF_PREFIX_RM_RCV
)
11975 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11976 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11977 vty_out(vty
, " AF-dependant capabilities:\n");
11979 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11980 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11981 PEER_CAP_ORF_PREFIX_SM_RCV
)
11982 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11983 PEER_CAP_ORF_PREFIX_RM_ADV
)
11984 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11985 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11987 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11989 bgp_show_peer_afi_orf_cap(
11990 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11991 PEER_CAP_ORF_PREFIX_RM_ADV
,
11992 PEER_CAP_ORF_PREFIX_SM_RCV
,
11993 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
11995 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11996 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11997 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11998 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11999 PEER_CAP_ORF_PREFIX_RM_ADV
)
12000 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12001 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12003 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12004 ORF_TYPE_PREFIX_OLD
);
12005 bgp_show_peer_afi_orf_cap(
12006 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12007 PEER_CAP_ORF_PREFIX_RM_ADV
,
12008 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12009 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12012 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12013 p
->host
, afi
, safi
);
12014 orf_pfx_count
= prefix_bgp_show_prefix_list(
12015 NULL
, afi
, orf_pfx_name
, use_json
);
12017 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12018 PEER_STATUS_ORF_PREFIX_SEND
)
12019 || orf_pfx_count
) {
12020 vty_out(vty
, " Outbound Route Filter (ORF):");
12021 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12022 PEER_STATUS_ORF_PREFIX_SEND
))
12023 vty_out(vty
, " sent;");
12025 vty_out(vty
, " received (%d entries)",
12027 vty_out(vty
, "\n");
12029 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12030 PEER_STATUS_ORF_WAIT_REFRESH
))
12032 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12034 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12035 PEER_FLAG_REFLECTOR_CLIENT
))
12036 vty_out(vty
, " Route-Reflector Client\n");
12037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12038 PEER_FLAG_RSERVER_CLIENT
))
12039 vty_out(vty
, " Route-Server Client\n");
12040 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12042 " Inbound soft reconfiguration allowed\n");
12044 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12045 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12047 " Private AS numbers (all) replaced in updates to this neighbor\n");
12048 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12049 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12051 " Private AS numbers replaced in updates to this neighbor\n");
12052 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12053 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12055 " Private AS numbers (all) removed in updates to this neighbor\n");
12056 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12057 PEER_FLAG_REMOVE_PRIVATE_AS
))
12059 " Private AS numbers removed in updates to this neighbor\n");
12061 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12062 vty_out(vty
, " %s\n",
12063 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12064 ->human_description
);
12066 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12068 " Override ASNs in outbound updates if aspath equals remote-as\n");
12070 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12071 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12072 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12073 vty_out(vty
, " NEXT_HOP is always this router\n");
12074 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12075 PEER_FLAG_AS_PATH_UNCHANGED
))
12077 " AS_PATH is propagated unchanged to this neighbor\n");
12078 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12079 PEER_FLAG_NEXTHOP_UNCHANGED
))
12081 " NEXT_HOP is propagated unchanged to this neighbor\n");
12082 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12084 " MED is propagated unchanged to this neighbor\n");
12085 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12086 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12087 PEER_FLAG_SEND_EXT_COMMUNITY
)
12088 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12089 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12091 " Community attribute sent to this neighbor");
12092 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12093 PEER_FLAG_SEND_COMMUNITY
)
12094 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12095 PEER_FLAG_SEND_EXT_COMMUNITY
)
12096 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12097 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12098 vty_out(vty
, "(all)\n");
12099 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12100 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12101 vty_out(vty
, "(large)\n");
12102 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12103 PEER_FLAG_SEND_EXT_COMMUNITY
))
12104 vty_out(vty
, "(extended)\n");
12106 vty_out(vty
, "(standard)\n");
12108 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12109 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12110 vty_out(vty
, " Default information originate,");
12112 if (p
->default_rmap
[afi
][safi
].name
)
12113 vty_out(vty
, " default route-map %s%s,",
12114 p
->default_rmap
[afi
][safi
].map
? "*"
12116 p
->default_rmap
[afi
][safi
].name
);
12117 if (paf
&& PAF_SUBGRP(paf
)
12118 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12119 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12120 vty_out(vty
, " default sent\n");
12122 vty_out(vty
, " default not sent\n");
12125 /* advertise-vni-all */
12126 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12127 if (is_evpn_enabled())
12128 vty_out(vty
, " advertise-all-vni\n");
12131 if (filter
->plist
[FILTER_IN
].name
12132 || filter
->dlist
[FILTER_IN
].name
12133 || filter
->aslist
[FILTER_IN
].name
12134 || filter
->map
[RMAP_IN
].name
)
12135 vty_out(vty
, " Inbound path policy configured\n");
12136 if (filter
->plist
[FILTER_OUT
].name
12137 || filter
->dlist
[FILTER_OUT
].name
12138 || filter
->aslist
[FILTER_OUT
].name
12139 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12140 vty_out(vty
, " Outbound path policy configured\n");
12143 if (filter
->plist
[FILTER_IN
].name
)
12145 " Incoming update prefix filter list is %s%s\n",
12146 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12147 filter
->plist
[FILTER_IN
].name
);
12148 if (filter
->plist
[FILTER_OUT
].name
)
12150 " Outgoing update prefix filter list is %s%s\n",
12151 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12152 filter
->plist
[FILTER_OUT
].name
);
12154 /* distribute-list */
12155 if (filter
->dlist
[FILTER_IN
].name
)
12157 " Incoming update network filter list is %s%s\n",
12158 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12159 filter
->dlist
[FILTER_IN
].name
);
12160 if (filter
->dlist
[FILTER_OUT
].name
)
12162 " Outgoing update network filter list is %s%s\n",
12163 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12164 filter
->dlist
[FILTER_OUT
].name
);
12167 if (filter
->aslist
[FILTER_IN
].name
)
12169 " Incoming update AS path filter list is %s%s\n",
12170 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12171 filter
->aslist
[FILTER_IN
].name
);
12172 if (filter
->aslist
[FILTER_OUT
].name
)
12174 " Outgoing update AS path filter list is %s%s\n",
12175 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12176 filter
->aslist
[FILTER_OUT
].name
);
12179 if (filter
->map
[RMAP_IN
].name
)
12181 " Route map for incoming advertisements is %s%s\n",
12182 filter
->map
[RMAP_IN
].map
? "*" : "",
12183 filter
->map
[RMAP_IN
].name
);
12184 if (filter
->map
[RMAP_OUT
].name
)
12186 " Route map for outgoing advertisements is %s%s\n",
12187 filter
->map
[RMAP_OUT
].map
? "*" : "",
12188 filter
->map
[RMAP_OUT
].name
);
12190 /* ebgp-requires-policy (inbound) */
12191 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12192 && !bgp_inbound_policy_exists(p
, filter
))
12194 " Inbound updates discarded due to missing policy\n");
12196 /* ebgp-requires-policy (outbound) */
12197 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12198 && !bgp_outbound_policy_exists(p
, filter
))
12200 " Outbound updates discarded due to missing policy\n");
12202 /* unsuppress-map */
12203 if (filter
->usmap
.name
)
12205 " Route map for selective unsuppress is %s%s\n",
12206 filter
->usmap
.map
? "*" : "",
12207 filter
->usmap
.name
);
12209 /* advertise-map */
12210 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12212 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12213 filter
->advmap
.condition
? "EXIST"
12215 filter
->advmap
.cmap
? "*" : "",
12216 filter
->advmap
.cname
,
12217 filter
->advmap
.amap
? "*" : "",
12218 filter
->advmap
.aname
,
12219 filter
->advmap
.update_type
== ADVERTISE
12223 /* Receive prefix count */
12224 vty_out(vty
, " %u accepted prefixes\n",
12225 p
->pcount
[afi
][safi
]);
12227 /* maximum-prefix-out */
12228 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12229 PEER_FLAG_MAX_PREFIX_OUT
))
12231 " Maximum allowed prefixes sent %u\n",
12232 p
->pmax_out
[afi
][safi
]);
12234 /* Maximum prefix */
12235 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12237 " Maximum prefixes allowed %u%s\n",
12238 p
->pmax
[afi
][safi
],
12239 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12240 PEER_FLAG_MAX_PREFIX_WARNING
)
12241 ? " (warning-only)"
12243 vty_out(vty
, " Threshold for warning message %d%%",
12244 p
->pmax_threshold
[afi
][safi
]);
12245 if (p
->pmax_restart
[afi
][safi
])
12246 vty_out(vty
, ", restart interval %d min",
12247 p
->pmax_restart
[afi
][safi
]);
12248 vty_out(vty
, "\n");
12251 vty_out(vty
, "\n");
12255 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12259 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12260 char timebuf
[BGP_UPTIME_LEN
];
12266 json_object
*json_neigh
= NULL
;
12268 uint32_t sync_tcp_mss
;
12273 json_neigh
= json_object_new_object();
12275 memset(dn_flag
, '\0', sizeof(dn_flag
));
12276 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12280 if (p
->conf_if
) /* Configured interface name. */
12281 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12282 BGP_PEER_SU_UNSPEC(p
)
12284 : sockunion2str(&p
->su
, buf
,
12286 else /* Configured IP address. */
12287 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12292 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12293 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12295 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12296 json_object_string_add(
12297 json_neigh
, "bgpNeighborAddr",
12298 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12300 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12302 if (p
->change_local_as
)
12303 json_object_int_add(json_neigh
, "localAs",
12304 p
->change_local_as
);
12306 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12308 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12309 json_object_boolean_true_add(json_neigh
,
12310 "localAsNoPrepend");
12312 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12313 json_object_boolean_true_add(json_neigh
,
12314 "localAsReplaceAs");
12316 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12317 || (p
->as_type
== AS_INTERNAL
))
12318 vty_out(vty
, "remote AS %u, ", p
->as
);
12320 vty_out(vty
, "remote AS Unspecified, ");
12321 vty_out(vty
, "local AS %u%s%s, ",
12322 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12323 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12326 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12330 /* peer type internal or confed-internal */
12331 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12333 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12334 json_object_boolean_true_add(
12335 json_neigh
, "nbrConfedInternalLink");
12337 json_object_boolean_true_add(json_neigh
,
12338 "nbrInternalLink");
12340 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12341 vty_out(vty
, "confed-internal link\n");
12343 vty_out(vty
, "internal link\n");
12345 /* peer type external or confed-external */
12346 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12348 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12349 json_object_boolean_true_add(
12350 json_neigh
, "nbrConfedExternalLink");
12352 json_object_boolean_true_add(json_neigh
,
12353 "nbrExternalLink");
12355 if (bgp_confederation_peers_check(bgp
, p
->as
))
12356 vty_out(vty
, "confed-external link\n");
12358 vty_out(vty
, "external link\n");
12362 json_object_boolean_true_add(json_neigh
,
12363 "nbrUnspecifiedLink");
12365 vty_out(vty
, "unspecified link\n");
12371 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12373 vty_out(vty
, " Description: %s\n", p
->desc
);
12379 json_object_string_add(json_neigh
, "hostname",
12383 json_object_string_add(json_neigh
, "domainname",
12386 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12387 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12390 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12397 json_object_string_add(json_neigh
, "peerGroup",
12401 struct prefix prefix
, *range
= NULL
;
12403 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12404 range
= peer_group_lookup_dynamic_neighbor_range(
12405 p
->group
, &prefix
);
12408 json_object_string_addf(
12410 "peerSubnetRangeGroup", "%pFX",
12416 " Member of peer-group %s for session parameters\n",
12420 struct prefix prefix
, *range
= NULL
;
12422 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12423 range
= peer_group_lookup_dynamic_neighbor_range(
12424 p
->group
, &prefix
);
12428 " Belongs to the subnet range group: %pFX\n",
12436 /* Administrative shutdown. */
12437 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12438 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12439 json_object_boolean_true_add(json_neigh
,
12443 json_object_int_add(json_neigh
, "bgpVersion", 4);
12444 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12446 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12449 /* Confederation */
12450 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12451 && bgp_confederation_peers_check(bgp
, p
->as
))
12452 json_object_boolean_true_add(json_neigh
,
12456 json_object_string_add(
12457 json_neigh
, "bgpState",
12458 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12460 if (peer_established(p
)) {
12463 uptime
= bgp_clock();
12464 uptime
-= p
->uptime
;
12465 epoch_tbuf
= time(NULL
) - uptime
;
12467 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12469 json_object_string_add(json_neigh
, "bgpTimerUpString",
12470 peer_uptime(p
->uptime
, timebuf
,
12473 json_object_int_add(json_neigh
,
12474 "bgpTimerUpEstablishedEpoch",
12478 else if (p
->status
== Active
) {
12479 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12480 json_object_string_add(json_neigh
, "bgpStateIs",
12482 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12483 json_object_string_add(json_neigh
, "bgpStateIs",
12491 uptime
= bgp_clock();
12492 uptime
-= p
->readtime
;
12493 gmtime_r(&uptime
, &tm
);
12495 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12496 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12497 + (tm
.tm_hour
* 3600000));
12499 uptime
= bgp_clock();
12500 uptime
-= p
->last_write
;
12501 gmtime_r(&uptime
, &tm
);
12503 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12504 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12505 + (tm
.tm_hour
* 3600000));
12507 uptime
= bgp_clock();
12508 uptime
-= p
->update_time
;
12509 gmtime_r(&uptime
, &tm
);
12511 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12512 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12513 + (tm
.tm_hour
* 3600000));
12515 /* Configured timer values. */
12516 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12517 p
->v_holdtime
* 1000);
12518 json_object_int_add(json_neigh
,
12519 "bgpTimerKeepAliveIntervalMsecs",
12520 p
->v_keepalive
* 1000);
12521 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12522 json_object_int_add(json_neigh
,
12523 "bgpTimerDelayOpenTimeMsecs",
12524 p
->v_delayopen
* 1000);
12527 /* Configured and Synced tcp-mss value for peer */
12528 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12529 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12530 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12532 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12536 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12537 json_object_int_add(json_neigh
,
12538 "bgpTimerConfiguredHoldTimeMsecs",
12539 p
->holdtime
* 1000);
12540 json_object_int_add(
12542 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12543 p
->keepalive
* 1000);
12544 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12545 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12546 json_object_int_add(json_neigh
,
12547 "bgpTimerConfiguredHoldTimeMsecs",
12548 bgp
->default_holdtime
);
12549 json_object_int_add(
12551 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12552 bgp
->default_keepalive
);
12555 /* Extended Optional Parameters Length for BGP OPEN Message */
12556 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12557 json_object_boolean_true_add(
12558 json_neigh
, "extendedOptionalParametersLength");
12560 json_object_boolean_false_add(
12561 json_neigh
, "extendedOptionalParametersLength");
12563 /* Conditional advertisements */
12564 json_object_int_add(
12566 "bgpTimerConfiguredConditionalAdvertisementsSec",
12567 bgp
->condition_check_period
);
12568 if (thread_is_scheduled(bgp
->t_condition_check
))
12569 json_object_int_add(
12571 "bgpTimerUntilConditionalAdvertisementsSec",
12572 thread_timer_remain_second(
12573 bgp
->t_condition_check
));
12575 /* Administrative shutdown. */
12576 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12577 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12578 vty_out(vty
, " Administratively shut down\n");
12581 vty_out(vty
, " BGP version 4");
12582 vty_out(vty
, ", remote router ID %s",
12583 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12584 vty_out(vty
, ", local router ID %s\n",
12585 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12588 /* Confederation */
12589 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12590 && bgp_confederation_peers_check(bgp
, p
->as
))
12592 " Neighbor under common administration\n");
12595 vty_out(vty
, " BGP state = %s",
12596 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12598 if (peer_established(p
))
12599 vty_out(vty
, ", up for %8s",
12600 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12603 else if (p
->status
== Active
) {
12604 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12605 vty_out(vty
, " (passive)");
12606 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12607 vty_out(vty
, " (NSF passive)");
12609 vty_out(vty
, "\n");
12612 vty_out(vty
, " Last read %s",
12613 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12615 vty_out(vty
, ", Last write %s\n",
12616 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12619 /* Configured timer values. */
12621 " Hold time is %d, keepalive interval is %d seconds\n",
12622 p
->v_holdtime
, p
->v_keepalive
);
12623 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12624 vty_out(vty
, " Configured hold time is %d",
12626 vty_out(vty
, ", keepalive interval is %d seconds\n",
12628 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12629 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12630 vty_out(vty
, " Configured hold time is %d",
12631 bgp
->default_holdtime
);
12632 vty_out(vty
, ", keepalive interval is %d seconds\n",
12633 bgp
->default_keepalive
);
12635 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12637 " Configured DelayOpenTime is %d seconds\n",
12640 /* Configured and synced tcp-mss value for peer */
12641 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12642 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12643 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12644 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12647 /* Extended Optional Parameters Length for BGP OPEN Message */
12648 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12650 " Extended Optional Parameters Length is enabled\n");
12652 /* Conditional advertisements */
12654 " Configured conditional advertisements interval is %d seconds\n",
12655 bgp
->condition_check_period
);
12656 if (thread_is_scheduled(bgp
->t_condition_check
))
12658 " Time until conditional advertisements begin is %lu seconds\n",
12659 thread_timer_remain_second(
12660 bgp
->t_condition_check
));
12663 if (peer_established(p
) &&
12664 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12666 json_object
*json_cap
= NULL
;
12668 json_cap
= json_object_new_object();
12671 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12672 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12673 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12674 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12675 json_object_string_add(
12676 json_cap
, "4byteAs",
12677 "advertisedAndReceived");
12678 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12679 json_object_string_add(json_cap
,
12682 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12683 json_object_string_add(json_cap
,
12688 /* Extended Message Support */
12689 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12690 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12691 json_object_string_add(json_cap
,
12693 "advertisedAndReceived");
12694 else if (CHECK_FLAG(p
->cap
,
12695 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12696 json_object_string_add(json_cap
,
12699 else if (CHECK_FLAG(p
->cap
,
12700 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12701 json_object_string_add(json_cap
,
12706 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12707 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12708 json_object
*json_add
= NULL
;
12709 const char *print_store
;
12711 json_add
= json_object_new_object();
12713 FOREACH_AFI_SAFI (afi
, safi
) {
12714 json_object
*json_sub
= NULL
;
12715 json_sub
= json_object_new_object();
12716 print_store
= get_afi_safi_str(
12720 p
->af_cap
[afi
][safi
],
12721 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12723 p
->af_cap
[afi
][safi
],
12724 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12728 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12732 PEER_CAP_ADDPATH_AF_TX_RCV
))
12733 json_object_boolean_true_add(
12735 "txAdvertisedAndReceived");
12740 PEER_CAP_ADDPATH_AF_TX_ADV
))
12741 json_object_boolean_true_add(
12748 PEER_CAP_ADDPATH_AF_TX_RCV
))
12749 json_object_boolean_true_add(
12755 p
->af_cap
[afi
][safi
],
12756 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12758 p
->af_cap
[afi
][safi
],
12759 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12763 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12767 PEER_CAP_ADDPATH_AF_RX_RCV
))
12768 json_object_boolean_true_add(
12770 "rxAdvertisedAndReceived");
12775 PEER_CAP_ADDPATH_AF_RX_ADV
))
12776 json_object_boolean_true_add(
12783 PEER_CAP_ADDPATH_AF_RX_RCV
))
12784 json_object_boolean_true_add(
12790 p
->af_cap
[afi
][safi
],
12791 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12793 p
->af_cap
[afi
][safi
],
12794 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
12796 p
->af_cap
[afi
][safi
],
12797 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12799 p
->af_cap
[afi
][safi
],
12800 PEER_CAP_ADDPATH_AF_RX_RCV
))
12801 json_object_object_add(
12802 json_add
, print_store
,
12805 json_object_free(json_sub
);
12808 json_object_object_add(json_cap
, "addPath",
12813 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
12814 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
12815 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
12816 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
12817 json_object_string_add(
12818 json_cap
, "dynamic",
12819 "advertisedAndReceived");
12820 else if (CHECK_FLAG(p
->cap
,
12821 PEER_CAP_DYNAMIC_ADV
))
12822 json_object_string_add(json_cap
,
12825 else if (CHECK_FLAG(p
->cap
,
12826 PEER_CAP_DYNAMIC_RCV
))
12827 json_object_string_add(json_cap
,
12832 /* Extended nexthop */
12833 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
12834 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12835 json_object
*json_nxt
= NULL
;
12836 const char *print_store
;
12839 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
12840 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12841 json_object_string_add(
12842 json_cap
, "extendedNexthop",
12843 "advertisedAndReceived");
12844 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
12845 json_object_string_add(
12846 json_cap
, "extendedNexthop",
12848 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12849 json_object_string_add(
12850 json_cap
, "extendedNexthop",
12853 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
12854 json_nxt
= json_object_new_object();
12856 for (safi
= SAFI_UNICAST
;
12857 safi
< SAFI_MAX
; safi
++) {
12861 PEER_CAP_ENHE_AF_RCV
)) {
12867 json_object_string_add(
12870 "recieved"); /* misspelled for compatibility */
12873 json_object_object_add(
12875 "extendedNexthopFamililesByPeer",
12880 /* Long-lived Graceful Restart */
12881 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
12882 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
12883 json_object
*json_llgr
= NULL
;
12884 const char *afi_safi_str
;
12886 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
12887 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12888 json_object_string_add(
12890 "longLivedGracefulRestart",
12891 "advertisedAndReceived");
12892 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
12893 json_object_string_add(
12895 "longLivedGracefulRestart",
12897 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12898 json_object_string_add(
12900 "longLivedGracefulRestart",
12903 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
12904 json_llgr
= json_object_new_object();
12906 FOREACH_AFI_SAFI (afi
, safi
) {
12910 PEER_CAP_ENHE_AF_RCV
)) {
12916 json_object_string_add(
12922 json_object_object_add(
12924 "longLivedGracefulRestartByPeer",
12929 /* Route Refresh */
12930 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
12931 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
12932 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
12933 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
12934 (CHECK_FLAG(p
->cap
,
12935 PEER_CAP_REFRESH_NEW_RCV
) ||
12937 PEER_CAP_REFRESH_OLD_RCV
))) {
12940 PEER_CAP_REFRESH_OLD_RCV
) &&
12943 PEER_CAP_REFRESH_NEW_RCV
))
12944 json_object_string_add(
12947 "advertisedAndReceivedOldNew");
12951 PEER_CAP_REFRESH_OLD_RCV
))
12952 json_object_string_add(
12955 "advertisedAndReceivedOld");
12957 json_object_string_add(
12960 "advertisedAndReceivedNew");
12962 } else if (CHECK_FLAG(p
->cap
,
12963 PEER_CAP_REFRESH_ADV
))
12964 json_object_string_add(json_cap
,
12967 else if (CHECK_FLAG(p
->cap
,
12968 PEER_CAP_REFRESH_NEW_RCV
) ||
12970 PEER_CAP_REFRESH_OLD_RCV
))
12971 json_object_string_add(json_cap
,
12976 /* Enhanced Route Refresh */
12977 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
12978 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
12979 if (CHECK_FLAG(p
->cap
,
12980 PEER_CAP_ENHANCED_RR_ADV
) &&
12982 PEER_CAP_ENHANCED_RR_RCV
))
12983 json_object_string_add(
12985 "enhancedRouteRefresh",
12986 "advertisedAndReceived");
12987 else if (CHECK_FLAG(p
->cap
,
12988 PEER_CAP_ENHANCED_RR_ADV
))
12989 json_object_string_add(
12991 "enhancedRouteRefresh",
12993 else if (CHECK_FLAG(p
->cap
,
12994 PEER_CAP_ENHANCED_RR_RCV
))
12995 json_object_string_add(
12997 "enhancedRouteRefresh",
13001 /* Multiprotocol Extensions */
13002 json_object
*json_multi
= NULL
;
13004 json_multi
= json_object_new_object();
13006 FOREACH_AFI_SAFI (afi
, safi
) {
13007 if (p
->afc_adv
[afi
][safi
] ||
13008 p
->afc_recv
[afi
][safi
]) {
13009 json_object
*json_exten
= NULL
;
13010 json_exten
= json_object_new_object();
13012 if (p
->afc_adv
[afi
][safi
] &&
13013 p
->afc_recv
[afi
][safi
])
13014 json_object_boolean_true_add(
13016 "advertisedAndReceived");
13017 else if (p
->afc_adv
[afi
][safi
])
13018 json_object_boolean_true_add(
13021 else if (p
->afc_recv
[afi
][safi
])
13022 json_object_boolean_true_add(
13023 json_exten
, "received");
13025 json_object_object_add(
13027 get_afi_safi_str(afi
, safi
,
13032 json_object_object_add(json_cap
,
13033 "multiprotocolExtensions",
13036 /* Hostname capabilities */
13037 json_object
*json_hname
= NULL
;
13039 json_hname
= json_object_new_object();
13041 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13042 json_object_string_add(
13043 json_hname
, "advHostName",
13044 bgp
->peer_self
->hostname
13045 ? bgp
->peer_self
->hostname
13047 json_object_string_add(
13048 json_hname
, "advDomainName",
13049 bgp
->peer_self
->domainname
13050 ? bgp
->peer_self
->domainname
13055 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13056 json_object_string_add(
13057 json_hname
, "rcvHostName",
13058 p
->hostname
? p
->hostname
: "n/a");
13059 json_object_string_add(
13060 json_hname
, "rcvDomainName",
13061 p
->domainname
? p
->domainname
: "n/a");
13064 json_object_object_add(json_cap
, "hostName",
13067 /* Graceful Restart */
13068 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13069 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13070 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13071 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13072 json_object_string_add(
13073 json_cap
, "gracefulRestart",
13074 "advertisedAndReceived");
13075 else if (CHECK_FLAG(p
->cap
,
13076 PEER_CAP_RESTART_ADV
))
13077 json_object_string_add(
13079 "gracefulRestartCapability",
13081 else if (CHECK_FLAG(p
->cap
,
13082 PEER_CAP_RESTART_RCV
))
13083 json_object_string_add(
13085 "gracefulRestartCapability",
13088 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13089 int restart_af_count
= 0;
13090 json_object
*json_restart
= NULL
;
13091 json_restart
= json_object_new_object();
13093 json_object_int_add(
13095 "gracefulRestartRemoteTimerMsecs",
13096 p
->v_gr_restart
* 1000);
13098 FOREACH_AFI_SAFI (afi
, safi
) {
13102 PEER_CAP_RESTART_AF_RCV
)) {
13103 json_object
*json_sub
=
13106 json_object_new_object();
13112 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13113 json_object_boolean_true_add(
13116 restart_af_count
++;
13117 json_object_object_add(
13126 if (!restart_af_count
) {
13127 json_object_string_add(
13129 "addressFamiliesByPeer",
13131 json_object_free(json_restart
);
13133 json_object_object_add(
13135 "addressFamiliesByPeer",
13139 json_object_object_add(
13140 json_neigh
, "neighborCapabilities", json_cap
);
13142 vty_out(vty
, " Neighbor capabilities:\n");
13145 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13146 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13147 vty_out(vty
, " 4 Byte AS:");
13148 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13149 vty_out(vty
, " advertised");
13150 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13151 vty_out(vty
, " %sreceived",
13156 vty_out(vty
, "\n");
13159 /* Extended Message Support */
13160 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13161 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13162 vty_out(vty
, " Extended Message:");
13163 if (CHECK_FLAG(p
->cap
,
13164 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13165 vty_out(vty
, " advertised");
13166 if (CHECK_FLAG(p
->cap
,
13167 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13168 vty_out(vty
, " %sreceived",
13171 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13174 vty_out(vty
, "\n");
13178 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13179 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13180 vty_out(vty
, " AddPath:\n");
13182 FOREACH_AFI_SAFI (afi
, safi
) {
13184 p
->af_cap
[afi
][safi
],
13185 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13187 p
->af_cap
[afi
][safi
],
13188 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13189 vty_out(vty
, " %s: TX ",
13197 PEER_CAP_ADDPATH_AF_TX_ADV
))
13204 PEER_CAP_ADDPATH_AF_TX_RCV
))
13211 PEER_CAP_ADDPATH_AF_TX_ADV
)
13215 vty_out(vty
, "\n");
13219 p
->af_cap
[afi
][safi
],
13220 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13222 p
->af_cap
[afi
][safi
],
13223 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13224 vty_out(vty
, " %s: RX ",
13232 PEER_CAP_ADDPATH_AF_RX_ADV
))
13239 PEER_CAP_ADDPATH_AF_RX_RCV
))
13246 PEER_CAP_ADDPATH_AF_RX_ADV
)
13250 vty_out(vty
, "\n");
13256 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13257 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13258 vty_out(vty
, " Dynamic:");
13259 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13260 vty_out(vty
, " advertised");
13261 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13262 vty_out(vty
, " %sreceived",
13264 PEER_CAP_DYNAMIC_ADV
)
13267 vty_out(vty
, "\n");
13270 /* Extended nexthop */
13271 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13272 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13273 vty_out(vty
, " Extended nexthop:");
13274 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13275 vty_out(vty
, " advertised");
13276 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13277 vty_out(vty
, " %sreceived",
13282 vty_out(vty
, "\n");
13284 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13286 " Address families by peer:\n ");
13287 for (safi
= SAFI_UNICAST
;
13288 safi
< SAFI_MAX
; safi
++)
13292 PEER_CAP_ENHE_AF_RCV
))
13302 /* Long-lived Graceful Restart */
13303 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13304 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13306 " Long-lived Graceful Restart:");
13307 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13308 vty_out(vty
, " advertised");
13309 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13310 vty_out(vty
, " %sreceived",
13315 vty_out(vty
, "\n");
13317 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13319 " Address families by peer:\n");
13320 FOREACH_AFI_SAFI (afi
, safi
)
13324 PEER_CAP_LLGR_AF_RCV
))
13334 /* Route Refresh */
13335 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13336 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13337 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13338 vty_out(vty
, " Route refresh:");
13339 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13340 vty_out(vty
, " advertised");
13341 if (CHECK_FLAG(p
->cap
,
13342 PEER_CAP_REFRESH_NEW_RCV
) ||
13344 PEER_CAP_REFRESH_OLD_RCV
))
13345 vty_out(vty
, " %sreceived(%s)",
13347 PEER_CAP_REFRESH_ADV
)
13352 PEER_CAP_REFRESH_OLD_RCV
) &&
13355 PEER_CAP_REFRESH_NEW_RCV
))
13359 PEER_CAP_REFRESH_OLD_RCV
)
13363 vty_out(vty
, "\n");
13366 /* Enhanced Route Refresh */
13367 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13368 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13369 vty_out(vty
, " Enhanced Route Refresh:");
13370 if (CHECK_FLAG(p
->cap
,
13371 PEER_CAP_ENHANCED_RR_ADV
))
13372 vty_out(vty
, " advertised");
13373 if (CHECK_FLAG(p
->cap
,
13374 PEER_CAP_ENHANCED_RR_RCV
))
13375 vty_out(vty
, " %sreceived",
13377 PEER_CAP_REFRESH_ADV
)
13380 vty_out(vty
, "\n");
13383 /* Multiprotocol Extensions */
13384 FOREACH_AFI_SAFI (afi
, safi
)
13385 if (p
->afc_adv
[afi
][safi
] ||
13386 p
->afc_recv
[afi
][safi
]) {
13387 vty_out(vty
, " Address Family %s:",
13388 get_afi_safi_str(afi
, safi
,
13390 if (p
->afc_adv
[afi
][safi
])
13391 vty_out(vty
, " advertised");
13392 if (p
->afc_recv
[afi
][safi
])
13393 vty_out(vty
, " %sreceived",
13394 p
->afc_adv
[afi
][safi
]
13397 vty_out(vty
, "\n");
13400 /* Hostname capability */
13401 vty_out(vty
, " Hostname Capability:");
13403 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13405 " advertised (name: %s,domain name: %s)",
13406 bgp
->peer_self
->hostname
13407 ? bgp
->peer_self
->hostname
13409 bgp
->peer_self
->domainname
13410 ? bgp
->peer_self
->domainname
13413 vty_out(vty
, " not advertised");
13416 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13418 " received (name: %s,domain name: %s)",
13419 p
->hostname
? p
->hostname
: "n/a",
13420 p
->domainname
? p
->domainname
: "n/a");
13422 vty_out(vty
, " not received");
13425 vty_out(vty
, "\n");
13427 /* Graceful Restart */
13428 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13429 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13431 " Graceful Restart Capability:");
13432 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13433 vty_out(vty
, " advertised");
13434 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13435 vty_out(vty
, " %sreceived",
13437 PEER_CAP_RESTART_ADV
)
13440 vty_out(vty
, "\n");
13442 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13443 int restart_af_count
= 0;
13446 " Remote Restart timer is %d seconds\n",
13449 " Address families by peer:\n ");
13451 FOREACH_AFI_SAFI (afi
, safi
)
13455 PEER_CAP_RESTART_AF_RCV
)) {
13456 vty_out(vty
, "%s%s(%s)",
13468 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13470 : "not preserved");
13471 restart_af_count
++;
13473 if (!restart_af_count
)
13474 vty_out(vty
, "none");
13475 vty_out(vty
, "\n");
13477 } /* Graceful Restart */
13481 /* graceful restart information */
13482 json_object
*json_grace
= NULL
;
13483 json_object
*json_grace_send
= NULL
;
13484 json_object
*json_grace_recv
= NULL
;
13485 int eor_send_af_count
= 0;
13486 int eor_receive_af_count
= 0;
13489 json_grace
= json_object_new_object();
13490 json_grace_send
= json_object_new_object();
13491 json_grace_recv
= json_object_new_object();
13493 if ((peer_established(p
)) &&
13494 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13495 FOREACH_AFI_SAFI (afi
, safi
) {
13496 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13497 PEER_STATUS_EOR_SEND
)) {
13498 json_object_boolean_true_add(
13500 get_afi_safi_str(afi
, safi
,
13502 eor_send_af_count
++;
13505 FOREACH_AFI_SAFI (afi
, safi
) {
13506 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13507 PEER_STATUS_EOR_RECEIVED
)) {
13508 json_object_boolean_true_add(
13510 get_afi_safi_str(afi
, safi
,
13512 eor_receive_af_count
++;
13516 json_object_object_add(json_grace
, "endOfRibSend",
13518 json_object_object_add(json_grace
, "endOfRibRecv",
13522 if (p
->t_gr_restart
)
13523 json_object_int_add(
13524 json_grace
, "gracefulRestartTimerMsecs",
13525 thread_timer_remain_second(p
->t_gr_restart
) *
13529 json_object_int_add(
13530 json_grace
, "gracefulStalepathTimerMsecs",
13531 thread_timer_remain_second(p
->t_gr_stale
) *
13533 /* more gr info in new format */
13534 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13535 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13538 vty_out(vty
, " Graceful restart information:\n");
13539 if ((peer_established(p
)) &&
13540 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13542 vty_out(vty
, " End-of-RIB send: ");
13543 FOREACH_AFI_SAFI (afi
, safi
) {
13544 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13545 PEER_STATUS_EOR_SEND
)) {
13546 vty_out(vty
, "%s%s",
13547 eor_send_af_count
? ", " : "",
13548 get_afi_safi_str(afi
, safi
,
13550 eor_send_af_count
++;
13553 vty_out(vty
, "\n");
13554 vty_out(vty
, " End-of-RIB received: ");
13555 FOREACH_AFI_SAFI (afi
, safi
) {
13556 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13557 PEER_STATUS_EOR_RECEIVED
)) {
13558 vty_out(vty
, "%s%s",
13559 eor_receive_af_count
? ", "
13561 get_afi_safi_str(afi
, safi
,
13563 eor_receive_af_count
++;
13566 vty_out(vty
, "\n");
13569 if (p
->t_gr_restart
)
13571 " The remaining time of restart timer is %ld\n",
13572 thread_timer_remain_second(p
->t_gr_restart
));
13576 " The remaining time of stalepath timer is %ld\n",
13577 thread_timer_remain_second(p
->t_gr_stale
));
13579 /* more gr info in new format */
13580 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13584 json_object
*json_stat
= NULL
;
13585 json_stat
= json_object_new_object();
13586 /* Packet counts. */
13588 atomic_size_t outq_count
, inq_count
;
13589 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13590 memory_order_relaxed
);
13591 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13592 memory_order_relaxed
);
13594 json_object_int_add(json_stat
, "depthInq",
13595 (unsigned long)inq_count
);
13596 json_object_int_add(json_stat
, "depthOutq",
13597 (unsigned long)outq_count
);
13598 json_object_int_add(json_stat
, "opensSent",
13599 atomic_load_explicit(&p
->open_out
,
13600 memory_order_relaxed
));
13601 json_object_int_add(json_stat
, "opensRecv",
13602 atomic_load_explicit(&p
->open_in
,
13603 memory_order_relaxed
));
13604 json_object_int_add(json_stat
, "notificationsSent",
13605 atomic_load_explicit(&p
->notify_out
,
13606 memory_order_relaxed
));
13607 json_object_int_add(json_stat
, "notificationsRecv",
13608 atomic_load_explicit(&p
->notify_in
,
13609 memory_order_relaxed
));
13610 json_object_int_add(json_stat
, "updatesSent",
13611 atomic_load_explicit(&p
->update_out
,
13612 memory_order_relaxed
));
13613 json_object_int_add(json_stat
, "updatesRecv",
13614 atomic_load_explicit(&p
->update_in
,
13615 memory_order_relaxed
));
13616 json_object_int_add(json_stat
, "keepalivesSent",
13617 atomic_load_explicit(&p
->keepalive_out
,
13618 memory_order_relaxed
));
13619 json_object_int_add(json_stat
, "keepalivesRecv",
13620 atomic_load_explicit(&p
->keepalive_in
,
13621 memory_order_relaxed
));
13622 json_object_int_add(json_stat
, "routeRefreshSent",
13623 atomic_load_explicit(&p
->refresh_out
,
13624 memory_order_relaxed
));
13625 json_object_int_add(json_stat
, "routeRefreshRecv",
13626 atomic_load_explicit(&p
->refresh_in
,
13627 memory_order_relaxed
));
13628 json_object_int_add(json_stat
, "capabilitySent",
13629 atomic_load_explicit(&p
->dynamic_cap_out
,
13630 memory_order_relaxed
));
13631 json_object_int_add(json_stat
, "capabilityRecv",
13632 atomic_load_explicit(&p
->dynamic_cap_in
,
13633 memory_order_relaxed
));
13634 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13635 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13636 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13638 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13639 notify_out
, notify_in
, update_out
, update_in
,
13640 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13641 dynamic_cap_out
, dynamic_cap_in
;
13642 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13643 memory_order_relaxed
);
13644 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13645 memory_order_relaxed
);
13646 open_out
= atomic_load_explicit(&p
->open_out
,
13647 memory_order_relaxed
);
13649 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13650 notify_out
= atomic_load_explicit(&p
->notify_out
,
13651 memory_order_relaxed
);
13652 notify_in
= atomic_load_explicit(&p
->notify_in
,
13653 memory_order_relaxed
);
13654 update_out
= atomic_load_explicit(&p
->update_out
,
13655 memory_order_relaxed
);
13656 update_in
= atomic_load_explicit(&p
->update_in
,
13657 memory_order_relaxed
);
13658 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13659 memory_order_relaxed
);
13660 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13661 memory_order_relaxed
);
13662 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13663 memory_order_relaxed
);
13664 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13665 memory_order_relaxed
);
13666 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13667 memory_order_relaxed
);
13668 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13669 memory_order_relaxed
);
13671 /* Packet counts. */
13672 vty_out(vty
, " Message statistics:\n");
13673 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13674 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13675 vty_out(vty
, " Sent Rcvd\n");
13676 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13678 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13680 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13682 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13684 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13686 vty_out(vty
, " Capability: %10zu %10zu\n",
13687 dynamic_cap_out
, dynamic_cap_in
);
13688 vty_out(vty
, " Total: %10u %10u\n",
13689 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13693 /* advertisement-interval */
13694 json_object_int_add(json_neigh
,
13695 "minBtwnAdvertisementRunsTimerMsecs",
13696 p
->v_routeadv
* 1000);
13698 /* Update-source. */
13699 if (p
->update_if
|| p
->update_source
) {
13701 json_object_string_add(json_neigh
,
13704 else if (p
->update_source
)
13705 json_object_string_add(
13706 json_neigh
, "updateSource",
13707 sockunion2str(p
->update_source
, buf1
,
13711 /* advertisement-interval */
13713 " Minimum time between advertisement runs is %d seconds\n",
13716 /* Update-source. */
13717 if (p
->update_if
|| p
->update_source
) {
13718 vty_out(vty
, " Update source is ");
13720 vty_out(vty
, "%s", p
->update_if
);
13721 else if (p
->update_source
)
13723 sockunion2str(p
->update_source
, buf1
,
13725 vty_out(vty
, "\n");
13728 vty_out(vty
, "\n");
13731 /* Address Family Information */
13732 json_object
*json_hold
= NULL
;
13735 json_hold
= json_object_new_object();
13737 FOREACH_AFI_SAFI (afi
, safi
)
13738 if (p
->afc
[afi
][safi
])
13739 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13743 json_object_object_add(json_neigh
, "addressFamilyInfo",
13745 json_object_int_add(json_neigh
, "connectionsEstablished",
13747 json_object_int_add(json_neigh
, "connectionsDropped",
13750 vty_out(vty
, " Connections established %d; dropped %d\n",
13751 p
->established
, p
->dropped
);
13753 if (!p
->last_reset
) {
13755 json_object_string_add(json_neigh
, "lastReset",
13758 vty_out(vty
, " Last reset never\n");
13764 uptime
= bgp_clock();
13765 uptime
-= p
->resettime
;
13766 gmtime_r(&uptime
, &tm
);
13768 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13770 + (tm
.tm_min
* 60000)
13771 + (tm
.tm_hour
* 3600000));
13772 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13774 vty_out(vty
, " Last reset %s, ",
13775 peer_uptime(p
->resettime
, timebuf
,
13776 BGP_UPTIME_LEN
, 0, NULL
));
13778 bgp_show_peer_reset(vty
, p
, NULL
, false);
13779 if (p
->last_reset_cause_size
) {
13780 msg
= p
->last_reset_cause
;
13782 " Message received that caused BGP to send a NOTIFICATION:\n ");
13783 for (i
= 1; i
<= p
->last_reset_cause_size
;
13785 vty_out(vty
, "%02X", *msg
++);
13787 if (i
!= p
->last_reset_cause_size
) {
13789 vty_out(vty
, "\n ");
13790 } else if (i
% 4 == 0) {
13795 vty_out(vty
, "\n");
13800 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13802 json_object_boolean_true_add(json_neigh
,
13803 "prefixesConfigExceedMax");
13806 " Peer had exceeded the max. no. of prefixes configured.\n");
13808 if (p
->t_pmax_restart
) {
13810 json_object_boolean_true_add(
13811 json_neigh
, "reducePrefixNumFrom");
13812 json_object_int_add(json_neigh
,
13813 "restartInTimerMsec",
13814 thread_timer_remain_second(
13819 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13820 p
->host
, thread_timer_remain_second(
13821 p
->t_pmax_restart
));
13824 json_object_boolean_true_add(
13826 "reducePrefixNumAndClearIpBgp");
13829 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13834 /* EBGP Multihop and GTSM */
13835 if (p
->sort
!= BGP_PEER_IBGP
) {
13837 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13838 json_object_int_add(json_neigh
,
13839 "externalBgpNbrMaxHopsAway",
13841 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13842 json_object_int_add(json_neigh
,
13843 "externalBgpNbrMaxHopsAway",
13846 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13848 " External BGP neighbor may be up to %d hops away.\n",
13850 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13852 " External BGP neighbor may be up to %d hops away.\n",
13856 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13858 json_object_int_add(json_neigh
,
13859 "internalBgpNbrMaxHopsAway",
13863 " Internal BGP neighbor may be up to %d hops away.\n",
13868 /* Local address. */
13871 json_object_string_add(json_neigh
, "hostLocal",
13872 sockunion2str(p
->su_local
, buf1
,
13874 json_object_int_add(json_neigh
, "portLocal",
13875 ntohs(p
->su_local
->sin
.sin_port
));
13877 vty_out(vty
, "Local host: %s, Local port: %d\n",
13878 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13879 ntohs(p
->su_local
->sin
.sin_port
));
13882 /* Remote address. */
13883 if (p
->su_remote
) {
13885 json_object_string_add(json_neigh
, "hostForeign",
13886 sockunion2str(p
->su_remote
, buf1
,
13888 json_object_int_add(json_neigh
, "portForeign",
13889 ntohs(p
->su_remote
->sin
.sin_port
));
13891 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13892 sockunion2str(p
->su_remote
, buf1
,
13894 ntohs(p
->su_remote
->sin
.sin_port
));
13897 /* Nexthop display. */
13900 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
13902 json_object_string_addf(json_neigh
, "nexthopGlobal",
13903 "%pI6", &p
->nexthop
.v6_global
);
13904 json_object_string_addf(json_neigh
, "nexthopLocal",
13905 "%pI6", &p
->nexthop
.v6_local
);
13906 if (p
->shared_network
)
13907 json_object_string_add(json_neigh
,
13911 json_object_string_add(json_neigh
,
13913 "nonSharedNetwork");
13915 vty_out(vty
, "Nexthop: %s\n",
13916 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13918 vty_out(vty
, "Nexthop global: %s\n",
13919 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
13921 vty_out(vty
, "Nexthop local: %s\n",
13922 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
13924 vty_out(vty
, "BGP connection: %s\n",
13925 p
->shared_network
? "shared network"
13926 : "non shared network");
13930 /* Timer information. */
13932 json_object_int_add(json_neigh
, "connectRetryTimer",
13934 if (peer_established(p
) && p
->rtt
)
13935 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
13938 json_object_int_add(
13939 json_neigh
, "nextStartTimerDueInMsecs",
13940 thread_timer_remain_second(p
->t_start
) * 1000);
13942 json_object_int_add(
13943 json_neigh
, "nextConnectTimerDueInMsecs",
13944 thread_timer_remain_second(p
->t_connect
)
13946 if (p
->t_routeadv
) {
13947 json_object_int_add(json_neigh
, "mraiInterval",
13949 json_object_int_add(
13950 json_neigh
, "mraiTimerExpireInMsecs",
13951 thread_timer_remain_second(p
->t_routeadv
)
13955 json_object_int_add(json_neigh
, "authenticationEnabled",
13959 json_object_string_add(json_neigh
, "readThread", "on");
13961 json_object_string_add(json_neigh
, "readThread", "off");
13963 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
13964 json_object_string_add(json_neigh
, "writeThread", "on");
13966 json_object_string_add(json_neigh
, "writeThread",
13969 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
13971 if (peer_established(p
) && p
->rtt
)
13972 vty_out(vty
, "Estimated round trip time: %d ms\n",
13975 vty_out(vty
, "Next start timer due in %ld seconds\n",
13976 thread_timer_remain_second(p
->t_start
));
13978 vty_out(vty
, "Next connect timer due in %ld seconds\n",
13979 thread_timer_remain_second(p
->t_connect
));
13982 "MRAI (interval %u) timer expires in %ld seconds\n",
13984 thread_timer_remain_second(p
->t_routeadv
));
13986 vty_out(vty
, "Peer Authentication Enabled\n");
13988 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
13989 p
->t_read
? "on" : "off",
13990 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
13995 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
13996 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
13997 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14000 vty_out(vty
, "\n");
14002 /* BFD information. */
14004 bgp_bfd_show_info(vty
, p
, json_neigh
);
14007 if (p
->conf_if
) /* Configured interface name. */
14008 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14009 else /* Configured IP address. */
14010 json_object_object_add(json
, p
->host
, json_neigh
);
14014 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14015 enum show_type type
,
14016 union sockunion
*su
,
14017 const char *conf_if
, afi_t afi
,
14020 struct listnode
*node
, *nnode
;
14023 safi_t safi
= SAFI_UNICAST
;
14024 json_object
*json
= NULL
;
14025 json_object
*json_neighbor
= NULL
;
14028 json
= json_object_new_object();
14029 json_neighbor
= json_object_new_object();
14032 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14034 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14037 if ((peer
->afc
[afi
][safi
]) == 0)
14040 if (type
== show_all
) {
14041 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14045 json_object_object_add(json
, peer
->host
,
14047 json_neighbor
= NULL
;
14050 } else if (type
== show_peer
) {
14053 && !strcmp(peer
->conf_if
, conf_if
))
14055 && !strcmp(peer
->hostname
, conf_if
))) {
14057 bgp_show_peer_gr_status(vty
, peer
,
14062 if (sockunion_same(&peer
->su
, su
)) {
14064 bgp_show_peer_gr_status(vty
, peer
,
14069 if (use_json
&& find
)
14070 json_object_object_add(json
, peer
->host
,
14075 json_neighbor
= NULL
;
14080 if (type
== show_peer
&& !find
) {
14082 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14084 vty_out(vty
, "%% No such neighbor\n");
14088 json_object_free(json_neighbor
);
14089 vty_json(vty
, json
);
14091 vty_out(vty
, "\n");
14094 return CMD_SUCCESS
;
14097 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14098 enum show_type type
, union sockunion
*su
,
14099 const char *conf_if
, bool use_json
,
14102 struct listnode
*node
, *nnode
;
14105 bool nbr_output
= false;
14106 afi_t afi
= AFI_MAX
;
14107 safi_t safi
= SAFI_MAX
;
14109 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14111 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14115 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14116 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14121 bgp_show_peer(vty
, peer
, use_json
, json
);
14127 && !strcmp(peer
->conf_if
, conf_if
))
14129 && !strcmp(peer
->hostname
, conf_if
))) {
14131 bgp_show_peer(vty
, peer
, use_json
,
14135 if (sockunion_same(&peer
->su
, su
)) {
14137 bgp_show_peer(vty
, peer
, use_json
,
14142 case show_ipv4_peer
:
14143 case show_ipv6_peer
:
14144 FOREACH_SAFI (safi
) {
14145 if (peer
->afc
[afi
][safi
]) {
14148 && !strcmp(peer
->conf_if
, conf_if
))
14150 && !strcmp(peer
->hostname
, conf_if
))) {
14152 bgp_show_peer(vty
, peer
, use_json
,
14157 if (sockunion_same(&peer
->su
, su
)) {
14159 bgp_show_peer(vty
, peer
, use_json
,
14167 case show_ipv4_all
:
14168 case show_ipv6_all
:
14169 FOREACH_SAFI (safi
) {
14170 if (peer
->afc
[afi
][safi
]) {
14171 bgp_show_peer(vty
, peer
, use_json
, json
);
14180 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14181 type
== show_ipv6_peer
) && !find
) {
14183 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14185 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14188 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14189 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14190 vty_out(vty
, "%% No BGP neighbors found\n");
14193 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14194 json
, JSON_C_TO_STRING_PRETTY
));
14196 vty_out(vty
, "\n");
14199 return CMD_SUCCESS
;
14202 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14203 enum show_type type
,
14204 const char *ip_str
,
14205 afi_t afi
, bool use_json
)
14210 union sockunion su
;
14212 bgp
= bgp_get_default();
14218 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14222 ret
= str2sockunion(ip_str
, &su
);
14224 bgp_show_neighbor_graceful_restart(
14225 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14227 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14228 NULL
, afi
, use_json
);
14230 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14234 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14235 enum show_type type
,
14236 const char *ip_str
,
14239 struct listnode
*node
, *nnode
;
14241 union sockunion su
;
14242 json_object
*json
= NULL
;
14243 int ret
, is_first
= 1;
14244 bool nbr_output
= false;
14247 vty_out(vty
, "{\n");
14249 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14252 if (!(json
= json_object_new_object())) {
14254 EC_BGP_JSON_MEM_ERROR
,
14255 "Unable to allocate memory for JSON object");
14257 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14261 json_object_int_add(json
, "vrfId",
14262 (bgp
->vrf_id
== VRF_UNKNOWN
)
14264 : (int64_t)bgp
->vrf_id
);
14265 json_object_string_add(
14267 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14272 vty_out(vty
, ",\n");
14276 vty_out(vty
, "\"%s\":",
14277 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14281 vty_out(vty
, "\nInstance %s:\n",
14282 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14287 if (type
== show_peer
|| type
== show_ipv4_peer
||
14288 type
== show_ipv6_peer
) {
14289 ret
= str2sockunion(ip_str
, &su
);
14291 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14294 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14297 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14300 json_object_free(json
);
14305 vty_out(vty
, "}\n");
14306 else if (!nbr_output
)
14307 vty_out(vty
, "%% BGP instance not found\n");
14310 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14311 enum show_type type
, const char *ip_str
,
14316 union sockunion su
;
14317 json_object
*json
= NULL
;
14320 if (strmatch(name
, "all")) {
14321 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14323 return CMD_SUCCESS
;
14325 bgp
= bgp_lookup_by_name(name
);
14328 json
= json_object_new_object();
14329 vty_json(vty
, json
);
14332 "%% BGP instance not found\n");
14334 return CMD_WARNING
;
14338 bgp
= bgp_get_default();
14342 json
= json_object_new_object();
14344 ret
= str2sockunion(ip_str
, &su
);
14346 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14349 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14352 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14355 json_object_free(json
);
14358 vty_out(vty
, "{}\n");
14360 vty_out(vty
, "%% BGP instance not found\n");
14363 return CMD_SUCCESS
;
14368 /* "show [ip] bgp neighbors graceful-restart" commands. */
14369 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14370 show_ip_bgp_neighbors_graceful_restart_cmd
,
14371 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14377 "Neighbor to display information about\n"
14378 "Neighbor to display information about\n"
14379 "Neighbor on BGP configured interface\n"
14383 char *sh_arg
= NULL
;
14384 enum show_type sh_type
;
14386 afi_t afi
= AFI_MAX
;
14387 bool uj
= use_json(argc
, argv
);
14389 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14394 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14395 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14396 || argv_find(argv
, argc
, "WORD", &idx
)) {
14397 sh_type
= show_peer
;
14398 sh_arg
= argv
[idx
]->arg
;
14400 sh_type
= show_all
;
14402 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14403 return CMD_SUCCESS
;
14406 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14410 /* "show [ip] bgp neighbors" commands. */
14411 DEFUN (show_ip_bgp_neighbors
,
14412 show_ip_bgp_neighbors_cmd
,
14413 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14417 BGP_INSTANCE_HELP_STR
14420 "Detailed information on TCP and BGP neighbor connections\n"
14421 "Neighbor to display information about\n"
14422 "Neighbor to display information about\n"
14423 "Neighbor on BGP configured interface\n"
14427 char *sh_arg
= NULL
;
14428 enum show_type sh_type
;
14429 afi_t afi
= AFI_MAX
;
14431 bool uj
= use_json(argc
, argv
);
14435 /* [<vrf> VIEWVRFNAME] */
14436 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14437 vrf
= argv
[idx
+ 1]->arg
;
14438 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14440 } else if (argv_find(argv
, argc
, "view", &idx
))
14441 /* [<view> VIEWVRFNAME] */
14442 vrf
= argv
[idx
+ 1]->arg
;
14446 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14447 sh_type
= show_ipv4_all
;
14449 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14450 sh_type
= show_ipv6_all
;
14453 sh_type
= show_all
;
14456 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14457 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14458 || argv_find(argv
, argc
, "WORD", &idx
)) {
14459 sh_type
= show_peer
;
14460 sh_arg
= argv
[idx
]->arg
;
14463 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14464 sh_type
= show_ipv4_peer
;
14465 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14466 sh_type
= show_ipv6_peer
;
14469 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14472 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14473 paths' and `show ip mbgp paths'. Those functions results are the
14475 DEFUN (show_ip_bgp_paths
,
14476 show_ip_bgp_paths_cmd
,
14477 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14482 "Path information\n")
14484 vty_out(vty
, "Address Refcnt Path\n");
14485 aspath_print_all_vty(vty
);
14486 return CMD_SUCCESS
;
14491 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14494 struct community
*com
;
14496 com
= (struct community
*)bucket
->data
;
14497 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14498 community_str(com
, false, false));
14501 /* Show BGP's community internal data. */
14502 DEFUN (show_ip_bgp_community_info
,
14503 show_ip_bgp_community_info_cmd
,
14504 "show [ip] bgp community-info",
14508 "List all bgp community information\n")
14510 vty_out(vty
, "Address Refcnt Community\n");
14512 hash_iterate(community_hash(),
14513 (void (*)(struct hash_bucket
*,
14514 void *))community_show_all_iterator
,
14517 return CMD_SUCCESS
;
14520 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14523 struct lcommunity
*lcom
;
14525 lcom
= (struct lcommunity
*)bucket
->data
;
14526 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14527 lcommunity_str(lcom
, false, false));
14530 /* Show BGP's community internal data. */
14531 DEFUN (show_ip_bgp_lcommunity_info
,
14532 show_ip_bgp_lcommunity_info_cmd
,
14533 "show ip bgp large-community-info",
14537 "List all bgp large-community information\n")
14539 vty_out(vty
, "Address Refcnt Large-community\n");
14541 hash_iterate(lcommunity_hash(),
14542 (void (*)(struct hash_bucket
*,
14543 void *))lcommunity_show_all_iterator
,
14546 return CMD_SUCCESS
;
14548 /* Graceful Restart */
14550 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14557 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14559 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14561 switch (bgp_global_gr_mode
) {
14563 case GLOBAL_HELPER
:
14564 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14568 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14571 case GLOBAL_DISABLE
:
14572 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14575 case GLOBAL_INVALID
:
14577 "Global BGP GR Mode Invalid\n");
14580 vty_out(vty
, "\n");
14583 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14584 enum show_type type
,
14585 const char *ip_str
,
14586 afi_t afi
, bool use_json
)
14588 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14591 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14593 bgp_show_neighbor_graceful_restart_vty(
14594 vty
, type
, ip_str
, afi
, use_json
);
14597 } else if (afi
!= AFI_MAX
) {
14598 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14601 return CMD_ERR_INCOMPLETE
;
14604 return CMD_SUCCESS
;
14606 /* Graceful Restart */
14608 DEFUN (show_ip_bgp_attr_info
,
14609 show_ip_bgp_attr_info_cmd
,
14610 "show [ip] bgp attribute-info",
14614 "List all bgp attribute information\n")
14616 attr_show_all(vty
);
14617 return CMD_SUCCESS
;
14620 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14621 afi_t afi
, safi_t safi
,
14622 bool use_json
, json_object
*json
)
14625 struct listnode
*node
;
14627 char buf1
[INET6_ADDRSTRLEN
];
14629 enum vpn_policy_direction dir
;
14632 json_object
*json_import_vrfs
= NULL
;
14633 json_object
*json_export_vrfs
= NULL
;
14635 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14638 vty_json(vty
, json
);
14640 return CMD_WARNING
;
14643 /* Provide context for the block */
14644 json_object_string_add(json
, "vrf", name
? name
: "default");
14645 json_object_string_add(json
, "afiSafi",
14646 get_afi_safi_str(afi
, safi
, true));
14648 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14649 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14650 json_object_string_add(json
, "importFromVrfs", "none");
14651 json_object_string_add(json
, "importRts", "none");
14653 json_import_vrfs
= json_object_new_array();
14655 for (ALL_LIST_ELEMENTS_RO(
14656 bgp
->vpn_policy
[afi
].import_vrf
,
14658 json_object_array_add(json_import_vrfs
,
14659 json_object_new_string(vname
));
14661 json_object_object_add(json
, "importFromVrfs",
14663 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14664 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14665 ecom_str
= ecommunity_ecom2str(
14666 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14667 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14668 json_object_string_add(json
, "importRts",
14670 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14672 json_object_string_add(json
, "importRts",
14676 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14677 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14678 json_object_string_add(json
, "exportToVrfs", "none");
14679 json_object_string_add(json
, "routeDistinguisher",
14681 json_object_string_add(json
, "exportRts", "none");
14683 json_export_vrfs
= json_object_new_array();
14685 for (ALL_LIST_ELEMENTS_RO(
14686 bgp
->vpn_policy
[afi
].export_vrf
,
14688 json_object_array_add(json_export_vrfs
,
14689 json_object_new_string(vname
));
14690 json_object_object_add(json
, "exportToVrfs",
14692 json_object_string_add(json
, "routeDistinguisher",
14693 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14694 buf1
, RD_ADDRSTRLEN
));
14696 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14697 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14698 ecom_str
= ecommunity_ecom2str(
14699 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14700 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14701 json_object_string_add(json
, "exportRts",
14703 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14705 json_object_string_add(json
, "exportRts",
14710 vty_json(vty
, json
);
14713 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14716 vty_out(vty
, "%% No such BGP instance exist\n");
14717 return CMD_WARNING
;
14720 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14721 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14723 "This VRF is not importing %s routes from any other VRF\n",
14724 get_afi_safi_str(afi
, safi
, false));
14727 "This VRF is importing %s routes from the following VRFs:\n",
14728 get_afi_safi_str(afi
, safi
, false));
14730 for (ALL_LIST_ELEMENTS_RO(
14731 bgp
->vpn_policy
[afi
].import_vrf
,
14733 vty_out(vty
, " %s\n", vname
);
14735 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14737 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14738 ecom_str
= ecommunity_ecom2str(
14739 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14740 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14741 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14743 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14745 vty_out(vty
, "Import RT(s):\n");
14748 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14749 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14751 "This VRF is not exporting %s routes to any other VRF\n",
14752 get_afi_safi_str(afi
, safi
, false));
14755 "This VRF is exporting %s routes to the following VRFs:\n",
14756 get_afi_safi_str(afi
, safi
, false));
14758 for (ALL_LIST_ELEMENTS_RO(
14759 bgp
->vpn_policy
[afi
].export_vrf
,
14761 vty_out(vty
, " %s\n", vname
);
14763 vty_out(vty
, "RD: %s\n",
14764 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14765 buf1
, RD_ADDRSTRLEN
));
14767 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14768 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14769 ecom_str
= ecommunity_ecom2str(
14770 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14771 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14772 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14773 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14775 vty_out(vty
, "Import RT(s):\n");
14779 return CMD_SUCCESS
;
14782 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14783 safi_t safi
, bool use_json
)
14785 struct listnode
*node
, *nnode
;
14787 char *vrf_name
= NULL
;
14788 json_object
*json
= NULL
;
14789 json_object
*json_vrf
= NULL
;
14790 json_object
*json_vrfs
= NULL
;
14793 json
= json_object_new_object();
14794 json_vrfs
= json_object_new_object();
14797 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14799 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14800 vrf_name
= bgp
->name
;
14803 json_vrf
= json_object_new_object();
14805 vty_out(vty
, "\nInstance %s:\n",
14806 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14807 ? VRF_DEFAULT_NAME
: bgp
->name
);
14809 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14811 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14812 json_object_object_add(json_vrfs
,
14813 VRF_DEFAULT_NAME
, json_vrf
);
14815 json_object_object_add(json_vrfs
, vrf_name
,
14821 json_object_object_add(json
, "vrfs", json_vrfs
);
14822 vty_json(vty
, json
);
14825 return CMD_SUCCESS
;
14828 /* "show [ip] bgp route-leak" command. */
14829 DEFUN (show_ip_bgp_route_leak
,
14830 show_ip_bgp_route_leak_cmd
,
14831 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14835 BGP_INSTANCE_HELP_STR
14838 "Route leaking information\n"
14842 afi_t afi
= AFI_MAX
;
14843 safi_t safi
= SAFI_MAX
;
14845 bool uj
= use_json(argc
, argv
);
14847 json_object
*json
= NULL
;
14849 /* show [ip] bgp */
14850 if (argv_find(argv
, argc
, "ip", &idx
)) {
14852 safi
= SAFI_UNICAST
;
14854 /* [vrf VIEWVRFNAME] */
14855 if (argv_find(argv
, argc
, "view", &idx
)) {
14857 "%% This command is not applicable to BGP views\n");
14858 return CMD_WARNING
;
14861 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14862 vrf
= argv
[idx
+ 1]->arg
;
14863 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14866 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14867 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14868 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14870 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14872 "%% This command is applicable only for unicast ipv4|ipv6\n");
14873 return CMD_WARNING
;
14876 if (vrf
&& strmatch(vrf
, "all"))
14877 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14880 json
= json_object_new_object();
14882 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14885 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14888 struct listnode
*node
, *nnode
;
14891 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14892 vty_out(vty
, "\nInstance %s:\n",
14893 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14896 update_group_show(bgp
, afi
, safi
, vty
, 0);
14900 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14901 int safi
, uint64_t subgrp_id
)
14906 if (strmatch(name
, "all")) {
14907 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14908 return CMD_SUCCESS
;
14910 bgp
= bgp_lookup_by_name(name
);
14913 bgp
= bgp_get_default();
14917 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
14918 return CMD_SUCCESS
;
14921 DEFUN (show_ip_bgp_updgrps
,
14922 show_ip_bgp_updgrps_cmd
,
14923 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
14927 BGP_INSTANCE_HELP_STR
14929 BGP_SAFI_WITH_LABEL_HELP_STR
14930 "Detailed info about dynamic update groups\n"
14931 "Specific subgroup to display detailed info for\n")
14934 afi_t afi
= AFI_IP6
;
14935 safi_t safi
= SAFI_UNICAST
;
14936 uint64_t subgrp_id
= 0;
14940 /* show [ip] bgp */
14941 if (argv_find(argv
, argc
, "ip", &idx
))
14943 /* [<vrf> VIEWVRFNAME] */
14944 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14945 vrf
= argv
[idx
+ 1]->arg
;
14946 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14948 } else if (argv_find(argv
, argc
, "view", &idx
))
14949 /* [<view> VIEWVRFNAME] */
14950 vrf
= argv
[idx
+ 1]->arg
;
14951 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14952 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14953 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14956 /* get subgroup id, if provided */
14958 if (argv
[idx
]->type
== VARIABLE_TKN
)
14959 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
14961 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
14964 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
14965 show_bgp_instance_all_ipv6_updgrps_cmd
,
14966 "show [ip] bgp <view|vrf> all update-groups",
14970 BGP_INSTANCE_ALL_HELP_STR
14971 "Detailed info about dynamic update groups\n")
14973 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
14974 return CMD_SUCCESS
;
14977 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
14978 show_bgp_l2vpn_evpn_updgrps_cmd
,
14979 "show [ip] bgp l2vpn evpn update-groups",
14983 "l2vpn address family\n"
14984 "evpn sub-address family\n"
14985 "Detailed info about dynamic update groups\n")
14988 uint64_t subgrp_id
= 0;
14990 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
14991 return CMD_SUCCESS
;
14994 DEFUN (show_bgp_updgrps_stats
,
14995 show_bgp_updgrps_stats_cmd
,
14996 "show [ip] bgp update-groups statistics",
15000 "Detailed info about dynamic update groups\n"
15005 bgp
= bgp_get_default();
15007 update_group_show_stats(bgp
, vty
);
15009 return CMD_SUCCESS
;
15012 DEFUN (show_bgp_instance_updgrps_stats
,
15013 show_bgp_instance_updgrps_stats_cmd
,
15014 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15018 BGP_INSTANCE_HELP_STR
15019 "Detailed info about dynamic update groups\n"
15025 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15027 update_group_show_stats(bgp
, vty
);
15029 return CMD_SUCCESS
;
15032 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15033 afi_t afi
, safi_t safi
,
15034 const char *what
, uint64_t subgrp_id
)
15039 bgp
= bgp_lookup_by_name(name
);
15041 bgp
= bgp_get_default();
15044 if (!strcmp(what
, "advertise-queue"))
15045 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15047 else if (!strcmp(what
, "advertised-routes"))
15048 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15050 else if (!strcmp(what
, "packet-queue"))
15051 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15056 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15057 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15058 "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",
15059 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15061 "Detailed info about dynamic update groups\n"
15062 "Specific subgroup to display info for\n"
15063 "Advertisement queue\n"
15064 "Announced routes\n"
15067 uint64_t subgrp_id
= 0;
15071 subgrp_id
= strtoull(sgid
, NULL
, 10);
15076 afiz
= bgp_vty_afi_from_str(afi
);
15080 afiz
= bgp_vty_afi_from_str(afi
);
15081 if (afiz
!= AFI_IP
)
15083 "%% Cannot specify both 'ip' and 'ipv6'\n");
15084 return CMD_WARNING
;
15087 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15089 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15090 return CMD_SUCCESS
;
15093 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15096 struct listnode
*node
, *nnode
;
15097 struct prefix
*range
;
15102 const char *peer_status
;
15106 json_object
*json_peer_group
= NULL
;
15107 json_object
*json_peer_group_afc
= NULL
;
15108 json_object
*json_peer_group_members
= NULL
;
15109 json_object
*json_peer_group_dynamic
= NULL
;
15110 json_object
*json_peer_group_dynamic_af
= NULL
;
15111 json_object
*json_peer_group_ranges
= NULL
;
15113 conf
= group
->conf
;
15116 json_peer_group
= json_object_new_object();
15117 json_peer_group_afc
= json_object_new_array();
15120 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15122 json_object_int_add(json_peer_group
, "remoteAs",
15125 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15126 group
->name
, conf
->as
);
15127 } else if (conf
->as_type
== AS_INTERNAL
) {
15129 json_object_int_add(json_peer_group
, "remoteAs",
15132 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15133 group
->name
, group
->bgp
->as
);
15136 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15139 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15141 json_object_string_add(json_peer_group
, "type",
15144 vty_out(vty
, " Peer-group type is internal\n");
15147 json_object_string_add(json_peer_group
, "type",
15150 vty_out(vty
, " Peer-group type is external\n");
15153 /* Display AFs configured. */
15155 vty_out(vty
, " Configured address-families:");
15157 FOREACH_AFI_SAFI (afi
, safi
) {
15158 if (conf
->afc
[afi
][safi
]) {
15161 json_object_array_add(
15162 json_peer_group_afc
,
15163 json_object_new_string(get_afi_safi_str(
15164 afi
, safi
, false)));
15166 vty_out(vty
, " %s;",
15167 get_afi_safi_str(afi
, safi
, false));
15172 json_object_object_add(json_peer_group
,
15173 "addressFamiliesConfigured",
15174 json_peer_group_afc
);
15177 vty_out(vty
, " none\n");
15179 vty_out(vty
, "\n");
15182 /* Display listen ranges (for dynamic neighbors), if any */
15183 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15184 lr_count
= listcount(group
->listen_range
[afi
]);
15187 if (!json_peer_group_dynamic
)
15188 json_peer_group_dynamic
=
15189 json_object_new_object();
15191 json_peer_group_dynamic_af
=
15192 json_object_new_object();
15193 json_peer_group_ranges
=
15194 json_object_new_array();
15195 json_object_int_add(json_peer_group_dynamic_af
,
15196 "count", lr_count
);
15198 vty_out(vty
, " %d %s listen range(s)\n",
15199 lr_count
, afi2str(afi
));
15202 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15207 snprintfrr(buf
, sizeof(buf
), "%pFX",
15210 json_object_array_add(
15211 json_peer_group_ranges
,
15212 json_object_new_string(buf
));
15214 vty_out(vty
, " %pFX\n", range
);
15219 json_object_object_add(
15220 json_peer_group_dynamic_af
, "ranges",
15221 json_peer_group_ranges
);
15223 json_object_object_add(
15224 json_peer_group_dynamic
, afi2str(afi
),
15225 json_peer_group_dynamic_af
);
15230 if (json_peer_group_dynamic
)
15231 json_object_object_add(json_peer_group
, "dynamicRanges",
15232 json_peer_group_dynamic
);
15234 /* Display group members and their status */
15235 if (listcount(group
->peer
)) {
15237 json_peer_group_members
= json_object_new_object();
15239 vty_out(vty
, " Peer-group members:\n");
15240 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15241 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15242 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15243 peer_status
= "Idle (Admin)";
15244 else if (CHECK_FLAG(peer
->sflags
,
15245 PEER_STATUS_PREFIX_OVERFLOW
))
15246 peer_status
= "Idle (PfxCt)";
15248 peer_status
= lookup_msg(bgp_status_msg
,
15249 peer
->status
, NULL
);
15251 dynamic
= peer_dynamic_neighbor(peer
);
15254 json_object
*json_peer_group_member
=
15255 json_object_new_object();
15257 json_object_string_add(json_peer_group_member
,
15258 "status", peer_status
);
15261 json_object_boolean_true_add(
15262 json_peer_group_member
,
15265 json_object_object_add(json_peer_group_members
,
15267 json_peer_group_member
);
15269 vty_out(vty
, " %s %s %s \n", peer
->host
,
15270 dynamic
? "(dynamic)" : "",
15275 json_object_object_add(json_peer_group
, "members",
15276 json_peer_group_members
);
15280 json_object_object_add(json
, group
->name
, json_peer_group
);
15282 return CMD_SUCCESS
;
15285 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15286 const char *group_name
, bool uj
)
15289 struct listnode
*node
, *nnode
;
15290 struct peer_group
*group
;
15291 bool found
= false;
15292 json_object
*json
= NULL
;
15295 json
= json_object_new_object();
15297 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15301 vty_json(vty
, json
);
15303 vty_out(vty
, "%% BGP instance not found\n");
15305 return CMD_WARNING
;
15308 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15310 if (strmatch(group
->name
, group_name
)) {
15311 bgp_show_one_peer_group(vty
, group
, json
);
15316 bgp_show_one_peer_group(vty
, group
, json
);
15320 if (group_name
&& !found
&& !uj
)
15321 vty_out(vty
, "%% No such peer-group\n");
15324 vty_json(vty
, json
);
15326 return CMD_SUCCESS
;
15329 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15330 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15331 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15332 "Detailed information on BGP peer groups\n"
15333 "Peer group name\n" JSON_STR
)
15337 bool uj
= use_json(argc
, argv
);
15339 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15341 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15343 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15347 /* Redistribute VTY commands. */
15349 DEFUN (bgp_redistribute_ipv4
,
15350 bgp_redistribute_ipv4_cmd
,
15351 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15352 "Redistribute information from another routing protocol\n"
15353 FRR_IP_REDIST_HELP_STR_BGPD
)
15355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15356 int idx_protocol
= 1;
15359 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15361 vty_out(vty
, "%% Invalid route type\n");
15362 return CMD_WARNING_CONFIG_FAILED
;
15365 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15366 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15370 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15371 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15372 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15374 DEFUN (bgp_redistribute_ipv4_rmap
,
15375 bgp_redistribute_ipv4_rmap_cmd
,
15376 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15377 "Redistribute information from another routing protocol\n"
15378 FRR_IP_REDIST_HELP_STR_BGPD
15379 "Route map reference\n"
15380 "Pointer to route-map entries\n")
15382 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15383 int idx_protocol
= 1;
15386 struct bgp_redist
*red
;
15388 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15389 vty
, argv
[idx_word
]->arg
);
15391 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15393 vty_out(vty
, "%% Invalid route type\n");
15394 return CMD_WARNING_CONFIG_FAILED
;
15397 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15399 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15400 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15404 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15405 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15406 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15407 "Route map reference\n"
15408 "Pointer to route-map entries\n")
15410 DEFUN (bgp_redistribute_ipv4_metric
,
15411 bgp_redistribute_ipv4_metric_cmd
,
15412 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15413 "Redistribute information from another routing protocol\n"
15414 FRR_IP_REDIST_HELP_STR_BGPD
15415 "Metric for redistributed routes\n"
15416 "Default metric\n")
15418 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15419 int idx_protocol
= 1;
15420 int idx_number
= 3;
15423 struct bgp_redist
*red
;
15426 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15428 vty_out(vty
, "%% Invalid route type\n");
15429 return CMD_WARNING_CONFIG_FAILED
;
15431 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15433 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15434 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15435 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15439 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15440 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15441 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15442 "Metric for redistributed routes\n"
15443 "Default metric\n")
15445 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15446 bgp_redistribute_ipv4_rmap_metric_cmd
,
15447 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15448 "Redistribute information from another routing protocol\n"
15449 FRR_IP_REDIST_HELP_STR_BGPD
15450 "Route map reference\n"
15451 "Pointer to route-map entries\n"
15452 "Metric for redistributed routes\n"
15453 "Default metric\n")
15455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15456 int idx_protocol
= 1;
15458 int idx_number
= 5;
15461 struct bgp_redist
*red
;
15463 struct route_map
*route_map
=
15464 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15466 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15468 vty_out(vty
, "%% Invalid route type\n");
15469 return CMD_WARNING_CONFIG_FAILED
;
15471 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15473 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15475 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15476 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15477 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15481 bgp_redistribute_ipv4_rmap_metric
,
15482 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15483 "redistribute " FRR_IP_REDIST_STR_BGPD
15484 " route-map WORD metric (0-4294967295)",
15485 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15486 "Route map reference\n"
15487 "Pointer to route-map entries\n"
15488 "Metric for redistributed routes\n"
15489 "Default metric\n")
15491 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15492 bgp_redistribute_ipv4_metric_rmap_cmd
,
15493 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15494 "Redistribute information from another routing protocol\n"
15495 FRR_IP_REDIST_HELP_STR_BGPD
15496 "Metric for redistributed routes\n"
15498 "Route map reference\n"
15499 "Pointer to route-map entries\n")
15501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15502 int idx_protocol
= 1;
15503 int idx_number
= 3;
15507 struct bgp_redist
*red
;
15509 struct route_map
*route_map
=
15510 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15512 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15514 vty_out(vty
, "%% Invalid route type\n");
15515 return CMD_WARNING_CONFIG_FAILED
;
15517 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15519 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15520 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15522 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15523 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15527 bgp_redistribute_ipv4_metric_rmap
,
15528 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15529 "redistribute " FRR_IP_REDIST_STR_BGPD
15530 " metric (0-4294967295) route-map WORD",
15531 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15532 "Metric for redistributed routes\n"
15534 "Route map reference\n"
15535 "Pointer to route-map entries\n")
15537 DEFUN (bgp_redistribute_ipv4_ospf
,
15538 bgp_redistribute_ipv4_ospf_cmd
,
15539 "redistribute <ospf|table> (1-65535)",
15540 "Redistribute information from another routing protocol\n"
15541 "Open Shortest Path First (OSPFv2)\n"
15542 "Non-main Kernel Routing Table\n"
15543 "Instance ID/Table ID\n")
15545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15546 int idx_ospf_table
= 1;
15547 int idx_number
= 2;
15548 unsigned short instance
;
15549 unsigned short protocol
;
15551 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15553 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15554 protocol
= ZEBRA_ROUTE_OSPF
;
15556 protocol
= ZEBRA_ROUTE_TABLE
;
15558 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15559 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15562 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15563 "redistribute <ospf|table> (1-65535)",
15564 "Redistribute information from another routing protocol\n"
15565 "Open Shortest Path First (OSPFv2)\n"
15566 "Non-main Kernel Routing Table\n"
15567 "Instance ID/Table ID\n")
15569 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15570 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15571 "redistribute <ospf|table> (1-65535) route-map WORD",
15572 "Redistribute information from another routing protocol\n"
15573 "Open Shortest Path First (OSPFv2)\n"
15574 "Non-main Kernel Routing Table\n"
15575 "Instance ID/Table ID\n"
15576 "Route map reference\n"
15577 "Pointer to route-map entries\n")
15579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15580 int idx_ospf_table
= 1;
15581 int idx_number
= 2;
15583 struct bgp_redist
*red
;
15584 unsigned short instance
;
15587 struct route_map
*route_map
=
15588 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15590 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15591 protocol
= ZEBRA_ROUTE_OSPF
;
15593 protocol
= ZEBRA_ROUTE_TABLE
;
15595 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15596 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15598 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15599 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15602 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15603 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15604 "redistribute <ospf|table> (1-65535) route-map WORD",
15605 "Redistribute information from another routing protocol\n"
15606 "Open Shortest Path First (OSPFv2)\n"
15607 "Non-main Kernel Routing Table\n"
15608 "Instance ID/Table ID\n"
15609 "Route map reference\n"
15610 "Pointer to route-map entries\n")
15612 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15613 bgp_redistribute_ipv4_ospf_metric_cmd
,
15614 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15615 "Redistribute information from another routing protocol\n"
15616 "Open Shortest Path First (OSPFv2)\n"
15617 "Non-main Kernel Routing Table\n"
15618 "Instance ID/Table ID\n"
15619 "Metric for redistributed routes\n"
15620 "Default metric\n")
15622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15623 int idx_ospf_table
= 1;
15624 int idx_number
= 2;
15625 int idx_number_2
= 4;
15627 struct bgp_redist
*red
;
15628 unsigned short instance
;
15632 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15633 protocol
= ZEBRA_ROUTE_OSPF
;
15635 protocol
= ZEBRA_ROUTE_TABLE
;
15637 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15638 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15640 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15641 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15643 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15646 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15647 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15648 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15649 "Redistribute information from another routing protocol\n"
15650 "Open Shortest Path First (OSPFv2)\n"
15651 "Non-main Kernel Routing Table\n"
15652 "Instance ID/Table ID\n"
15653 "Metric for redistributed routes\n"
15654 "Default metric\n")
15656 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15657 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15658 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15659 "Redistribute information from another routing protocol\n"
15660 "Open Shortest Path First (OSPFv2)\n"
15661 "Non-main Kernel Routing Table\n"
15662 "Instance ID/Table ID\n"
15663 "Route map reference\n"
15664 "Pointer to route-map entries\n"
15665 "Metric for redistributed routes\n"
15666 "Default metric\n")
15668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15669 int idx_ospf_table
= 1;
15670 int idx_number
= 2;
15672 int idx_number_2
= 6;
15674 struct bgp_redist
*red
;
15675 unsigned short instance
;
15678 struct route_map
*route_map
=
15679 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15681 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15682 protocol
= ZEBRA_ROUTE_OSPF
;
15684 protocol
= ZEBRA_ROUTE_TABLE
;
15686 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15687 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15689 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15691 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15692 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15694 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15698 bgp_redistribute_ipv4_ospf_rmap_metric
,
15699 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15700 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15701 "Redistribute information from another routing protocol\n"
15702 "Open Shortest Path First (OSPFv2)\n"
15703 "Non-main Kernel Routing Table\n"
15704 "Instance ID/Table ID\n"
15705 "Route map reference\n"
15706 "Pointer to route-map entries\n"
15707 "Metric for redistributed routes\n"
15708 "Default metric\n")
15710 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15711 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15712 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15713 "Redistribute information from another routing protocol\n"
15714 "Open Shortest Path First (OSPFv2)\n"
15715 "Non-main Kernel Routing Table\n"
15716 "Instance ID/Table ID\n"
15717 "Metric for redistributed routes\n"
15719 "Route map reference\n"
15720 "Pointer to route-map entries\n")
15722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15723 int idx_ospf_table
= 1;
15724 int idx_number
= 2;
15725 int idx_number_2
= 4;
15728 struct bgp_redist
*red
;
15729 unsigned short instance
;
15732 struct route_map
*route_map
=
15733 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15735 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15736 protocol
= ZEBRA_ROUTE_OSPF
;
15738 protocol
= ZEBRA_ROUTE_TABLE
;
15740 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15741 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15743 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15744 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15747 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15748 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15752 bgp_redistribute_ipv4_ospf_metric_rmap
,
15753 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15754 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15755 "Redistribute information from another routing protocol\n"
15756 "Open Shortest Path First (OSPFv2)\n"
15757 "Non-main Kernel Routing Table\n"
15758 "Instance ID/Table ID\n"
15759 "Metric for redistributed routes\n"
15761 "Route map reference\n"
15762 "Pointer to route-map entries\n")
15764 DEFUN (no_bgp_redistribute_ipv4_ospf
,
15765 no_bgp_redistribute_ipv4_ospf_cmd
,
15766 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15768 "Redistribute information from another routing protocol\n"
15769 "Open Shortest Path First (OSPFv2)\n"
15770 "Non-main Kernel Routing Table\n"
15771 "Instance ID/Table ID\n"
15772 "Metric for redistributed routes\n"
15774 "Route map reference\n"
15775 "Pointer to route-map entries\n")
15777 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15778 int idx_ospf_table
= 2;
15779 int idx_number
= 3;
15780 unsigned short instance
;
15783 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15784 protocol
= ZEBRA_ROUTE_OSPF
;
15786 protocol
= ZEBRA_ROUTE_TABLE
;
15788 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15789 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
15793 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15794 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15796 "Redistribute information from another routing protocol\n"
15797 "Open Shortest Path First (OSPFv2)\n"
15798 "Non-main Kernel Routing Table\n"
15799 "Instance ID/Table ID\n"
15800 "Metric for redistributed routes\n"
15802 "Route map reference\n"
15803 "Pointer to route-map entries\n")
15805 DEFUN (no_bgp_redistribute_ipv4
,
15806 no_bgp_redistribute_ipv4_cmd
,
15807 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15809 "Redistribute information from another routing protocol\n"
15810 FRR_IP_REDIST_HELP_STR_BGPD
15811 "Metric for redistributed routes\n"
15813 "Route map reference\n"
15814 "Pointer to route-map entries\n")
15816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15817 int idx_protocol
= 2;
15820 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15822 vty_out(vty
, "%% Invalid route type\n");
15823 return CMD_WARNING_CONFIG_FAILED
;
15825 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
15829 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15830 "no redistribute " FRR_IP_REDIST_STR_BGPD
15831 " [{metric (0-4294967295)|route-map WORD}]",
15833 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15834 "Metric for redistributed routes\n"
15836 "Route map reference\n"
15837 "Pointer to route-map entries\n")
15839 DEFUN (bgp_redistribute_ipv6
,
15840 bgp_redistribute_ipv6_cmd
,
15841 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15842 "Redistribute information from another routing protocol\n"
15843 FRR_IP6_REDIST_HELP_STR_BGPD
)
15845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15846 int idx_protocol
= 1;
15849 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15851 vty_out(vty
, "%% Invalid route type\n");
15852 return CMD_WARNING_CONFIG_FAILED
;
15855 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15856 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
15859 DEFUN (bgp_redistribute_ipv6_rmap
,
15860 bgp_redistribute_ipv6_rmap_cmd
,
15861 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15862 "Redistribute information from another routing protocol\n"
15863 FRR_IP6_REDIST_HELP_STR_BGPD
15864 "Route map reference\n"
15865 "Pointer to route-map entries\n")
15867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15868 int idx_protocol
= 1;
15871 struct bgp_redist
*red
;
15873 struct route_map
*route_map
=
15874 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15876 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15878 vty_out(vty
, "%% Invalid route type\n");
15879 return CMD_WARNING_CONFIG_FAILED
;
15882 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15884 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15885 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15888 DEFUN (bgp_redistribute_ipv6_metric
,
15889 bgp_redistribute_ipv6_metric_cmd
,
15890 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15891 "Redistribute information from another routing protocol\n"
15892 FRR_IP6_REDIST_HELP_STR_BGPD
15893 "Metric for redistributed routes\n"
15894 "Default metric\n")
15896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15897 int idx_protocol
= 1;
15898 int idx_number
= 3;
15901 struct bgp_redist
*red
;
15904 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15906 vty_out(vty
, "%% Invalid route type\n");
15907 return CMD_WARNING_CONFIG_FAILED
;
15909 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15911 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15912 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
15913 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15916 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
15917 bgp_redistribute_ipv6_rmap_metric_cmd
,
15918 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15919 "Redistribute information from another routing protocol\n"
15920 FRR_IP6_REDIST_HELP_STR_BGPD
15921 "Route map reference\n"
15922 "Pointer to route-map entries\n"
15923 "Metric for redistributed routes\n"
15924 "Default metric\n")
15926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15927 int idx_protocol
= 1;
15929 int idx_number
= 5;
15932 struct bgp_redist
*red
;
15934 struct route_map
*route_map
=
15935 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15937 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15939 vty_out(vty
, "%% Invalid route type\n");
15940 return CMD_WARNING_CONFIG_FAILED
;
15942 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15944 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15946 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15947 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
15949 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15952 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
15953 bgp_redistribute_ipv6_metric_rmap_cmd
,
15954 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15955 "Redistribute information from another routing protocol\n"
15956 FRR_IP6_REDIST_HELP_STR_BGPD
15957 "Metric for redistributed routes\n"
15959 "Route map reference\n"
15960 "Pointer to route-map entries\n")
15962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15963 int idx_protocol
= 1;
15964 int idx_number
= 3;
15968 struct bgp_redist
*red
;
15970 struct route_map
*route_map
=
15971 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15973 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15975 vty_out(vty
, "%% Invalid route type\n");
15976 return CMD_WARNING_CONFIG_FAILED
;
15978 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15980 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15981 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
15984 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15985 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15988 DEFUN (no_bgp_redistribute_ipv6
,
15989 no_bgp_redistribute_ipv6_cmd
,
15990 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15992 "Redistribute information from another routing protocol\n"
15993 FRR_IP6_REDIST_HELP_STR_BGPD
15994 "Metric for redistributed routes\n"
15996 "Route map reference\n"
15997 "Pointer to route-map entries\n")
15999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16000 int idx_protocol
= 2;
16003 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16005 vty_out(vty
, "%% Invalid route type\n");
16006 return CMD_WARNING_CONFIG_FAILED
;
16009 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16012 /* Neighbor update tcp-mss. */
16013 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16014 const char *tcp_mss_str
)
16017 uint32_t tcp_mss_val
= 0;
16019 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16021 return CMD_WARNING_CONFIG_FAILED
;
16024 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16025 peer_tcp_mss_set(peer
, tcp_mss_val
);
16027 peer_tcp_mss_unset(peer
);
16030 return CMD_SUCCESS
;
16033 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16034 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16035 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16036 "TCP max segment size\n"
16039 int peer_index
= 1;
16043 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16044 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16045 argv
[mss_index
]->arg
);
16048 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16049 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16050 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16051 "TCP max segment size\n"
16054 int peer_index
= 2;
16057 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16058 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16061 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16062 afi_t afi
, safi_t safi
)
16066 /* Unicast redistribution only. */
16067 if (safi
!= SAFI_UNICAST
)
16070 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16071 /* Redistribute BGP does not make sense. */
16072 if (i
!= ZEBRA_ROUTE_BGP
) {
16073 struct list
*red_list
;
16074 struct listnode
*node
;
16075 struct bgp_redist
*red
;
16077 red_list
= bgp
->redist
[afi
][i
];
16081 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16082 /* "redistribute" configuration. */
16083 vty_out(vty
, " redistribute %s",
16084 zebra_route_string(i
));
16086 vty_out(vty
, " %d", red
->instance
);
16087 if (red
->redist_metric_flag
)
16088 vty_out(vty
, " metric %u",
16089 red
->redist_metric
);
16090 if (red
->rmap
.name
)
16091 vty_out(vty
, " route-map %s",
16093 vty_out(vty
, "\n");
16099 /* peer-group helpers for config-write */
16101 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16103 if (!peer_group_active(peer
)) {
16104 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16105 return !CHECK_FLAG(peer
->flags
, flag
);
16107 return !!CHECK_FLAG(peer
->flags
, flag
);
16110 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16113 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16116 if (!peer_group_active(peer
)) {
16117 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16118 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16120 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16123 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16126 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16127 uint8_t type
, int direct
)
16129 struct bgp_filter
*filter
;
16131 if (peer_group_active(peer
))
16132 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16135 filter
= &peer
->filter
[afi
][safi
];
16137 case PEER_FT_DISTRIBUTE_LIST
:
16138 return !!(filter
->dlist
[direct
].name
);
16139 case PEER_FT_FILTER_LIST
:
16140 return !!(filter
->aslist
[direct
].name
);
16141 case PEER_FT_PREFIX_LIST
:
16142 return !!(filter
->plist
[direct
].name
);
16143 case PEER_FT_ROUTE_MAP
:
16144 return !!(filter
->map
[direct
].name
);
16145 case PEER_FT_UNSUPPRESS_MAP
:
16146 return !!(filter
->usmap
.name
);
16147 case PEER_FT_ADVERTISE_MAP
:
16148 return !!(filter
->advmap
.aname
16149 && ((filter
->advmap
.condition
== direct
)
16150 && filter
->advmap
.cname
));
16156 /* Return true if the addpath type is set for peer and different from
16159 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16162 enum bgp_addpath_strat type
, g_type
;
16164 type
= peer
->addpath_type
[afi
][safi
];
16166 if (type
!= BGP_ADDPATH_NONE
) {
16167 if (peer_group_active(peer
)) {
16168 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16170 if (type
!= g_type
)
16182 /* This is part of the address-family block (unicast only) */
16183 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16187 uint32_t tovpn_sid_index
= 0;
16189 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16190 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16191 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16192 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16193 bgp
->vpn_policy
[afi
]
16194 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16196 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16197 bgp
->vpn_policy
[afi
]
16198 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16200 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16201 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16202 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16203 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16206 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16207 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16209 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16212 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16213 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16214 bgp
->vpn_policy
[afi
].tovpn_label
);
16218 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16219 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16220 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16221 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16222 } else if (tovpn_sid_index
!= 0) {
16223 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16227 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16228 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16229 char buf
[RD_ADDRSTRLEN
];
16230 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16231 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16234 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16235 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16237 char buf
[PREFIX_STRLEN
];
16238 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16239 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16242 vty_out(vty
, "%*snexthop vpn export %s\n",
16246 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16247 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16249 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16250 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16252 char *b
= ecommunity_ecom2str(
16253 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16254 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16255 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16256 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16258 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16259 char *b
= ecommunity_ecom2str(
16260 bgp
->vpn_policy
[afi
]
16261 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16262 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16263 ECOMMUNITY_ROUTE_TARGET
);
16264 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16265 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16267 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16268 char *b
= ecommunity_ecom2str(
16269 bgp
->vpn_policy
[afi
]
16270 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16271 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16272 ECOMMUNITY_ROUTE_TARGET
);
16273 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16274 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16278 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16279 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16280 bgp
->vpn_policy
[afi
]
16281 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16283 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16284 char *b
= ecommunity_ecom2str(
16285 bgp
->vpn_policy
[afi
]
16286 .import_redirect_rtlist
,
16287 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16288 ECOMMUNITY_ROUTE_TARGET
);
16290 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16291 != ECOMMUNITY_SIZE
)
16292 vty_out(vty
, "%*srt6 redirect import %s\n",
16295 vty_out(vty
, "%*srt redirect import %s\n",
16297 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16301 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16302 afi_t afi
, safi_t safi
)
16304 struct bgp_filter
*filter
;
16308 filter
= &peer
->filter
[afi
][safi
];
16310 /* distribute-list. */
16311 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16313 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16314 filter
->dlist
[FILTER_IN
].name
);
16316 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16318 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16319 filter
->dlist
[FILTER_OUT
].name
);
16322 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16324 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16325 filter
->plist
[FILTER_IN
].name
);
16327 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16329 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16330 filter
->plist
[FILTER_OUT
].name
);
16333 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16334 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16335 filter
->map
[RMAP_IN
].name
);
16337 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16339 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16340 filter
->map
[RMAP_OUT
].name
);
16342 /* unsuppress-map */
16343 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16344 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16345 filter
->usmap
.name
);
16347 /* advertise-map : always applied in OUT direction*/
16348 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16349 CONDITION_NON_EXIST
))
16351 " neighbor %s advertise-map %s non-exist-map %s\n",
16352 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16354 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16356 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16357 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16360 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16362 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16363 filter
->aslist
[FILTER_IN
].name
);
16365 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16367 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16368 filter
->aslist
[FILTER_OUT
].name
);
16371 /* BGP peer configuration display function. */
16372 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16375 struct peer
*g_peer
= NULL
;
16376 char buf
[SU_ADDRSTRLEN
];
16378 int if_pg_printed
= false;
16379 int if_ras_printed
= false;
16381 /* Skip dynamic neighbors. */
16382 if (peer_dynamic_neighbor(peer
))
16386 addr
= peer
->conf_if
;
16390 /************************************
16391 ****** Global to the neighbor ******
16392 ************************************/
16393 if (peer
->conf_if
) {
16394 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16395 vty_out(vty
, " neighbor %s interface v6only", addr
);
16397 vty_out(vty
, " neighbor %s interface", addr
);
16399 if (peer_group_active(peer
)) {
16400 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16401 if_pg_printed
= true;
16402 } else if (peer
->as_type
== AS_SPECIFIED
) {
16403 vty_out(vty
, " remote-as %u", peer
->as
);
16404 if_ras_printed
= true;
16405 } else if (peer
->as_type
== AS_INTERNAL
) {
16406 vty_out(vty
, " remote-as internal");
16407 if_ras_printed
= true;
16408 } else if (peer
->as_type
== AS_EXTERNAL
) {
16409 vty_out(vty
, " remote-as external");
16410 if_ras_printed
= true;
16413 vty_out(vty
, "\n");
16416 /* remote-as and peer-group */
16417 /* peer is a member of a peer-group */
16418 if (peer_group_active(peer
)) {
16419 g_peer
= peer
->group
->conf
;
16421 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16422 if (peer
->as_type
== AS_SPECIFIED
) {
16423 vty_out(vty
, " neighbor %s remote-as %u\n",
16425 } else if (peer
->as_type
== AS_INTERNAL
) {
16427 " neighbor %s remote-as internal\n",
16429 } else if (peer
->as_type
== AS_EXTERNAL
) {
16431 " neighbor %s remote-as external\n",
16436 /* For swpX peers we displayed the peer-group
16437 * via 'neighbor swpX interface peer-group PGNAME' */
16438 if (!if_pg_printed
)
16439 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16440 peer
->group
->name
);
16443 /* peer is NOT a member of a peer-group */
16445 /* peer is a peer-group, declare the peer-group */
16446 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16447 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16450 if (!if_ras_printed
) {
16451 if (peer
->as_type
== AS_SPECIFIED
) {
16452 vty_out(vty
, " neighbor %s remote-as %u\n",
16454 } else if (peer
->as_type
== AS_INTERNAL
) {
16456 " neighbor %s remote-as internal\n",
16458 } else if (peer
->as_type
== AS_EXTERNAL
) {
16460 " neighbor %s remote-as external\n",
16467 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16468 vty_out(vty
, " neighbor %s local-as %u", addr
,
16469 peer
->change_local_as
);
16470 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16471 vty_out(vty
, " no-prepend");
16472 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16473 vty_out(vty
, " replace-as");
16474 vty_out(vty
, "\n");
16479 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16483 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16484 if (peer
->tx_shutdown_message
)
16485 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16486 peer
->tx_shutdown_message
);
16488 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16491 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16492 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16493 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16496 if (peer
->bfd_config
)
16497 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16500 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16501 vty_out(vty
, " neighbor %s password %s\n", addr
,
16504 /* neighbor solo */
16505 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16506 if (!peer_group_active(peer
)) {
16507 vty_out(vty
, " neighbor %s solo\n", addr
);
16512 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16513 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16516 /* Local interface name */
16517 if (peer
->ifname
) {
16518 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16521 /* TCP max segment size */
16522 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16523 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16526 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16527 vty_out(vty
, " neighbor %s passive\n", addr
);
16529 /* ebgp-multihop */
16530 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16531 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16532 && peer
->ttl
== MAXTTL
)) {
16533 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16534 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16539 /* ttl-security hops */
16540 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16541 if (!peer_group_active(peer
)
16542 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16543 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16544 addr
, peer
->gtsm_hops
);
16548 /* disable-connected-check */
16549 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16550 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16552 /* link-bw-encoding-ieee */
16553 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16554 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16557 /* extended-optional-parameters */
16558 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16559 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16562 /* enforce-first-as */
16563 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16564 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16566 /* update-source */
16567 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16568 if (peer
->update_source
)
16569 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16570 sockunion2str(peer
->update_source
, buf
,
16572 else if (peer
->update_if
)
16573 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16577 /* advertisement-interval */
16578 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16579 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16583 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16584 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16585 peer
->keepalive
, peer
->holdtime
);
16587 /* timers connect */
16588 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16589 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16591 /* need special-case handling for changed default values due to
16592 * config profile / version (because there is no "timers bgp connect"
16593 * command, we need to save this per-peer :/)
16595 else if (!peer_group_active(peer
) && !peer
->connect
&&
16596 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16597 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16598 peer
->bgp
->default_connect_retry
);
16600 /* timers delayopen */
16601 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16602 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16604 /* Save config even though flag is not set if default values have been
16607 else if (!peer_group_active(peer
) && !peer
->delayopen
16608 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16609 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16610 peer
->bgp
->default_delayopen
);
16612 /* capability dynamic */
16613 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16614 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16616 /* capability extended-nexthop */
16617 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16618 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
))
16620 " no neighbor %s capability extended-nexthop\n",
16622 else if (!peer
->conf_if
)
16624 " neighbor %s capability extended-nexthop\n",
16628 /* dont-capability-negotiation */
16629 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16630 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16632 /* override-capability */
16633 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16634 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16636 /* strict-capability-match */
16637 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16638 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16640 /* Sender side AS path loop detection. */
16641 if (peer
->as_path_loop_detection
)
16642 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16645 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16646 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16648 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16649 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16651 " neighbor %s graceful-restart-helper\n", addr
);
16652 } else if (CHECK_FLAG(
16653 peer
->peer_gr_new_status_flag
,
16654 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16656 " neighbor %s graceful-restart\n", addr
);
16658 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16659 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16661 peer
->peer_gr_new_status_flag
,
16662 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16663 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16669 /* BGP peer configuration display function. */
16670 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16671 struct peer
*peer
, afi_t afi
, safi_t safi
)
16673 struct peer
*g_peer
= NULL
;
16675 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16677 /* Skip dynamic neighbors. */
16678 if (peer_dynamic_neighbor(peer
))
16682 addr
= peer
->conf_if
;
16686 /************************************
16687 ****** Per AF to the neighbor ******
16688 ************************************/
16689 if (peer_group_active(peer
)) {
16690 g_peer
= peer
->group
->conf
;
16692 /* If the peer-group is active but peer is not, print a 'no
16694 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16695 vty_out(vty
, " no neighbor %s activate\n", addr
);
16698 /* If the peer-group is not active but peer is, print an
16700 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16701 vty_out(vty
, " neighbor %s activate\n", addr
);
16704 if (peer
->afc
[afi
][safi
]) {
16705 if (safi
== SAFI_ENCAP
)
16706 vty_out(vty
, " neighbor %s activate\n", addr
);
16707 else if (!bgp
->default_af
[afi
][safi
])
16708 vty_out(vty
, " neighbor %s activate\n", addr
);
16710 if (bgp
->default_af
[afi
][safi
])
16711 vty_out(vty
, " no neighbor %s activate\n",
16716 /* addpath TX knobs */
16717 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16718 switch (peer
->addpath_type
[afi
][safi
]) {
16719 case BGP_ADDPATH_ALL
:
16720 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16723 case BGP_ADDPATH_BEST_PER_AS
:
16725 " neighbor %s addpath-tx-bestpath-per-AS\n",
16728 case BGP_ADDPATH_MAX
:
16729 case BGP_ADDPATH_NONE
:
16734 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
16735 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
16737 /* ORF capability. */
16738 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16739 || peergroup_af_flag_check(peer
, afi
, safi
,
16740 PEER_FLAG_ORF_PREFIX_RM
)) {
16741 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16743 if (peergroup_af_flag_check(peer
, afi
, safi
,
16744 PEER_FLAG_ORF_PREFIX_SM
)
16745 && peergroup_af_flag_check(peer
, afi
, safi
,
16746 PEER_FLAG_ORF_PREFIX_RM
))
16747 vty_out(vty
, " both");
16748 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16749 PEER_FLAG_ORF_PREFIX_SM
))
16750 vty_out(vty
, " send");
16752 vty_out(vty
, " receive");
16753 vty_out(vty
, "\n");
16756 /* Route reflector client. */
16757 if (peergroup_af_flag_check(peer
, afi
, safi
,
16758 PEER_FLAG_REFLECTOR_CLIENT
)) {
16759 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16762 /* next-hop-self force */
16763 if (peergroup_af_flag_check(peer
, afi
, safi
,
16764 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16765 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16768 /* next-hop-self */
16769 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16770 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16773 /* remove-private-AS */
16774 if (peergroup_af_flag_check(peer
, afi
, safi
,
16775 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16776 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16780 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16781 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16782 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16786 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16787 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16788 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16791 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16792 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16793 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16797 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16798 vty_out(vty
, " neighbor %s as-override\n", addr
);
16801 /* send-community print. */
16802 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16803 PEER_FLAG_SEND_COMMUNITY
);
16804 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16805 PEER_FLAG_SEND_EXT_COMMUNITY
);
16806 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16807 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16809 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16810 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16813 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16816 " no neighbor %s send-community extended\n",
16820 vty_out(vty
, " no neighbor %s send-community large\n",
16824 /* Default information */
16825 if (peergroup_af_flag_check(peer
, afi
, safi
,
16826 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16827 vty_out(vty
, " neighbor %s default-originate", addr
);
16829 if (peer
->default_rmap
[afi
][safi
].name
)
16830 vty_out(vty
, " route-map %s",
16831 peer
->default_rmap
[afi
][safi
].name
);
16833 vty_out(vty
, "\n");
16836 /* Soft reconfiguration inbound. */
16837 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16838 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16842 /* maximum-prefix. */
16843 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16844 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16845 peer
->pmax
[afi
][safi
]);
16847 if (peer
->pmax_threshold
[afi
][safi
]
16848 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16849 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16850 if (peer_af_flag_check(peer
, afi
, safi
,
16851 PEER_FLAG_MAX_PREFIX_WARNING
))
16852 vty_out(vty
, " warning-only");
16853 if (peer
->pmax_restart
[afi
][safi
])
16854 vty_out(vty
, " restart %u",
16855 peer
->pmax_restart
[afi
][safi
]);
16856 if (peer_af_flag_check(peer
, afi
, safi
,
16857 PEER_FLAG_MAX_PREFIX_FORCE
))
16858 vty_out(vty
, " force");
16860 vty_out(vty
, "\n");
16863 /* maximum-prefix-out */
16864 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16865 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16866 addr
, peer
->pmax_out
[afi
][safi
]);
16868 /* Route server client. */
16869 if (peergroup_af_flag_check(peer
, afi
, safi
,
16870 PEER_FLAG_RSERVER_CLIENT
)) {
16871 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16874 /* Nexthop-local unchanged. */
16875 if (peergroup_af_flag_check(peer
, afi
, safi
,
16876 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16877 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16880 /* allowas-in <1-10> */
16881 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16882 if (peer_af_flag_check(peer
, afi
, safi
,
16883 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16884 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16885 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16886 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16888 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16889 peer
->allowas_in
[afi
][safi
]);
16894 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16895 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16896 peer
->weight
[afi
][safi
]);
16899 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16901 /* atribute-unchanged. */
16902 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16903 || (safi
!= SAFI_EVPN
16904 && peer_af_flag_check(peer
, afi
, safi
,
16905 PEER_FLAG_NEXTHOP_UNCHANGED
))
16906 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16908 if (!peer_group_active(peer
)
16909 || peergroup_af_flag_check(peer
, afi
, safi
,
16910 PEER_FLAG_AS_PATH_UNCHANGED
)
16911 || peergroup_af_flag_check(peer
, afi
, safi
,
16912 PEER_FLAG_NEXTHOP_UNCHANGED
)
16913 || peergroup_af_flag_check(peer
, afi
, safi
,
16914 PEER_FLAG_MED_UNCHANGED
)) {
16917 " neighbor %s attribute-unchanged%s%s%s\n",
16919 peer_af_flag_check(peer
, afi
, safi
,
16920 PEER_FLAG_AS_PATH_UNCHANGED
)
16923 peer_af_flag_check(peer
, afi
, safi
,
16924 PEER_FLAG_NEXTHOP_UNCHANGED
)
16927 peer_af_flag_check(peer
, afi
, safi
,
16928 PEER_FLAG_MED_UNCHANGED
)
16935 /* Address family based peer configuration display. */
16936 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16940 struct peer_group
*group
;
16941 struct listnode
*node
, *nnode
;
16944 vty_frame(vty
, " !\n address-family ");
16945 if (afi
== AFI_IP
) {
16946 if (safi
== SAFI_UNICAST
)
16947 vty_frame(vty
, "ipv4 unicast");
16948 else if (safi
== SAFI_LABELED_UNICAST
)
16949 vty_frame(vty
, "ipv4 labeled-unicast");
16950 else if (safi
== SAFI_MULTICAST
)
16951 vty_frame(vty
, "ipv4 multicast");
16952 else if (safi
== SAFI_MPLS_VPN
)
16953 vty_frame(vty
, "ipv4 vpn");
16954 else if (safi
== SAFI_ENCAP
)
16955 vty_frame(vty
, "ipv4 encap");
16956 else if (safi
== SAFI_FLOWSPEC
)
16957 vty_frame(vty
, "ipv4 flowspec");
16958 } else if (afi
== AFI_IP6
) {
16959 if (safi
== SAFI_UNICAST
)
16960 vty_frame(vty
, "ipv6 unicast");
16961 else if (safi
== SAFI_LABELED_UNICAST
)
16962 vty_frame(vty
, "ipv6 labeled-unicast");
16963 else if (safi
== SAFI_MULTICAST
)
16964 vty_frame(vty
, "ipv6 multicast");
16965 else if (safi
== SAFI_MPLS_VPN
)
16966 vty_frame(vty
, "ipv6 vpn");
16967 else if (safi
== SAFI_ENCAP
)
16968 vty_frame(vty
, "ipv6 encap");
16969 else if (safi
== SAFI_FLOWSPEC
)
16970 vty_frame(vty
, "ipv6 flowspec");
16971 } else if (afi
== AFI_L2VPN
) {
16972 if (safi
== SAFI_EVPN
)
16973 vty_frame(vty
, "l2vpn evpn");
16975 vty_frame(vty
, "\n");
16977 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16979 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16981 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16983 /* BGP flag dampening. */
16984 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16985 bgp_config_write_damp(vty
, afi
, safi
);
16987 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16988 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16990 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16991 /* Do not display doppelganger peers */
16992 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16993 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16996 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16997 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16999 if (safi
== SAFI_EVPN
)
17000 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17002 if (safi
== SAFI_FLOWSPEC
)
17003 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17005 if (safi
== SAFI_UNICAST
) {
17006 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17007 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17008 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17010 vty_out(vty
, " export vpn\n");
17012 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17013 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17015 vty_out(vty
, " import vpn\n");
17017 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17018 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17021 for (ALL_LIST_ELEMENTS_RO(
17022 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17024 vty_out(vty
, " import vrf %s\n", name
);
17028 vty_endframe(vty
, " exit-address-family\n");
17031 int bgp_config_write(struct vty
*vty
)
17034 struct peer_group
*group
;
17036 struct listnode
*node
, *nnode
;
17037 struct listnode
*mnode
, *mnnode
;
17041 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17042 vty_out(vty
, "bgp route-map delay-timer %u\n",
17043 bm
->rmap_update_timer
);
17045 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17046 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17047 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17048 vty_out(vty
, " %d", bm
->v_establish_wait
);
17049 vty_out(vty
, "\n");
17052 if (bm
->wait_for_fib
)
17053 vty_out(vty
, "bgp suppress-fib-pending\n");
17055 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17056 vty_out(vty
, "bgp graceful-shutdown\n");
17058 /* No-RIB (Zebra) option flag configuration */
17059 if (bgp_option_check(BGP_OPT_NO_FIB
))
17060 vty_out(vty
, "bgp no-rib\n");
17062 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17063 vty_out(vty
, "bgp send-extra-data zebra\n");
17065 /* BGP configuration. */
17066 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17068 /* skip all auto created vrf as they dont have user config */
17069 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17072 /* Router bgp ASN */
17073 vty_out(vty
, "router bgp %u", bgp
->as
);
17076 vty_out(vty
, " %s %s",
17077 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17078 ? "view" : "vrf", bgp
->name
);
17079 vty_out(vty
, "\n");
17081 /* BGP fast-external-failover. */
17082 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17083 vty_out(vty
, " no bgp fast-external-failover\n");
17085 /* BGP router ID. */
17086 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17087 vty_out(vty
, " bgp router-id %pI4\n",
17088 &bgp
->router_id_static
);
17090 /* Suppress fib pending */
17091 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17092 vty_out(vty
, " bgp suppress-fib-pending\n");
17094 /* BGP log-neighbor-changes. */
17095 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17096 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17097 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17098 CHECK_FLAG(bgp
->flags
,
17099 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17103 /* BGP configuration. */
17104 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17105 vty_out(vty
, " bgp always-compare-med\n");
17107 /* RFC8212 default eBGP policy. */
17108 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17109 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17110 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17111 CHECK_FLAG(bgp
->flags
,
17112 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17116 /* draft-ietf-idr-deprecate-as-set-confed-set */
17117 if (bgp
->reject_as_sets
)
17118 vty_out(vty
, " bgp reject-as-sets\n");
17120 /* Suppress duplicate updates if the route actually not changed
17122 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17123 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17124 vty_out(vty
, " %sbgp suppress-duplicates\n",
17125 CHECK_FLAG(bgp
->flags
,
17126 BGP_FLAG_SUPPRESS_DUPLICATES
)
17130 /* BGP default <afi>-<safi> */
17131 FOREACH_AFI_SAFI (afi
, safi
) {
17132 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17133 if (!bgp
->default_af
[afi
][safi
])
17134 vty_out(vty
, " no bgp default %s\n",
17135 get_bgp_default_af_flag(afi
,
17137 } else if (bgp
->default_af
[afi
][safi
])
17138 vty_out(vty
, " bgp default %s\n",
17139 get_bgp_default_af_flag(afi
, safi
));
17142 /* BGP default local-preference. */
17143 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17144 vty_out(vty
, " bgp default local-preference %u\n",
17145 bgp
->default_local_pref
);
17147 /* BGP default show-hostname */
17148 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17149 != SAVE_BGP_SHOW_HOSTNAME
)
17150 vty_out(vty
, " %sbgp default show-hostname\n",
17151 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17155 /* BGP default show-nexthop-hostname */
17156 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17157 != SAVE_BGP_SHOW_HOSTNAME
)
17158 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17159 CHECK_FLAG(bgp
->flags
,
17160 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17164 /* BGP default subgroup-pkt-queue-max. */
17165 if (bgp
->default_subgroup_pkt_queue_max
17166 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17167 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17168 bgp
->default_subgroup_pkt_queue_max
);
17170 /* BGP client-to-client reflection. */
17171 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17172 vty_out(vty
, " no bgp client-to-client reflection\n");
17174 /* BGP cluster ID. */
17175 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17176 vty_out(vty
, " bgp cluster-id %pI4\n",
17179 /* Disable ebgp connected nexthop check */
17180 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17182 " bgp disable-ebgp-connected-route-check\n");
17184 /* Confederation identifier*/
17185 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17186 vty_out(vty
, " bgp confederation identifier %u\n",
17189 /* Confederation peer */
17190 if (bgp
->confed_peers_cnt
> 0) {
17193 vty_out(vty
, " bgp confederation peers");
17195 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17196 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17198 vty_out(vty
, "\n");
17201 /* BGP deterministic-med. */
17202 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17203 != SAVE_BGP_DETERMINISTIC_MED
)
17204 vty_out(vty
, " %sbgp deterministic-med\n",
17205 CHECK_FLAG(bgp
->flags
,
17206 BGP_FLAG_DETERMINISTIC_MED
)
17210 /* BGP update-delay. */
17211 bgp_config_write_update_delay(vty
, bgp
);
17213 if (bgp
->v_maxmed_onstartup
17214 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17215 vty_out(vty
, " bgp max-med on-startup %u",
17216 bgp
->v_maxmed_onstartup
);
17217 if (bgp
->maxmed_onstartup_value
17218 != BGP_MAXMED_VALUE_DEFAULT
)
17219 vty_out(vty
, " %u",
17220 bgp
->maxmed_onstartup_value
);
17221 vty_out(vty
, "\n");
17223 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17224 vty_out(vty
, " bgp max-med administrative");
17225 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17226 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17227 vty_out(vty
, "\n");
17231 bgp_config_write_wpkt_quanta(vty
, bgp
);
17233 bgp_config_write_rpkt_quanta(vty
, bgp
);
17235 /* coalesce time */
17236 bgp_config_write_coalesce_time(vty
, bgp
);
17238 /* BGP per-instance graceful-shutdown */
17239 /* BGP-wide settings and per-instance settings are mutually
17242 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17243 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17244 vty_out(vty
, " bgp graceful-shutdown\n");
17246 /* Long-lived Graceful Restart */
17247 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17249 " bgp long-lived-graceful-restart stale-time %u\n",
17250 bgp
->llgr_stale_time
);
17252 /* BGP graceful-restart. */
17253 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17255 " bgp graceful-restart stalepath-time %u\n",
17256 bgp
->stalepath_time
);
17258 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17259 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17260 bgp
->restart_time
);
17262 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17264 " bgp graceful-restart select-defer-time %u\n",
17265 bgp
->select_defer_time
);
17267 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17268 vty_out(vty
, " bgp graceful-restart\n");
17270 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17271 vty_out(vty
, " bgp graceful-restart-disable\n");
17273 /* BGP graceful-restart Preserve State F bit. */
17274 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17276 " bgp graceful-restart preserve-fw-state\n");
17278 /* Stale timer for RIB */
17279 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17281 " bgp graceful-restart rib-stale-time %u\n",
17282 bgp
->rib_stale_time
);
17284 /* BGP bestpath method. */
17285 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17286 vty_out(vty
, " bgp bestpath as-path ignore\n");
17287 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17288 vty_out(vty
, " bgp bestpath as-path confed\n");
17290 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17291 if (CHECK_FLAG(bgp
->flags
,
17292 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17294 " bgp bestpath as-path multipath-relax as-set\n");
17297 " bgp bestpath as-path multipath-relax\n");
17301 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17303 " bgp route-reflector allow-outbound-policy\n");
17305 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17306 vty_out(vty
, " bgp bestpath compare-routerid\n");
17307 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17308 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17309 vty_out(vty
, " bgp bestpath med");
17310 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17311 vty_out(vty
, " confed");
17312 if (CHECK_FLAG(bgp
->flags
,
17313 BGP_FLAG_MED_MISSING_AS_WORST
))
17314 vty_out(vty
, " missing-as-worst");
17315 vty_out(vty
, "\n");
17318 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17320 " bgp bestpath peer-type multipath-relax\n");
17322 /* Link bandwidth handling. */
17323 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17324 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17325 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17326 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17327 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17328 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17330 /* BGP network import check. */
17331 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17332 != SAVE_BGP_IMPORT_CHECK
)
17333 vty_out(vty
, " %sbgp network import-check\n",
17334 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17338 /* BGP timers configuration. */
17339 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17340 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17341 vty_out(vty
, " timers bgp %u %u\n",
17342 bgp
->default_keepalive
, bgp
->default_holdtime
);
17344 /* BGP minimum holdtime configuration. */
17345 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17346 && bgp
->default_min_holdtime
!= 0)
17347 vty_out(vty
, " bgp minimum-holdtime %u\n",
17348 bgp
->default_min_holdtime
);
17350 /* Conditional advertisement timer configuration */
17351 if (bgp
->condition_check_period
17352 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17354 " bgp conditional-advertisement timer %u\n",
17355 bgp
->condition_check_period
);
17358 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17359 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17362 /* Normal neighbor configuration. */
17363 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17364 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17365 bgp_config_write_peer_global(vty
, bgp
, peer
);
17368 /* listen range and limit for dynamic BGP neighbors */
17369 bgp_config_write_listen(vty
, bgp
);
17372 * BGP default autoshutdown neighbors
17374 * This must be placed after any peer and peer-group
17375 * configuration, to avoid setting all peers to shutdown after
17376 * a daemon restart, which is undesired behavior. (see #2286)
17378 if (bgp
->autoshutdown
)
17379 vty_out(vty
, " bgp default shutdown\n");
17381 /* BGP instance administrative shutdown */
17382 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17383 vty_out(vty
, " bgp shutdown\n");
17385 if (bgp
->fast_convergence
)
17386 vty_out(vty
, " bgp fast-convergence\n");
17388 if (bgp
->srv6_enabled
) {
17389 vty_frame(vty
, " !\n segment-routing srv6\n");
17390 if (strlen(bgp
->srv6_locator_name
))
17391 vty_out(vty
, " locator %s\n",
17392 bgp
->srv6_locator_name
);
17393 vty_endframe(vty
, " exit\n");
17397 /* IPv4 unicast configuration. */
17398 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17400 /* IPv4 multicast configuration. */
17401 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17403 /* IPv4 labeled-unicast configuration. */
17404 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17406 /* IPv4 VPN configuration. */
17407 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17409 /* ENCAPv4 configuration. */
17410 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17412 /* FLOWSPEC v4 configuration. */
17413 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17415 /* IPv6 unicast configuration. */
17416 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17418 /* IPv6 multicast configuration. */
17419 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17421 /* IPv6 labeled-unicast configuration. */
17422 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17423 SAFI_LABELED_UNICAST
);
17425 /* IPv6 VPN configuration. */
17426 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17428 /* ENCAPv6 configuration. */
17429 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17431 /* FLOWSPEC v6 configuration. */
17432 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17434 /* EVPN configuration. */
17435 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17437 hook_call(bgp_inst_config_write
, bgp
, vty
);
17439 #ifdef ENABLE_BGP_VNC
17440 bgp_rfapi_cfg_write(vty
, bgp
);
17443 vty_out(vty
, "exit\n");
17444 vty_out(vty
, "!\n");
17450 /* BGP node structure. */
17451 static struct cmd_node bgp_node
= {
17454 .parent_node
= CONFIG_NODE
,
17455 .prompt
= "%s(config-router)# ",
17456 .config_write
= bgp_config_write
,
17459 static struct cmd_node bgp_ipv4_unicast_node
= {
17460 .name
= "bgp ipv4 unicast",
17461 .node
= BGP_IPV4_NODE
,
17462 .parent_node
= BGP_NODE
,
17463 .prompt
= "%s(config-router-af)# ",
17467 static struct cmd_node bgp_ipv4_multicast_node
= {
17468 .name
= "bgp ipv4 multicast",
17469 .node
= BGP_IPV4M_NODE
,
17470 .parent_node
= BGP_NODE
,
17471 .prompt
= "%s(config-router-af)# ",
17475 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17476 .name
= "bgp ipv4 labeled unicast",
17477 .node
= BGP_IPV4L_NODE
,
17478 .parent_node
= BGP_NODE
,
17479 .prompt
= "%s(config-router-af)# ",
17483 static struct cmd_node bgp_ipv6_unicast_node
= {
17484 .name
= "bgp ipv6 unicast",
17485 .node
= BGP_IPV6_NODE
,
17486 .parent_node
= BGP_NODE
,
17487 .prompt
= "%s(config-router-af)# ",
17491 static struct cmd_node bgp_ipv6_multicast_node
= {
17492 .name
= "bgp ipv6 multicast",
17493 .node
= BGP_IPV6M_NODE
,
17494 .parent_node
= BGP_NODE
,
17495 .prompt
= "%s(config-router-af)# ",
17499 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17500 .name
= "bgp ipv6 labeled unicast",
17501 .node
= BGP_IPV6L_NODE
,
17502 .parent_node
= BGP_NODE
,
17503 .prompt
= "%s(config-router-af)# ",
17507 static struct cmd_node bgp_vpnv4_node
= {
17508 .name
= "bgp vpnv4",
17509 .node
= BGP_VPNV4_NODE
,
17510 .parent_node
= BGP_NODE
,
17511 .prompt
= "%s(config-router-af)# ",
17515 static struct cmd_node bgp_vpnv6_node
= {
17516 .name
= "bgp vpnv6",
17517 .node
= BGP_VPNV6_NODE
,
17518 .parent_node
= BGP_NODE
,
17519 .prompt
= "%s(config-router-af-vpnv6)# ",
17523 static struct cmd_node bgp_evpn_node
= {
17524 .name
= "bgp evpn",
17525 .node
= BGP_EVPN_NODE
,
17526 .parent_node
= BGP_NODE
,
17527 .prompt
= "%s(config-router-evpn)# ",
17531 static struct cmd_node bgp_evpn_vni_node
= {
17532 .name
= "bgp evpn vni",
17533 .node
= BGP_EVPN_VNI_NODE
,
17534 .parent_node
= BGP_EVPN_NODE
,
17535 .prompt
= "%s(config-router-af-vni)# ",
17538 static struct cmd_node bgp_flowspecv4_node
= {
17539 .name
= "bgp ipv4 flowspec",
17540 .node
= BGP_FLOWSPECV4_NODE
,
17541 .parent_node
= BGP_NODE
,
17542 .prompt
= "%s(config-router-af)# ",
17546 static struct cmd_node bgp_flowspecv6_node
= {
17547 .name
= "bgp ipv6 flowspec",
17548 .node
= BGP_FLOWSPECV6_NODE
,
17549 .parent_node
= BGP_NODE
,
17550 .prompt
= "%s(config-router-af-vpnv6)# ",
17554 static struct cmd_node bgp_srv6_node
= {
17555 .name
= "bgp srv6",
17556 .node
= BGP_SRV6_NODE
,
17557 .parent_node
= BGP_NODE
,
17558 .prompt
= "%s(config-router-srv6)# ",
17561 static void community_list_vty(void);
17563 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17566 struct peer_group
*group
;
17567 struct listnode
*lnbgp
, *lnpeer
;
17569 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17570 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17572 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17576 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17580 struct listnode
*lnbgp
, *lnpeer
;
17582 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17583 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17584 /* only provide suggestions on the appropriate input
17586 * they'll otherwise show up multiple times */
17587 enum cmd_token_type match_type
;
17588 char *name
= peer
->host
;
17590 if (peer
->conf_if
) {
17591 match_type
= VARIABLE_TKN
;
17592 name
= peer
->conf_if
;
17593 } else if (strchr(peer
->host
, ':'))
17594 match_type
= IPV6_TKN
;
17596 match_type
= IPV4_TKN
;
17598 if (token
->type
!= match_type
)
17601 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17606 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17608 bgp_ac_peer(comps
, token
);
17610 if (token
->type
== VARIABLE_TKN
)
17611 bgp_ac_peergroup(comps
, token
);
17614 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17615 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17616 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17617 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17618 {.completions
= NULL
}};
17620 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17621 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17622 {.completions
= NULL
} };
17624 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
17626 static struct thread
*t_bgp_cfg
;
17628 bool bgp_config_inprocess(void)
17630 return thread_is_scheduled(t_bgp_cfg
);
17633 static void bgp_config_finish(struct thread
*t
)
17635 struct listnode
*node
;
17638 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
17639 hook_call(bgp_config_end
, bgp
);
17642 static void bgp_config_start(void)
17644 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
17645 THREAD_OFF(t_bgp_cfg
);
17646 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17647 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
17650 /* When we receive a hook the configuration is read,
17651 * we start a timer to make sure we postpone sending
17652 * EoR before route-maps are processed.
17653 * This is especially valid if using `bgp route-map delay-timer`.
17655 static void bgp_config_end(void)
17657 #define BGP_POST_CONFIG_DELAY_SECONDS 1
17658 uint32_t bgp_post_config_delay
=
17659 thread_is_scheduled(bm
->t_rmap_update
)
17660 ? thread_timer_remain_second(bm
->t_rmap_update
)
17661 : BGP_POST_CONFIG_DELAY_SECONDS
;
17663 /* If BGP config processing thread isn't running, then
17664 * we can return and rely it's properly handled.
17666 if (!bgp_config_inprocess())
17669 THREAD_OFF(t_bgp_cfg
);
17671 /* Start a new timer to make sure we don't send EoR
17672 * before route-maps are processed.
17674 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
17675 bgp_post_config_delay
, &t_bgp_cfg
);
17678 void bgp_vty_init(void)
17680 cmd_variable_handler_register(bgp_var_neighbor
);
17681 cmd_variable_handler_register(bgp_var_peergroup
);
17683 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
17685 /* Install bgp top node. */
17686 install_node(&bgp_node
);
17687 install_node(&bgp_ipv4_unicast_node
);
17688 install_node(&bgp_ipv4_multicast_node
);
17689 install_node(&bgp_ipv4_labeled_unicast_node
);
17690 install_node(&bgp_ipv6_unicast_node
);
17691 install_node(&bgp_ipv6_multicast_node
);
17692 install_node(&bgp_ipv6_labeled_unicast_node
);
17693 install_node(&bgp_vpnv4_node
);
17694 install_node(&bgp_vpnv6_node
);
17695 install_node(&bgp_evpn_node
);
17696 install_node(&bgp_evpn_vni_node
);
17697 install_node(&bgp_flowspecv4_node
);
17698 install_node(&bgp_flowspecv6_node
);
17699 install_node(&bgp_srv6_node
);
17701 /* Install default VTY commands to new nodes. */
17702 install_default(BGP_NODE
);
17703 install_default(BGP_IPV4_NODE
);
17704 install_default(BGP_IPV4M_NODE
);
17705 install_default(BGP_IPV4L_NODE
);
17706 install_default(BGP_IPV6_NODE
);
17707 install_default(BGP_IPV6M_NODE
);
17708 install_default(BGP_IPV6L_NODE
);
17709 install_default(BGP_VPNV4_NODE
);
17710 install_default(BGP_VPNV6_NODE
);
17711 install_default(BGP_FLOWSPECV4_NODE
);
17712 install_default(BGP_FLOWSPECV6_NODE
);
17713 install_default(BGP_EVPN_NODE
);
17714 install_default(BGP_EVPN_VNI_NODE
);
17715 install_default(BGP_SRV6_NODE
);
17717 /* "bgp local-mac" hidden commands. */
17718 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17719 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17721 /* "bgp suppress-fib-pending" global */
17722 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17724 /* bgp route-map delay-timer commands. */
17725 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17726 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17728 /* bgp fast-convergence command */
17729 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
17730 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
17732 /* global bgp update-delay command */
17733 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17734 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17736 /* global bgp graceful-shutdown command */
17737 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17738 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17740 /* Dummy commands (Currently not supported) */
17741 install_element(BGP_NODE
, &no_synchronization_cmd
);
17742 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17744 /* "router bgp" commands. */
17745 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17747 /* "no router bgp" commands. */
17748 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17750 /* "bgp router-id" commands. */
17751 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17752 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17754 /* "bgp suppress-fib-pending" command */
17755 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17757 /* "bgp cluster-id" commands. */
17758 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17759 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17761 /* "bgp no-rib" commands. */
17762 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17763 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17765 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17767 /* "bgp confederation" commands. */
17768 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17769 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17771 /* "bgp confederation peers" commands. */
17772 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17773 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17775 /* bgp max-med command */
17776 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17777 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17778 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17779 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17780 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17782 /* bgp disable-ebgp-connected-nh-check */
17783 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17784 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17786 /* bgp update-delay command */
17787 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17788 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17790 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17791 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17793 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17794 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17796 /* "maximum-paths" commands. */
17797 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17798 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17799 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17800 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17801 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17802 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17803 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17804 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17805 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17806 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17807 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17808 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17809 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17810 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17811 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17813 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17814 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17815 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17816 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17817 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17818 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17819 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17820 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17821 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17822 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17824 /* "timers bgp" commands. */
17825 install_element(BGP_NODE
, &bgp_timers_cmd
);
17826 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17828 /* "minimum-holdtime" commands. */
17829 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
17830 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
17832 /* route-map delay-timer commands - per instance for backwards compat.
17834 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17835 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17837 /* "bgp client-to-client reflection" commands */
17838 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17839 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17841 /* "bgp always-compare-med" commands */
17842 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17843 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17845 /* bgp ebgp-requires-policy */
17846 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17847 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17849 /* bgp suppress-duplicates */
17850 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17851 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17853 /* bgp reject-as-sets */
17854 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17855 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17857 /* "bgp deterministic-med" commands */
17858 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17859 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17861 /* "bgp graceful-restart" command */
17862 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17863 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17865 /* "bgp graceful-restart-disable" command */
17866 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17867 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17869 /* "neighbor a:b:c:d graceful-restart" command */
17870 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17871 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17873 /* "neighbor a:b:c:d graceful-restart-disable" command */
17874 install_element(BGP_NODE
,
17875 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17876 install_element(BGP_NODE
,
17877 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17879 /* "neighbor a:b:c:d graceful-restart-helper" command */
17880 install_element(BGP_NODE
,
17881 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17882 install_element(BGP_NODE
,
17883 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17885 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17886 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17887 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17888 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17889 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17890 install_element(BGP_NODE
,
17891 &no_bgp_graceful_restart_select_defer_time_cmd
);
17892 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17893 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17895 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17896 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17897 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17898 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17900 /* "bgp graceful-shutdown" commands */
17901 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17902 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17904 /* "bgp long-lived-graceful-restart" commands */
17905 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
17906 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
17908 /* "bgp fast-external-failover" commands */
17909 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17910 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17912 /* "bgp bestpath compare-routerid" commands */
17913 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17914 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17916 /* "bgp bestpath as-path ignore" commands */
17917 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17918 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17920 /* "bgp bestpath as-path confed" commands */
17921 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17922 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17924 /* "bgp bestpath as-path multipath-relax" commands */
17925 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17926 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17928 /* "bgp bestpath peer-type multipath-relax" commands */
17929 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
17930 install_element(BGP_NODE
,
17931 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
17933 /* "bgp log-neighbor-changes" commands */
17934 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17935 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17937 /* "bgp bestpath med" commands */
17938 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17939 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17941 /* "bgp bestpath bandwidth" commands */
17942 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17943 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17945 /* "no bgp default <afi>-<safi>" commands. */
17946 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
17948 /* "bgp network import-check" commands. */
17949 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17950 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17951 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17953 /* "bgp default local-preference" commands. */
17954 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17955 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17957 /* bgp default show-hostname */
17958 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17959 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17961 /* bgp default show-nexthop-hostname */
17962 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17963 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17965 /* "bgp default subgroup-pkt-queue-max" commands. */
17966 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17967 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17969 /* bgp ibgp-allow-policy-mods command */
17970 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17971 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17973 /* "bgp listen limit" commands. */
17974 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17975 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17977 /* "bgp listen range" commands. */
17978 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17979 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17981 /* "bgp default shutdown" command */
17982 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17984 /* "bgp shutdown" commands */
17985 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17986 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17987 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17988 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17990 /* "neighbor remote-as" commands. */
17991 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17992 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17993 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17994 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17995 install_element(BGP_NODE
,
17996 &neighbor_interface_v6only_config_remote_as_cmd
);
17997 install_element(BGP_NODE
, &no_neighbor_cmd
);
17998 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18000 /* "neighbor peer-group" commands. */
18001 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18002 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18003 install_element(BGP_NODE
,
18004 &no_neighbor_interface_peer_group_remote_as_cmd
);
18006 /* "neighbor local-as" commands. */
18007 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18008 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18009 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18010 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18012 /* "neighbor solo" commands. */
18013 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18014 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18016 /* "neighbor password" commands. */
18017 install_element(BGP_NODE
, &neighbor_password_cmd
);
18018 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18020 /* "neighbor activate" commands. */
18021 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18022 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18023 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18024 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18025 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18026 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18027 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18028 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18029 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18030 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18031 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18032 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18034 /* "no neighbor activate" commands. */
18035 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18036 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18037 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18038 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18039 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18040 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18042 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18043 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18044 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18045 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18046 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18048 /* "neighbor peer-group" set commands. */
18049 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18050 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18051 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18052 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18053 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18054 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18055 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18056 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18057 install_element(BGP_FLOWSPECV4_NODE
,
18058 &neighbor_set_peer_group_hidden_cmd
);
18059 install_element(BGP_FLOWSPECV6_NODE
,
18060 &neighbor_set_peer_group_hidden_cmd
);
18062 /* "no neighbor peer-group unset" commands. */
18063 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18064 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18065 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18066 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18067 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18068 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18069 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18070 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18071 install_element(BGP_FLOWSPECV4_NODE
,
18072 &no_neighbor_set_peer_group_hidden_cmd
);
18073 install_element(BGP_FLOWSPECV6_NODE
,
18074 &no_neighbor_set_peer_group_hidden_cmd
);
18076 /* "neighbor softreconfiguration inbound" commands.*/
18077 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18078 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18079 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18080 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18081 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18082 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18083 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18084 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18085 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18086 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18087 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18088 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18089 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18090 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18091 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18092 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18093 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18094 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18095 install_element(BGP_FLOWSPECV4_NODE
,
18096 &neighbor_soft_reconfiguration_cmd
);
18097 install_element(BGP_FLOWSPECV4_NODE
,
18098 &no_neighbor_soft_reconfiguration_cmd
);
18099 install_element(BGP_FLOWSPECV6_NODE
,
18100 &neighbor_soft_reconfiguration_cmd
);
18101 install_element(BGP_FLOWSPECV6_NODE
,
18102 &no_neighbor_soft_reconfiguration_cmd
);
18103 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18104 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18106 /* "neighbor attribute-unchanged" commands. */
18107 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18108 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18109 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18110 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18111 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18112 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18113 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18114 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18115 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18116 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18117 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18118 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18119 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18120 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18121 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18122 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18123 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18124 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18126 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18127 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18129 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18130 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18131 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18132 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18134 /* "nexthop-local unchanged" commands */
18135 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18136 install_element(BGP_IPV6_NODE
,
18137 &no_neighbor_nexthop_local_unchanged_cmd
);
18139 /* "neighbor next-hop-self" commands. */
18140 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18141 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18142 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18143 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18144 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18145 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18146 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18147 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18148 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18149 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18150 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18151 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18152 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18153 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18154 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18155 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18156 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18157 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18158 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18159 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18161 /* "neighbor next-hop-self force" commands. */
18162 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18163 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18164 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18165 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18166 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18167 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18168 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18169 install_element(BGP_IPV4_NODE
,
18170 &no_neighbor_nexthop_self_all_hidden_cmd
);
18171 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18172 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18173 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18174 install_element(BGP_IPV4M_NODE
,
18175 &no_neighbor_nexthop_self_all_hidden_cmd
);
18176 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18177 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18178 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18179 install_element(BGP_IPV4L_NODE
,
18180 &no_neighbor_nexthop_self_all_hidden_cmd
);
18181 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18182 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18183 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18184 install_element(BGP_IPV6_NODE
,
18185 &no_neighbor_nexthop_self_all_hidden_cmd
);
18186 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18187 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18188 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18189 install_element(BGP_IPV6M_NODE
,
18190 &no_neighbor_nexthop_self_all_hidden_cmd
);
18191 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18192 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18193 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18194 install_element(BGP_IPV6L_NODE
,
18195 &no_neighbor_nexthop_self_all_hidden_cmd
);
18196 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18197 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18198 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18199 install_element(BGP_VPNV4_NODE
,
18200 &no_neighbor_nexthop_self_all_hidden_cmd
);
18201 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18202 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18203 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18204 install_element(BGP_VPNV6_NODE
,
18205 &no_neighbor_nexthop_self_all_hidden_cmd
);
18206 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18207 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18209 /* "neighbor as-override" commands. */
18210 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18211 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18212 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18213 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18214 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18215 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18216 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18217 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18218 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18219 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18220 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18221 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18222 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18223 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18224 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18225 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18226 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18227 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18229 /* "neighbor remove-private-AS" commands. */
18230 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18231 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18232 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18233 install_element(BGP_NODE
,
18234 &no_neighbor_remove_private_as_all_hidden_cmd
);
18235 install_element(BGP_NODE
,
18236 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18237 install_element(BGP_NODE
,
18238 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18239 install_element(BGP_NODE
,
18240 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18243 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18244 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18245 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18246 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18247 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18248 install_element(BGP_IPV4_NODE
,
18249 &neighbor_remove_private_as_replace_as_cmd
);
18250 install_element(BGP_IPV4_NODE
,
18251 &no_neighbor_remove_private_as_replace_as_cmd
);
18252 install_element(BGP_IPV4_NODE
,
18253 &neighbor_remove_private_as_all_replace_as_cmd
);
18254 install_element(BGP_IPV4_NODE
,
18255 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18256 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18257 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18258 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18259 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18260 install_element(BGP_IPV4M_NODE
,
18261 &neighbor_remove_private_as_replace_as_cmd
);
18262 install_element(BGP_IPV4M_NODE
,
18263 &no_neighbor_remove_private_as_replace_as_cmd
);
18264 install_element(BGP_IPV4M_NODE
,
18265 &neighbor_remove_private_as_all_replace_as_cmd
);
18266 install_element(BGP_IPV4M_NODE
,
18267 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18268 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18269 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18270 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18271 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18272 install_element(BGP_IPV4L_NODE
,
18273 &neighbor_remove_private_as_replace_as_cmd
);
18274 install_element(BGP_IPV4L_NODE
,
18275 &no_neighbor_remove_private_as_replace_as_cmd
);
18276 install_element(BGP_IPV4L_NODE
,
18277 &neighbor_remove_private_as_all_replace_as_cmd
);
18278 install_element(BGP_IPV4L_NODE
,
18279 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18280 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18281 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18282 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18283 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18284 install_element(BGP_IPV6_NODE
,
18285 &neighbor_remove_private_as_replace_as_cmd
);
18286 install_element(BGP_IPV6_NODE
,
18287 &no_neighbor_remove_private_as_replace_as_cmd
);
18288 install_element(BGP_IPV6_NODE
,
18289 &neighbor_remove_private_as_all_replace_as_cmd
);
18290 install_element(BGP_IPV6_NODE
,
18291 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18292 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18293 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18294 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18295 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18296 install_element(BGP_IPV6M_NODE
,
18297 &neighbor_remove_private_as_replace_as_cmd
);
18298 install_element(BGP_IPV6M_NODE
,
18299 &no_neighbor_remove_private_as_replace_as_cmd
);
18300 install_element(BGP_IPV6M_NODE
,
18301 &neighbor_remove_private_as_all_replace_as_cmd
);
18302 install_element(BGP_IPV6M_NODE
,
18303 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18304 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18305 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18306 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18307 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18308 install_element(BGP_IPV6L_NODE
,
18309 &neighbor_remove_private_as_replace_as_cmd
);
18310 install_element(BGP_IPV6L_NODE
,
18311 &no_neighbor_remove_private_as_replace_as_cmd
);
18312 install_element(BGP_IPV6L_NODE
,
18313 &neighbor_remove_private_as_all_replace_as_cmd
);
18314 install_element(BGP_IPV6L_NODE
,
18315 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18316 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18317 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18318 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18319 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18320 install_element(BGP_VPNV4_NODE
,
18321 &neighbor_remove_private_as_replace_as_cmd
);
18322 install_element(BGP_VPNV4_NODE
,
18323 &no_neighbor_remove_private_as_replace_as_cmd
);
18324 install_element(BGP_VPNV4_NODE
,
18325 &neighbor_remove_private_as_all_replace_as_cmd
);
18326 install_element(BGP_VPNV4_NODE
,
18327 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18328 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18329 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18330 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18331 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18332 install_element(BGP_VPNV6_NODE
,
18333 &neighbor_remove_private_as_replace_as_cmd
);
18334 install_element(BGP_VPNV6_NODE
,
18335 &no_neighbor_remove_private_as_replace_as_cmd
);
18336 install_element(BGP_VPNV6_NODE
,
18337 &neighbor_remove_private_as_all_replace_as_cmd
);
18338 install_element(BGP_VPNV6_NODE
,
18339 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18341 /* "neighbor send-community" commands.*/
18342 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18343 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18344 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18345 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18346 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18347 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18348 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18349 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18350 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18351 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18352 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18353 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18354 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18355 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18356 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18357 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18358 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18359 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18360 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18361 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18362 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18363 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18364 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18365 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18366 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18367 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18368 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18369 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18370 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18371 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18372 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18373 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18374 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18375 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18376 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18377 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18379 /* "neighbor route-reflector" commands.*/
18380 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18381 install_element(BGP_NODE
,
18382 &no_neighbor_route_reflector_client_hidden_cmd
);
18383 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18384 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18385 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18386 install_element(BGP_IPV4M_NODE
,
18387 &no_neighbor_route_reflector_client_cmd
);
18388 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18389 install_element(BGP_IPV4L_NODE
,
18390 &no_neighbor_route_reflector_client_cmd
);
18391 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18392 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18393 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18394 install_element(BGP_IPV6M_NODE
,
18395 &no_neighbor_route_reflector_client_cmd
);
18396 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18397 install_element(BGP_IPV6L_NODE
,
18398 &no_neighbor_route_reflector_client_cmd
);
18399 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18400 install_element(BGP_VPNV4_NODE
,
18401 &no_neighbor_route_reflector_client_cmd
);
18402 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18403 install_element(BGP_VPNV6_NODE
,
18404 &no_neighbor_route_reflector_client_cmd
);
18405 install_element(BGP_FLOWSPECV4_NODE
,
18406 &neighbor_route_reflector_client_cmd
);
18407 install_element(BGP_FLOWSPECV4_NODE
,
18408 &no_neighbor_route_reflector_client_cmd
);
18409 install_element(BGP_FLOWSPECV6_NODE
,
18410 &neighbor_route_reflector_client_cmd
);
18411 install_element(BGP_FLOWSPECV6_NODE
,
18412 &no_neighbor_route_reflector_client_cmd
);
18413 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18414 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18416 /* "neighbor route-server" commands.*/
18417 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18418 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18419 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18420 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18421 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18422 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18423 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18424 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18425 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18426 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18427 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18428 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18429 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18430 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18431 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18432 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18433 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18434 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18435 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18436 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18437 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18438 install_element(BGP_FLOWSPECV4_NODE
,
18439 &no_neighbor_route_server_client_cmd
);
18440 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18441 install_element(BGP_FLOWSPECV6_NODE
,
18442 &no_neighbor_route_server_client_cmd
);
18444 /* "neighbor disable-addpath-rx" commands. */
18445 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18446 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18447 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18448 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18449 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18450 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18451 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18452 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18453 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18454 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18455 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18456 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18457 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18458 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18459 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18460 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18462 /* "neighbor addpath-tx-all-paths" commands.*/
18463 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18464 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18465 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18466 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18467 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18468 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18469 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18470 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18471 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18472 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18473 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18474 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18475 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18476 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18477 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18478 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18479 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18480 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18482 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18483 install_element(BGP_NODE
,
18484 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18485 install_element(BGP_NODE
,
18486 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18487 install_element(BGP_IPV4_NODE
,
18488 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18489 install_element(BGP_IPV4_NODE
,
18490 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18491 install_element(BGP_IPV4M_NODE
,
18492 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18493 install_element(BGP_IPV4M_NODE
,
18494 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18495 install_element(BGP_IPV4L_NODE
,
18496 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18497 install_element(BGP_IPV4L_NODE
,
18498 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18499 install_element(BGP_IPV6_NODE
,
18500 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18501 install_element(BGP_IPV6_NODE
,
18502 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18503 install_element(BGP_IPV6M_NODE
,
18504 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18505 install_element(BGP_IPV6M_NODE
,
18506 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18507 install_element(BGP_IPV6L_NODE
,
18508 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18509 install_element(BGP_IPV6L_NODE
,
18510 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18511 install_element(BGP_VPNV4_NODE
,
18512 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18513 install_element(BGP_VPNV4_NODE
,
18514 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18515 install_element(BGP_VPNV6_NODE
,
18516 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18517 install_element(BGP_VPNV6_NODE
,
18518 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18520 /* "neighbor sender-as-path-loop-detection" commands. */
18521 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18522 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18524 /* "neighbor passive" commands. */
18525 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18526 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18529 /* "neighbor shutdown" commands. */
18530 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18531 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18532 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18533 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18534 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18535 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18537 /* "neighbor capability extended-nexthop" commands.*/
18538 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18539 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18541 /* "neighbor capability orf prefix-list" commands.*/
18542 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18543 install_element(BGP_NODE
,
18544 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18545 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18546 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18547 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18548 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18549 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18550 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18551 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18552 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18553 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18554 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18555 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18556 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18558 /* "neighbor capability dynamic" commands.*/
18559 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18562 /* "neighbor dont-capability-negotiate" commands. */
18563 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18564 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18566 /* "neighbor ebgp-multihop" commands. */
18567 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18568 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18569 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18571 /* "neighbor disable-connected-check" commands. */
18572 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18573 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18575 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18576 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18577 install_element(BGP_NODE
,
18578 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18580 /* "neighbor extended-optional-parameters" commands. */
18581 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18582 install_element(BGP_NODE
,
18583 &no_neighbor_extended_optional_parameters_cmd
);
18585 /* "neighbor enforce-first-as" commands. */
18586 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18587 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18589 /* "neighbor description" commands. */
18590 install_element(BGP_NODE
, &neighbor_description_cmd
);
18591 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18592 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18594 /* "neighbor update-source" commands. "*/
18595 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18596 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18598 /* "neighbor default-originate" commands. */
18599 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18600 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18601 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18602 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18603 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18604 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18605 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18606 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18607 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18608 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18609 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18610 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18611 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18612 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18613 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18614 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18615 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18616 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18617 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18618 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18619 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18621 /* "neighbor port" commands. */
18622 install_element(BGP_NODE
, &neighbor_port_cmd
);
18623 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18625 /* "neighbor weight" commands. */
18626 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18627 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18629 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18630 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18631 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18632 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18633 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18634 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18635 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18636 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18637 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18638 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18639 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18640 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18641 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18642 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18643 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18644 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18646 /* "neighbor override-capability" commands. */
18647 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18648 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18650 /* "neighbor strict-capability-match" commands. */
18651 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18652 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18654 /* "neighbor timers" commands. */
18655 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18656 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18658 /* "neighbor timers connect" commands. */
18659 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18660 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18662 /* "neighbor timers delayopen" commands. */
18663 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18664 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18666 /* "neighbor advertisement-interval" commands. */
18667 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18668 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18670 /* "neighbor interface" commands. */
18671 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18672 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18674 /* "neighbor distribute" commands. */
18675 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18676 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18677 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18678 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18679 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18680 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18681 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18682 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18683 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18684 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18685 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18686 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18687 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18688 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18689 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18690 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18691 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18692 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18694 /* "neighbor prefix-list" commands. */
18695 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18696 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18697 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18698 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18699 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18700 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18701 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18702 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18703 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18704 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18705 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18706 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18707 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18708 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18709 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18710 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18711 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18712 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18713 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18714 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18715 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18716 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18718 /* "neighbor filter-list" commands. */
18719 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18720 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18721 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18722 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18723 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18724 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18725 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18726 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18727 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18728 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18729 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18730 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18731 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18732 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18733 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18734 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18735 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18736 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18737 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18738 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18739 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18740 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18742 /* "neighbor route-map" commands. */
18743 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18744 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18745 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18746 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18747 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18748 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18749 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18750 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18751 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18752 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18753 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18754 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18755 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18756 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18757 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18758 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18760 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18761 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18762 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18763 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18764 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18765 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18766 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18768 /* "neighbor unsuppress-map" commands. */
18769 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18770 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18771 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18772 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18773 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18774 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18775 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18776 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18777 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18778 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18779 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18780 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18781 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18782 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18783 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18784 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18785 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18786 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18788 /* "neighbor advertise-map" commands. */
18789 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
18790 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18791 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18792 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18793 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18794 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18795 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18796 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18797 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18798 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18800 /* neighbor maximum-prefix-out commands. */
18801 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18802 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18803 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18804 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18805 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18806 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18807 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18808 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18809 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18810 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18811 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18812 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18813 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18814 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18815 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18816 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18817 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18818 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18820 /* "neighbor maximum-prefix" commands. */
18821 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18822 install_element(BGP_NODE
,
18823 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18824 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18825 install_element(BGP_NODE
,
18826 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18827 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18828 install_element(BGP_NODE
,
18829 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18830 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18831 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18832 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18833 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18834 install_element(BGP_IPV4_NODE
,
18835 &neighbor_maximum_prefix_threshold_warning_cmd
);
18836 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18837 install_element(BGP_IPV4_NODE
,
18838 &neighbor_maximum_prefix_threshold_restart_cmd
);
18839 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18840 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18841 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18842 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18843 install_element(BGP_IPV4M_NODE
,
18844 &neighbor_maximum_prefix_threshold_warning_cmd
);
18845 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18846 install_element(BGP_IPV4M_NODE
,
18847 &neighbor_maximum_prefix_threshold_restart_cmd
);
18848 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18849 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18850 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18851 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18852 install_element(BGP_IPV4L_NODE
,
18853 &neighbor_maximum_prefix_threshold_warning_cmd
);
18854 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18855 install_element(BGP_IPV4L_NODE
,
18856 &neighbor_maximum_prefix_threshold_restart_cmd
);
18857 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18858 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18859 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18860 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18861 install_element(BGP_IPV6_NODE
,
18862 &neighbor_maximum_prefix_threshold_warning_cmd
);
18863 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18864 install_element(BGP_IPV6_NODE
,
18865 &neighbor_maximum_prefix_threshold_restart_cmd
);
18866 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18867 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18868 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18869 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18870 install_element(BGP_IPV6M_NODE
,
18871 &neighbor_maximum_prefix_threshold_warning_cmd
);
18872 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18873 install_element(BGP_IPV6M_NODE
,
18874 &neighbor_maximum_prefix_threshold_restart_cmd
);
18875 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18876 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18877 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18878 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18879 install_element(BGP_IPV6L_NODE
,
18880 &neighbor_maximum_prefix_threshold_warning_cmd
);
18881 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18882 install_element(BGP_IPV6L_NODE
,
18883 &neighbor_maximum_prefix_threshold_restart_cmd
);
18884 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18885 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18886 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18887 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18888 install_element(BGP_VPNV4_NODE
,
18889 &neighbor_maximum_prefix_threshold_warning_cmd
);
18890 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18891 install_element(BGP_VPNV4_NODE
,
18892 &neighbor_maximum_prefix_threshold_restart_cmd
);
18893 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18894 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18895 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18896 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18897 install_element(BGP_VPNV6_NODE
,
18898 &neighbor_maximum_prefix_threshold_warning_cmd
);
18899 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18900 install_element(BGP_VPNV6_NODE
,
18901 &neighbor_maximum_prefix_threshold_restart_cmd
);
18902 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18904 /* "neighbor allowas-in" */
18905 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18906 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18907 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18908 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18909 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18910 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18911 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18912 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18913 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18914 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18915 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18916 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18917 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18918 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18919 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18920 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18921 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18922 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18923 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18924 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18926 /* address-family commands. */
18927 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18928 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18929 #ifdef KEEP_OLD_VPN_COMMANDS
18930 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18931 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18932 #endif /* KEEP_OLD_VPN_COMMANDS */
18934 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18936 /* "exit-address-family" command. */
18937 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18938 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18939 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18940 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18941 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18942 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18943 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18944 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18945 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18946 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18947 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18949 /* "clear ip bgp commands" */
18950 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18952 /* clear ip bgp prefix */
18953 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18954 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18955 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18957 /* "show [ip] bgp summary" commands. */
18958 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18959 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18960 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18961 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18962 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18963 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18964 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18966 /* "show [ip] bgp neighbors" commands. */
18967 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18969 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18971 /* "show [ip] bgp peer-group" commands. */
18972 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18974 /* "show [ip] bgp paths" commands. */
18975 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18977 /* "show [ip] bgp community" commands. */
18978 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18980 /* "show ip bgp large-community" commands. */
18981 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18982 /* "show [ip] bgp attribute-info" commands. */
18983 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18984 /* "show [ip] bgp route-leak" command */
18985 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18987 /* "redistribute" commands. */
18988 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18989 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18990 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18991 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18992 install_element(BGP_NODE
,
18993 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18994 install_element(BGP_NODE
,
18995 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18996 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18997 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18998 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18999 install_element(BGP_NODE
,
19000 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19001 install_element(BGP_NODE
,
19002 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19003 install_element(BGP_NODE
,
19004 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19005 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19006 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19007 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19008 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19009 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19010 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19011 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19012 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19013 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19014 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19015 install_element(BGP_IPV4_NODE
,
19016 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19017 install_element(BGP_IPV4_NODE
,
19018 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19019 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19020 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19021 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19022 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19023 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19024 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19026 /* import|export vpn [route-map WORD] */
19027 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19028 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19030 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19031 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19033 /* ttl_security commands */
19034 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19035 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19037 /* "show [ip] bgp memory" commands. */
19038 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19040 /* "show bgp martian next-hop" */
19041 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19043 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19045 /* "show [ip] bgp views" commands. */
19046 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19048 /* "show [ip] bgp vrfs" commands. */
19049 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19051 /* Community-list. */
19052 community_list_vty();
19054 community_alias_vty();
19056 /* vpn-policy commands */
19057 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19058 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19059 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19060 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19061 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19062 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19063 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19064 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19065 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19066 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19067 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19068 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19070 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19071 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19073 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19074 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19075 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19076 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19077 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19078 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19079 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19080 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19081 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19082 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19084 /* tcp-mss command */
19085 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19086 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19088 /* srv6 commands */
19089 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19090 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19091 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19092 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19093 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19094 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19095 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19098 #include "memory.h"
19099 #include "bgp_regex.h"
19100 #include "bgp_clist.h"
19101 #include "bgp_ecommunity.h"
19103 /* VTY functions. */
19105 /* Direction value to string conversion. */
19106 static const char *community_direct_str(int direct
)
19109 case COMMUNITY_DENY
:
19111 case COMMUNITY_PERMIT
:
19118 /* Display error string. */
19119 static void community_list_perror(struct vty
*vty
, int ret
)
19122 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19123 vty_out(vty
, "%% Can't find community-list\n");
19125 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19126 vty_out(vty
, "%% Malformed community-list value\n");
19128 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19130 "%% Community name conflict, previously defined as standard community\n");
19132 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19134 "%% Community name conflict, previously defined as expanded community\n");
19139 /* "community-list" keyword help string. */
19140 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19142 /*community-list standard */
19143 DEFUN (community_list_standard
,
19144 bgp_community_list_standard_cmd
,
19145 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19148 "Community list number (standard)\n"
19149 "Add an standard community-list entry\n"
19150 "Community list name\n"
19151 "Sequence number of an entry\n"
19152 "Sequence number\n"
19153 "Specify community to reject\n"
19154 "Specify community to accept\n"
19157 char *cl_name_or_number
= NULL
;
19160 int style
= COMMUNITY_LIST_STANDARD
;
19163 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19165 seq
= argv
[idx
]->arg
;
19168 argv_find(argv
, argc
, "(1-99)", &idx
);
19169 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19170 cl_name_or_number
= argv
[idx
]->arg
;
19171 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19173 argv_find(argv
, argc
, "AA:NN", &idx
);
19174 char *str
= argv_concat(argv
, argc
, idx
);
19176 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19179 XFREE(MTYPE_TMP
, str
);
19182 /* Display error string. */
19183 community_list_perror(vty
, ret
);
19184 return CMD_WARNING_CONFIG_FAILED
;
19187 return CMD_SUCCESS
;
19190 DEFUN (no_community_list_standard_all
,
19191 no_bgp_community_list_standard_all_cmd
,
19192 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19196 "Community list number (standard)\n"
19197 "Add an standard community-list entry\n"
19198 "Community list name\n"
19199 "Sequence number of an entry\n"
19200 "Sequence number\n"
19201 "Specify community to reject\n"
19202 "Specify community to accept\n"
19205 char *cl_name_or_number
= NULL
;
19208 int style
= COMMUNITY_LIST_STANDARD
;
19212 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19214 seq
= argv
[idx
]->arg
;
19217 argv_find(argv
, argc
, "permit", &idx
);
19218 argv_find(argv
, argc
, "deny", &idx
);
19221 direct
= argv_find(argv
, argc
, "permit", &idx
)
19226 argv_find(argv
, argc
, "AA:NN", &idx
);
19227 str
= argv_concat(argv
, argc
, idx
);
19231 argv_find(argv
, argc
, "(1-99)", &idx
);
19232 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19233 cl_name_or_number
= argv
[idx
]->arg
;
19235 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19238 XFREE(MTYPE_TMP
, str
);
19241 community_list_perror(vty
, ret
);
19242 return CMD_WARNING_CONFIG_FAILED
;
19245 return CMD_SUCCESS
;
19248 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19249 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19250 NO_STR BGP_STR COMMUNITY_LIST_STR
19251 "Community list number (standard)\n"
19252 "Add an standard community-list entry\n"
19253 "Community list name\n")
19255 /*community-list expanded */
19256 DEFUN (community_list_expanded_all
,
19257 bgp_community_list_expanded_all_cmd
,
19258 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19261 "Community list number (expanded)\n"
19262 "Add an expanded community-list entry\n"
19263 "Community list name\n"
19264 "Sequence number of an entry\n"
19265 "Sequence number\n"
19266 "Specify community to reject\n"
19267 "Specify community to accept\n"
19270 char *cl_name_or_number
= NULL
;
19273 int style
= COMMUNITY_LIST_EXPANDED
;
19276 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19278 seq
= argv
[idx
]->arg
;
19282 argv_find(argv
, argc
, "(100-500)", &idx
);
19283 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19284 cl_name_or_number
= argv
[idx
]->arg
;
19285 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19287 argv_find(argv
, argc
, "AA:NN", &idx
);
19288 char *str
= argv_concat(argv
, argc
, idx
);
19290 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19293 XFREE(MTYPE_TMP
, str
);
19296 /* Display error string. */
19297 community_list_perror(vty
, ret
);
19298 return CMD_WARNING_CONFIG_FAILED
;
19301 return CMD_SUCCESS
;
19304 DEFUN (no_community_list_expanded_all
,
19305 no_bgp_community_list_expanded_all_cmd
,
19306 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19310 "Community list number (expanded)\n"
19311 "Add an expanded community-list entry\n"
19312 "Community list name\n"
19313 "Sequence number of an entry\n"
19314 "Sequence number\n"
19315 "Specify community to reject\n"
19316 "Specify community to accept\n"
19319 char *cl_name_or_number
= NULL
;
19323 int style
= COMMUNITY_LIST_EXPANDED
;
19326 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19328 seq
= argv
[idx
]->arg
;
19331 argv_find(argv
, argc
, "permit", &idx
);
19332 argv_find(argv
, argc
, "deny", &idx
);
19335 direct
= argv_find(argv
, argc
, "permit", &idx
)
19340 argv_find(argv
, argc
, "AA:NN", &idx
);
19341 str
= argv_concat(argv
, argc
, idx
);
19345 argv_find(argv
, argc
, "(100-500)", &idx
);
19346 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19347 cl_name_or_number
= argv
[idx
]->arg
;
19349 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19352 XFREE(MTYPE_TMP
, str
);
19355 community_list_perror(vty
, ret
);
19356 return CMD_WARNING_CONFIG_FAILED
;
19359 return CMD_SUCCESS
;
19362 ALIAS(no_community_list_expanded_all
,
19363 no_bgp_community_list_expanded_all_list_cmd
,
19364 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19365 NO_STR BGP_STR COMMUNITY_LIST_STR
19366 "Community list number (expanded)\n"
19367 "Add an expanded community-list entry\n"
19368 "Community list name\n")
19370 /* Return configuration string of community-list entry. */
19371 static const char *community_list_config_str(struct community_entry
*entry
)
19378 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19379 str
= community_str(entry
->u
.com
, false, false);
19380 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19381 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19383 str
= entry
->config
;
19388 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19390 struct community_entry
*entry
;
19392 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19393 if (entry
== list
->head
) {
19394 if (all_digit(list
->name
))
19395 vty_out(vty
, "Community %s list %s\n",
19396 entry
->style
== COMMUNITY_LIST_STANDARD
19398 : "(expanded) access",
19401 vty_out(vty
, "Named Community %s list %s\n",
19402 entry
->style
== COMMUNITY_LIST_STANDARD
19408 vty_out(vty
, " %s\n",
19409 community_direct_str(entry
->direct
));
19411 vty_out(vty
, " %s %s\n",
19412 community_direct_str(entry
->direct
),
19413 community_list_config_str(entry
));
19417 DEFUN (show_community_list
,
19418 show_bgp_community_list_cmd
,
19419 "show bgp community-list",
19422 "List community-list\n")
19424 struct community_list
*list
;
19425 struct community_list_master
*cm
;
19427 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19429 return CMD_SUCCESS
;
19431 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19432 community_list_show(vty
, list
);
19434 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19435 community_list_show(vty
, list
);
19437 return CMD_SUCCESS
;
19440 DEFUN (show_community_list_arg
,
19441 show_bgp_community_list_arg_cmd
,
19442 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19445 "List community-list\n"
19446 "Community-list number\n"
19447 "Community-list name\n"
19448 "Detailed information on community-list\n")
19450 int idx_comm_list
= 3;
19451 struct community_list
*list
;
19453 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19454 COMMUNITY_LIST_MASTER
);
19456 vty_out(vty
, "%% Can't find community-list\n");
19457 return CMD_WARNING
;
19460 community_list_show(vty
, list
);
19462 return CMD_SUCCESS
;
19466 * Large Community code.
19468 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19469 struct cmd_token
**argv
, int style
,
19470 int reject_all_digit_name
)
19479 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19480 seq
= argv
[idx
]->arg
;
19483 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19486 /* All digit name check. */
19488 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19489 argv_find(argv
, argc
, "(1-99)", &idx
);
19490 argv_find(argv
, argc
, "(100-500)", &idx
);
19491 cl_name
= argv
[idx
]->arg
;
19492 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19493 vty_out(vty
, "%% Community name cannot have all digits\n");
19494 return CMD_WARNING_CONFIG_FAILED
;
19498 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19499 argv_find(argv
, argc
, "LINE", &idx
);
19500 /* Concat community string argument. */
19502 str
= argv_concat(argv
, argc
, idx
);
19506 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19508 /* Free temporary community list string allocated by
19510 XFREE(MTYPE_TMP
, str
);
19513 community_list_perror(vty
, ret
);
19514 return CMD_WARNING_CONFIG_FAILED
;
19516 return CMD_SUCCESS
;
19519 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19520 struct cmd_token
**argv
, int style
)
19528 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19529 seq
= argv
[idx
]->arg
;
19532 argv_find(argv
, argc
, "permit", &idx
);
19533 argv_find(argv
, argc
, "deny", &idx
);
19536 /* Check the list direct. */
19537 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19538 direct
= COMMUNITY_PERMIT
;
19540 direct
= COMMUNITY_DENY
;
19543 argv_find(argv
, argc
, "LINE", &idx
);
19544 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19545 /* Concat community string argument. */
19546 str
= argv_concat(argv
, argc
, idx
);
19550 argv_find(argv
, argc
, "(1-99)", &idx
);
19551 argv_find(argv
, argc
, "(100-500)", &idx
);
19552 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19554 /* Unset community list. */
19555 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19558 /* Free temporary community list string allocated by
19560 XFREE(MTYPE_TMP
, str
);
19563 community_list_perror(vty
, ret
);
19564 return CMD_WARNING_CONFIG_FAILED
;
19567 return CMD_SUCCESS
;
19570 /* "large-community-list" keyword help string. */
19571 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19572 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19574 DEFUN (lcommunity_list_standard
,
19575 bgp_lcommunity_list_standard_cmd
,
19576 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19578 LCOMMUNITY_LIST_STR
19579 "Large Community list number (standard)\n"
19580 "Sequence number of an entry\n"
19581 "Sequence number\n"
19582 "Specify large community to reject\n"
19583 "Specify large community to accept\n"
19584 LCOMMUNITY_VAL_STR
)
19586 return lcommunity_list_set_vty(vty
, argc
, argv
,
19587 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19590 DEFUN (lcommunity_list_expanded
,
19591 bgp_lcommunity_list_expanded_cmd
,
19592 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19594 LCOMMUNITY_LIST_STR
19595 "Large Community list number (expanded)\n"
19596 "Sequence number of an entry\n"
19597 "Sequence number\n"
19598 "Specify large community to reject\n"
19599 "Specify large community to accept\n"
19600 "An ordered list as a regular-expression\n")
19602 return lcommunity_list_set_vty(vty
, argc
, argv
,
19603 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19606 DEFUN (lcommunity_list_name_standard
,
19607 bgp_lcommunity_list_name_standard_cmd
,
19608 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19610 LCOMMUNITY_LIST_STR
19611 "Specify standard large-community-list\n"
19612 "Large Community list name\n"
19613 "Sequence number of an entry\n"
19614 "Sequence number\n"
19615 "Specify large community to reject\n"
19616 "Specify large community to accept\n"
19617 LCOMMUNITY_VAL_STR
)
19619 return lcommunity_list_set_vty(vty
, argc
, argv
,
19620 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19623 DEFUN (lcommunity_list_name_expanded
,
19624 bgp_lcommunity_list_name_expanded_cmd
,
19625 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19627 LCOMMUNITY_LIST_STR
19628 "Specify expanded large-community-list\n"
19629 "Large Community list name\n"
19630 "Sequence number of an entry\n"
19631 "Sequence number\n"
19632 "Specify large community to reject\n"
19633 "Specify large community to accept\n"
19634 "An ordered list as a regular-expression\n")
19636 return lcommunity_list_set_vty(vty
, argc
, argv
,
19637 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19640 DEFUN (no_lcommunity_list_all
,
19641 no_bgp_lcommunity_list_all_cmd
,
19642 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19645 LCOMMUNITY_LIST_STR
19646 "Large Community list number (standard)\n"
19647 "Large Community list number (expanded)\n"
19648 "Large Community list name\n")
19650 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19651 LARGE_COMMUNITY_LIST_STANDARD
);
19654 DEFUN (no_lcommunity_list_name_standard_all
,
19655 no_bgp_lcommunity_list_name_standard_all_cmd
,
19656 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19659 LCOMMUNITY_LIST_STR
19660 "Specify standard large-community-list\n"
19661 "Large Community list name\n")
19663 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19664 LARGE_COMMUNITY_LIST_STANDARD
);
19667 DEFUN (no_lcommunity_list_name_expanded_all
,
19668 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19669 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19672 LCOMMUNITY_LIST_STR
19673 "Specify expanded large-community-list\n"
19674 "Large Community list name\n")
19676 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19677 LARGE_COMMUNITY_LIST_EXPANDED
);
19680 DEFUN (no_lcommunity_list_standard
,
19681 no_bgp_lcommunity_list_standard_cmd
,
19682 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19685 LCOMMUNITY_LIST_STR
19686 "Large Community list number (standard)\n"
19687 "Sequence number of an entry\n"
19688 "Sequence number\n"
19689 "Specify large community to reject\n"
19690 "Specify large community to accept\n"
19691 LCOMMUNITY_VAL_STR
)
19693 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19694 LARGE_COMMUNITY_LIST_STANDARD
);
19697 DEFUN (no_lcommunity_list_expanded
,
19698 no_bgp_lcommunity_list_expanded_cmd
,
19699 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19702 LCOMMUNITY_LIST_STR
19703 "Large Community list number (expanded)\n"
19704 "Sequence number of an entry\n"
19705 "Sequence number\n"
19706 "Specify large community to reject\n"
19707 "Specify large community to accept\n"
19708 "An ordered list as a regular-expression\n")
19710 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19711 LARGE_COMMUNITY_LIST_EXPANDED
);
19714 DEFUN (no_lcommunity_list_name_standard
,
19715 no_bgp_lcommunity_list_name_standard_cmd
,
19716 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19719 LCOMMUNITY_LIST_STR
19720 "Specify standard large-community-list\n"
19721 "Large Community list name\n"
19722 "Sequence number of an entry\n"
19723 "Sequence number\n"
19724 "Specify large community to reject\n"
19725 "Specify large community to accept\n"
19726 LCOMMUNITY_VAL_STR
)
19728 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19729 LARGE_COMMUNITY_LIST_STANDARD
);
19732 DEFUN (no_lcommunity_list_name_expanded
,
19733 no_bgp_lcommunity_list_name_expanded_cmd
,
19734 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19737 LCOMMUNITY_LIST_STR
19738 "Specify expanded large-community-list\n"
19739 "Large community list name\n"
19740 "Sequence number of an entry\n"
19741 "Sequence number\n"
19742 "Specify large community to reject\n"
19743 "Specify large community to accept\n"
19744 "An ordered list as a regular-expression\n")
19746 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19747 LARGE_COMMUNITY_LIST_EXPANDED
);
19750 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19752 struct community_entry
*entry
;
19754 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19755 if (entry
== list
->head
) {
19756 if (all_digit(list
->name
))
19757 vty_out(vty
, "Large community %s list %s\n",
19759 LARGE_COMMUNITY_LIST_STANDARD
19761 : "(expanded) access",
19765 "Named large community %s list %s\n",
19767 LARGE_COMMUNITY_LIST_STANDARD
19773 vty_out(vty
, " %s\n",
19774 community_direct_str(entry
->direct
));
19776 vty_out(vty
, " %s %s\n",
19777 community_direct_str(entry
->direct
),
19778 community_list_config_str(entry
));
19782 DEFUN (show_lcommunity_list
,
19783 show_bgp_lcommunity_list_cmd
,
19784 "show bgp large-community-list",
19787 "List large-community list\n")
19789 struct community_list
*list
;
19790 struct community_list_master
*cm
;
19792 cm
= community_list_master_lookup(bgp_clist
,
19793 LARGE_COMMUNITY_LIST_MASTER
);
19795 return CMD_SUCCESS
;
19797 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19798 lcommunity_list_show(vty
, list
);
19800 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19801 lcommunity_list_show(vty
, list
);
19803 return CMD_SUCCESS
;
19806 DEFUN (show_lcommunity_list_arg
,
19807 show_bgp_lcommunity_list_arg_cmd
,
19808 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
19811 "List large-community list\n"
19812 "Large-community-list number\n"
19813 "Large-community-list name\n"
19814 "Detailed information on large-community-list\n")
19816 struct community_list
*list
;
19818 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19819 LARGE_COMMUNITY_LIST_MASTER
);
19821 vty_out(vty
, "%% Can't find large-community-list\n");
19822 return CMD_WARNING
;
19825 lcommunity_list_show(vty
, list
);
19827 return CMD_SUCCESS
;
19830 /* "extcommunity-list" keyword help string. */
19831 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19832 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19834 DEFUN (extcommunity_list_standard
,
19835 bgp_extcommunity_list_standard_cmd
,
19836 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19838 EXTCOMMUNITY_LIST_STR
19839 "Extended Community list number (standard)\n"
19840 "Specify standard extcommunity-list\n"
19841 "Community list name\n"
19842 "Sequence number of an entry\n"
19843 "Sequence number\n"
19844 "Specify community to reject\n"
19845 "Specify community to accept\n"
19846 EXTCOMMUNITY_VAL_STR
)
19848 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19850 char *cl_number_or_name
= NULL
;
19855 argv_find(argv
, argc
, "(1-99)", &idx
);
19856 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19857 cl_number_or_name
= argv
[idx
]->arg
;
19859 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19860 seq
= argv
[idx
]->arg
;
19862 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19864 argv_find(argv
, argc
, "AA:NN", &idx
);
19865 char *str
= argv_concat(argv
, argc
, idx
);
19867 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19870 XFREE(MTYPE_TMP
, str
);
19873 community_list_perror(vty
, ret
);
19874 return CMD_WARNING_CONFIG_FAILED
;
19877 return CMD_SUCCESS
;
19880 DEFUN (extcommunity_list_name_expanded
,
19881 bgp_extcommunity_list_name_expanded_cmd
,
19882 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19884 EXTCOMMUNITY_LIST_STR
19885 "Extended Community list number (expanded)\n"
19886 "Specify expanded extcommunity-list\n"
19887 "Extended Community list name\n"
19888 "Sequence number of an entry\n"
19889 "Sequence number\n"
19890 "Specify community to reject\n"
19891 "Specify community to accept\n"
19892 "An ordered list as a regular-expression\n")
19894 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19896 char *cl_number_or_name
= NULL
;
19900 argv_find(argv
, argc
, "(100-500)", &idx
);
19901 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19902 cl_number_or_name
= argv
[idx
]->arg
;
19904 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19905 seq
= argv
[idx
]->arg
;
19907 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19909 argv_find(argv
, argc
, "LINE", &idx
);
19910 char *str
= argv_concat(argv
, argc
, idx
);
19912 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19915 XFREE(MTYPE_TMP
, str
);
19918 community_list_perror(vty
, ret
);
19919 return CMD_WARNING_CONFIG_FAILED
;
19922 return CMD_SUCCESS
;
19925 DEFUN (no_extcommunity_list_standard_all
,
19926 no_bgp_extcommunity_list_standard_all_cmd
,
19927 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19930 EXTCOMMUNITY_LIST_STR
19931 "Extended Community list number (standard)\n"
19932 "Specify standard extcommunity-list\n"
19933 "Community list name\n"
19934 "Sequence number of an entry\n"
19935 "Sequence number\n"
19936 "Specify community to reject\n"
19937 "Specify community to accept\n"
19938 EXTCOMMUNITY_VAL_STR
)
19940 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19942 char *cl_number_or_name
= NULL
;
19947 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19948 seq
= argv
[idx
]->arg
;
19951 argv_find(argv
, argc
, "permit", &idx
);
19952 argv_find(argv
, argc
, "deny", &idx
);
19954 direct
= argv_find(argv
, argc
, "permit", &idx
)
19959 argv_find(argv
, argc
, "AA:NN", &idx
);
19960 str
= argv_concat(argv
, argc
, idx
);
19964 argv_find(argv
, argc
, "(1-99)", &idx
);
19965 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19966 cl_number_or_name
= argv
[idx
]->arg
;
19968 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19969 seq
, direct
, style
);
19971 XFREE(MTYPE_TMP
, str
);
19974 community_list_perror(vty
, ret
);
19975 return CMD_WARNING_CONFIG_FAILED
;
19978 return CMD_SUCCESS
;
19981 ALIAS(no_extcommunity_list_standard_all
,
19982 no_bgp_extcommunity_list_standard_all_list_cmd
,
19983 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
19984 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19985 "Extended Community list number (standard)\n"
19986 "Specify standard extcommunity-list\n"
19987 "Community list name\n")
19989 DEFUN (no_extcommunity_list_expanded_all
,
19990 no_bgp_extcommunity_list_expanded_all_cmd
,
19991 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19994 EXTCOMMUNITY_LIST_STR
19995 "Extended Community list number (expanded)\n"
19996 "Specify expanded extcommunity-list\n"
19997 "Extended Community list name\n"
19998 "Sequence number of an entry\n"
19999 "Sequence number\n"
20000 "Specify community to reject\n"
20001 "Specify community to accept\n"
20002 "An ordered list as a regular-expression\n")
20004 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20006 char *cl_number_or_name
= NULL
;
20011 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20012 seq
= argv
[idx
]->arg
;
20015 argv_find(argv
, argc
, "permit", &idx
);
20016 argv_find(argv
, argc
, "deny", &idx
);
20019 direct
= argv_find(argv
, argc
, "permit", &idx
)
20024 argv_find(argv
, argc
, "LINE", &idx
);
20025 str
= argv_concat(argv
, argc
, idx
);
20029 argv_find(argv
, argc
, "(100-500)", &idx
);
20030 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20031 cl_number_or_name
= argv
[idx
]->arg
;
20033 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20034 seq
, direct
, style
);
20036 XFREE(MTYPE_TMP
, str
);
20039 community_list_perror(vty
, ret
);
20040 return CMD_WARNING_CONFIG_FAILED
;
20043 return CMD_SUCCESS
;
20046 ALIAS(no_extcommunity_list_expanded_all
,
20047 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20048 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20049 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20050 "Extended Community list number (expanded)\n"
20051 "Specify expanded extcommunity-list\n"
20052 "Extended Community list name\n")
20054 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20056 struct community_entry
*entry
;
20058 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20059 if (entry
== list
->head
) {
20060 if (all_digit(list
->name
))
20061 vty_out(vty
, "Extended community %s list %s\n",
20062 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20064 : "(expanded) access",
20068 "Named extended community %s list %s\n",
20069 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20075 vty_out(vty
, " %s\n",
20076 community_direct_str(entry
->direct
));
20078 vty_out(vty
, " %s %s\n",
20079 community_direct_str(entry
->direct
),
20080 community_list_config_str(entry
));
20084 DEFUN (show_extcommunity_list
,
20085 show_bgp_extcommunity_list_cmd
,
20086 "show bgp extcommunity-list",
20089 "List extended-community list\n")
20091 struct community_list
*list
;
20092 struct community_list_master
*cm
;
20094 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20096 return CMD_SUCCESS
;
20098 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20099 extcommunity_list_show(vty
, list
);
20101 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20102 extcommunity_list_show(vty
, list
);
20104 return CMD_SUCCESS
;
20107 DEFUN (show_extcommunity_list_arg
,
20108 show_bgp_extcommunity_list_arg_cmd
,
20109 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20112 "List extended-community list\n"
20113 "Extcommunity-list number\n"
20114 "Extcommunity-list name\n"
20115 "Detailed information on extcommunity-list\n")
20117 int idx_comm_list
= 3;
20118 struct community_list
*list
;
20120 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20121 EXTCOMMUNITY_LIST_MASTER
);
20123 vty_out(vty
, "%% Can't find extcommunity-list\n");
20124 return CMD_WARNING
;
20127 extcommunity_list_show(vty
, list
);
20129 return CMD_SUCCESS
;
20132 /* Display community-list and extcommunity-list configuration. */
20133 static int community_list_config_write(struct vty
*vty
)
20135 struct community_list
*list
;
20136 struct community_entry
*entry
;
20137 struct community_list_master
*cm
;
20140 /* Community-list. */
20141 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20143 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20144 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20146 "bgp community-list %s seq %" PRId64
" %s %s\n",
20147 list
->name
, entry
->seq
,
20148 community_direct_str(entry
->direct
),
20149 community_list_config_str(entry
));
20152 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20153 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20155 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20156 entry
->style
== COMMUNITY_LIST_STANDARD
20159 list
->name
, entry
->seq
,
20160 community_direct_str(entry
->direct
),
20161 community_list_config_str(entry
));
20165 /* Extcommunity-list. */
20166 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20168 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20169 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20171 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20172 list
->name
, entry
->seq
,
20173 community_direct_str(entry
->direct
),
20174 community_list_config_str(entry
));
20177 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20178 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20180 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20181 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20184 list
->name
, entry
->seq
,
20185 community_direct_str(entry
->direct
),
20186 community_list_config_str(entry
));
20191 /* lcommunity-list. */
20192 cm
= community_list_master_lookup(bgp_clist
,
20193 LARGE_COMMUNITY_LIST_MASTER
);
20195 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20196 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20198 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20199 list
->name
, entry
->seq
,
20200 community_direct_str(entry
->direct
),
20201 community_list_config_str(entry
));
20204 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20205 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20207 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20209 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20212 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20213 community_list_config_str(entry
));
20220 static int community_list_config_write(struct vty
*vty
);
20221 static struct cmd_node community_list_node
= {
20222 .name
= "community list",
20223 .node
= COMMUNITY_LIST_NODE
,
20225 .config_write
= community_list_config_write
,
20228 static void community_list_vty(void)
20230 install_node(&community_list_node
);
20232 /* Community-list. */
20233 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20234 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20235 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20236 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20237 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20238 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20239 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20240 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20242 /* Extcommunity-list. */
20243 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20244 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20245 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20246 install_element(CONFIG_NODE
,
20247 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20248 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20249 install_element(CONFIG_NODE
,
20250 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20251 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20252 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20254 /* Large Community List */
20255 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20256 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20257 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20258 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20259 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20260 install_element(CONFIG_NODE
,
20261 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20262 install_element(CONFIG_NODE
,
20263 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20264 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20265 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20266 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20267 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20268 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20269 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20271 bgp_community_list_command_completion_setup();
20274 static struct cmd_node community_alias_node
= {
20275 .name
= "community alias",
20276 .node
= COMMUNITY_ALIAS_NODE
,
20278 .config_write
= bgp_community_alias_write
,
20281 void community_alias_vty(void)
20283 install_node(&community_alias_node
);
20285 /* Community-list. */
20286 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20288 bgp_community_alias_command_completion_setup();