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 prefix_ipv6
*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",
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 WORD$advertise_str <exist-map|non-exist-map>$exist WORD$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 WORD$advertise_str <exist-map|non-exist-map>$exist WORD$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 vpn_policy_direction_t 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 vpn_policy_direction_t 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 vpn_policy_direction_t 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 vpn_policy_direction_t 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 vpn_policy_direction_t 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 prefix_ipv6
*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
, 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 /* Administrative shutdown. */
12564 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12565 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12566 vty_out(vty
, " Administratively shut down\n");
12569 vty_out(vty
, " BGP version 4");
12570 vty_out(vty
, ", remote router ID %s",
12571 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12572 vty_out(vty
, ", local router ID %s\n",
12573 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12576 /* Confederation */
12577 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12578 && bgp_confederation_peers_check(bgp
, p
->as
))
12580 " Neighbor under common administration\n");
12583 vty_out(vty
, " BGP state = %s",
12584 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12586 if (peer_established(p
))
12587 vty_out(vty
, ", up for %8s",
12588 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12591 else if (p
->status
== Active
) {
12592 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12593 vty_out(vty
, " (passive)");
12594 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12595 vty_out(vty
, " (NSF passive)");
12597 vty_out(vty
, "\n");
12600 vty_out(vty
, " Last read %s",
12601 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12603 vty_out(vty
, ", Last write %s\n",
12604 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12607 /* Configured timer values. */
12609 " Hold time is %d, keepalive interval is %d seconds\n",
12610 p
->v_holdtime
, p
->v_keepalive
);
12611 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12612 vty_out(vty
, " Configured hold time is %d",
12614 vty_out(vty
, ", keepalive interval is %d seconds\n",
12616 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12617 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12618 vty_out(vty
, " Configured hold time is %d",
12619 bgp
->default_holdtime
);
12620 vty_out(vty
, ", keepalive interval is %d seconds\n",
12621 bgp
->default_keepalive
);
12623 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12625 " Configured DelayOpenTime is %d seconds\n",
12628 /* Configured and synced tcp-mss value for peer */
12629 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12630 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12631 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12632 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12635 /* Extended Optional Parameters Length for BGP OPEN Message */
12636 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12638 " Extended Optional Parameters Length is enabled\n");
12641 if (peer_established(p
) &&
12642 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12644 json_object
*json_cap
= NULL
;
12646 json_cap
= json_object_new_object();
12649 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12650 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12651 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12652 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12653 json_object_string_add(
12654 json_cap
, "4byteAs",
12655 "advertisedAndReceived");
12656 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12657 json_object_string_add(json_cap
,
12660 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12661 json_object_string_add(json_cap
,
12666 /* Extended Message Support */
12667 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12668 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12669 json_object_string_add(json_cap
,
12671 "advertisedAndReceived");
12672 else if (CHECK_FLAG(p
->cap
,
12673 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12674 json_object_string_add(json_cap
,
12677 else if (CHECK_FLAG(p
->cap
,
12678 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12679 json_object_string_add(json_cap
,
12684 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12685 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12686 json_object
*json_add
= NULL
;
12687 const char *print_store
;
12689 json_add
= json_object_new_object();
12691 FOREACH_AFI_SAFI (afi
, safi
) {
12692 json_object
*json_sub
= NULL
;
12693 json_sub
= json_object_new_object();
12694 print_store
= get_afi_safi_str(
12698 p
->af_cap
[afi
][safi
],
12699 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12701 p
->af_cap
[afi
][safi
],
12702 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12706 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12710 PEER_CAP_ADDPATH_AF_TX_RCV
))
12711 json_object_boolean_true_add(
12713 "txAdvertisedAndReceived");
12718 PEER_CAP_ADDPATH_AF_TX_ADV
))
12719 json_object_boolean_true_add(
12726 PEER_CAP_ADDPATH_AF_TX_RCV
))
12727 json_object_boolean_true_add(
12733 p
->af_cap
[afi
][safi
],
12734 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12736 p
->af_cap
[afi
][safi
],
12737 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12741 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12745 PEER_CAP_ADDPATH_AF_RX_RCV
))
12746 json_object_boolean_true_add(
12748 "rxAdvertisedAndReceived");
12753 PEER_CAP_ADDPATH_AF_RX_ADV
))
12754 json_object_boolean_true_add(
12761 PEER_CAP_ADDPATH_AF_RX_RCV
))
12762 json_object_boolean_true_add(
12768 p
->af_cap
[afi
][safi
],
12769 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12771 p
->af_cap
[afi
][safi
],
12772 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
12774 p
->af_cap
[afi
][safi
],
12775 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12777 p
->af_cap
[afi
][safi
],
12778 PEER_CAP_ADDPATH_AF_RX_RCV
))
12779 json_object_object_add(
12780 json_add
, print_store
,
12783 json_object_free(json_sub
);
12786 json_object_object_add(json_cap
, "addPath",
12791 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
12792 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
12793 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
12794 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
12795 json_object_string_add(
12796 json_cap
, "dynamic",
12797 "advertisedAndReceived");
12798 else if (CHECK_FLAG(p
->cap
,
12799 PEER_CAP_DYNAMIC_ADV
))
12800 json_object_string_add(json_cap
,
12803 else if (CHECK_FLAG(p
->cap
,
12804 PEER_CAP_DYNAMIC_RCV
))
12805 json_object_string_add(json_cap
,
12810 /* Extended nexthop */
12811 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
12812 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12813 json_object
*json_nxt
= NULL
;
12814 const char *print_store
;
12817 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
12818 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12819 json_object_string_add(
12820 json_cap
, "extendedNexthop",
12821 "advertisedAndReceived");
12822 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
12823 json_object_string_add(
12824 json_cap
, "extendedNexthop",
12826 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12827 json_object_string_add(
12828 json_cap
, "extendedNexthop",
12831 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
12832 json_nxt
= json_object_new_object();
12834 for (safi
= SAFI_UNICAST
;
12835 safi
< SAFI_MAX
; safi
++) {
12839 PEER_CAP_ENHE_AF_RCV
)) {
12845 json_object_string_add(
12848 "recieved"); /* misspelled for compatibility */
12851 json_object_object_add(
12853 "extendedNexthopFamililesByPeer",
12858 /* Long-lived Graceful Restart */
12859 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
12860 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
12861 json_object
*json_llgr
= NULL
;
12862 const char *afi_safi_str
;
12864 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
12865 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12866 json_object_string_add(
12868 "longLivedGracefulRestart",
12869 "advertisedAndReceived");
12870 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
12871 json_object_string_add(
12873 "longLivedGracefulRestart",
12875 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12876 json_object_string_add(
12878 "longLivedGracefulRestart",
12881 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
12882 json_llgr
= json_object_new_object();
12884 FOREACH_AFI_SAFI (afi
, safi
) {
12888 PEER_CAP_ENHE_AF_RCV
)) {
12894 json_object_string_add(
12900 json_object_object_add(
12902 "longLivedGracefulRestartByPeer",
12907 /* Route Refresh */
12908 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
12909 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
12910 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
12911 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
12912 (CHECK_FLAG(p
->cap
,
12913 PEER_CAP_REFRESH_NEW_RCV
) ||
12915 PEER_CAP_REFRESH_OLD_RCV
))) {
12918 PEER_CAP_REFRESH_OLD_RCV
) &&
12921 PEER_CAP_REFRESH_NEW_RCV
))
12922 json_object_string_add(
12925 "advertisedAndReceivedOldNew");
12929 PEER_CAP_REFRESH_OLD_RCV
))
12930 json_object_string_add(
12933 "advertisedAndReceivedOld");
12935 json_object_string_add(
12938 "advertisedAndReceivedNew");
12940 } else if (CHECK_FLAG(p
->cap
,
12941 PEER_CAP_REFRESH_ADV
))
12942 json_object_string_add(json_cap
,
12945 else if (CHECK_FLAG(p
->cap
,
12946 PEER_CAP_REFRESH_NEW_RCV
) ||
12948 PEER_CAP_REFRESH_OLD_RCV
))
12949 json_object_string_add(json_cap
,
12954 /* Enhanced Route Refresh */
12955 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
12956 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
12957 if (CHECK_FLAG(p
->cap
,
12958 PEER_CAP_ENHANCED_RR_ADV
) &&
12960 PEER_CAP_ENHANCED_RR_RCV
))
12961 json_object_string_add(
12963 "enhancedRouteRefresh",
12964 "advertisedAndReceived");
12965 else if (CHECK_FLAG(p
->cap
,
12966 PEER_CAP_ENHANCED_RR_ADV
))
12967 json_object_string_add(
12969 "enhancedRouteRefresh",
12971 else if (CHECK_FLAG(p
->cap
,
12972 PEER_CAP_ENHANCED_RR_RCV
))
12973 json_object_string_add(
12975 "enhancedRouteRefresh",
12979 /* Multiprotocol Extensions */
12980 json_object
*json_multi
= NULL
;
12982 json_multi
= json_object_new_object();
12984 FOREACH_AFI_SAFI (afi
, safi
) {
12985 if (p
->afc_adv
[afi
][safi
] ||
12986 p
->afc_recv
[afi
][safi
]) {
12987 json_object
*json_exten
= NULL
;
12988 json_exten
= json_object_new_object();
12990 if (p
->afc_adv
[afi
][safi
] &&
12991 p
->afc_recv
[afi
][safi
])
12992 json_object_boolean_true_add(
12994 "advertisedAndReceived");
12995 else if (p
->afc_adv
[afi
][safi
])
12996 json_object_boolean_true_add(
12999 else if (p
->afc_recv
[afi
][safi
])
13000 json_object_boolean_true_add(
13001 json_exten
, "received");
13003 json_object_object_add(
13005 get_afi_safi_str(afi
, safi
,
13010 json_object_object_add(json_cap
,
13011 "multiprotocolExtensions",
13014 /* Hostname capabilities */
13015 json_object
*json_hname
= NULL
;
13017 json_hname
= json_object_new_object();
13019 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13020 json_object_string_add(
13021 json_hname
, "advHostName",
13022 bgp
->peer_self
->hostname
13023 ? bgp
->peer_self
->hostname
13025 json_object_string_add(
13026 json_hname
, "advDomainName",
13027 bgp
->peer_self
->domainname
13028 ? bgp
->peer_self
->domainname
13033 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13034 json_object_string_add(
13035 json_hname
, "rcvHostName",
13036 p
->hostname
? p
->hostname
: "n/a");
13037 json_object_string_add(
13038 json_hname
, "rcvDomainName",
13039 p
->domainname
? p
->domainname
: "n/a");
13042 json_object_object_add(json_cap
, "hostName",
13045 /* Gracefull Restart */
13046 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13047 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13048 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13049 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13050 json_object_string_add(
13051 json_cap
, "gracefulRestart",
13052 "advertisedAndReceived");
13053 else if (CHECK_FLAG(p
->cap
,
13054 PEER_CAP_RESTART_ADV
))
13055 json_object_string_add(
13057 "gracefulRestartCapability",
13059 else if (CHECK_FLAG(p
->cap
,
13060 PEER_CAP_RESTART_RCV
))
13061 json_object_string_add(
13063 "gracefulRestartCapability",
13066 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13067 int restart_af_count
= 0;
13068 json_object
*json_restart
= NULL
;
13069 json_restart
= json_object_new_object();
13071 json_object_int_add(
13073 "gracefulRestartRemoteTimerMsecs",
13074 p
->v_gr_restart
* 1000);
13076 FOREACH_AFI_SAFI (afi
, safi
) {
13080 PEER_CAP_RESTART_AF_RCV
)) {
13081 json_object
*json_sub
=
13084 json_object_new_object();
13090 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13091 json_object_boolean_true_add(
13094 restart_af_count
++;
13095 json_object_object_add(
13104 if (!restart_af_count
) {
13105 json_object_string_add(
13107 "addressFamiliesByPeer",
13109 json_object_free(json_restart
);
13111 json_object_object_add(
13113 "addressFamiliesByPeer",
13117 json_object_object_add(
13118 json_neigh
, "neighborCapabilities", json_cap
);
13120 vty_out(vty
, " Neighbor capabilities:\n");
13123 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13124 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13125 vty_out(vty
, " 4 Byte AS:");
13126 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13127 vty_out(vty
, " advertised");
13128 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13129 vty_out(vty
, " %sreceived",
13134 vty_out(vty
, "\n");
13137 /* Extended Message Support */
13138 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13139 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13140 vty_out(vty
, " Extended Message:");
13141 if (CHECK_FLAG(p
->cap
,
13142 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13143 vty_out(vty
, " advertised");
13144 if (CHECK_FLAG(p
->cap
,
13145 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13146 vty_out(vty
, " %sreceived",
13149 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13152 vty_out(vty
, "\n");
13156 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13157 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13158 vty_out(vty
, " AddPath:\n");
13160 FOREACH_AFI_SAFI (afi
, safi
) {
13162 p
->af_cap
[afi
][safi
],
13163 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13165 p
->af_cap
[afi
][safi
],
13166 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13167 vty_out(vty
, " %s: TX ",
13175 PEER_CAP_ADDPATH_AF_TX_ADV
))
13182 PEER_CAP_ADDPATH_AF_TX_RCV
))
13189 PEER_CAP_ADDPATH_AF_TX_ADV
)
13193 vty_out(vty
, "\n");
13197 p
->af_cap
[afi
][safi
],
13198 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13200 p
->af_cap
[afi
][safi
],
13201 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13202 vty_out(vty
, " %s: RX ",
13210 PEER_CAP_ADDPATH_AF_RX_ADV
))
13217 PEER_CAP_ADDPATH_AF_RX_RCV
))
13224 PEER_CAP_ADDPATH_AF_RX_ADV
)
13228 vty_out(vty
, "\n");
13234 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13235 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13236 vty_out(vty
, " Dynamic:");
13237 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13238 vty_out(vty
, " advertised");
13239 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13240 vty_out(vty
, " %sreceived",
13242 PEER_CAP_DYNAMIC_ADV
)
13245 vty_out(vty
, "\n");
13248 /* Extended nexthop */
13249 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13250 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13251 vty_out(vty
, " Extended nexthop:");
13252 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13253 vty_out(vty
, " advertised");
13254 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13255 vty_out(vty
, " %sreceived",
13260 vty_out(vty
, "\n");
13262 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13264 " Address families by peer:\n ");
13265 for (safi
= SAFI_UNICAST
;
13266 safi
< SAFI_MAX
; safi
++)
13270 PEER_CAP_ENHE_AF_RCV
))
13280 /* Long-lived Graceful Restart */
13281 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13282 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13284 " Long-lived Graceful Restart:");
13285 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13286 vty_out(vty
, " advertised");
13287 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13288 vty_out(vty
, " %sreceived",
13293 vty_out(vty
, "\n");
13295 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13297 " Address families by peer:\n");
13298 FOREACH_AFI_SAFI (afi
, safi
)
13302 PEER_CAP_LLGR_AF_RCV
))
13312 /* Route Refresh */
13313 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13314 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13315 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13316 vty_out(vty
, " Route refresh:");
13317 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13318 vty_out(vty
, " advertised");
13319 if (CHECK_FLAG(p
->cap
,
13320 PEER_CAP_REFRESH_NEW_RCV
) ||
13322 PEER_CAP_REFRESH_OLD_RCV
))
13323 vty_out(vty
, " %sreceived(%s)",
13325 PEER_CAP_REFRESH_ADV
)
13330 PEER_CAP_REFRESH_OLD_RCV
) &&
13333 PEER_CAP_REFRESH_NEW_RCV
))
13337 PEER_CAP_REFRESH_OLD_RCV
)
13341 vty_out(vty
, "\n");
13344 /* Enhanced Route Refresh */
13345 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13346 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13347 vty_out(vty
, " Enhanced Route Refresh:");
13348 if (CHECK_FLAG(p
->cap
,
13349 PEER_CAP_ENHANCED_RR_ADV
))
13350 vty_out(vty
, " advertised");
13351 if (CHECK_FLAG(p
->cap
,
13352 PEER_CAP_ENHANCED_RR_RCV
))
13353 vty_out(vty
, " %sreceived",
13355 PEER_CAP_REFRESH_ADV
)
13358 vty_out(vty
, "\n");
13361 /* Multiprotocol Extensions */
13362 FOREACH_AFI_SAFI (afi
, safi
)
13363 if (p
->afc_adv
[afi
][safi
] ||
13364 p
->afc_recv
[afi
][safi
]) {
13365 vty_out(vty
, " Address Family %s:",
13366 get_afi_safi_str(afi
, safi
,
13368 if (p
->afc_adv
[afi
][safi
])
13369 vty_out(vty
, " advertised");
13370 if (p
->afc_recv
[afi
][safi
])
13371 vty_out(vty
, " %sreceived",
13372 p
->afc_adv
[afi
][safi
]
13375 vty_out(vty
, "\n");
13378 /* Hostname capability */
13379 vty_out(vty
, " Hostname Capability:");
13381 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13383 " advertised (name: %s,domain name: %s)",
13384 bgp
->peer_self
->hostname
13385 ? bgp
->peer_self
->hostname
13387 bgp
->peer_self
->domainname
13388 ? bgp
->peer_self
->domainname
13391 vty_out(vty
, " not advertised");
13394 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13396 " received (name: %s,domain name: %s)",
13397 p
->hostname
? p
->hostname
: "n/a",
13398 p
->domainname
? p
->domainname
: "n/a");
13400 vty_out(vty
, " not received");
13403 vty_out(vty
, "\n");
13405 /* Graceful Restart */
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13407 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13409 " Graceful Restart Capability:");
13410 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13411 vty_out(vty
, " advertised");
13412 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13413 vty_out(vty
, " %sreceived",
13415 PEER_CAP_RESTART_ADV
)
13418 vty_out(vty
, "\n");
13420 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13421 int restart_af_count
= 0;
13424 " Remote Restart timer is %d seconds\n",
13427 " Address families by peer:\n ");
13429 FOREACH_AFI_SAFI (afi
, safi
)
13433 PEER_CAP_RESTART_AF_RCV
)) {
13434 vty_out(vty
, "%s%s(%s)",
13446 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13448 : "not preserved");
13449 restart_af_count
++;
13451 if (!restart_af_count
)
13452 vty_out(vty
, "none");
13453 vty_out(vty
, "\n");
13455 } /* Gracefull Restart */
13459 /* graceful restart information */
13460 json_object
*json_grace
= NULL
;
13461 json_object
*json_grace_send
= NULL
;
13462 json_object
*json_grace_recv
= NULL
;
13463 int eor_send_af_count
= 0;
13464 int eor_receive_af_count
= 0;
13467 json_grace
= json_object_new_object();
13468 json_grace_send
= json_object_new_object();
13469 json_grace_recv
= json_object_new_object();
13471 if ((peer_established(p
)) &&
13472 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13473 FOREACH_AFI_SAFI (afi
, safi
) {
13474 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13475 PEER_STATUS_EOR_SEND
)) {
13476 json_object_boolean_true_add(
13478 get_afi_safi_str(afi
, safi
,
13480 eor_send_af_count
++;
13483 FOREACH_AFI_SAFI (afi
, safi
) {
13484 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13485 PEER_STATUS_EOR_RECEIVED
)) {
13486 json_object_boolean_true_add(
13488 get_afi_safi_str(afi
, safi
,
13490 eor_receive_af_count
++;
13494 json_object_object_add(json_grace
, "endOfRibSend",
13496 json_object_object_add(json_grace
, "endOfRibRecv",
13500 if (p
->t_gr_restart
)
13501 json_object_int_add(
13502 json_grace
, "gracefulRestartTimerMsecs",
13503 thread_timer_remain_second(p
->t_gr_restart
) *
13507 json_object_int_add(
13508 json_grace
, "gracefulStalepathTimerMsecs",
13509 thread_timer_remain_second(p
->t_gr_stale
) *
13511 /* more gr info in new format */
13512 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13513 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13516 vty_out(vty
, " Graceful restart information:\n");
13517 if ((peer_established(p
)) &&
13518 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13520 vty_out(vty
, " End-of-RIB send: ");
13521 FOREACH_AFI_SAFI (afi
, safi
) {
13522 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13523 PEER_STATUS_EOR_SEND
)) {
13524 vty_out(vty
, "%s%s",
13525 eor_send_af_count
? ", " : "",
13526 get_afi_safi_str(afi
, safi
,
13528 eor_send_af_count
++;
13531 vty_out(vty
, "\n");
13532 vty_out(vty
, " End-of-RIB received: ");
13533 FOREACH_AFI_SAFI (afi
, safi
) {
13534 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13535 PEER_STATUS_EOR_RECEIVED
)) {
13536 vty_out(vty
, "%s%s",
13537 eor_receive_af_count
? ", "
13539 get_afi_safi_str(afi
, safi
,
13541 eor_receive_af_count
++;
13544 vty_out(vty
, "\n");
13547 if (p
->t_gr_restart
)
13549 " The remaining time of restart timer is %ld\n",
13550 thread_timer_remain_second(p
->t_gr_restart
));
13554 " The remaining time of stalepath timer is %ld\n",
13555 thread_timer_remain_second(p
->t_gr_stale
));
13557 /* more gr info in new format */
13558 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13562 json_object
*json_stat
= NULL
;
13563 json_stat
= json_object_new_object();
13564 /* Packet counts. */
13566 atomic_size_t outq_count
, inq_count
;
13567 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13568 memory_order_relaxed
);
13569 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13570 memory_order_relaxed
);
13572 json_object_int_add(json_stat
, "depthInq",
13573 (unsigned long)inq_count
);
13574 json_object_int_add(json_stat
, "depthOutq",
13575 (unsigned long)outq_count
);
13576 json_object_int_add(json_stat
, "opensSent",
13577 atomic_load_explicit(&p
->open_out
,
13578 memory_order_relaxed
));
13579 json_object_int_add(json_stat
, "opensRecv",
13580 atomic_load_explicit(&p
->open_in
,
13581 memory_order_relaxed
));
13582 json_object_int_add(json_stat
, "notificationsSent",
13583 atomic_load_explicit(&p
->notify_out
,
13584 memory_order_relaxed
));
13585 json_object_int_add(json_stat
, "notificationsRecv",
13586 atomic_load_explicit(&p
->notify_in
,
13587 memory_order_relaxed
));
13588 json_object_int_add(json_stat
, "updatesSent",
13589 atomic_load_explicit(&p
->update_out
,
13590 memory_order_relaxed
));
13591 json_object_int_add(json_stat
, "updatesRecv",
13592 atomic_load_explicit(&p
->update_in
,
13593 memory_order_relaxed
));
13594 json_object_int_add(json_stat
, "keepalivesSent",
13595 atomic_load_explicit(&p
->keepalive_out
,
13596 memory_order_relaxed
));
13597 json_object_int_add(json_stat
, "keepalivesRecv",
13598 atomic_load_explicit(&p
->keepalive_in
,
13599 memory_order_relaxed
));
13600 json_object_int_add(json_stat
, "routeRefreshSent",
13601 atomic_load_explicit(&p
->refresh_out
,
13602 memory_order_relaxed
));
13603 json_object_int_add(json_stat
, "routeRefreshRecv",
13604 atomic_load_explicit(&p
->refresh_in
,
13605 memory_order_relaxed
));
13606 json_object_int_add(json_stat
, "capabilitySent",
13607 atomic_load_explicit(&p
->dynamic_cap_out
,
13608 memory_order_relaxed
));
13609 json_object_int_add(json_stat
, "capabilityRecv",
13610 atomic_load_explicit(&p
->dynamic_cap_in
,
13611 memory_order_relaxed
));
13612 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13613 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13614 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13616 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13617 notify_out
, notify_in
, update_out
, update_in
,
13618 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13619 dynamic_cap_out
, dynamic_cap_in
;
13620 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13621 memory_order_relaxed
);
13622 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13623 memory_order_relaxed
);
13624 open_out
= atomic_load_explicit(&p
->open_out
,
13625 memory_order_relaxed
);
13627 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
13628 notify_out
= atomic_load_explicit(&p
->notify_out
,
13629 memory_order_relaxed
);
13630 notify_in
= atomic_load_explicit(&p
->notify_in
,
13631 memory_order_relaxed
);
13632 update_out
= atomic_load_explicit(&p
->update_out
,
13633 memory_order_relaxed
);
13634 update_in
= atomic_load_explicit(&p
->update_in
,
13635 memory_order_relaxed
);
13636 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
13637 memory_order_relaxed
);
13638 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
13639 memory_order_relaxed
);
13640 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
13641 memory_order_relaxed
);
13642 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
13643 memory_order_relaxed
);
13644 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
13645 memory_order_relaxed
);
13646 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
13647 memory_order_relaxed
);
13649 /* Packet counts. */
13650 vty_out(vty
, " Message statistics:\n");
13651 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13652 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13653 vty_out(vty
, " Sent Rcvd\n");
13654 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
13656 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
13658 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
13660 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
13662 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
13664 vty_out(vty
, " Capability: %10zu %10zu\n",
13665 dynamic_cap_out
, dynamic_cap_in
);
13666 vty_out(vty
, " Total: %10u %10u\n",
13667 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
13671 /* advertisement-interval */
13672 json_object_int_add(json_neigh
,
13673 "minBtwnAdvertisementRunsTimerMsecs",
13674 p
->v_routeadv
* 1000);
13676 /* Update-source. */
13677 if (p
->update_if
|| p
->update_source
) {
13679 json_object_string_add(json_neigh
,
13682 else if (p
->update_source
)
13683 json_object_string_add(
13684 json_neigh
, "updateSource",
13685 sockunion2str(p
->update_source
, buf1
,
13689 /* advertisement-interval */
13691 " Minimum time between advertisement runs is %d seconds\n",
13694 /* Update-source. */
13695 if (p
->update_if
|| p
->update_source
) {
13696 vty_out(vty
, " Update source is ");
13698 vty_out(vty
, "%s", p
->update_if
);
13699 else if (p
->update_source
)
13701 sockunion2str(p
->update_source
, buf1
,
13703 vty_out(vty
, "\n");
13706 vty_out(vty
, "\n");
13709 /* Address Family Information */
13710 json_object
*json_hold
= NULL
;
13713 json_hold
= json_object_new_object();
13715 FOREACH_AFI_SAFI (afi
, safi
)
13716 if (p
->afc
[afi
][safi
])
13717 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13721 json_object_object_add(json_neigh
, "addressFamilyInfo",
13723 json_object_int_add(json_neigh
, "connectionsEstablished",
13725 json_object_int_add(json_neigh
, "connectionsDropped",
13728 vty_out(vty
, " Connections established %d; dropped %d\n",
13729 p
->established
, p
->dropped
);
13731 if (!p
->last_reset
) {
13733 json_object_string_add(json_neigh
, "lastReset",
13736 vty_out(vty
, " Last reset never\n");
13742 uptime
= bgp_clock();
13743 uptime
-= p
->resettime
;
13744 gmtime_r(&uptime
, &tm
);
13746 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13748 + (tm
.tm_min
* 60000)
13749 + (tm
.tm_hour
* 3600000));
13750 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13752 vty_out(vty
, " Last reset %s, ",
13753 peer_uptime(p
->resettime
, timebuf
,
13754 BGP_UPTIME_LEN
, 0, NULL
));
13756 bgp_show_peer_reset(vty
, p
, NULL
, false);
13757 if (p
->last_reset_cause_size
) {
13758 msg
= p
->last_reset_cause
;
13760 " Message received that caused BGP to send a NOTIFICATION:\n ");
13761 for (i
= 1; i
<= p
->last_reset_cause_size
;
13763 vty_out(vty
, "%02X", *msg
++);
13765 if (i
!= p
->last_reset_cause_size
) {
13767 vty_out(vty
, "\n ");
13768 } else if (i
% 4 == 0) {
13773 vty_out(vty
, "\n");
13778 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13780 json_object_boolean_true_add(json_neigh
,
13781 "prefixesConfigExceedMax");
13784 " Peer had exceeded the max. no. of prefixes configured.\n");
13786 if (p
->t_pmax_restart
) {
13788 json_object_boolean_true_add(
13789 json_neigh
, "reducePrefixNumFrom");
13790 json_object_int_add(json_neigh
,
13791 "restartInTimerMsec",
13792 thread_timer_remain_second(
13797 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13798 p
->host
, thread_timer_remain_second(
13799 p
->t_pmax_restart
));
13802 json_object_boolean_true_add(
13804 "reducePrefixNumAndClearIpBgp");
13807 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13812 /* EBGP Multihop and GTSM */
13813 if (p
->sort
!= BGP_PEER_IBGP
) {
13815 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13816 json_object_int_add(json_neigh
,
13817 "externalBgpNbrMaxHopsAway",
13819 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13820 json_object_int_add(json_neigh
,
13821 "externalBgpNbrMaxHopsAway",
13824 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13826 " External BGP neighbor may be up to %d hops away.\n",
13828 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13830 " External BGP neighbor may be up to %d hops away.\n",
13834 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13836 json_object_int_add(json_neigh
,
13837 "internalBgpNbrMaxHopsAway",
13841 " Internal BGP neighbor may be up to %d hops away.\n",
13846 /* Local address. */
13849 json_object_string_add(json_neigh
, "hostLocal",
13850 sockunion2str(p
->su_local
, buf1
,
13852 json_object_int_add(json_neigh
, "portLocal",
13853 ntohs(p
->su_local
->sin
.sin_port
));
13855 vty_out(vty
, "Local host: %s, Local port: %d\n",
13856 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13857 ntohs(p
->su_local
->sin
.sin_port
));
13860 /* Remote address. */
13861 if (p
->su_remote
) {
13863 json_object_string_add(json_neigh
, "hostForeign",
13864 sockunion2str(p
->su_remote
, buf1
,
13866 json_object_int_add(json_neigh
, "portForeign",
13867 ntohs(p
->su_remote
->sin
.sin_port
));
13869 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13870 sockunion2str(p
->su_remote
, buf1
,
13872 ntohs(p
->su_remote
->sin
.sin_port
));
13875 /* Nexthop display. */
13878 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
13880 json_object_string_addf(json_neigh
, "nexthopGlobal",
13881 "%pI6", &p
->nexthop
.v6_global
);
13882 json_object_string_addf(json_neigh
, "nexthopLocal",
13883 "%pI6", &p
->nexthop
.v6_local
);
13884 if (p
->shared_network
)
13885 json_object_string_add(json_neigh
,
13889 json_object_string_add(json_neigh
,
13891 "nonSharedNetwork");
13893 vty_out(vty
, "Nexthop: %s\n",
13894 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13896 vty_out(vty
, "Nexthop global: %s\n",
13897 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
13899 vty_out(vty
, "Nexthop local: %s\n",
13900 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
13902 vty_out(vty
, "BGP connection: %s\n",
13903 p
->shared_network
? "shared network"
13904 : "non shared network");
13908 /* Timer information. */
13910 json_object_int_add(json_neigh
, "connectRetryTimer",
13912 if (peer_established(p
) && p
->rtt
)
13913 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
13916 json_object_int_add(
13917 json_neigh
, "nextStartTimerDueInMsecs",
13918 thread_timer_remain_second(p
->t_start
) * 1000);
13920 json_object_int_add(
13921 json_neigh
, "nextConnectTimerDueInMsecs",
13922 thread_timer_remain_second(p
->t_connect
)
13924 if (p
->t_routeadv
) {
13925 json_object_int_add(json_neigh
, "mraiInterval",
13927 json_object_int_add(
13928 json_neigh
, "mraiTimerExpireInMsecs",
13929 thread_timer_remain_second(p
->t_routeadv
)
13933 json_object_int_add(json_neigh
, "authenticationEnabled",
13937 json_object_string_add(json_neigh
, "readThread", "on");
13939 json_object_string_add(json_neigh
, "readThread", "off");
13941 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
13942 json_object_string_add(json_neigh
, "writeThread", "on");
13944 json_object_string_add(json_neigh
, "writeThread",
13947 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
13949 if (peer_established(p
) && p
->rtt
)
13950 vty_out(vty
, "Estimated round trip time: %d ms\n",
13953 vty_out(vty
, "Next start timer due in %ld seconds\n",
13954 thread_timer_remain_second(p
->t_start
));
13956 vty_out(vty
, "Next connect timer due in %ld seconds\n",
13957 thread_timer_remain_second(p
->t_connect
));
13960 "MRAI (interval %u) timer expires in %ld seconds\n",
13962 thread_timer_remain_second(p
->t_routeadv
));
13964 vty_out(vty
, "Peer Authentication Enabled\n");
13966 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
13967 p
->t_read
? "on" : "off",
13968 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
13973 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
13974 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
13975 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
13978 vty_out(vty
, "\n");
13980 /* BFD information. */
13982 bgp_bfd_show_info(vty
, p
, json_neigh
);
13985 if (p
->conf_if
) /* Configured interface name. */
13986 json_object_object_add(json
, p
->conf_if
, json_neigh
);
13987 else /* Configured IP address. */
13988 json_object_object_add(json
, p
->host
, json_neigh
);
13992 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
13993 enum show_type type
,
13994 union sockunion
*su
,
13995 const char *conf_if
, afi_t afi
,
13998 struct listnode
*node
, *nnode
;
14001 safi_t safi
= SAFI_UNICAST
;
14002 json_object
*json
= NULL
;
14003 json_object
*json_neighbor
= NULL
;
14006 json
= json_object_new_object();
14007 json_neighbor
= json_object_new_object();
14010 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14012 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14015 if ((peer
->afc
[afi
][safi
]) == 0)
14018 if (type
== show_all
) {
14019 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14023 json_object_object_add(json
, peer
->host
,
14025 json_neighbor
= NULL
;
14028 } else if (type
== show_peer
) {
14031 && !strcmp(peer
->conf_if
, conf_if
))
14033 && !strcmp(peer
->hostname
, conf_if
))) {
14035 bgp_show_peer_gr_status(vty
, peer
,
14040 if (sockunion_same(&peer
->su
, su
)) {
14042 bgp_show_peer_gr_status(vty
, peer
,
14047 if (use_json
&& find
)
14048 json_object_object_add(json
, peer
->host
,
14053 json_neighbor
= NULL
;
14058 if (type
== show_peer
&& !find
) {
14060 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14062 vty_out(vty
, "%% No such neighbor\n");
14066 json_object_free(json_neighbor
);
14067 vty_json(vty
, json
);
14069 vty_out(vty
, "\n");
14072 return CMD_SUCCESS
;
14075 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14076 enum show_type type
, union sockunion
*su
,
14077 const char *conf_if
, bool use_json
,
14080 struct listnode
*node
, *nnode
;
14083 bool nbr_output
= false;
14084 afi_t afi
= AFI_MAX
;
14085 safi_t safi
= SAFI_MAX
;
14087 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14089 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14093 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14094 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14099 bgp_show_peer(vty
, peer
, use_json
, json
);
14105 && !strcmp(peer
->conf_if
, conf_if
))
14107 && !strcmp(peer
->hostname
, conf_if
))) {
14109 bgp_show_peer(vty
, peer
, use_json
,
14113 if (sockunion_same(&peer
->su
, su
)) {
14115 bgp_show_peer(vty
, peer
, use_json
,
14120 case show_ipv4_peer
:
14121 case show_ipv6_peer
:
14122 FOREACH_SAFI (safi
) {
14123 if (peer
->afc
[afi
][safi
]) {
14126 && !strcmp(peer
->conf_if
, conf_if
))
14128 && !strcmp(peer
->hostname
, conf_if
))) {
14130 bgp_show_peer(vty
, peer
, use_json
,
14135 if (sockunion_same(&peer
->su
, su
)) {
14137 bgp_show_peer(vty
, peer
, use_json
,
14145 case show_ipv4_all
:
14146 case show_ipv6_all
:
14147 FOREACH_SAFI (safi
) {
14148 if (peer
->afc
[afi
][safi
]) {
14149 bgp_show_peer(vty
, peer
, use_json
, json
);
14158 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14159 type
== show_ipv6_peer
) && !find
) {
14161 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14163 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14166 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14167 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14168 vty_out(vty
, "%% No BGP neighbors found\n");
14171 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14172 json
, JSON_C_TO_STRING_PRETTY
));
14174 vty_out(vty
, "\n");
14177 return CMD_SUCCESS
;
14180 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14181 enum show_type type
,
14182 const char *ip_str
,
14183 afi_t afi
, bool use_json
)
14188 union sockunion su
;
14190 bgp
= bgp_get_default();
14196 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14200 ret
= str2sockunion(ip_str
, &su
);
14202 bgp_show_neighbor_graceful_restart(
14203 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14205 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14206 NULL
, afi
, use_json
);
14208 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14212 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14213 enum show_type type
,
14214 const char *ip_str
,
14217 struct listnode
*node
, *nnode
;
14219 union sockunion su
;
14220 json_object
*json
= NULL
;
14221 int ret
, is_first
= 1;
14222 bool nbr_output
= false;
14225 vty_out(vty
, "{\n");
14227 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14230 if (!(json
= json_object_new_object())) {
14232 EC_BGP_JSON_MEM_ERROR
,
14233 "Unable to allocate memory for JSON object");
14235 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14239 json_object_int_add(json
, "vrfId",
14240 (bgp
->vrf_id
== VRF_UNKNOWN
)
14242 : (int64_t)bgp
->vrf_id
);
14243 json_object_string_add(
14245 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14250 vty_out(vty
, ",\n");
14254 vty_out(vty
, "\"%s\":",
14255 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14259 vty_out(vty
, "\nInstance %s:\n",
14260 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14265 if (type
== show_peer
|| type
== show_ipv4_peer
||
14266 type
== show_ipv6_peer
) {
14267 ret
= str2sockunion(ip_str
, &su
);
14269 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14272 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14275 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14278 json_object_free(json
);
14283 vty_out(vty
, "}\n");
14284 else if (!nbr_output
)
14285 vty_out(vty
, "%% BGP instance not found\n");
14288 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14289 enum show_type type
, const char *ip_str
,
14294 union sockunion su
;
14295 json_object
*json
= NULL
;
14298 if (strmatch(name
, "all")) {
14299 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14301 return CMD_SUCCESS
;
14303 bgp
= bgp_lookup_by_name(name
);
14306 json
= json_object_new_object();
14307 vty_json(vty
, json
);
14310 "%% BGP instance not found\n");
14312 return CMD_WARNING
;
14316 bgp
= bgp_get_default();
14320 json
= json_object_new_object();
14322 ret
= str2sockunion(ip_str
, &su
);
14324 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14327 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14330 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14333 json_object_free(json
);
14336 vty_out(vty
, "{}\n");
14338 vty_out(vty
, "%% BGP instance not found\n");
14341 return CMD_SUCCESS
;
14346 /* "show [ip] bgp neighbors graceful-restart" commands. */
14347 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14348 show_ip_bgp_neighbors_graceful_restart_cmd
,
14349 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14355 "Neighbor to display information about\n"
14356 "Neighbor to display information about\n"
14357 "Neighbor on BGP configured interface\n"
14361 char *sh_arg
= NULL
;
14362 enum show_type sh_type
;
14364 afi_t afi
= AFI_MAX
;
14365 bool uj
= use_json(argc
, argv
);
14367 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14372 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14373 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14374 || argv_find(argv
, argc
, "WORD", &idx
)) {
14375 sh_type
= show_peer
;
14376 sh_arg
= argv
[idx
]->arg
;
14378 sh_type
= show_all
;
14380 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14381 return CMD_SUCCESS
;
14384 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14388 /* "show [ip] bgp neighbors" commands. */
14389 DEFUN (show_ip_bgp_neighbors
,
14390 show_ip_bgp_neighbors_cmd
,
14391 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14395 BGP_INSTANCE_HELP_STR
14398 "Detailed information on TCP and BGP neighbor connections\n"
14399 "Neighbor to display information about\n"
14400 "Neighbor to display information about\n"
14401 "Neighbor on BGP configured interface\n"
14405 char *sh_arg
= NULL
;
14406 enum show_type sh_type
;
14407 afi_t afi
= AFI_MAX
;
14409 bool uj
= use_json(argc
, argv
);
14413 /* [<vrf> VIEWVRFNAME] */
14414 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14415 vrf
= argv
[idx
+ 1]->arg
;
14416 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14418 } else if (argv_find(argv
, argc
, "view", &idx
))
14419 /* [<view> VIEWVRFNAME] */
14420 vrf
= argv
[idx
+ 1]->arg
;
14424 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14425 sh_type
= show_ipv4_all
;
14427 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14428 sh_type
= show_ipv6_all
;
14431 sh_type
= show_all
;
14434 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14435 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14436 || argv_find(argv
, argc
, "WORD", &idx
)) {
14437 sh_type
= show_peer
;
14438 sh_arg
= argv
[idx
]->arg
;
14441 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14442 sh_type
= show_ipv4_peer
;
14443 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14444 sh_type
= show_ipv6_peer
;
14447 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14450 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14451 paths' and `show ip mbgp paths'. Those functions results are the
14453 DEFUN (show_ip_bgp_paths
,
14454 show_ip_bgp_paths_cmd
,
14455 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14460 "Path information\n")
14462 vty_out(vty
, "Address Refcnt Path\n");
14463 aspath_print_all_vty(vty
);
14464 return CMD_SUCCESS
;
14469 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14472 struct community
*com
;
14474 com
= (struct community
*)bucket
->data
;
14475 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14476 community_str(com
, false));
14479 /* Show BGP's community internal data. */
14480 DEFUN (show_ip_bgp_community_info
,
14481 show_ip_bgp_community_info_cmd
,
14482 "show [ip] bgp community-info",
14486 "List all bgp community information\n")
14488 vty_out(vty
, "Address Refcnt Community\n");
14490 hash_iterate(community_hash(),
14491 (void (*)(struct hash_bucket
*,
14492 void *))community_show_all_iterator
,
14495 return CMD_SUCCESS
;
14498 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14501 struct lcommunity
*lcom
;
14503 lcom
= (struct lcommunity
*)bucket
->data
;
14504 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14505 lcommunity_str(lcom
, false));
14508 /* Show BGP's community internal data. */
14509 DEFUN (show_ip_bgp_lcommunity_info
,
14510 show_ip_bgp_lcommunity_info_cmd
,
14511 "show ip bgp large-community-info",
14515 "List all bgp large-community information\n")
14517 vty_out(vty
, "Address Refcnt Large-community\n");
14519 hash_iterate(lcommunity_hash(),
14520 (void (*)(struct hash_bucket
*,
14521 void *))lcommunity_show_all_iterator
,
14524 return CMD_SUCCESS
;
14526 /* Graceful Restart */
14528 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14535 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14537 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14539 switch (bgp_global_gr_mode
) {
14541 case GLOBAL_HELPER
:
14542 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14546 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14549 case GLOBAL_DISABLE
:
14550 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14553 case GLOBAL_INVALID
:
14555 "Global BGP GR Mode Invalid\n");
14558 vty_out(vty
, "\n");
14561 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14562 enum show_type type
,
14563 const char *ip_str
,
14564 afi_t afi
, bool use_json
)
14566 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14569 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14571 bgp_show_neighbor_graceful_restart_vty(
14572 vty
, type
, ip_str
, afi
, use_json
);
14575 } else if (afi
!= AFI_MAX
) {
14576 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14579 return CMD_ERR_INCOMPLETE
;
14582 return CMD_SUCCESS
;
14584 /* Graceful Restart */
14586 DEFUN (show_ip_bgp_attr_info
,
14587 show_ip_bgp_attr_info_cmd
,
14588 "show [ip] bgp attribute-info",
14592 "List all bgp attribute information\n")
14594 attr_show_all(vty
);
14595 return CMD_SUCCESS
;
14598 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14599 afi_t afi
, safi_t safi
,
14600 bool use_json
, json_object
*json
)
14603 struct listnode
*node
;
14605 char buf1
[INET6_ADDRSTRLEN
];
14607 vpn_policy_direction_t dir
;
14610 json_object
*json_import_vrfs
= NULL
;
14611 json_object
*json_export_vrfs
= NULL
;
14613 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14616 vty_json(vty
, json
);
14618 return CMD_WARNING
;
14621 /* Provide context for the block */
14622 json_object_string_add(json
, "vrf", name
? name
: "default");
14623 json_object_string_add(json
, "afiSafi",
14624 get_afi_safi_str(afi
, safi
, true));
14626 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14627 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14628 json_object_string_add(json
, "importFromVrfs", "none");
14629 json_object_string_add(json
, "importRts", "none");
14631 json_import_vrfs
= json_object_new_array();
14633 for (ALL_LIST_ELEMENTS_RO(
14634 bgp
->vpn_policy
[afi
].import_vrf
,
14636 json_object_array_add(json_import_vrfs
,
14637 json_object_new_string(vname
));
14639 json_object_object_add(json
, "importFromVrfs",
14641 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14642 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14643 ecom_str
= ecommunity_ecom2str(
14644 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14645 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14646 json_object_string_add(json
, "importRts",
14648 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14650 json_object_string_add(json
, "importRts",
14654 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14655 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14656 json_object_string_add(json
, "exportToVrfs", "none");
14657 json_object_string_add(json
, "routeDistinguisher",
14659 json_object_string_add(json
, "exportRts", "none");
14661 json_export_vrfs
= json_object_new_array();
14663 for (ALL_LIST_ELEMENTS_RO(
14664 bgp
->vpn_policy
[afi
].export_vrf
,
14666 json_object_array_add(json_export_vrfs
,
14667 json_object_new_string(vname
));
14668 json_object_object_add(json
, "exportToVrfs",
14670 json_object_string_add(json
, "routeDistinguisher",
14671 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14672 buf1
, RD_ADDRSTRLEN
));
14674 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14675 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14676 ecom_str
= ecommunity_ecom2str(
14677 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14678 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14679 json_object_string_add(json
, "exportRts",
14681 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14683 json_object_string_add(json
, "exportRts",
14688 vty_json(vty
, json
);
14691 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14694 vty_out(vty
, "%% No such BGP instance exist\n");
14695 return CMD_WARNING
;
14698 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14699 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14701 "This VRF is not importing %s routes from any other VRF\n",
14702 get_afi_safi_str(afi
, safi
, false));
14705 "This VRF is importing %s routes from the following VRFs:\n",
14706 get_afi_safi_str(afi
, safi
, false));
14708 for (ALL_LIST_ELEMENTS_RO(
14709 bgp
->vpn_policy
[afi
].import_vrf
,
14711 vty_out(vty
, " %s\n", vname
);
14713 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14715 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14716 ecom_str
= ecommunity_ecom2str(
14717 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14718 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14719 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14721 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14723 vty_out(vty
, "Import RT(s):\n");
14726 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14727 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14729 "This VRF is not exporting %s routes to any other VRF\n",
14730 get_afi_safi_str(afi
, safi
, false));
14733 "This VRF is exporting %s routes to the following VRFs:\n",
14734 get_afi_safi_str(afi
, safi
, false));
14736 for (ALL_LIST_ELEMENTS_RO(
14737 bgp
->vpn_policy
[afi
].export_vrf
,
14739 vty_out(vty
, " %s\n", vname
);
14741 vty_out(vty
, "RD: %s\n",
14742 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14743 buf1
, RD_ADDRSTRLEN
));
14745 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14746 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14747 ecom_str
= ecommunity_ecom2str(
14748 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14749 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14750 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14751 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14753 vty_out(vty
, "Import RT(s):\n");
14757 return CMD_SUCCESS
;
14760 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14761 safi_t safi
, bool use_json
)
14763 struct listnode
*node
, *nnode
;
14765 char *vrf_name
= NULL
;
14766 json_object
*json
= NULL
;
14767 json_object
*json_vrf
= NULL
;
14768 json_object
*json_vrfs
= NULL
;
14771 json
= json_object_new_object();
14772 json_vrfs
= json_object_new_object();
14775 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14777 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14778 vrf_name
= bgp
->name
;
14781 json_vrf
= json_object_new_object();
14783 vty_out(vty
, "\nInstance %s:\n",
14784 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14785 ? VRF_DEFAULT_NAME
: bgp
->name
);
14787 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14789 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14790 json_object_object_add(json_vrfs
,
14791 VRF_DEFAULT_NAME
, json_vrf
);
14793 json_object_object_add(json_vrfs
, vrf_name
,
14799 json_object_object_add(json
, "vrfs", json_vrfs
);
14800 vty_json(vty
, json
);
14803 return CMD_SUCCESS
;
14806 /* "show [ip] bgp route-leak" command. */
14807 DEFUN (show_ip_bgp_route_leak
,
14808 show_ip_bgp_route_leak_cmd
,
14809 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14813 BGP_INSTANCE_HELP_STR
14816 "Route leaking information\n"
14820 afi_t afi
= AFI_MAX
;
14821 safi_t safi
= SAFI_MAX
;
14823 bool uj
= use_json(argc
, argv
);
14825 json_object
*json
= NULL
;
14827 /* show [ip] bgp */
14828 if (argv_find(argv
, argc
, "ip", &idx
)) {
14830 safi
= SAFI_UNICAST
;
14832 /* [vrf VIEWVRFNAME] */
14833 if (argv_find(argv
, argc
, "view", &idx
)) {
14835 "%% This command is not applicable to BGP views\n");
14836 return CMD_WARNING
;
14839 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14840 vrf
= argv
[idx
+ 1]->arg
;
14841 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14844 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14845 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14846 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14848 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14850 "%% This command is applicable only for unicast ipv4|ipv6\n");
14851 return CMD_WARNING
;
14854 if (vrf
&& strmatch(vrf
, "all"))
14855 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14858 json
= json_object_new_object();
14860 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14863 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14866 struct listnode
*node
, *nnode
;
14869 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14870 vty_out(vty
, "\nInstance %s:\n",
14871 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14874 update_group_show(bgp
, afi
, safi
, vty
, 0);
14878 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14879 int safi
, uint64_t subgrp_id
)
14884 if (strmatch(name
, "all")) {
14885 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14886 return CMD_SUCCESS
;
14888 bgp
= bgp_lookup_by_name(name
);
14891 bgp
= bgp_get_default();
14895 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
14896 return CMD_SUCCESS
;
14899 DEFUN (show_ip_bgp_updgrps
,
14900 show_ip_bgp_updgrps_cmd
,
14901 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
14905 BGP_INSTANCE_HELP_STR
14907 BGP_SAFI_WITH_LABEL_HELP_STR
14908 "Detailed info about dynamic update groups\n"
14909 "Specific subgroup to display detailed info for\n")
14912 afi_t afi
= AFI_IP6
;
14913 safi_t safi
= SAFI_UNICAST
;
14914 uint64_t subgrp_id
= 0;
14918 /* show [ip] bgp */
14919 if (argv_find(argv
, argc
, "ip", &idx
))
14921 /* [<vrf> VIEWVRFNAME] */
14922 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14923 vrf
= argv
[idx
+ 1]->arg
;
14924 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14926 } else if (argv_find(argv
, argc
, "view", &idx
))
14927 /* [<view> VIEWVRFNAME] */
14928 vrf
= argv
[idx
+ 1]->arg
;
14929 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14930 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14931 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14934 /* get subgroup id, if provided */
14936 if (argv
[idx
]->type
== VARIABLE_TKN
)
14937 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
14939 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
14942 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
14943 show_bgp_instance_all_ipv6_updgrps_cmd
,
14944 "show [ip] bgp <view|vrf> all update-groups",
14948 BGP_INSTANCE_ALL_HELP_STR
14949 "Detailed info about dynamic update groups\n")
14951 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
14952 return CMD_SUCCESS
;
14955 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
14956 show_bgp_l2vpn_evpn_updgrps_cmd
,
14957 "show [ip] bgp l2vpn evpn update-groups",
14961 "l2vpn address family\n"
14962 "evpn sub-address family\n"
14963 "Detailed info about dynamic update groups\n")
14966 uint64_t subgrp_id
= 0;
14968 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
14969 return CMD_SUCCESS
;
14972 DEFUN (show_bgp_updgrps_stats
,
14973 show_bgp_updgrps_stats_cmd
,
14974 "show [ip] bgp update-groups statistics",
14978 "Detailed info about dynamic update groups\n"
14983 bgp
= bgp_get_default();
14985 update_group_show_stats(bgp
, vty
);
14987 return CMD_SUCCESS
;
14990 DEFUN (show_bgp_instance_updgrps_stats
,
14991 show_bgp_instance_updgrps_stats_cmd
,
14992 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
14996 BGP_INSTANCE_HELP_STR
14997 "Detailed info about dynamic update groups\n"
15003 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15005 update_group_show_stats(bgp
, vty
);
15007 return CMD_SUCCESS
;
15010 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15011 afi_t afi
, safi_t safi
,
15012 const char *what
, uint64_t subgrp_id
)
15017 bgp
= bgp_lookup_by_name(name
);
15019 bgp
= bgp_get_default();
15022 if (!strcmp(what
, "advertise-queue"))
15023 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15025 else if (!strcmp(what
, "advertised-routes"))
15026 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15028 else if (!strcmp(what
, "packet-queue"))
15029 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15034 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15035 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15036 "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",
15037 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15039 "Detailed info about dynamic update groups\n"
15040 "Specific subgroup to display info for\n"
15041 "Advertisement queue\n"
15042 "Announced routes\n"
15045 uint64_t subgrp_id
= 0;
15049 subgrp_id
= strtoull(sgid
, NULL
, 10);
15054 afiz
= bgp_vty_afi_from_str(afi
);
15058 afiz
= bgp_vty_afi_from_str(afi
);
15059 if (afiz
!= AFI_IP
)
15061 "%% Cannot specify both 'ip' and 'ipv6'\n");
15062 return CMD_WARNING
;
15065 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15067 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15068 return CMD_SUCCESS
;
15071 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15074 struct listnode
*node
, *nnode
;
15075 struct prefix
*range
;
15080 const char *peer_status
;
15084 json_object
*json_peer_group
= NULL
;
15085 json_object
*json_peer_group_afc
= NULL
;
15086 json_object
*json_peer_group_members
= NULL
;
15087 json_object
*json_peer_group_dynamic
= NULL
;
15088 json_object
*json_peer_group_dynamic_af
= NULL
;
15089 json_object
*json_peer_group_ranges
= NULL
;
15091 conf
= group
->conf
;
15094 json_peer_group
= json_object_new_object();
15095 json_peer_group_afc
= json_object_new_array();
15098 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15100 json_object_int_add(json_peer_group
, "remoteAs",
15103 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15104 group
->name
, conf
->as
);
15105 } else if (conf
->as_type
== AS_INTERNAL
) {
15107 json_object_int_add(json_peer_group
, "remoteAs",
15110 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15111 group
->name
, group
->bgp
->as
);
15114 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15117 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15119 json_object_string_add(json_peer_group
, "type",
15122 vty_out(vty
, " Peer-group type is internal\n");
15125 json_object_string_add(json_peer_group
, "type",
15128 vty_out(vty
, " Peer-group type is external\n");
15131 /* Display AFs configured. */
15133 vty_out(vty
, " Configured address-families:");
15135 FOREACH_AFI_SAFI (afi
, safi
) {
15136 if (conf
->afc
[afi
][safi
]) {
15139 json_object_array_add(
15140 json_peer_group_afc
,
15141 json_object_new_string(get_afi_safi_str(
15142 afi
, safi
, false)));
15144 vty_out(vty
, " %s;",
15145 get_afi_safi_str(afi
, safi
, false));
15150 json_object_object_add(json_peer_group
,
15151 "addressFamiliesConfigured",
15152 json_peer_group_afc
);
15155 vty_out(vty
, " none\n");
15157 vty_out(vty
, "\n");
15160 /* Display listen ranges (for dynamic neighbors), if any */
15161 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15162 lr_count
= listcount(group
->listen_range
[afi
]);
15165 if (!json_peer_group_dynamic
)
15166 json_peer_group_dynamic
=
15167 json_object_new_object();
15169 json_peer_group_dynamic_af
=
15170 json_object_new_object();
15171 json_peer_group_ranges
=
15172 json_object_new_array();
15173 json_object_int_add(json_peer_group_dynamic_af
,
15174 "count", lr_count
);
15176 vty_out(vty
, " %d %s listen range(s)\n",
15177 lr_count
, afi2str(afi
));
15180 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15185 snprintfrr(buf
, sizeof(buf
), "%pFX",
15188 json_object_array_add(
15189 json_peer_group_ranges
,
15190 json_object_new_string(buf
));
15192 vty_out(vty
, " %pFX\n", range
);
15197 json_object_object_add(
15198 json_peer_group_dynamic_af
, "ranges",
15199 json_peer_group_ranges
);
15201 json_object_object_add(
15202 json_peer_group_dynamic
, afi2str(afi
),
15203 json_peer_group_dynamic_af
);
15208 if (json_peer_group_dynamic
)
15209 json_object_object_add(json_peer_group
, "dynamicRanges",
15210 json_peer_group_dynamic
);
15212 /* Display group members and their status */
15213 if (listcount(group
->peer
)) {
15215 json_peer_group_members
= json_object_new_object();
15217 vty_out(vty
, " Peer-group members:\n");
15218 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15219 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15220 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15221 peer_status
= "Idle (Admin)";
15222 else if (CHECK_FLAG(peer
->sflags
,
15223 PEER_STATUS_PREFIX_OVERFLOW
))
15224 peer_status
= "Idle (PfxCt)";
15226 peer_status
= lookup_msg(bgp_status_msg
,
15227 peer
->status
, NULL
);
15229 dynamic
= peer_dynamic_neighbor(peer
);
15232 json_object
*json_peer_group_member
=
15233 json_object_new_object();
15235 json_object_string_add(json_peer_group_member
,
15236 "status", peer_status
);
15239 json_object_boolean_true_add(
15240 json_peer_group_member
,
15243 json_object_object_add(json_peer_group_members
,
15245 json_peer_group_member
);
15247 vty_out(vty
, " %s %s %s \n", peer
->host
,
15248 dynamic
? "(dynamic)" : "",
15253 json_object_object_add(json_peer_group
, "members",
15254 json_peer_group_members
);
15258 json_object_object_add(json
, group
->name
, json_peer_group
);
15260 return CMD_SUCCESS
;
15263 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15264 const char *group_name
, bool uj
)
15267 struct listnode
*node
, *nnode
;
15268 struct peer_group
*group
;
15269 bool found
= false;
15270 json_object
*json
= NULL
;
15273 json
= json_object_new_object();
15275 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15279 vty_json(vty
, json
);
15281 vty_out(vty
, "%% BGP instance not found\n");
15283 return CMD_WARNING
;
15286 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15288 if (strmatch(group
->name
, group_name
)) {
15289 bgp_show_one_peer_group(vty
, group
, json
);
15294 bgp_show_one_peer_group(vty
, group
, json
);
15298 if (group_name
&& !found
&& !uj
)
15299 vty_out(vty
, "%% No such peer-group\n");
15302 vty_json(vty
, json
);
15304 return CMD_SUCCESS
;
15307 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15308 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15309 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15310 "Detailed information on BGP peer groups\n"
15311 "Peer group name\n" JSON_STR
)
15315 bool uj
= use_json(argc
, argv
);
15317 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15319 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15321 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15325 /* Redistribute VTY commands. */
15327 DEFUN (bgp_redistribute_ipv4
,
15328 bgp_redistribute_ipv4_cmd
,
15329 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15330 "Redistribute information from another routing protocol\n"
15331 FRR_IP_REDIST_HELP_STR_BGPD
)
15333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15334 int idx_protocol
= 1;
15337 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15339 vty_out(vty
, "%% Invalid route type\n");
15340 return CMD_WARNING_CONFIG_FAILED
;
15343 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15344 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15348 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15349 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15350 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15352 DEFUN (bgp_redistribute_ipv4_rmap
,
15353 bgp_redistribute_ipv4_rmap_cmd
,
15354 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15355 "Redistribute information from another routing protocol\n"
15356 FRR_IP_REDIST_HELP_STR_BGPD
15357 "Route map reference\n"
15358 "Pointer to route-map entries\n")
15360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15361 int idx_protocol
= 1;
15364 struct bgp_redist
*red
;
15366 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15367 vty
, argv
[idx_word
]->arg
);
15369 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15371 vty_out(vty
, "%% Invalid route type\n");
15372 return CMD_WARNING_CONFIG_FAILED
;
15375 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15377 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15378 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15382 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15383 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15384 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15385 "Route map reference\n"
15386 "Pointer to route-map entries\n")
15388 DEFUN (bgp_redistribute_ipv4_metric
,
15389 bgp_redistribute_ipv4_metric_cmd
,
15390 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15391 "Redistribute information from another routing protocol\n"
15392 FRR_IP_REDIST_HELP_STR_BGPD
15393 "Metric for redistributed routes\n"
15394 "Default metric\n")
15396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15397 int idx_protocol
= 1;
15398 int idx_number
= 3;
15401 struct bgp_redist
*red
;
15404 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15406 vty_out(vty
, "%% Invalid route type\n");
15407 return CMD_WARNING_CONFIG_FAILED
;
15409 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15411 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15412 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15413 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15417 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15418 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15419 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15420 "Metric for redistributed routes\n"
15421 "Default metric\n")
15423 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15424 bgp_redistribute_ipv4_rmap_metric_cmd
,
15425 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15426 "Redistribute information from another routing protocol\n"
15427 FRR_IP_REDIST_HELP_STR_BGPD
15428 "Route map reference\n"
15429 "Pointer to route-map entries\n"
15430 "Metric for redistributed routes\n"
15431 "Default metric\n")
15433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15434 int idx_protocol
= 1;
15436 int idx_number
= 5;
15439 struct bgp_redist
*red
;
15441 struct route_map
*route_map
=
15442 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15444 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15446 vty_out(vty
, "%% Invalid route type\n");
15447 return CMD_WARNING_CONFIG_FAILED
;
15449 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15451 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15453 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15454 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15455 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15459 bgp_redistribute_ipv4_rmap_metric
,
15460 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15461 "redistribute " FRR_IP_REDIST_STR_BGPD
15462 " route-map WORD metric (0-4294967295)",
15463 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15464 "Route map reference\n"
15465 "Pointer to route-map entries\n"
15466 "Metric for redistributed routes\n"
15467 "Default metric\n")
15469 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15470 bgp_redistribute_ipv4_metric_rmap_cmd
,
15471 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15472 "Redistribute information from another routing protocol\n"
15473 FRR_IP_REDIST_HELP_STR_BGPD
15474 "Metric for redistributed routes\n"
15476 "Route map reference\n"
15477 "Pointer to route-map entries\n")
15479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15480 int idx_protocol
= 1;
15481 int idx_number
= 3;
15485 struct bgp_redist
*red
;
15487 struct route_map
*route_map
=
15488 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15490 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15492 vty_out(vty
, "%% Invalid route type\n");
15493 return CMD_WARNING_CONFIG_FAILED
;
15495 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15497 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15498 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15500 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15501 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15505 bgp_redistribute_ipv4_metric_rmap
,
15506 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15507 "redistribute " FRR_IP_REDIST_STR_BGPD
15508 " metric (0-4294967295) route-map WORD",
15509 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15510 "Metric for redistributed routes\n"
15512 "Route map reference\n"
15513 "Pointer to route-map entries\n")
15515 DEFUN (bgp_redistribute_ipv4_ospf
,
15516 bgp_redistribute_ipv4_ospf_cmd
,
15517 "redistribute <ospf|table> (1-65535)",
15518 "Redistribute information from another routing protocol\n"
15519 "Open Shortest Path First (OSPFv2)\n"
15520 "Non-main Kernel Routing Table\n"
15521 "Instance ID/Table ID\n")
15523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15524 int idx_ospf_table
= 1;
15525 int idx_number
= 2;
15526 unsigned short instance
;
15527 unsigned short protocol
;
15529 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15531 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15532 protocol
= ZEBRA_ROUTE_OSPF
;
15534 protocol
= ZEBRA_ROUTE_TABLE
;
15536 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15537 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15540 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15541 "redistribute <ospf|table> (1-65535)",
15542 "Redistribute information from another routing protocol\n"
15543 "Open Shortest Path First (OSPFv2)\n"
15544 "Non-main Kernel Routing Table\n"
15545 "Instance ID/Table ID\n")
15547 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15548 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15549 "redistribute <ospf|table> (1-65535) route-map WORD",
15550 "Redistribute information from another routing protocol\n"
15551 "Open Shortest Path First (OSPFv2)\n"
15552 "Non-main Kernel Routing Table\n"
15553 "Instance ID/Table ID\n"
15554 "Route map reference\n"
15555 "Pointer to route-map entries\n")
15557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15558 int idx_ospf_table
= 1;
15559 int idx_number
= 2;
15561 struct bgp_redist
*red
;
15562 unsigned short instance
;
15565 struct route_map
*route_map
=
15566 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15568 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15569 protocol
= ZEBRA_ROUTE_OSPF
;
15571 protocol
= ZEBRA_ROUTE_TABLE
;
15573 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15574 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15576 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15577 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15580 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15581 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15582 "redistribute <ospf|table> (1-65535) route-map WORD",
15583 "Redistribute information from another routing protocol\n"
15584 "Open Shortest Path First (OSPFv2)\n"
15585 "Non-main Kernel Routing Table\n"
15586 "Instance ID/Table ID\n"
15587 "Route map reference\n"
15588 "Pointer to route-map entries\n")
15590 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15591 bgp_redistribute_ipv4_ospf_metric_cmd
,
15592 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15593 "Redistribute information from another routing protocol\n"
15594 "Open Shortest Path First (OSPFv2)\n"
15595 "Non-main Kernel Routing Table\n"
15596 "Instance ID/Table ID\n"
15597 "Metric for redistributed routes\n"
15598 "Default metric\n")
15600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15601 int idx_ospf_table
= 1;
15602 int idx_number
= 2;
15603 int idx_number_2
= 4;
15605 struct bgp_redist
*red
;
15606 unsigned short instance
;
15610 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15611 protocol
= ZEBRA_ROUTE_OSPF
;
15613 protocol
= ZEBRA_ROUTE_TABLE
;
15615 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15616 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15618 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15619 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15621 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15624 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15625 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15626 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15627 "Redistribute information from another routing protocol\n"
15628 "Open Shortest Path First (OSPFv2)\n"
15629 "Non-main Kernel Routing Table\n"
15630 "Instance ID/Table ID\n"
15631 "Metric for redistributed routes\n"
15632 "Default metric\n")
15634 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15635 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15636 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15637 "Redistribute information from another routing protocol\n"
15638 "Open Shortest Path First (OSPFv2)\n"
15639 "Non-main Kernel Routing Table\n"
15640 "Instance ID/Table ID\n"
15641 "Route map reference\n"
15642 "Pointer to route-map entries\n"
15643 "Metric for redistributed routes\n"
15644 "Default metric\n")
15646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15647 int idx_ospf_table
= 1;
15648 int idx_number
= 2;
15650 int idx_number_2
= 6;
15652 struct bgp_redist
*red
;
15653 unsigned short instance
;
15656 struct route_map
*route_map
=
15657 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15659 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15660 protocol
= ZEBRA_ROUTE_OSPF
;
15662 protocol
= ZEBRA_ROUTE_TABLE
;
15664 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15665 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15667 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15669 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15670 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15672 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15676 bgp_redistribute_ipv4_ospf_rmap_metric
,
15677 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15678 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15679 "Redistribute information from another routing protocol\n"
15680 "Open Shortest Path First (OSPFv2)\n"
15681 "Non-main Kernel Routing Table\n"
15682 "Instance ID/Table ID\n"
15683 "Route map reference\n"
15684 "Pointer to route-map entries\n"
15685 "Metric for redistributed routes\n"
15686 "Default metric\n")
15688 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15689 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15690 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15691 "Redistribute information from another routing protocol\n"
15692 "Open Shortest Path First (OSPFv2)\n"
15693 "Non-main Kernel Routing Table\n"
15694 "Instance ID/Table ID\n"
15695 "Metric for redistributed routes\n"
15697 "Route map reference\n"
15698 "Pointer to route-map entries\n")
15700 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15701 int idx_ospf_table
= 1;
15702 int idx_number
= 2;
15703 int idx_number_2
= 4;
15706 struct bgp_redist
*red
;
15707 unsigned short instance
;
15710 struct route_map
*route_map
=
15711 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15713 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15714 protocol
= ZEBRA_ROUTE_OSPF
;
15716 protocol
= ZEBRA_ROUTE_TABLE
;
15718 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15719 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15721 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15722 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15725 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15726 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15730 bgp_redistribute_ipv4_ospf_metric_rmap
,
15731 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15732 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15733 "Redistribute information from another routing protocol\n"
15734 "Open Shortest Path First (OSPFv2)\n"
15735 "Non-main Kernel Routing Table\n"
15736 "Instance ID/Table ID\n"
15737 "Metric for redistributed routes\n"
15739 "Route map reference\n"
15740 "Pointer to route-map entries\n")
15742 DEFUN (no_bgp_redistribute_ipv4_ospf
,
15743 no_bgp_redistribute_ipv4_ospf_cmd
,
15744 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15746 "Redistribute information from another routing protocol\n"
15747 "Open Shortest Path First (OSPFv2)\n"
15748 "Non-main Kernel Routing Table\n"
15749 "Instance ID/Table ID\n"
15750 "Metric for redistributed routes\n"
15752 "Route map reference\n"
15753 "Pointer to route-map entries\n")
15755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15756 int idx_ospf_table
= 2;
15757 int idx_number
= 3;
15758 unsigned short instance
;
15761 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15762 protocol
= ZEBRA_ROUTE_OSPF
;
15764 protocol
= ZEBRA_ROUTE_TABLE
;
15766 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15767 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
15771 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15772 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15774 "Redistribute information from another routing protocol\n"
15775 "Open Shortest Path First (OSPFv2)\n"
15776 "Non-main Kernel Routing Table\n"
15777 "Instance ID/Table ID\n"
15778 "Metric for redistributed routes\n"
15780 "Route map reference\n"
15781 "Pointer to route-map entries\n")
15783 DEFUN (no_bgp_redistribute_ipv4
,
15784 no_bgp_redistribute_ipv4_cmd
,
15785 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15787 "Redistribute information from another routing protocol\n"
15788 FRR_IP_REDIST_HELP_STR_BGPD
15789 "Metric for redistributed routes\n"
15791 "Route map reference\n"
15792 "Pointer to route-map entries\n")
15794 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15795 int idx_protocol
= 2;
15798 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15800 vty_out(vty
, "%% Invalid route type\n");
15801 return CMD_WARNING_CONFIG_FAILED
;
15803 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
15807 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15808 "no redistribute " FRR_IP_REDIST_STR_BGPD
15809 " [{metric (0-4294967295)|route-map WORD}]",
15811 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15812 "Metric for redistributed routes\n"
15814 "Route map reference\n"
15815 "Pointer to route-map entries\n")
15817 DEFUN (bgp_redistribute_ipv6
,
15818 bgp_redistribute_ipv6_cmd
,
15819 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15820 "Redistribute information from another routing protocol\n"
15821 FRR_IP6_REDIST_HELP_STR_BGPD
)
15823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15824 int idx_protocol
= 1;
15827 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15829 vty_out(vty
, "%% Invalid route type\n");
15830 return CMD_WARNING_CONFIG_FAILED
;
15833 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15834 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
15837 DEFUN (bgp_redistribute_ipv6_rmap
,
15838 bgp_redistribute_ipv6_rmap_cmd
,
15839 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15840 "Redistribute information from another routing protocol\n"
15841 FRR_IP6_REDIST_HELP_STR_BGPD
15842 "Route map reference\n"
15843 "Pointer to route-map entries\n")
15845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15846 int idx_protocol
= 1;
15849 struct bgp_redist
*red
;
15851 struct route_map
*route_map
=
15852 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15854 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15856 vty_out(vty
, "%% Invalid route type\n");
15857 return CMD_WARNING_CONFIG_FAILED
;
15860 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15862 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15863 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15866 DEFUN (bgp_redistribute_ipv6_metric
,
15867 bgp_redistribute_ipv6_metric_cmd
,
15868 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15869 "Redistribute information from another routing protocol\n"
15870 FRR_IP6_REDIST_HELP_STR_BGPD
15871 "Metric for redistributed routes\n"
15872 "Default metric\n")
15874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15875 int idx_protocol
= 1;
15876 int idx_number
= 3;
15879 struct bgp_redist
*red
;
15882 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15884 vty_out(vty
, "%% Invalid route type\n");
15885 return CMD_WARNING_CONFIG_FAILED
;
15887 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15889 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15890 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
15891 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15894 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
15895 bgp_redistribute_ipv6_rmap_metric_cmd
,
15896 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15897 "Redistribute information from another routing protocol\n"
15898 FRR_IP6_REDIST_HELP_STR_BGPD
15899 "Route map reference\n"
15900 "Pointer to route-map entries\n"
15901 "Metric for redistributed routes\n"
15902 "Default metric\n")
15904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15905 int idx_protocol
= 1;
15907 int idx_number
= 5;
15910 struct bgp_redist
*red
;
15912 struct route_map
*route_map
=
15913 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15915 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15917 vty_out(vty
, "%% Invalid route type\n");
15918 return CMD_WARNING_CONFIG_FAILED
;
15920 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15922 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15924 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15925 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
15927 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15930 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
15931 bgp_redistribute_ipv6_metric_rmap_cmd
,
15932 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15933 "Redistribute information from another routing protocol\n"
15934 FRR_IP6_REDIST_HELP_STR_BGPD
15935 "Metric for redistributed routes\n"
15937 "Route map reference\n"
15938 "Pointer to route-map entries\n")
15940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15941 int idx_protocol
= 1;
15942 int idx_number
= 3;
15946 struct bgp_redist
*red
;
15948 struct route_map
*route_map
=
15949 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15951 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15953 vty_out(vty
, "%% Invalid route type\n");
15954 return CMD_WARNING_CONFIG_FAILED
;
15956 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15958 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15959 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
15962 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15963 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15966 DEFUN (no_bgp_redistribute_ipv6
,
15967 no_bgp_redistribute_ipv6_cmd
,
15968 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15970 "Redistribute information from another routing protocol\n"
15971 FRR_IP6_REDIST_HELP_STR_BGPD
15972 "Metric for redistributed routes\n"
15974 "Route map reference\n"
15975 "Pointer to route-map entries\n")
15977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15978 int idx_protocol
= 2;
15981 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15983 vty_out(vty
, "%% Invalid route type\n");
15984 return CMD_WARNING_CONFIG_FAILED
;
15987 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
15990 /* Neighbor update tcp-mss. */
15991 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
15992 const char *tcp_mss_str
)
15995 uint32_t tcp_mss_val
= 0;
15997 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
15999 return CMD_WARNING_CONFIG_FAILED
;
16002 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16003 peer_tcp_mss_set(peer
, tcp_mss_val
);
16005 peer_tcp_mss_unset(peer
);
16008 return CMD_SUCCESS
;
16011 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16012 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16013 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16014 "TCP max segment size\n"
16017 int peer_index
= 1;
16021 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16022 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16023 argv
[mss_index
]->arg
);
16026 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16027 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16028 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16029 "TCP max segment size\n"
16032 int peer_index
= 2;
16035 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16036 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16039 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16040 afi_t afi
, safi_t safi
)
16044 /* Unicast redistribution only. */
16045 if (safi
!= SAFI_UNICAST
)
16048 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16049 /* Redistribute BGP does not make sense. */
16050 if (i
!= ZEBRA_ROUTE_BGP
) {
16051 struct list
*red_list
;
16052 struct listnode
*node
;
16053 struct bgp_redist
*red
;
16055 red_list
= bgp
->redist
[afi
][i
];
16059 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16060 /* "redistribute" configuration. */
16061 vty_out(vty
, " redistribute %s",
16062 zebra_route_string(i
));
16064 vty_out(vty
, " %d", red
->instance
);
16065 if (red
->redist_metric_flag
)
16066 vty_out(vty
, " metric %u",
16067 red
->redist_metric
);
16068 if (red
->rmap
.name
)
16069 vty_out(vty
, " route-map %s",
16071 vty_out(vty
, "\n");
16077 /* peer-group helpers for config-write */
16079 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16081 if (!peer_group_active(peer
)) {
16082 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16083 return !CHECK_FLAG(peer
->flags
, flag
);
16085 return !!CHECK_FLAG(peer
->flags
, flag
);
16088 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16091 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16094 if (!peer_group_active(peer
)) {
16095 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16096 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16098 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16101 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16104 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16105 uint8_t type
, int direct
)
16107 struct bgp_filter
*filter
;
16109 if (peer_group_active(peer
))
16110 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16113 filter
= &peer
->filter
[afi
][safi
];
16115 case PEER_FT_DISTRIBUTE_LIST
:
16116 return !!(filter
->dlist
[direct
].name
);
16117 case PEER_FT_FILTER_LIST
:
16118 return !!(filter
->aslist
[direct
].name
);
16119 case PEER_FT_PREFIX_LIST
:
16120 return !!(filter
->plist
[direct
].name
);
16121 case PEER_FT_ROUTE_MAP
:
16122 return !!(filter
->map
[direct
].name
);
16123 case PEER_FT_UNSUPPRESS_MAP
:
16124 return !!(filter
->usmap
.name
);
16125 case PEER_FT_ADVERTISE_MAP
:
16126 return !!(filter
->advmap
.aname
16127 && ((filter
->advmap
.condition
== direct
)
16128 && filter
->advmap
.cname
));
16134 /* Return true if the addpath type is set for peer and different from
16137 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16140 enum bgp_addpath_strat type
, g_type
;
16142 type
= peer
->addpath_type
[afi
][safi
];
16144 if (type
!= BGP_ADDPATH_NONE
) {
16145 if (peer_group_active(peer
)) {
16146 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16148 if (type
!= g_type
)
16160 /* This is part of the address-family block (unicast only) */
16161 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16165 uint32_t tovpn_sid_index
= 0;
16167 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16168 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16169 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16170 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16171 bgp
->vpn_policy
[afi
]
16172 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16174 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16175 bgp
->vpn_policy
[afi
]
16176 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16178 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16179 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16180 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16181 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16184 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16185 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16187 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16190 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16191 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16192 bgp
->vpn_policy
[afi
].tovpn_label
);
16196 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16197 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16198 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16199 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16200 } else if (tovpn_sid_index
!= 0) {
16201 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16205 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16206 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16207 char buf
[RD_ADDRSTRLEN
];
16208 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16209 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16212 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16213 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16215 char buf
[PREFIX_STRLEN
];
16216 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16217 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16220 vty_out(vty
, "%*snexthop vpn export %s\n",
16224 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16225 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16227 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16228 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16230 char *b
= ecommunity_ecom2str(
16231 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16232 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16233 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16234 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16236 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16237 char *b
= ecommunity_ecom2str(
16238 bgp
->vpn_policy
[afi
]
16239 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16240 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16241 ECOMMUNITY_ROUTE_TARGET
);
16242 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16243 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16245 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16246 char *b
= ecommunity_ecom2str(
16247 bgp
->vpn_policy
[afi
]
16248 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16249 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16250 ECOMMUNITY_ROUTE_TARGET
);
16251 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16252 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16256 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16257 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16258 bgp
->vpn_policy
[afi
]
16259 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16261 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16262 char *b
= ecommunity_ecom2str(
16263 bgp
->vpn_policy
[afi
]
16264 .import_redirect_rtlist
,
16265 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16266 ECOMMUNITY_ROUTE_TARGET
);
16268 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16269 != ECOMMUNITY_SIZE
)
16270 vty_out(vty
, "%*srt6 redirect import %s\n",
16273 vty_out(vty
, "%*srt redirect import %s\n",
16275 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16279 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16280 afi_t afi
, safi_t safi
)
16282 struct bgp_filter
*filter
;
16286 filter
= &peer
->filter
[afi
][safi
];
16288 /* distribute-list. */
16289 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16291 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16292 filter
->dlist
[FILTER_IN
].name
);
16294 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16296 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16297 filter
->dlist
[FILTER_OUT
].name
);
16300 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16302 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16303 filter
->plist
[FILTER_IN
].name
);
16305 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16307 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16308 filter
->plist
[FILTER_OUT
].name
);
16311 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16312 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16313 filter
->map
[RMAP_IN
].name
);
16315 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16317 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16318 filter
->map
[RMAP_OUT
].name
);
16320 /* unsuppress-map */
16321 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16322 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16323 filter
->usmap
.name
);
16325 /* advertise-map : always applied in OUT direction*/
16326 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16327 CONDITION_NON_EXIST
))
16329 " neighbor %s advertise-map %s non-exist-map %s\n",
16330 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16332 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16334 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16335 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16338 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16340 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16341 filter
->aslist
[FILTER_IN
].name
);
16343 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16345 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16346 filter
->aslist
[FILTER_OUT
].name
);
16349 /* BGP peer configuration display function. */
16350 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16353 struct peer
*g_peer
= NULL
;
16354 char buf
[SU_ADDRSTRLEN
];
16356 int if_pg_printed
= false;
16357 int if_ras_printed
= false;
16359 /* Skip dynamic neighbors. */
16360 if (peer_dynamic_neighbor(peer
))
16364 addr
= peer
->conf_if
;
16368 /************************************
16369 ****** Global to the neighbor ******
16370 ************************************/
16371 if (peer
->conf_if
) {
16372 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16373 vty_out(vty
, " neighbor %s interface v6only", addr
);
16375 vty_out(vty
, " neighbor %s interface", addr
);
16377 if (peer_group_active(peer
)) {
16378 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16379 if_pg_printed
= true;
16380 } else if (peer
->as_type
== AS_SPECIFIED
) {
16381 vty_out(vty
, " remote-as %u", peer
->as
);
16382 if_ras_printed
= true;
16383 } else if (peer
->as_type
== AS_INTERNAL
) {
16384 vty_out(vty
, " remote-as internal");
16385 if_ras_printed
= true;
16386 } else if (peer
->as_type
== AS_EXTERNAL
) {
16387 vty_out(vty
, " remote-as external");
16388 if_ras_printed
= true;
16391 vty_out(vty
, "\n");
16394 /* remote-as and peer-group */
16395 /* peer is a member of a peer-group */
16396 if (peer_group_active(peer
)) {
16397 g_peer
= peer
->group
->conf
;
16399 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16400 if (peer
->as_type
== AS_SPECIFIED
) {
16401 vty_out(vty
, " neighbor %s remote-as %u\n",
16403 } else if (peer
->as_type
== AS_INTERNAL
) {
16405 " neighbor %s remote-as internal\n",
16407 } else if (peer
->as_type
== AS_EXTERNAL
) {
16409 " neighbor %s remote-as external\n",
16414 /* For swpX peers we displayed the peer-group
16415 * via 'neighbor swpX interface peer-group PGNAME' */
16416 if (!if_pg_printed
)
16417 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16418 peer
->group
->name
);
16421 /* peer is NOT a member of a peer-group */
16423 /* peer is a peer-group, declare the peer-group */
16424 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16425 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16428 if (!if_ras_printed
) {
16429 if (peer
->as_type
== AS_SPECIFIED
) {
16430 vty_out(vty
, " neighbor %s remote-as %u\n",
16432 } else if (peer
->as_type
== AS_INTERNAL
) {
16434 " neighbor %s remote-as internal\n",
16436 } else if (peer
->as_type
== AS_EXTERNAL
) {
16438 " neighbor %s remote-as external\n",
16445 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16446 vty_out(vty
, " neighbor %s local-as %u", addr
,
16447 peer
->change_local_as
);
16448 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16449 vty_out(vty
, " no-prepend");
16450 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16451 vty_out(vty
, " replace-as");
16452 vty_out(vty
, "\n");
16457 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16461 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16462 if (peer
->tx_shutdown_message
)
16463 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16464 peer
->tx_shutdown_message
);
16466 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16469 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16470 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16471 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16474 if (peer
->bfd_config
)
16475 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16478 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16479 vty_out(vty
, " neighbor %s password %s\n", addr
,
16482 /* neighbor solo */
16483 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16484 if (!peer_group_active(peer
)) {
16485 vty_out(vty
, " neighbor %s solo\n", addr
);
16490 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16491 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16494 /* Local interface name */
16495 if (peer
->ifname
) {
16496 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16499 /* TCP max segment size */
16500 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16501 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16504 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16505 vty_out(vty
, " neighbor %s passive\n", addr
);
16507 /* ebgp-multihop */
16508 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16509 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16510 && peer
->ttl
== MAXTTL
)) {
16511 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16512 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16517 /* ttl-security hops */
16518 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16519 if (!peer_group_active(peer
)
16520 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16521 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16522 addr
, peer
->gtsm_hops
);
16526 /* disable-connected-check */
16527 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16528 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16530 /* link-bw-encoding-ieee */
16531 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16532 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16535 /* extended-optional-parameters */
16536 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16537 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16540 /* enforce-first-as */
16541 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16542 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16544 /* update-source */
16545 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16546 if (peer
->update_source
)
16547 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16548 sockunion2str(peer
->update_source
, buf
,
16550 else if (peer
->update_if
)
16551 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16555 /* advertisement-interval */
16556 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16557 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16561 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16562 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16563 peer
->keepalive
, peer
->holdtime
);
16565 /* timers connect */
16566 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16567 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16569 /* need special-case handling for changed default values due to
16570 * config profile / version (because there is no "timers bgp connect"
16571 * command, we need to save this per-peer :/)
16573 else if (!peer_group_active(peer
) && !peer
->connect
&&
16574 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16575 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16576 peer
->bgp
->default_connect_retry
);
16578 /* timers delayopen */
16579 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16580 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16582 /* Save config even though flag is not set if default values have been
16585 else if (!peer_group_active(peer
) && !peer
->delayopen
16586 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16587 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16588 peer
->bgp
->default_delayopen
);
16590 /* capability dynamic */
16591 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16592 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16594 /* capability extended-nexthop */
16595 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16596 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
))
16598 " no neighbor %s capability extended-nexthop\n",
16600 else if (!peer
->conf_if
)
16602 " neighbor %s capability extended-nexthop\n",
16606 /* dont-capability-negotiation */
16607 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16608 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16610 /* override-capability */
16611 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16612 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16614 /* strict-capability-match */
16615 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16616 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16618 /* Sender side AS path loop detection. */
16619 if (peer
->as_path_loop_detection
)
16620 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16623 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16624 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16626 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16627 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16629 " neighbor %s graceful-restart-helper\n", addr
);
16630 } else if (CHECK_FLAG(
16631 peer
->peer_gr_new_status_flag
,
16632 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16634 " neighbor %s graceful-restart\n", addr
);
16636 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16637 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16639 peer
->peer_gr_new_status_flag
,
16640 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16641 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16647 /* BGP peer configuration display function. */
16648 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16649 struct peer
*peer
, afi_t afi
, safi_t safi
)
16651 struct peer
*g_peer
= NULL
;
16653 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16655 /* Skip dynamic neighbors. */
16656 if (peer_dynamic_neighbor(peer
))
16660 addr
= peer
->conf_if
;
16664 /************************************
16665 ****** Per AF to the neighbor ******
16666 ************************************/
16667 if (peer_group_active(peer
)) {
16668 g_peer
= peer
->group
->conf
;
16670 /* If the peer-group is active but peer is not, print a 'no
16672 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16673 vty_out(vty
, " no neighbor %s activate\n", addr
);
16676 /* If the peer-group is not active but peer is, print an
16678 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16679 vty_out(vty
, " neighbor %s activate\n", addr
);
16682 if (peer
->afc
[afi
][safi
]) {
16683 if (safi
== SAFI_ENCAP
)
16684 vty_out(vty
, " neighbor %s activate\n", addr
);
16685 else if (!bgp
->default_af
[afi
][safi
])
16686 vty_out(vty
, " neighbor %s activate\n", addr
);
16688 if (bgp
->default_af
[afi
][safi
])
16689 vty_out(vty
, " no neighbor %s activate\n",
16694 /* addpath TX knobs */
16695 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16696 switch (peer
->addpath_type
[afi
][safi
]) {
16697 case BGP_ADDPATH_ALL
:
16698 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16701 case BGP_ADDPATH_BEST_PER_AS
:
16703 " neighbor %s addpath-tx-bestpath-per-AS\n",
16706 case BGP_ADDPATH_MAX
:
16707 case BGP_ADDPATH_NONE
:
16712 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
16713 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
16715 /* ORF capability. */
16716 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16717 || peergroup_af_flag_check(peer
, afi
, safi
,
16718 PEER_FLAG_ORF_PREFIX_RM
)) {
16719 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16721 if (peergroup_af_flag_check(peer
, afi
, safi
,
16722 PEER_FLAG_ORF_PREFIX_SM
)
16723 && peergroup_af_flag_check(peer
, afi
, safi
,
16724 PEER_FLAG_ORF_PREFIX_RM
))
16725 vty_out(vty
, " both");
16726 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16727 PEER_FLAG_ORF_PREFIX_SM
))
16728 vty_out(vty
, " send");
16730 vty_out(vty
, " receive");
16731 vty_out(vty
, "\n");
16734 /* Route reflector client. */
16735 if (peergroup_af_flag_check(peer
, afi
, safi
,
16736 PEER_FLAG_REFLECTOR_CLIENT
)) {
16737 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16740 /* next-hop-self force */
16741 if (peergroup_af_flag_check(peer
, afi
, safi
,
16742 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16743 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16746 /* next-hop-self */
16747 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16748 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16751 /* remove-private-AS */
16752 if (peergroup_af_flag_check(peer
, afi
, safi
,
16753 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16754 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16758 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16759 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16760 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16764 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16765 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16766 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16769 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16770 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16771 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16775 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16776 vty_out(vty
, " neighbor %s as-override\n", addr
);
16779 /* send-community print. */
16780 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16781 PEER_FLAG_SEND_COMMUNITY
);
16782 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16783 PEER_FLAG_SEND_EXT_COMMUNITY
);
16784 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16785 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16787 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16788 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16791 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16794 " no neighbor %s send-community extended\n",
16798 vty_out(vty
, " no neighbor %s send-community large\n",
16802 /* Default information */
16803 if (peergroup_af_flag_check(peer
, afi
, safi
,
16804 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16805 vty_out(vty
, " neighbor %s default-originate", addr
);
16807 if (peer
->default_rmap
[afi
][safi
].name
)
16808 vty_out(vty
, " route-map %s",
16809 peer
->default_rmap
[afi
][safi
].name
);
16811 vty_out(vty
, "\n");
16814 /* Soft reconfiguration inbound. */
16815 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16816 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16820 /* maximum-prefix. */
16821 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16822 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16823 peer
->pmax
[afi
][safi
]);
16825 if (peer
->pmax_threshold
[afi
][safi
]
16826 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16827 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16828 if (peer_af_flag_check(peer
, afi
, safi
,
16829 PEER_FLAG_MAX_PREFIX_WARNING
))
16830 vty_out(vty
, " warning-only");
16831 if (peer
->pmax_restart
[afi
][safi
])
16832 vty_out(vty
, " restart %u",
16833 peer
->pmax_restart
[afi
][safi
]);
16834 if (peer_af_flag_check(peer
, afi
, safi
,
16835 PEER_FLAG_MAX_PREFIX_FORCE
))
16836 vty_out(vty
, " force");
16838 vty_out(vty
, "\n");
16841 /* maximum-prefix-out */
16842 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16843 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16844 addr
, peer
->pmax_out
[afi
][safi
]);
16846 /* Route server client. */
16847 if (peergroup_af_flag_check(peer
, afi
, safi
,
16848 PEER_FLAG_RSERVER_CLIENT
)) {
16849 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16852 /* Nexthop-local unchanged. */
16853 if (peergroup_af_flag_check(peer
, afi
, safi
,
16854 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16855 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16858 /* allowas-in <1-10> */
16859 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16860 if (peer_af_flag_check(peer
, afi
, safi
,
16861 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16862 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16863 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16864 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16866 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16867 peer
->allowas_in
[afi
][safi
]);
16872 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16873 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16874 peer
->weight
[afi
][safi
]);
16877 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16879 /* atribute-unchanged. */
16880 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16881 || (safi
!= SAFI_EVPN
16882 && peer_af_flag_check(peer
, afi
, safi
,
16883 PEER_FLAG_NEXTHOP_UNCHANGED
))
16884 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16886 if (!peer_group_active(peer
)
16887 || peergroup_af_flag_check(peer
, afi
, safi
,
16888 PEER_FLAG_AS_PATH_UNCHANGED
)
16889 || peergroup_af_flag_check(peer
, afi
, safi
,
16890 PEER_FLAG_NEXTHOP_UNCHANGED
)
16891 || peergroup_af_flag_check(peer
, afi
, safi
,
16892 PEER_FLAG_MED_UNCHANGED
)) {
16895 " neighbor %s attribute-unchanged%s%s%s\n",
16897 peer_af_flag_check(peer
, afi
, safi
,
16898 PEER_FLAG_AS_PATH_UNCHANGED
)
16901 peer_af_flag_check(peer
, afi
, safi
,
16902 PEER_FLAG_NEXTHOP_UNCHANGED
)
16905 peer_af_flag_check(peer
, afi
, safi
,
16906 PEER_FLAG_MED_UNCHANGED
)
16913 /* Address family based peer configuration display. */
16914 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16918 struct peer_group
*group
;
16919 struct listnode
*node
, *nnode
;
16922 vty_frame(vty
, " !\n address-family ");
16923 if (afi
== AFI_IP
) {
16924 if (safi
== SAFI_UNICAST
)
16925 vty_frame(vty
, "ipv4 unicast");
16926 else if (safi
== SAFI_LABELED_UNICAST
)
16927 vty_frame(vty
, "ipv4 labeled-unicast");
16928 else if (safi
== SAFI_MULTICAST
)
16929 vty_frame(vty
, "ipv4 multicast");
16930 else if (safi
== SAFI_MPLS_VPN
)
16931 vty_frame(vty
, "ipv4 vpn");
16932 else if (safi
== SAFI_ENCAP
)
16933 vty_frame(vty
, "ipv4 encap");
16934 else if (safi
== SAFI_FLOWSPEC
)
16935 vty_frame(vty
, "ipv4 flowspec");
16936 } else if (afi
== AFI_IP6
) {
16937 if (safi
== SAFI_UNICAST
)
16938 vty_frame(vty
, "ipv6 unicast");
16939 else if (safi
== SAFI_LABELED_UNICAST
)
16940 vty_frame(vty
, "ipv6 labeled-unicast");
16941 else if (safi
== SAFI_MULTICAST
)
16942 vty_frame(vty
, "ipv6 multicast");
16943 else if (safi
== SAFI_MPLS_VPN
)
16944 vty_frame(vty
, "ipv6 vpn");
16945 else if (safi
== SAFI_ENCAP
)
16946 vty_frame(vty
, "ipv6 encap");
16947 else if (safi
== SAFI_FLOWSPEC
)
16948 vty_frame(vty
, "ipv6 flowspec");
16949 } else if (afi
== AFI_L2VPN
) {
16950 if (safi
== SAFI_EVPN
)
16951 vty_frame(vty
, "l2vpn evpn");
16953 vty_frame(vty
, "\n");
16955 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16957 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16959 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16961 /* BGP flag dampening. */
16962 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16963 bgp_config_write_damp(vty
, afi
, safi
);
16965 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16966 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16968 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16969 /* Do not display doppelganger peers */
16970 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16971 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16974 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16975 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16977 if (safi
== SAFI_EVPN
)
16978 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16980 if (safi
== SAFI_FLOWSPEC
)
16981 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16983 if (safi
== SAFI_UNICAST
) {
16984 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16985 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16986 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16988 vty_out(vty
, " export vpn\n");
16990 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16991 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16993 vty_out(vty
, " import vpn\n");
16995 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16996 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16999 for (ALL_LIST_ELEMENTS_RO(
17000 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17002 vty_out(vty
, " import vrf %s\n", name
);
17006 vty_endframe(vty
, " exit-address-family\n");
17009 int bgp_config_write(struct vty
*vty
)
17012 struct peer_group
*group
;
17014 struct listnode
*node
, *nnode
;
17015 struct listnode
*mnode
, *mnnode
;
17019 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17020 vty_out(vty
, "bgp route-map delay-timer %u\n",
17021 bm
->rmap_update_timer
);
17023 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17024 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17025 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17026 vty_out(vty
, " %d", bm
->v_establish_wait
);
17027 vty_out(vty
, "\n");
17030 if (bm
->wait_for_fib
)
17031 vty_out(vty
, "bgp suppress-fib-pending\n");
17033 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17034 vty_out(vty
, "bgp graceful-shutdown\n");
17036 /* No-RIB (Zebra) option flag configuration */
17037 if (bgp_option_check(BGP_OPT_NO_FIB
))
17038 vty_out(vty
, "bgp no-rib\n");
17040 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17041 vty_out(vty
, "bgp send-extra-data zebra\n");
17043 /* BGP configuration. */
17044 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17046 /* skip all auto created vrf as they dont have user config */
17047 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17050 /* Router bgp ASN */
17051 vty_out(vty
, "router bgp %u", bgp
->as
);
17054 vty_out(vty
, " %s %s",
17055 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17056 ? "view" : "vrf", bgp
->name
);
17057 vty_out(vty
, "\n");
17059 /* BGP fast-external-failover. */
17060 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17061 vty_out(vty
, " no bgp fast-external-failover\n");
17063 /* BGP router ID. */
17064 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17065 vty_out(vty
, " bgp router-id %pI4\n",
17066 &bgp
->router_id_static
);
17068 /* Suppress fib pending */
17069 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17070 vty_out(vty
, " bgp suppress-fib-pending\n");
17072 /* BGP log-neighbor-changes. */
17073 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17074 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17075 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17076 CHECK_FLAG(bgp
->flags
,
17077 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17081 /* BGP configuration. */
17082 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17083 vty_out(vty
, " bgp always-compare-med\n");
17085 /* RFC8212 default eBGP policy. */
17086 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17087 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17088 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17089 CHECK_FLAG(bgp
->flags
,
17090 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17094 /* draft-ietf-idr-deprecate-as-set-confed-set */
17095 if (bgp
->reject_as_sets
)
17096 vty_out(vty
, " bgp reject-as-sets\n");
17098 /* Suppress duplicate updates if the route actually not changed
17100 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17101 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17102 vty_out(vty
, " %sbgp suppress-duplicates\n",
17103 CHECK_FLAG(bgp
->flags
,
17104 BGP_FLAG_SUPPRESS_DUPLICATES
)
17108 /* BGP default <afi>-<safi> */
17109 FOREACH_AFI_SAFI (afi
, safi
) {
17110 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17111 if (!bgp
->default_af
[afi
][safi
])
17112 vty_out(vty
, " no bgp default %s\n",
17113 get_bgp_default_af_flag(afi
,
17115 } else if (bgp
->default_af
[afi
][safi
])
17116 vty_out(vty
, " bgp default %s\n",
17117 get_bgp_default_af_flag(afi
, safi
));
17120 /* BGP default local-preference. */
17121 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17122 vty_out(vty
, " bgp default local-preference %u\n",
17123 bgp
->default_local_pref
);
17125 /* BGP default show-hostname */
17126 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17127 != SAVE_BGP_SHOW_HOSTNAME
)
17128 vty_out(vty
, " %sbgp default show-hostname\n",
17129 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17133 /* BGP default show-nexthop-hostname */
17134 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17135 != SAVE_BGP_SHOW_HOSTNAME
)
17136 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17137 CHECK_FLAG(bgp
->flags
,
17138 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17142 /* BGP default subgroup-pkt-queue-max. */
17143 if (bgp
->default_subgroup_pkt_queue_max
17144 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17145 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17146 bgp
->default_subgroup_pkt_queue_max
);
17148 /* BGP client-to-client reflection. */
17149 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17150 vty_out(vty
, " no bgp client-to-client reflection\n");
17152 /* BGP cluster ID. */
17153 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17154 vty_out(vty
, " bgp cluster-id %pI4\n",
17157 /* Disable ebgp connected nexthop check */
17158 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17160 " bgp disable-ebgp-connected-route-check\n");
17162 /* Confederation identifier*/
17163 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17164 vty_out(vty
, " bgp confederation identifier %u\n",
17167 /* Confederation peer */
17168 if (bgp
->confed_peers_cnt
> 0) {
17171 vty_out(vty
, " bgp confederation peers");
17173 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17174 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17176 vty_out(vty
, "\n");
17179 /* BGP deterministic-med. */
17180 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17181 != SAVE_BGP_DETERMINISTIC_MED
)
17182 vty_out(vty
, " %sbgp deterministic-med\n",
17183 CHECK_FLAG(bgp
->flags
,
17184 BGP_FLAG_DETERMINISTIC_MED
)
17188 /* BGP update-delay. */
17189 bgp_config_write_update_delay(vty
, bgp
);
17191 if (bgp
->v_maxmed_onstartup
17192 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17193 vty_out(vty
, " bgp max-med on-startup %u",
17194 bgp
->v_maxmed_onstartup
);
17195 if (bgp
->maxmed_onstartup_value
17196 != BGP_MAXMED_VALUE_DEFAULT
)
17197 vty_out(vty
, " %u",
17198 bgp
->maxmed_onstartup_value
);
17199 vty_out(vty
, "\n");
17201 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17202 vty_out(vty
, " bgp max-med administrative");
17203 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17204 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17205 vty_out(vty
, "\n");
17209 bgp_config_write_wpkt_quanta(vty
, bgp
);
17211 bgp_config_write_rpkt_quanta(vty
, bgp
);
17213 /* coalesce time */
17214 bgp_config_write_coalesce_time(vty
, bgp
);
17216 /* BGP per-instance graceful-shutdown */
17217 /* BGP-wide settings and per-instance settings are mutually
17220 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17221 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17222 vty_out(vty
, " bgp graceful-shutdown\n");
17224 /* Long-lived Graceful Restart */
17225 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17227 " bgp long-lived-graceful-restart stale-time %u\n",
17228 bgp
->llgr_stale_time
);
17230 /* BGP graceful-restart. */
17231 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17233 " bgp graceful-restart stalepath-time %u\n",
17234 bgp
->stalepath_time
);
17236 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17237 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17238 bgp
->restart_time
);
17240 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17242 " bgp graceful-restart select-defer-time %u\n",
17243 bgp
->select_defer_time
);
17245 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17246 vty_out(vty
, " bgp graceful-restart\n");
17248 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17249 vty_out(vty
, " bgp graceful-restart-disable\n");
17251 /* BGP graceful-restart Preserve State F bit. */
17252 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17254 " bgp graceful-restart preserve-fw-state\n");
17256 /* Stale timer for RIB */
17257 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17259 " bgp graceful-restart rib-stale-time %u\n",
17260 bgp
->rib_stale_time
);
17262 /* BGP bestpath method. */
17263 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17264 vty_out(vty
, " bgp bestpath as-path ignore\n");
17265 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17266 vty_out(vty
, " bgp bestpath as-path confed\n");
17268 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17269 if (CHECK_FLAG(bgp
->flags
,
17270 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17272 " bgp bestpath as-path multipath-relax as-set\n");
17275 " bgp bestpath as-path multipath-relax\n");
17279 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17281 " bgp route-reflector allow-outbound-policy\n");
17283 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17284 vty_out(vty
, " bgp bestpath compare-routerid\n");
17285 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17286 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17287 vty_out(vty
, " bgp bestpath med");
17288 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17289 vty_out(vty
, " confed");
17290 if (CHECK_FLAG(bgp
->flags
,
17291 BGP_FLAG_MED_MISSING_AS_WORST
))
17292 vty_out(vty
, " missing-as-worst");
17293 vty_out(vty
, "\n");
17296 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17298 " bgp bestpath peer-type multipath-relax\n");
17300 /* Link bandwidth handling. */
17301 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17302 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17303 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17304 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17305 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17306 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17308 /* BGP network import check. */
17309 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17310 != SAVE_BGP_IMPORT_CHECK
)
17311 vty_out(vty
, " %sbgp network import-check\n",
17312 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17316 /* BGP timers configuration. */
17317 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17318 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17319 vty_out(vty
, " timers bgp %u %u\n",
17320 bgp
->default_keepalive
, bgp
->default_holdtime
);
17322 /* BGP minimum holdtime configuration. */
17323 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17324 && bgp
->default_min_holdtime
!= 0)
17325 vty_out(vty
, " bgp minimum-holdtime %u\n",
17326 bgp
->default_min_holdtime
);
17328 /* Conditional advertisement timer configuration */
17329 if (bgp
->condition_check_period
17330 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17332 " bgp conditional-advertisement timer %u\n",
17333 bgp
->condition_check_period
);
17336 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17337 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17340 /* Normal neighbor configuration. */
17341 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17342 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17343 bgp_config_write_peer_global(vty
, bgp
, peer
);
17346 /* listen range and limit for dynamic BGP neighbors */
17347 bgp_config_write_listen(vty
, bgp
);
17350 * BGP default autoshutdown neighbors
17352 * This must be placed after any peer and peer-group
17353 * configuration, to avoid setting all peers to shutdown after
17354 * a daemon restart, which is undesired behavior. (see #2286)
17356 if (bgp
->autoshutdown
)
17357 vty_out(vty
, " bgp default shutdown\n");
17359 /* BGP instance administrative shutdown */
17360 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17361 vty_out(vty
, " bgp shutdown\n");
17363 if (bgp
->fast_convergence
)
17364 vty_out(vty
, " bgp fast-convergence\n");
17366 if (bgp
->srv6_enabled
) {
17367 vty_frame(vty
, " !\n segment-routing srv6\n");
17368 if (strlen(bgp
->srv6_locator_name
))
17369 vty_out(vty
, " locator %s\n",
17370 bgp
->srv6_locator_name
);
17371 vty_endframe(vty
, " exit\n");
17375 /* IPv4 unicast configuration. */
17376 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17378 /* IPv4 multicast configuration. */
17379 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17381 /* IPv4 labeled-unicast configuration. */
17382 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17384 /* IPv4 VPN configuration. */
17385 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17387 /* ENCAPv4 configuration. */
17388 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17390 /* FLOWSPEC v4 configuration. */
17391 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17393 /* IPv6 unicast configuration. */
17394 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17396 /* IPv6 multicast configuration. */
17397 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17399 /* IPv6 labeled-unicast configuration. */
17400 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17401 SAFI_LABELED_UNICAST
);
17403 /* IPv6 VPN configuration. */
17404 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17406 /* ENCAPv6 configuration. */
17407 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17409 /* FLOWSPEC v6 configuration. */
17410 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17412 /* EVPN configuration. */
17413 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17415 hook_call(bgp_inst_config_write
, bgp
, vty
);
17417 #ifdef ENABLE_BGP_VNC
17418 bgp_rfapi_cfg_write(vty
, bgp
);
17421 vty_out(vty
, "exit\n");
17422 vty_out(vty
, "!\n");
17428 /* BGP node structure. */
17429 static struct cmd_node bgp_node
= {
17432 .parent_node
= CONFIG_NODE
,
17433 .prompt
= "%s(config-router)# ",
17434 .config_write
= bgp_config_write
,
17437 static struct cmd_node bgp_ipv4_unicast_node
= {
17438 .name
= "bgp ipv4 unicast",
17439 .node
= BGP_IPV4_NODE
,
17440 .parent_node
= BGP_NODE
,
17441 .prompt
= "%s(config-router-af)# ",
17445 static struct cmd_node bgp_ipv4_multicast_node
= {
17446 .name
= "bgp ipv4 multicast",
17447 .node
= BGP_IPV4M_NODE
,
17448 .parent_node
= BGP_NODE
,
17449 .prompt
= "%s(config-router-af)# ",
17453 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17454 .name
= "bgp ipv4 labeled unicast",
17455 .node
= BGP_IPV4L_NODE
,
17456 .parent_node
= BGP_NODE
,
17457 .prompt
= "%s(config-router-af)# ",
17461 static struct cmd_node bgp_ipv6_unicast_node
= {
17462 .name
= "bgp ipv6 unicast",
17463 .node
= BGP_IPV6_NODE
,
17464 .parent_node
= BGP_NODE
,
17465 .prompt
= "%s(config-router-af)# ",
17469 static struct cmd_node bgp_ipv6_multicast_node
= {
17470 .name
= "bgp ipv6 multicast",
17471 .node
= BGP_IPV6M_NODE
,
17472 .parent_node
= BGP_NODE
,
17473 .prompt
= "%s(config-router-af)# ",
17477 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17478 .name
= "bgp ipv6 labeled unicast",
17479 .node
= BGP_IPV6L_NODE
,
17480 .parent_node
= BGP_NODE
,
17481 .prompt
= "%s(config-router-af)# ",
17485 static struct cmd_node bgp_vpnv4_node
= {
17486 .name
= "bgp vpnv4",
17487 .node
= BGP_VPNV4_NODE
,
17488 .parent_node
= BGP_NODE
,
17489 .prompt
= "%s(config-router-af)# ",
17493 static struct cmd_node bgp_vpnv6_node
= {
17494 .name
= "bgp vpnv6",
17495 .node
= BGP_VPNV6_NODE
,
17496 .parent_node
= BGP_NODE
,
17497 .prompt
= "%s(config-router-af-vpnv6)# ",
17501 static struct cmd_node bgp_evpn_node
= {
17502 .name
= "bgp evpn",
17503 .node
= BGP_EVPN_NODE
,
17504 .parent_node
= BGP_NODE
,
17505 .prompt
= "%s(config-router-evpn)# ",
17509 static struct cmd_node bgp_evpn_vni_node
= {
17510 .name
= "bgp evpn vni",
17511 .node
= BGP_EVPN_VNI_NODE
,
17512 .parent_node
= BGP_EVPN_NODE
,
17513 .prompt
= "%s(config-router-af-vni)# ",
17516 static struct cmd_node bgp_flowspecv4_node
= {
17517 .name
= "bgp ipv4 flowspec",
17518 .node
= BGP_FLOWSPECV4_NODE
,
17519 .parent_node
= BGP_NODE
,
17520 .prompt
= "%s(config-router-af)# ",
17524 static struct cmd_node bgp_flowspecv6_node
= {
17525 .name
= "bgp ipv6 flowspec",
17526 .node
= BGP_FLOWSPECV6_NODE
,
17527 .parent_node
= BGP_NODE
,
17528 .prompt
= "%s(config-router-af-vpnv6)# ",
17532 static struct cmd_node bgp_srv6_node
= {
17533 .name
= "bgp srv6",
17534 .node
= BGP_SRV6_NODE
,
17535 .parent_node
= BGP_NODE
,
17536 .prompt
= "%s(config-router-srv6)# ",
17539 static void community_list_vty(void);
17541 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17544 struct peer_group
*group
;
17545 struct listnode
*lnbgp
, *lnpeer
;
17547 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17548 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17550 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17554 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17558 struct listnode
*lnbgp
, *lnpeer
;
17560 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17561 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17562 /* only provide suggestions on the appropriate input
17564 * they'll otherwise show up multiple times */
17565 enum cmd_token_type match_type
;
17566 char *name
= peer
->host
;
17568 if (peer
->conf_if
) {
17569 match_type
= VARIABLE_TKN
;
17570 name
= peer
->conf_if
;
17571 } else if (strchr(peer
->host
, ':'))
17572 match_type
= IPV6_TKN
;
17574 match_type
= IPV4_TKN
;
17576 if (token
->type
!= match_type
)
17579 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17584 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17586 bgp_ac_peer(comps
, token
);
17588 if (token
->type
== VARIABLE_TKN
)
17589 bgp_ac_peergroup(comps
, token
);
17592 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17593 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17594 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17595 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17596 {.completions
= NULL
}};
17598 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17599 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17600 {.completions
= NULL
} };
17602 void bgp_vty_init(void)
17604 cmd_variable_handler_register(bgp_var_neighbor
);
17605 cmd_variable_handler_register(bgp_var_peergroup
);
17607 /* Install bgp top node. */
17608 install_node(&bgp_node
);
17609 install_node(&bgp_ipv4_unicast_node
);
17610 install_node(&bgp_ipv4_multicast_node
);
17611 install_node(&bgp_ipv4_labeled_unicast_node
);
17612 install_node(&bgp_ipv6_unicast_node
);
17613 install_node(&bgp_ipv6_multicast_node
);
17614 install_node(&bgp_ipv6_labeled_unicast_node
);
17615 install_node(&bgp_vpnv4_node
);
17616 install_node(&bgp_vpnv6_node
);
17617 install_node(&bgp_evpn_node
);
17618 install_node(&bgp_evpn_vni_node
);
17619 install_node(&bgp_flowspecv4_node
);
17620 install_node(&bgp_flowspecv6_node
);
17621 install_node(&bgp_srv6_node
);
17623 /* Install default VTY commands to new nodes. */
17624 install_default(BGP_NODE
);
17625 install_default(BGP_IPV4_NODE
);
17626 install_default(BGP_IPV4M_NODE
);
17627 install_default(BGP_IPV4L_NODE
);
17628 install_default(BGP_IPV6_NODE
);
17629 install_default(BGP_IPV6M_NODE
);
17630 install_default(BGP_IPV6L_NODE
);
17631 install_default(BGP_VPNV4_NODE
);
17632 install_default(BGP_VPNV6_NODE
);
17633 install_default(BGP_FLOWSPECV4_NODE
);
17634 install_default(BGP_FLOWSPECV6_NODE
);
17635 install_default(BGP_EVPN_NODE
);
17636 install_default(BGP_EVPN_VNI_NODE
);
17637 install_default(BGP_SRV6_NODE
);
17639 /* "bgp local-mac" hidden commands. */
17640 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17641 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17643 /* "bgp suppress-fib-pending" global */
17644 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17646 /* bgp route-map delay-timer commands. */
17647 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17648 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17650 /* bgp fast-convergence command */
17651 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
17652 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
17654 /* global bgp update-delay command */
17655 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17656 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17658 /* global bgp graceful-shutdown command */
17659 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17660 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17662 /* Dummy commands (Currently not supported) */
17663 install_element(BGP_NODE
, &no_synchronization_cmd
);
17664 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17666 /* "router bgp" commands. */
17667 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17669 /* "no router bgp" commands. */
17670 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17672 /* "bgp router-id" commands. */
17673 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17674 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17676 /* "bgp suppress-fib-pending" command */
17677 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17679 /* "bgp cluster-id" commands. */
17680 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17681 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17683 /* "bgp no-rib" commands. */
17684 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17685 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17687 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17689 /* "bgp confederation" commands. */
17690 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17691 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17693 /* "bgp confederation peers" commands. */
17694 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17695 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17697 /* bgp max-med command */
17698 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17699 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17700 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17701 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17702 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17704 /* bgp disable-ebgp-connected-nh-check */
17705 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17706 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17708 /* bgp update-delay command */
17709 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17710 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17712 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17713 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17715 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17716 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17718 /* "maximum-paths" commands. */
17719 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17720 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17721 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17722 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17723 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17724 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17725 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17726 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17727 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17728 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17729 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17730 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17731 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17732 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17733 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17735 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17736 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17737 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17738 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17739 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17740 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17741 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17742 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17743 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17744 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17746 /* "timers bgp" commands. */
17747 install_element(BGP_NODE
, &bgp_timers_cmd
);
17748 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17750 /* "minimum-holdtime" commands. */
17751 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
17752 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
17754 /* route-map delay-timer commands - per instance for backwards compat.
17756 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17757 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17759 /* "bgp client-to-client reflection" commands */
17760 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17761 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17763 /* "bgp always-compare-med" commands */
17764 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17765 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17767 /* bgp ebgp-requires-policy */
17768 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17769 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17771 /* bgp suppress-duplicates */
17772 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17773 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17775 /* bgp reject-as-sets */
17776 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17777 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17779 /* "bgp deterministic-med" commands */
17780 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17781 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17783 /* "bgp graceful-restart" command */
17784 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17785 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17787 /* "bgp graceful-restart-disable" command */
17788 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17789 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17791 /* "neighbor a:b:c:d graceful-restart" command */
17792 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17793 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17795 /* "neighbor a:b:c:d graceful-restart-disable" command */
17796 install_element(BGP_NODE
,
17797 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17798 install_element(BGP_NODE
,
17799 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17801 /* "neighbor a:b:c:d graceful-restart-helper" command */
17802 install_element(BGP_NODE
,
17803 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17804 install_element(BGP_NODE
,
17805 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17807 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17808 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17809 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17810 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17811 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17812 install_element(BGP_NODE
,
17813 &no_bgp_graceful_restart_select_defer_time_cmd
);
17814 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17815 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17817 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17818 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17819 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17820 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17822 /* "bgp graceful-shutdown" commands */
17823 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17824 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17826 /* "bgp long-lived-graceful-restart" commands */
17827 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
17828 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
17830 /* "bgp fast-external-failover" commands */
17831 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17832 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17834 /* "bgp bestpath compare-routerid" commands */
17835 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17836 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17838 /* "bgp bestpath as-path ignore" commands */
17839 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17840 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17842 /* "bgp bestpath as-path confed" commands */
17843 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17844 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17846 /* "bgp bestpath as-path multipath-relax" commands */
17847 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17848 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17850 /* "bgp bestpath peer-type multipath-relax" commands */
17851 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
17852 install_element(BGP_NODE
,
17853 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
17855 /* "bgp log-neighbor-changes" commands */
17856 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17857 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17859 /* "bgp bestpath med" commands */
17860 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17861 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17863 /* "bgp bestpath bandwidth" commands */
17864 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17865 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17867 /* "no bgp default <afi>-<safi>" commands. */
17868 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
17870 /* "bgp network import-check" commands. */
17871 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17872 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17873 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17875 /* "bgp default local-preference" commands. */
17876 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17877 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17879 /* bgp default show-hostname */
17880 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17881 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17883 /* bgp default show-nexthop-hostname */
17884 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17885 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17887 /* "bgp default subgroup-pkt-queue-max" commands. */
17888 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17889 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17891 /* bgp ibgp-allow-policy-mods command */
17892 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17893 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17895 /* "bgp listen limit" commands. */
17896 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17897 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17899 /* "bgp listen range" commands. */
17900 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17901 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17903 /* "bgp default shutdown" command */
17904 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17906 /* "bgp shutdown" commands */
17907 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17908 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17909 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17910 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17912 /* "neighbor remote-as" commands. */
17913 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17914 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17915 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17916 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17917 install_element(BGP_NODE
,
17918 &neighbor_interface_v6only_config_remote_as_cmd
);
17919 install_element(BGP_NODE
, &no_neighbor_cmd
);
17920 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17922 /* "neighbor peer-group" commands. */
17923 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17924 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17925 install_element(BGP_NODE
,
17926 &no_neighbor_interface_peer_group_remote_as_cmd
);
17928 /* "neighbor local-as" commands. */
17929 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17930 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17931 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17932 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17934 /* "neighbor solo" commands. */
17935 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17936 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17938 /* "neighbor password" commands. */
17939 install_element(BGP_NODE
, &neighbor_password_cmd
);
17940 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17942 /* "neighbor activate" commands. */
17943 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17944 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17945 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17946 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17947 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17948 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17949 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17950 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17951 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17952 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17953 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17954 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17956 /* "no neighbor activate" commands. */
17957 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17958 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17959 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17960 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17961 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17962 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17963 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17964 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17965 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17966 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17967 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17968 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17970 /* "neighbor peer-group" set commands. */
17971 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17972 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17973 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17974 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17975 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17976 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17977 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17978 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17979 install_element(BGP_FLOWSPECV4_NODE
,
17980 &neighbor_set_peer_group_hidden_cmd
);
17981 install_element(BGP_FLOWSPECV6_NODE
,
17982 &neighbor_set_peer_group_hidden_cmd
);
17984 /* "no neighbor peer-group unset" commands. */
17985 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17986 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17987 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17988 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17989 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17990 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17991 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17992 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17993 install_element(BGP_FLOWSPECV4_NODE
,
17994 &no_neighbor_set_peer_group_hidden_cmd
);
17995 install_element(BGP_FLOWSPECV6_NODE
,
17996 &no_neighbor_set_peer_group_hidden_cmd
);
17998 /* "neighbor softreconfiguration inbound" commands.*/
17999 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18000 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18001 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18002 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18003 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18004 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18005 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18006 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18007 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18008 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18009 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18010 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18011 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18012 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18013 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18014 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18015 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18016 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18017 install_element(BGP_FLOWSPECV4_NODE
,
18018 &neighbor_soft_reconfiguration_cmd
);
18019 install_element(BGP_FLOWSPECV4_NODE
,
18020 &no_neighbor_soft_reconfiguration_cmd
);
18021 install_element(BGP_FLOWSPECV6_NODE
,
18022 &neighbor_soft_reconfiguration_cmd
);
18023 install_element(BGP_FLOWSPECV6_NODE
,
18024 &no_neighbor_soft_reconfiguration_cmd
);
18025 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18026 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18028 /* "neighbor attribute-unchanged" commands. */
18029 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18030 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18031 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18032 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18033 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18034 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18035 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18036 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18037 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18038 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18039 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18040 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18042 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18043 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18044 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18045 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18046 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18048 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18049 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18051 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18052 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18053 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18054 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18056 /* "nexthop-local unchanged" commands */
18057 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18058 install_element(BGP_IPV6_NODE
,
18059 &no_neighbor_nexthop_local_unchanged_cmd
);
18061 /* "neighbor next-hop-self" commands. */
18062 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18063 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18064 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18065 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18066 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18067 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18068 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18069 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18070 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18071 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18072 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18073 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18074 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18075 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18076 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18077 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18078 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18079 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18080 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18081 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18083 /* "neighbor next-hop-self force" commands. */
18084 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18085 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18086 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18087 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18088 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18089 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18090 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18091 install_element(BGP_IPV4_NODE
,
18092 &no_neighbor_nexthop_self_all_hidden_cmd
);
18093 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18094 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18095 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18096 install_element(BGP_IPV4M_NODE
,
18097 &no_neighbor_nexthop_self_all_hidden_cmd
);
18098 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18099 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18100 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18101 install_element(BGP_IPV4L_NODE
,
18102 &no_neighbor_nexthop_self_all_hidden_cmd
);
18103 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18104 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18105 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18106 install_element(BGP_IPV6_NODE
,
18107 &no_neighbor_nexthop_self_all_hidden_cmd
);
18108 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18109 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18110 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18111 install_element(BGP_IPV6M_NODE
,
18112 &no_neighbor_nexthop_self_all_hidden_cmd
);
18113 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18114 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18115 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18116 install_element(BGP_IPV6L_NODE
,
18117 &no_neighbor_nexthop_self_all_hidden_cmd
);
18118 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18119 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18120 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18121 install_element(BGP_VPNV4_NODE
,
18122 &no_neighbor_nexthop_self_all_hidden_cmd
);
18123 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18124 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18125 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18126 install_element(BGP_VPNV6_NODE
,
18127 &no_neighbor_nexthop_self_all_hidden_cmd
);
18128 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18129 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18131 /* "neighbor as-override" commands. */
18132 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18133 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18134 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18135 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18136 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18137 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18138 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18139 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18140 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18141 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18142 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18143 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18144 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18145 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18146 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18147 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18148 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18149 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18151 /* "neighbor remove-private-AS" commands. */
18152 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18153 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18154 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18155 install_element(BGP_NODE
,
18156 &no_neighbor_remove_private_as_all_hidden_cmd
);
18157 install_element(BGP_NODE
,
18158 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18159 install_element(BGP_NODE
,
18160 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18161 install_element(BGP_NODE
,
18162 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18165 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18166 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18167 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18168 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18169 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18170 install_element(BGP_IPV4_NODE
,
18171 &neighbor_remove_private_as_replace_as_cmd
);
18172 install_element(BGP_IPV4_NODE
,
18173 &no_neighbor_remove_private_as_replace_as_cmd
);
18174 install_element(BGP_IPV4_NODE
,
18175 &neighbor_remove_private_as_all_replace_as_cmd
);
18176 install_element(BGP_IPV4_NODE
,
18177 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18178 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18179 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18180 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18181 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18182 install_element(BGP_IPV4M_NODE
,
18183 &neighbor_remove_private_as_replace_as_cmd
);
18184 install_element(BGP_IPV4M_NODE
,
18185 &no_neighbor_remove_private_as_replace_as_cmd
);
18186 install_element(BGP_IPV4M_NODE
,
18187 &neighbor_remove_private_as_all_replace_as_cmd
);
18188 install_element(BGP_IPV4M_NODE
,
18189 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18190 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18191 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18192 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18193 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18194 install_element(BGP_IPV4L_NODE
,
18195 &neighbor_remove_private_as_replace_as_cmd
);
18196 install_element(BGP_IPV4L_NODE
,
18197 &no_neighbor_remove_private_as_replace_as_cmd
);
18198 install_element(BGP_IPV4L_NODE
,
18199 &neighbor_remove_private_as_all_replace_as_cmd
);
18200 install_element(BGP_IPV4L_NODE
,
18201 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18202 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18203 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18204 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18205 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18206 install_element(BGP_IPV6_NODE
,
18207 &neighbor_remove_private_as_replace_as_cmd
);
18208 install_element(BGP_IPV6_NODE
,
18209 &no_neighbor_remove_private_as_replace_as_cmd
);
18210 install_element(BGP_IPV6_NODE
,
18211 &neighbor_remove_private_as_all_replace_as_cmd
);
18212 install_element(BGP_IPV6_NODE
,
18213 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18214 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18215 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18216 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18217 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18218 install_element(BGP_IPV6M_NODE
,
18219 &neighbor_remove_private_as_replace_as_cmd
);
18220 install_element(BGP_IPV6M_NODE
,
18221 &no_neighbor_remove_private_as_replace_as_cmd
);
18222 install_element(BGP_IPV6M_NODE
,
18223 &neighbor_remove_private_as_all_replace_as_cmd
);
18224 install_element(BGP_IPV6M_NODE
,
18225 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18226 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18227 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18228 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18229 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18230 install_element(BGP_IPV6L_NODE
,
18231 &neighbor_remove_private_as_replace_as_cmd
);
18232 install_element(BGP_IPV6L_NODE
,
18233 &no_neighbor_remove_private_as_replace_as_cmd
);
18234 install_element(BGP_IPV6L_NODE
,
18235 &neighbor_remove_private_as_all_replace_as_cmd
);
18236 install_element(BGP_IPV6L_NODE
,
18237 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18238 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18239 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18240 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18241 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18242 install_element(BGP_VPNV4_NODE
,
18243 &neighbor_remove_private_as_replace_as_cmd
);
18244 install_element(BGP_VPNV4_NODE
,
18245 &no_neighbor_remove_private_as_replace_as_cmd
);
18246 install_element(BGP_VPNV4_NODE
,
18247 &neighbor_remove_private_as_all_replace_as_cmd
);
18248 install_element(BGP_VPNV4_NODE
,
18249 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18250 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18251 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18252 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18253 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18254 install_element(BGP_VPNV6_NODE
,
18255 &neighbor_remove_private_as_replace_as_cmd
);
18256 install_element(BGP_VPNV6_NODE
,
18257 &no_neighbor_remove_private_as_replace_as_cmd
);
18258 install_element(BGP_VPNV6_NODE
,
18259 &neighbor_remove_private_as_all_replace_as_cmd
);
18260 install_element(BGP_VPNV6_NODE
,
18261 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18263 /* "neighbor send-community" commands.*/
18264 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18265 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18266 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18267 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18268 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18269 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18270 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18271 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18272 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18273 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18274 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18275 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18276 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18277 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18278 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18279 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18280 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18281 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18282 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18283 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18284 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18285 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18286 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18287 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18288 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18289 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18290 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18291 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18292 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18293 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18294 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18295 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18296 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18297 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18298 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18299 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18301 /* "neighbor route-reflector" commands.*/
18302 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18303 install_element(BGP_NODE
,
18304 &no_neighbor_route_reflector_client_hidden_cmd
);
18305 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18306 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18307 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18308 install_element(BGP_IPV4M_NODE
,
18309 &no_neighbor_route_reflector_client_cmd
);
18310 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18311 install_element(BGP_IPV4L_NODE
,
18312 &no_neighbor_route_reflector_client_cmd
);
18313 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18314 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18315 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18316 install_element(BGP_IPV6M_NODE
,
18317 &no_neighbor_route_reflector_client_cmd
);
18318 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18319 install_element(BGP_IPV6L_NODE
,
18320 &no_neighbor_route_reflector_client_cmd
);
18321 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18322 install_element(BGP_VPNV4_NODE
,
18323 &no_neighbor_route_reflector_client_cmd
);
18324 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18325 install_element(BGP_VPNV6_NODE
,
18326 &no_neighbor_route_reflector_client_cmd
);
18327 install_element(BGP_FLOWSPECV4_NODE
,
18328 &neighbor_route_reflector_client_cmd
);
18329 install_element(BGP_FLOWSPECV4_NODE
,
18330 &no_neighbor_route_reflector_client_cmd
);
18331 install_element(BGP_FLOWSPECV6_NODE
,
18332 &neighbor_route_reflector_client_cmd
);
18333 install_element(BGP_FLOWSPECV6_NODE
,
18334 &no_neighbor_route_reflector_client_cmd
);
18335 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18336 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18338 /* "neighbor route-server" commands.*/
18339 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18340 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18341 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18342 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18343 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18344 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18345 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18346 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18347 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18348 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18349 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18350 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18351 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18352 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18353 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18354 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18355 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18356 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18357 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18358 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18359 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18360 install_element(BGP_FLOWSPECV4_NODE
,
18361 &no_neighbor_route_server_client_cmd
);
18362 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18363 install_element(BGP_FLOWSPECV6_NODE
,
18364 &no_neighbor_route_server_client_cmd
);
18366 /* "neighbor disable-addpath-rx" commands. */
18367 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18368 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18369 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18370 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18371 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18372 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18373 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18374 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18375 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18376 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18377 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18378 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18379 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18380 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18381 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18382 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18384 /* "neighbor addpath-tx-all-paths" commands.*/
18385 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18386 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18387 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18388 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18389 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18390 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18391 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18392 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18393 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18394 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18395 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18396 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18397 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18398 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18399 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18400 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18401 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18402 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18404 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18405 install_element(BGP_NODE
,
18406 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18407 install_element(BGP_NODE
,
18408 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18409 install_element(BGP_IPV4_NODE
,
18410 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18411 install_element(BGP_IPV4_NODE
,
18412 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18413 install_element(BGP_IPV4M_NODE
,
18414 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18415 install_element(BGP_IPV4M_NODE
,
18416 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18417 install_element(BGP_IPV4L_NODE
,
18418 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18419 install_element(BGP_IPV4L_NODE
,
18420 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18421 install_element(BGP_IPV6_NODE
,
18422 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18423 install_element(BGP_IPV6_NODE
,
18424 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18425 install_element(BGP_IPV6M_NODE
,
18426 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18427 install_element(BGP_IPV6M_NODE
,
18428 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18429 install_element(BGP_IPV6L_NODE
,
18430 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18431 install_element(BGP_IPV6L_NODE
,
18432 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18433 install_element(BGP_VPNV4_NODE
,
18434 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18435 install_element(BGP_VPNV4_NODE
,
18436 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18437 install_element(BGP_VPNV6_NODE
,
18438 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18439 install_element(BGP_VPNV6_NODE
,
18440 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18442 /* "neighbor sender-as-path-loop-detection" commands. */
18443 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18444 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18446 /* "neighbor passive" commands. */
18447 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18448 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18451 /* "neighbor shutdown" commands. */
18452 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18453 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18454 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18455 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18456 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18457 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18459 /* "neighbor capability extended-nexthop" commands.*/
18460 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18461 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18463 /* "neighbor capability orf prefix-list" commands.*/
18464 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18465 install_element(BGP_NODE
,
18466 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18467 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18468 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18469 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18470 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18471 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18472 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18473 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18474 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18475 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18476 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18477 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18478 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18480 /* "neighbor capability dynamic" commands.*/
18481 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18482 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18484 /* "neighbor dont-capability-negotiate" commands. */
18485 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18486 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18488 /* "neighbor ebgp-multihop" commands. */
18489 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18490 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18491 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18493 /* "neighbor disable-connected-check" commands. */
18494 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18495 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18497 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18498 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18499 install_element(BGP_NODE
,
18500 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18502 /* "neighbor extended-optional-parameters" commands. */
18503 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18504 install_element(BGP_NODE
,
18505 &no_neighbor_extended_optional_parameters_cmd
);
18507 /* "neighbor enforce-first-as" commands. */
18508 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18509 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18511 /* "neighbor description" commands. */
18512 install_element(BGP_NODE
, &neighbor_description_cmd
);
18513 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18514 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18516 /* "neighbor update-source" commands. "*/
18517 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18518 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18520 /* "neighbor default-originate" commands. */
18521 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18522 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18523 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18524 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18525 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18526 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18527 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18528 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18529 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18530 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18531 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18532 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18533 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18534 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18535 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18536 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18537 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18538 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18539 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18540 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18541 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18543 /* "neighbor port" commands. */
18544 install_element(BGP_NODE
, &neighbor_port_cmd
);
18545 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18547 /* "neighbor weight" commands. */
18548 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18549 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18551 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18552 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18553 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18554 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18555 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18556 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18557 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18558 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18559 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18560 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18561 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18562 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18563 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18564 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18565 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18566 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18568 /* "neighbor override-capability" commands. */
18569 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18570 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18572 /* "neighbor strict-capability-match" commands. */
18573 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18574 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18576 /* "neighbor timers" commands. */
18577 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18578 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18580 /* "neighbor timers connect" commands. */
18581 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18582 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18584 /* "neighbor timers delayopen" commands. */
18585 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18586 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18588 /* "neighbor advertisement-interval" commands. */
18589 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18590 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18592 /* "neighbor interface" commands. */
18593 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18594 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18596 /* "neighbor distribute" commands. */
18597 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18598 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18599 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18600 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18601 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18602 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18603 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18604 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18605 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18606 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18607 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18608 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18609 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18610 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18611 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18612 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18613 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18614 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18616 /* "neighbor prefix-list" commands. */
18617 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18618 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18619 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18620 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18621 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18622 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18623 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18624 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18625 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18626 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18627 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18628 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18629 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18630 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18631 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18632 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18633 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18634 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18635 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18636 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18637 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18638 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18640 /* "neighbor filter-list" commands. */
18641 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18642 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18643 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18644 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18645 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18646 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18647 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18648 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18649 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18650 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18651 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18652 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18653 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18654 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18655 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18656 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18657 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18658 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18659 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18660 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18661 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18662 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18664 /* "neighbor route-map" commands. */
18665 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18666 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18667 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18668 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18669 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18670 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18671 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18672 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18673 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18674 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18675 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18676 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18677 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18678 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18679 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18680 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18681 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18682 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18683 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18684 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18685 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18686 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18687 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18688 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18690 /* "neighbor unsuppress-map" commands. */
18691 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18692 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18693 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18694 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18695 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18696 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18697 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18698 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18699 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18700 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18701 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18702 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18703 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18704 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18705 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18706 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18707 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18708 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18710 /* "neighbor advertise-map" commands. */
18711 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
18712 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18713 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18714 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18715 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18716 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18717 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18718 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18719 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18720 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18722 /* neighbor maximum-prefix-out commands. */
18723 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18724 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18725 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18726 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18727 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18728 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18729 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18730 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18731 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18732 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18733 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18734 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18735 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18736 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18737 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18738 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18739 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18740 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18742 /* "neighbor maximum-prefix" commands. */
18743 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18744 install_element(BGP_NODE
,
18745 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18746 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18747 install_element(BGP_NODE
,
18748 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18749 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18750 install_element(BGP_NODE
,
18751 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18752 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18753 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18754 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18755 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18756 install_element(BGP_IPV4_NODE
,
18757 &neighbor_maximum_prefix_threshold_warning_cmd
);
18758 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18759 install_element(BGP_IPV4_NODE
,
18760 &neighbor_maximum_prefix_threshold_restart_cmd
);
18761 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18762 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18763 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18764 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18765 install_element(BGP_IPV4M_NODE
,
18766 &neighbor_maximum_prefix_threshold_warning_cmd
);
18767 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18768 install_element(BGP_IPV4M_NODE
,
18769 &neighbor_maximum_prefix_threshold_restart_cmd
);
18770 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18771 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18772 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18773 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18774 install_element(BGP_IPV4L_NODE
,
18775 &neighbor_maximum_prefix_threshold_warning_cmd
);
18776 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18777 install_element(BGP_IPV4L_NODE
,
18778 &neighbor_maximum_prefix_threshold_restart_cmd
);
18779 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18780 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18781 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18782 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18783 install_element(BGP_IPV6_NODE
,
18784 &neighbor_maximum_prefix_threshold_warning_cmd
);
18785 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18786 install_element(BGP_IPV6_NODE
,
18787 &neighbor_maximum_prefix_threshold_restart_cmd
);
18788 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18789 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18790 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18791 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18792 install_element(BGP_IPV6M_NODE
,
18793 &neighbor_maximum_prefix_threshold_warning_cmd
);
18794 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18795 install_element(BGP_IPV6M_NODE
,
18796 &neighbor_maximum_prefix_threshold_restart_cmd
);
18797 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18798 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18799 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18800 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18801 install_element(BGP_IPV6L_NODE
,
18802 &neighbor_maximum_prefix_threshold_warning_cmd
);
18803 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18804 install_element(BGP_IPV6L_NODE
,
18805 &neighbor_maximum_prefix_threshold_restart_cmd
);
18806 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18807 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18808 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18809 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18810 install_element(BGP_VPNV4_NODE
,
18811 &neighbor_maximum_prefix_threshold_warning_cmd
);
18812 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18813 install_element(BGP_VPNV4_NODE
,
18814 &neighbor_maximum_prefix_threshold_restart_cmd
);
18815 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18816 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18817 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18818 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18819 install_element(BGP_VPNV6_NODE
,
18820 &neighbor_maximum_prefix_threshold_warning_cmd
);
18821 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18822 install_element(BGP_VPNV6_NODE
,
18823 &neighbor_maximum_prefix_threshold_restart_cmd
);
18824 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18826 /* "neighbor allowas-in" */
18827 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18828 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18829 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18830 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18831 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18832 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18833 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18834 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18835 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18836 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18837 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18838 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18839 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18840 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18841 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18842 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18843 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18844 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18845 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18846 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18848 /* address-family commands. */
18849 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18850 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18851 #ifdef KEEP_OLD_VPN_COMMANDS
18852 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18853 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18854 #endif /* KEEP_OLD_VPN_COMMANDS */
18856 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18858 /* "exit-address-family" command. */
18859 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18860 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18861 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18862 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18863 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18864 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18865 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18866 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18867 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18868 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18869 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18871 /* "clear ip bgp commands" */
18872 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18874 /* clear ip bgp prefix */
18875 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18876 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18877 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18879 /* "show [ip] bgp summary" commands. */
18880 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18881 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18882 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18883 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18884 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18885 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18886 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18888 /* "show [ip] bgp neighbors" commands. */
18889 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18891 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18893 /* "show [ip] bgp peer-group" commands. */
18894 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18896 /* "show [ip] bgp paths" commands. */
18897 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18899 /* "show [ip] bgp community" commands. */
18900 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18902 /* "show ip bgp large-community" commands. */
18903 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18904 /* "show [ip] bgp attribute-info" commands. */
18905 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18906 /* "show [ip] bgp route-leak" command */
18907 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18909 /* "redistribute" commands. */
18910 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18911 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18912 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18913 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18914 install_element(BGP_NODE
,
18915 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18916 install_element(BGP_NODE
,
18917 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18918 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18919 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18920 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18921 install_element(BGP_NODE
,
18922 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18923 install_element(BGP_NODE
,
18924 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18925 install_element(BGP_NODE
,
18926 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18927 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18928 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18929 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18930 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18931 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18932 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18933 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18934 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18935 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18936 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18937 install_element(BGP_IPV4_NODE
,
18938 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18939 install_element(BGP_IPV4_NODE
,
18940 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18941 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18942 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18943 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18944 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18945 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18946 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18948 /* import|export vpn [route-map WORD] */
18949 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18950 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18952 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18953 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18955 /* ttl_security commands */
18956 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18957 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18959 /* "show [ip] bgp memory" commands. */
18960 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18962 /* "show bgp martian next-hop" */
18963 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18965 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18967 /* "show [ip] bgp views" commands. */
18968 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18970 /* "show [ip] bgp vrfs" commands. */
18971 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18973 /* Community-list. */
18974 community_list_vty();
18976 community_alias_vty();
18978 /* vpn-policy commands */
18979 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18980 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18981 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18982 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18983 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18984 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18985 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18986 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18987 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18988 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18989 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18990 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18992 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18993 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18995 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18996 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18997 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18998 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18999 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19000 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19001 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19002 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19003 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19004 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19006 /* tcp-mss command */
19007 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19008 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19010 /* srv6 commands */
19011 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19012 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19013 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19014 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19015 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19016 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19017 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19020 #include "memory.h"
19021 #include "bgp_regex.h"
19022 #include "bgp_clist.h"
19023 #include "bgp_ecommunity.h"
19025 /* VTY functions. */
19027 /* Direction value to string conversion. */
19028 static const char *community_direct_str(int direct
)
19031 case COMMUNITY_DENY
:
19033 case COMMUNITY_PERMIT
:
19040 /* Display error string. */
19041 static void community_list_perror(struct vty
*vty
, int ret
)
19044 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19045 vty_out(vty
, "%% Can't find community-list\n");
19047 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19048 vty_out(vty
, "%% Malformed community-list value\n");
19050 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19052 "%% Community name conflict, previously defined as standard community\n");
19054 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19056 "%% Community name conflict, previously defined as expanded community\n");
19061 /* "community-list" keyword help string. */
19062 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19064 /*community-list standard */
19065 DEFUN (community_list_standard
,
19066 bgp_community_list_standard_cmd
,
19067 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19070 "Community list number (standard)\n"
19071 "Add an standard community-list entry\n"
19072 "Community list name\n"
19073 "Sequence number of an entry\n"
19074 "Sequence number\n"
19075 "Specify community to reject\n"
19076 "Specify community to accept\n"
19079 char *cl_name_or_number
= NULL
;
19082 int style
= COMMUNITY_LIST_STANDARD
;
19085 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19087 seq
= argv
[idx
]->arg
;
19090 argv_find(argv
, argc
, "(1-99)", &idx
);
19091 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19092 cl_name_or_number
= argv
[idx
]->arg
;
19093 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19095 argv_find(argv
, argc
, "AA:NN", &idx
);
19096 char *str
= argv_concat(argv
, argc
, idx
);
19098 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19101 XFREE(MTYPE_TMP
, str
);
19104 /* Display error string. */
19105 community_list_perror(vty
, ret
);
19106 return CMD_WARNING_CONFIG_FAILED
;
19109 return CMD_SUCCESS
;
19112 DEFUN (no_community_list_standard_all
,
19113 no_bgp_community_list_standard_all_cmd
,
19114 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19118 "Community list number (standard)\n"
19119 "Add an standard community-list entry\n"
19120 "Community list name\n"
19121 "Sequence number of an entry\n"
19122 "Sequence number\n"
19123 "Specify community to reject\n"
19124 "Specify community to accept\n"
19127 char *cl_name_or_number
= NULL
;
19130 int style
= COMMUNITY_LIST_STANDARD
;
19134 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19136 seq
= argv
[idx
]->arg
;
19139 argv_find(argv
, argc
, "permit", &idx
);
19140 argv_find(argv
, argc
, "deny", &idx
);
19143 direct
= argv_find(argv
, argc
, "permit", &idx
)
19148 argv_find(argv
, argc
, "AA:NN", &idx
);
19149 str
= argv_concat(argv
, argc
, idx
);
19153 argv_find(argv
, argc
, "(1-99)", &idx
);
19154 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19155 cl_name_or_number
= argv
[idx
]->arg
;
19157 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19160 XFREE(MTYPE_TMP
, str
);
19163 community_list_perror(vty
, ret
);
19164 return CMD_WARNING_CONFIG_FAILED
;
19167 return CMD_SUCCESS
;
19170 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19171 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19172 NO_STR BGP_STR COMMUNITY_LIST_STR
19173 "Community list number (standard)\n"
19174 "Add an standard community-list entry\n"
19175 "Community list name\n")
19177 /*community-list expanded */
19178 DEFUN (community_list_expanded_all
,
19179 bgp_community_list_expanded_all_cmd
,
19180 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19183 "Community list number (expanded)\n"
19184 "Add an expanded community-list entry\n"
19185 "Community list name\n"
19186 "Sequence number of an entry\n"
19187 "Sequence number\n"
19188 "Specify community to reject\n"
19189 "Specify community to accept\n"
19192 char *cl_name_or_number
= NULL
;
19195 int style
= COMMUNITY_LIST_EXPANDED
;
19198 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19200 seq
= argv
[idx
]->arg
;
19204 argv_find(argv
, argc
, "(100-500)", &idx
);
19205 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19206 cl_name_or_number
= argv
[idx
]->arg
;
19207 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19209 argv_find(argv
, argc
, "AA:NN", &idx
);
19210 char *str
= argv_concat(argv
, argc
, idx
);
19212 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19215 XFREE(MTYPE_TMP
, str
);
19218 /* Display error string. */
19219 community_list_perror(vty
, ret
);
19220 return CMD_WARNING_CONFIG_FAILED
;
19223 return CMD_SUCCESS
;
19226 DEFUN (no_community_list_expanded_all
,
19227 no_bgp_community_list_expanded_all_cmd
,
19228 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19232 "Community list number (expanded)\n"
19233 "Add an expanded community-list entry\n"
19234 "Community list name\n"
19235 "Sequence number of an entry\n"
19236 "Sequence number\n"
19237 "Specify community to reject\n"
19238 "Specify community to accept\n"
19241 char *cl_name_or_number
= NULL
;
19245 int style
= COMMUNITY_LIST_EXPANDED
;
19248 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19250 seq
= argv
[idx
]->arg
;
19253 argv_find(argv
, argc
, "permit", &idx
);
19254 argv_find(argv
, argc
, "deny", &idx
);
19257 direct
= argv_find(argv
, argc
, "permit", &idx
)
19262 argv_find(argv
, argc
, "AA:NN", &idx
);
19263 str
= argv_concat(argv
, argc
, idx
);
19267 argv_find(argv
, argc
, "(100-500)", &idx
);
19268 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19269 cl_name_or_number
= argv
[idx
]->arg
;
19271 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19274 XFREE(MTYPE_TMP
, str
);
19277 community_list_perror(vty
, ret
);
19278 return CMD_WARNING_CONFIG_FAILED
;
19281 return CMD_SUCCESS
;
19284 ALIAS(no_community_list_expanded_all
,
19285 no_bgp_community_list_expanded_all_list_cmd
,
19286 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19287 NO_STR BGP_STR COMMUNITY_LIST_STR
19288 "Community list number (expanded)\n"
19289 "Add an expanded community-list entry\n"
19290 "Community list name\n")
19292 /* Return configuration string of community-list entry. */
19293 static const char *community_list_config_str(struct community_entry
*entry
)
19300 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19301 str
= community_str(entry
->u
.com
, false);
19302 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19303 str
= lcommunity_str(entry
->u
.lcom
, false);
19305 str
= entry
->config
;
19310 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19312 struct community_entry
*entry
;
19314 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19315 if (entry
== list
->head
) {
19316 if (all_digit(list
->name
))
19317 vty_out(vty
, "Community %s list %s\n",
19318 entry
->style
== COMMUNITY_LIST_STANDARD
19320 : "(expanded) access",
19323 vty_out(vty
, "Named Community %s list %s\n",
19324 entry
->style
== COMMUNITY_LIST_STANDARD
19330 vty_out(vty
, " %s\n",
19331 community_direct_str(entry
->direct
));
19333 vty_out(vty
, " %s %s\n",
19334 community_direct_str(entry
->direct
),
19335 community_list_config_str(entry
));
19339 DEFUN (show_community_list
,
19340 show_bgp_community_list_cmd
,
19341 "show bgp community-list",
19344 "List community-list\n")
19346 struct community_list
*list
;
19347 struct community_list_master
*cm
;
19349 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19351 return CMD_SUCCESS
;
19353 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19354 community_list_show(vty
, list
);
19356 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19357 community_list_show(vty
, list
);
19359 return CMD_SUCCESS
;
19362 DEFUN (show_community_list_arg
,
19363 show_bgp_community_list_arg_cmd
,
19364 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19367 "List community-list\n"
19368 "Community-list number\n"
19369 "Community-list name\n"
19370 "Detailed information on community-list\n")
19372 int idx_comm_list
= 3;
19373 struct community_list
*list
;
19375 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19376 COMMUNITY_LIST_MASTER
);
19378 vty_out(vty
, "%% Can't find community-list\n");
19379 return CMD_WARNING
;
19382 community_list_show(vty
, list
);
19384 return CMD_SUCCESS
;
19388 * Large Community code.
19390 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19391 struct cmd_token
**argv
, int style
,
19392 int reject_all_digit_name
)
19401 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19402 seq
= argv
[idx
]->arg
;
19405 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19408 /* All digit name check. */
19410 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19411 argv_find(argv
, argc
, "(1-99)", &idx
);
19412 argv_find(argv
, argc
, "(100-500)", &idx
);
19413 cl_name
= argv
[idx
]->arg
;
19414 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19415 vty_out(vty
, "%% Community name cannot have all digits\n");
19416 return CMD_WARNING_CONFIG_FAILED
;
19420 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19421 argv_find(argv
, argc
, "LINE", &idx
);
19422 /* Concat community string argument. */
19424 str
= argv_concat(argv
, argc
, idx
);
19428 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19430 /* Free temporary community list string allocated by
19432 XFREE(MTYPE_TMP
, str
);
19435 community_list_perror(vty
, ret
);
19436 return CMD_WARNING_CONFIG_FAILED
;
19438 return CMD_SUCCESS
;
19441 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19442 struct cmd_token
**argv
, int style
)
19450 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19451 seq
= argv
[idx
]->arg
;
19454 argv_find(argv
, argc
, "permit", &idx
);
19455 argv_find(argv
, argc
, "deny", &idx
);
19458 /* Check the list direct. */
19459 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19460 direct
= COMMUNITY_PERMIT
;
19462 direct
= COMMUNITY_DENY
;
19465 argv_find(argv
, argc
, "LINE", &idx
);
19466 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19467 /* Concat community string argument. */
19468 str
= argv_concat(argv
, argc
, idx
);
19472 argv_find(argv
, argc
, "(1-99)", &idx
);
19473 argv_find(argv
, argc
, "(100-500)", &idx
);
19474 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19476 /* Unset community list. */
19477 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19480 /* Free temporary community list string allocated by
19482 XFREE(MTYPE_TMP
, str
);
19485 community_list_perror(vty
, ret
);
19486 return CMD_WARNING_CONFIG_FAILED
;
19489 return CMD_SUCCESS
;
19492 /* "large-community-list" keyword help string. */
19493 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19494 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19496 DEFUN (lcommunity_list_standard
,
19497 bgp_lcommunity_list_standard_cmd
,
19498 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19500 LCOMMUNITY_LIST_STR
19501 "Large Community list number (standard)\n"
19502 "Sequence number of an entry\n"
19503 "Sequence number\n"
19504 "Specify large community to reject\n"
19505 "Specify large community to accept\n"
19506 LCOMMUNITY_VAL_STR
)
19508 return lcommunity_list_set_vty(vty
, argc
, argv
,
19509 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19512 DEFUN (lcommunity_list_expanded
,
19513 bgp_lcommunity_list_expanded_cmd
,
19514 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19516 LCOMMUNITY_LIST_STR
19517 "Large Community list number (expanded)\n"
19518 "Sequence number of an entry\n"
19519 "Sequence number\n"
19520 "Specify large community to reject\n"
19521 "Specify large community to accept\n"
19522 "An ordered list as a regular-expression\n")
19524 return lcommunity_list_set_vty(vty
, argc
, argv
,
19525 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19528 DEFUN (lcommunity_list_name_standard
,
19529 bgp_lcommunity_list_name_standard_cmd
,
19530 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19532 LCOMMUNITY_LIST_STR
19533 "Specify standard large-community-list\n"
19534 "Large Community list name\n"
19535 "Sequence number of an entry\n"
19536 "Sequence number\n"
19537 "Specify large community to reject\n"
19538 "Specify large community to accept\n"
19539 LCOMMUNITY_VAL_STR
)
19541 return lcommunity_list_set_vty(vty
, argc
, argv
,
19542 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19545 DEFUN (lcommunity_list_name_expanded
,
19546 bgp_lcommunity_list_name_expanded_cmd
,
19547 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19549 LCOMMUNITY_LIST_STR
19550 "Specify expanded large-community-list\n"
19551 "Large Community list name\n"
19552 "Sequence number of an entry\n"
19553 "Sequence number\n"
19554 "Specify large community to reject\n"
19555 "Specify large community to accept\n"
19556 "An ordered list as a regular-expression\n")
19558 return lcommunity_list_set_vty(vty
, argc
, argv
,
19559 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19562 DEFUN (no_lcommunity_list_all
,
19563 no_bgp_lcommunity_list_all_cmd
,
19564 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19567 LCOMMUNITY_LIST_STR
19568 "Large Community list number (standard)\n"
19569 "Large Community list number (expanded)\n"
19570 "Large Community list name\n")
19572 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19573 LARGE_COMMUNITY_LIST_STANDARD
);
19576 DEFUN (no_lcommunity_list_name_standard_all
,
19577 no_bgp_lcommunity_list_name_standard_all_cmd
,
19578 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19581 LCOMMUNITY_LIST_STR
19582 "Specify standard large-community-list\n"
19583 "Large Community list name\n")
19585 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19586 LARGE_COMMUNITY_LIST_STANDARD
);
19589 DEFUN (no_lcommunity_list_name_expanded_all
,
19590 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19591 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19594 LCOMMUNITY_LIST_STR
19595 "Specify expanded large-community-list\n"
19596 "Large Community list name\n")
19598 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19599 LARGE_COMMUNITY_LIST_EXPANDED
);
19602 DEFUN (no_lcommunity_list_standard
,
19603 no_bgp_lcommunity_list_standard_cmd
,
19604 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19607 LCOMMUNITY_LIST_STR
19608 "Large Community list number (standard)\n"
19609 "Sequence number of an entry\n"
19610 "Sequence number\n"
19611 "Specify large community to reject\n"
19612 "Specify large community to accept\n"
19613 LCOMMUNITY_VAL_STR
)
19615 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19616 LARGE_COMMUNITY_LIST_STANDARD
);
19619 DEFUN (no_lcommunity_list_expanded
,
19620 no_bgp_lcommunity_list_expanded_cmd
,
19621 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19624 LCOMMUNITY_LIST_STR
19625 "Large Community list number (expanded)\n"
19626 "Sequence number of an entry\n"
19627 "Sequence number\n"
19628 "Specify large community to reject\n"
19629 "Specify large community to accept\n"
19630 "An ordered list as a regular-expression\n")
19632 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19633 LARGE_COMMUNITY_LIST_EXPANDED
);
19636 DEFUN (no_lcommunity_list_name_standard
,
19637 no_bgp_lcommunity_list_name_standard_cmd
,
19638 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19641 LCOMMUNITY_LIST_STR
19642 "Specify standard large-community-list\n"
19643 "Large Community list name\n"
19644 "Sequence number of an entry\n"
19645 "Sequence number\n"
19646 "Specify large community to reject\n"
19647 "Specify large community to accept\n"
19648 LCOMMUNITY_VAL_STR
)
19650 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19651 LARGE_COMMUNITY_LIST_STANDARD
);
19654 DEFUN (no_lcommunity_list_name_expanded
,
19655 no_bgp_lcommunity_list_name_expanded_cmd
,
19656 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19659 LCOMMUNITY_LIST_STR
19660 "Specify expanded large-community-list\n"
19661 "Large community list name\n"
19662 "Sequence number of an entry\n"
19663 "Sequence number\n"
19664 "Specify large community to reject\n"
19665 "Specify large community to accept\n"
19666 "An ordered list as a regular-expression\n")
19668 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19669 LARGE_COMMUNITY_LIST_EXPANDED
);
19672 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19674 struct community_entry
*entry
;
19676 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19677 if (entry
== list
->head
) {
19678 if (all_digit(list
->name
))
19679 vty_out(vty
, "Large community %s list %s\n",
19681 LARGE_COMMUNITY_LIST_STANDARD
19683 : "(expanded) access",
19687 "Named large community %s list %s\n",
19689 LARGE_COMMUNITY_LIST_STANDARD
19695 vty_out(vty
, " %s\n",
19696 community_direct_str(entry
->direct
));
19698 vty_out(vty
, " %s %s\n",
19699 community_direct_str(entry
->direct
),
19700 community_list_config_str(entry
));
19704 DEFUN (show_lcommunity_list
,
19705 show_bgp_lcommunity_list_cmd
,
19706 "show bgp large-community-list",
19709 "List large-community list\n")
19711 struct community_list
*list
;
19712 struct community_list_master
*cm
;
19714 cm
= community_list_master_lookup(bgp_clist
,
19715 LARGE_COMMUNITY_LIST_MASTER
);
19717 return CMD_SUCCESS
;
19719 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19720 lcommunity_list_show(vty
, list
);
19722 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19723 lcommunity_list_show(vty
, list
);
19725 return CMD_SUCCESS
;
19728 DEFUN (show_lcommunity_list_arg
,
19729 show_bgp_lcommunity_list_arg_cmd
,
19730 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
19733 "List large-community list\n"
19734 "Large-community-list number\n"
19735 "Large-community-list name\n"
19736 "Detailed information on large-community-list\n")
19738 struct community_list
*list
;
19740 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19741 LARGE_COMMUNITY_LIST_MASTER
);
19743 vty_out(vty
, "%% Can't find large-community-list\n");
19744 return CMD_WARNING
;
19747 lcommunity_list_show(vty
, list
);
19749 return CMD_SUCCESS
;
19752 /* "extcommunity-list" keyword help string. */
19753 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19754 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19756 DEFUN (extcommunity_list_standard
,
19757 bgp_extcommunity_list_standard_cmd
,
19758 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19760 EXTCOMMUNITY_LIST_STR
19761 "Extended Community list number (standard)\n"
19762 "Specify standard extcommunity-list\n"
19763 "Community list name\n"
19764 "Sequence number of an entry\n"
19765 "Sequence number\n"
19766 "Specify community to reject\n"
19767 "Specify community to accept\n"
19768 EXTCOMMUNITY_VAL_STR
)
19770 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19772 char *cl_number_or_name
= NULL
;
19777 argv_find(argv
, argc
, "(1-99)", &idx
);
19778 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19779 cl_number_or_name
= argv
[idx
]->arg
;
19781 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19782 seq
= argv
[idx
]->arg
;
19784 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19786 argv_find(argv
, argc
, "AA:NN", &idx
);
19787 char *str
= argv_concat(argv
, argc
, idx
);
19789 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19792 XFREE(MTYPE_TMP
, str
);
19795 community_list_perror(vty
, ret
);
19796 return CMD_WARNING_CONFIG_FAILED
;
19799 return CMD_SUCCESS
;
19802 DEFUN (extcommunity_list_name_expanded
,
19803 bgp_extcommunity_list_name_expanded_cmd
,
19804 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19806 EXTCOMMUNITY_LIST_STR
19807 "Extended Community list number (expanded)\n"
19808 "Specify expanded extcommunity-list\n"
19809 "Extended Community list name\n"
19810 "Sequence number of an entry\n"
19811 "Sequence number\n"
19812 "Specify community to reject\n"
19813 "Specify community to accept\n"
19814 "An ordered list as a regular-expression\n")
19816 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19818 char *cl_number_or_name
= NULL
;
19822 argv_find(argv
, argc
, "(100-500)", &idx
);
19823 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19824 cl_number_or_name
= argv
[idx
]->arg
;
19826 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19827 seq
= argv
[idx
]->arg
;
19829 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19831 argv_find(argv
, argc
, "LINE", &idx
);
19832 char *str
= argv_concat(argv
, argc
, idx
);
19834 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19837 XFREE(MTYPE_TMP
, str
);
19840 community_list_perror(vty
, ret
);
19841 return CMD_WARNING_CONFIG_FAILED
;
19844 return CMD_SUCCESS
;
19847 DEFUN (no_extcommunity_list_standard_all
,
19848 no_bgp_extcommunity_list_standard_all_cmd
,
19849 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19852 EXTCOMMUNITY_LIST_STR
19853 "Extended Community list number (standard)\n"
19854 "Specify standard extcommunity-list\n"
19855 "Community list name\n"
19856 "Sequence number of an entry\n"
19857 "Sequence number\n"
19858 "Specify community to reject\n"
19859 "Specify community to accept\n"
19860 EXTCOMMUNITY_VAL_STR
)
19862 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19864 char *cl_number_or_name
= NULL
;
19869 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19870 seq
= argv
[idx
]->arg
;
19873 argv_find(argv
, argc
, "permit", &idx
);
19874 argv_find(argv
, argc
, "deny", &idx
);
19876 direct
= argv_find(argv
, argc
, "permit", &idx
)
19881 argv_find(argv
, argc
, "AA:NN", &idx
);
19882 str
= argv_concat(argv
, argc
, idx
);
19886 argv_find(argv
, argc
, "(1-99)", &idx
);
19887 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19888 cl_number_or_name
= argv
[idx
]->arg
;
19890 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19891 seq
, direct
, style
);
19893 XFREE(MTYPE_TMP
, str
);
19896 community_list_perror(vty
, ret
);
19897 return CMD_WARNING_CONFIG_FAILED
;
19900 return CMD_SUCCESS
;
19903 ALIAS(no_extcommunity_list_standard_all
,
19904 no_bgp_extcommunity_list_standard_all_list_cmd
,
19905 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
19906 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19907 "Extended Community list number (standard)\n"
19908 "Specify standard extcommunity-list\n"
19909 "Community list name\n")
19911 DEFUN (no_extcommunity_list_expanded_all
,
19912 no_bgp_extcommunity_list_expanded_all_cmd
,
19913 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19916 EXTCOMMUNITY_LIST_STR
19917 "Extended Community list number (expanded)\n"
19918 "Specify expanded extcommunity-list\n"
19919 "Extended Community list name\n"
19920 "Sequence number of an entry\n"
19921 "Sequence number\n"
19922 "Specify community to reject\n"
19923 "Specify community to accept\n"
19924 "An ordered list as a regular-expression\n")
19926 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19928 char *cl_number_or_name
= NULL
;
19933 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19934 seq
= argv
[idx
]->arg
;
19937 argv_find(argv
, argc
, "permit", &idx
);
19938 argv_find(argv
, argc
, "deny", &idx
);
19941 direct
= argv_find(argv
, argc
, "permit", &idx
)
19946 argv_find(argv
, argc
, "LINE", &idx
);
19947 str
= argv_concat(argv
, argc
, idx
);
19951 argv_find(argv
, argc
, "(100-500)", &idx
);
19952 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19953 cl_number_or_name
= argv
[idx
]->arg
;
19955 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19956 seq
, direct
, style
);
19958 XFREE(MTYPE_TMP
, str
);
19961 community_list_perror(vty
, ret
);
19962 return CMD_WARNING_CONFIG_FAILED
;
19965 return CMD_SUCCESS
;
19968 ALIAS(no_extcommunity_list_expanded_all
,
19969 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19970 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
19971 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19972 "Extended Community list number (expanded)\n"
19973 "Specify expanded extcommunity-list\n"
19974 "Extended Community list name\n")
19976 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19978 struct community_entry
*entry
;
19980 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19981 if (entry
== list
->head
) {
19982 if (all_digit(list
->name
))
19983 vty_out(vty
, "Extended community %s list %s\n",
19984 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19986 : "(expanded) access",
19990 "Named extended community %s list %s\n",
19991 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19997 vty_out(vty
, " %s\n",
19998 community_direct_str(entry
->direct
));
20000 vty_out(vty
, " %s %s\n",
20001 community_direct_str(entry
->direct
),
20002 community_list_config_str(entry
));
20006 DEFUN (show_extcommunity_list
,
20007 show_bgp_extcommunity_list_cmd
,
20008 "show bgp extcommunity-list",
20011 "List extended-community list\n")
20013 struct community_list
*list
;
20014 struct community_list_master
*cm
;
20016 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20018 return CMD_SUCCESS
;
20020 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20021 extcommunity_list_show(vty
, list
);
20023 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20024 extcommunity_list_show(vty
, list
);
20026 return CMD_SUCCESS
;
20029 DEFUN (show_extcommunity_list_arg
,
20030 show_bgp_extcommunity_list_arg_cmd
,
20031 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20034 "List extended-community list\n"
20035 "Extcommunity-list number\n"
20036 "Extcommunity-list name\n"
20037 "Detailed information on extcommunity-list\n")
20039 int idx_comm_list
= 3;
20040 struct community_list
*list
;
20042 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20043 EXTCOMMUNITY_LIST_MASTER
);
20045 vty_out(vty
, "%% Can't find extcommunity-list\n");
20046 return CMD_WARNING
;
20049 extcommunity_list_show(vty
, list
);
20051 return CMD_SUCCESS
;
20054 /* Display community-list and extcommunity-list configuration. */
20055 static int community_list_config_write(struct vty
*vty
)
20057 struct community_list
*list
;
20058 struct community_entry
*entry
;
20059 struct community_list_master
*cm
;
20062 /* Community-list. */
20063 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20065 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20066 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20068 "bgp community-list %s seq %" PRId64
" %s %s\n",
20069 list
->name
, entry
->seq
,
20070 community_direct_str(entry
->direct
),
20071 community_list_config_str(entry
));
20074 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20075 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20077 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20078 entry
->style
== COMMUNITY_LIST_STANDARD
20081 list
->name
, entry
->seq
,
20082 community_direct_str(entry
->direct
),
20083 community_list_config_str(entry
));
20087 /* Extcommunity-list. */
20088 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20090 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20091 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20093 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20094 list
->name
, entry
->seq
,
20095 community_direct_str(entry
->direct
),
20096 community_list_config_str(entry
));
20099 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20100 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20102 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20103 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20106 list
->name
, entry
->seq
,
20107 community_direct_str(entry
->direct
),
20108 community_list_config_str(entry
));
20113 /* lcommunity-list. */
20114 cm
= community_list_master_lookup(bgp_clist
,
20115 LARGE_COMMUNITY_LIST_MASTER
);
20117 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20118 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20120 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20121 list
->name
, entry
->seq
,
20122 community_direct_str(entry
->direct
),
20123 community_list_config_str(entry
));
20126 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20127 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20129 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20131 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20134 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20135 community_list_config_str(entry
));
20142 static int community_list_config_write(struct vty
*vty
);
20143 static struct cmd_node community_list_node
= {
20144 .name
= "community list",
20145 .node
= COMMUNITY_LIST_NODE
,
20147 .config_write
= community_list_config_write
,
20150 static void community_list_vty(void)
20152 install_node(&community_list_node
);
20154 /* Community-list. */
20155 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20156 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20157 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20158 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20159 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20160 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20161 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20162 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20164 /* Extcommunity-list. */
20165 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20166 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20167 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20168 install_element(CONFIG_NODE
,
20169 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20170 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20171 install_element(CONFIG_NODE
,
20172 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20173 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20174 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20176 /* Large Community List */
20177 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20178 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20179 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20180 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20181 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20182 install_element(CONFIG_NODE
,
20183 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20184 install_element(CONFIG_NODE
,
20185 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20186 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20187 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20188 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20189 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20190 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20191 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20193 bgp_community_list_command_completion_setup();
20196 static struct cmd_node community_alias_node
= {
20197 .name
= "community alias",
20198 .node
= COMMUNITY_ALIAS_NODE
,
20200 .config_write
= bgp_community_alias_write
,
20203 void community_alias_vty(void)
20205 install_node(&community_alias_node
);
20207 /* Community-list. */
20208 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20210 bgp_community_alias_command_completion_setup();