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_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
163 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
166 afi_t afi
, bool use_json
);
168 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
174 return BGP_IPV4_NODE
;
176 return BGP_IPV4M_NODE
;
177 case SAFI_LABELED_UNICAST
:
178 return BGP_IPV4L_NODE
;
180 return BGP_VPNV4_NODE
;
182 return BGP_FLOWSPECV4_NODE
;
185 return BGP_IPV4_NODE
;
190 return BGP_IPV6_NODE
;
192 return BGP_IPV6M_NODE
;
193 case SAFI_LABELED_UNICAST
:
194 return BGP_IPV6L_NODE
;
196 return BGP_VPNV6_NODE
;
198 return BGP_FLOWSPECV6_NODE
;
201 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* unset srv6 locator */
294 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
297 struct listnode
*node
, *nnode
;
298 struct srv6_locator_chunk
*chunk
;
299 struct bgp_srv6_function
*func
;
301 struct in6_addr
*tovpn_sid
;
303 /* release chunk notification via ZAPI */
304 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
305 bgp
->srv6_locator_name
);
310 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
311 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
312 srv6_locator_chunk_free(chunk
);
315 /* refresh functions */
316 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
317 listnode_delete(bgp
->srv6_functions
, func
);
318 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
321 /* refresh tovpn_sid */
322 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
323 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
326 /* refresh vpnv4 tovpn_sid */
327 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
;
329 XFREE(MTYPE_BGP_SRV6_SID
,
330 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
332 /* refresh vpnv6 tovpn_sid */
333 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
;
335 XFREE(MTYPE_BGP_SRV6_SID
,
336 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
339 /* update vpn bgp processes */
340 vpn_leak_postchange_all();
342 /* refresh tovpn_sid_locator */
343 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
344 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
347 /* refresh vpnv4 tovpn_sid_locator */
348 XFREE(MTYPE_BGP_SRV6_SID
,
349 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
351 /* refresh vpnv6 tovpn_sid_locator */
352 XFREE(MTYPE_BGP_SRV6_SID
,
353 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
356 /* clear locator name */
357 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
362 /* Utility function to get address family from current node. */
363 afi_t
bgp_node_afi(struct vty
*vty
)
371 case BGP_FLOWSPECV6_NODE
:
384 /* Utility function to get subsequent address family from current
386 safi_t
bgp_node_safi(struct vty
*vty
)
392 safi
= SAFI_MPLS_VPN
;
396 safi
= SAFI_MULTICAST
;
403 safi
= SAFI_LABELED_UNICAST
;
405 case BGP_FLOWSPECV4_NODE
:
406 case BGP_FLOWSPECV6_NODE
:
407 safi
= SAFI_FLOWSPEC
;
417 * Converts an AFI in string form to afi_t
419 * @param afi string, one of
423 * @return the corresponding afi_t
425 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
427 afi_t afi
= AFI_MAX
; /* unknown */
428 if (strmatch(afi_str
, "ipv4"))
430 else if (strmatch(afi_str
, "ipv6"))
432 else if (strmatch(afi_str
, "l2vpn"))
437 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
441 if (argv_find(argv
, argc
, "ipv4", index
)) {
445 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
449 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
457 /* supports <unicast|multicast|vpn|labeled-unicast> */
458 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
460 safi_t safi
= SAFI_MAX
; /* unknown */
461 if (strmatch(safi_str
, "multicast"))
462 safi
= SAFI_MULTICAST
;
463 else if (strmatch(safi_str
, "unicast"))
465 else if (strmatch(safi_str
, "vpn"))
466 safi
= SAFI_MPLS_VPN
;
467 else if (strmatch(safi_str
, "evpn"))
469 else if (strmatch(safi_str
, "labeled-unicast"))
470 safi
= SAFI_LABELED_UNICAST
;
471 else if (strmatch(safi_str
, "flowspec"))
472 safi
= SAFI_FLOWSPEC
;
476 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
480 if (argv_find(argv
, argc
, "unicast", index
)) {
483 *safi
= SAFI_UNICAST
;
484 } else if (argv_find(argv
, argc
, "multicast", index
)) {
487 *safi
= SAFI_MULTICAST
;
488 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
491 *safi
= SAFI_LABELED_UNICAST
;
492 } else if (argv_find(argv
, argc
, "vpn", index
)) {
495 *safi
= SAFI_MPLS_VPN
;
496 } else if (argv_find(argv
, argc
, "evpn", index
)) {
500 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
503 *safi
= SAFI_FLOWSPEC
;
509 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
512 * address-family identifier
515 * subsequent address-family identifier
518 * default_af string corresponding to the supplied afi/safi pair.
519 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
522 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
528 return "ipv4-unicast";
530 return "ipv4-multicast";
535 case SAFI_LABELED_UNICAST
:
536 return "ipv4-labeled-unicast";
538 return "ipv4-flowspec";
540 return "unknown-afi/safi";
546 return "ipv6-unicast";
548 return "ipv6-multicast";
553 case SAFI_LABELED_UNICAST
:
554 return "ipv6-labeled-unicast";
556 return "ipv6-flowspec";
558 return "unknown-afi/safi";
566 return "unknown-afi/safi";
570 return "unknown-afi/safi";
572 /* all AFIs are accounted for above, so this shouldn't happen */
573 return "unknown-afi/safi";
576 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
577 enum bgp_instance_type inst_type
)
579 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
581 if (ret
== BGP_CREATED
) {
582 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
583 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
585 if (DFLT_BGP_IMPORT_CHECK
)
586 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
587 if (DFLT_BGP_SHOW_HOSTNAME
)
588 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
589 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
590 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
591 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
592 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
593 if (DFLT_BGP_DETERMINISTIC_MED
)
594 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
595 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
596 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
597 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
598 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
599 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
600 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
601 if (DFLT_BGP_HARD_ADMIN_RESET
)
602 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
610 * bgp_vty_find_and_parse_afi_safi_bgp
612 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
613 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
614 * to appropriate values for the calling function. This is to allow the
615 * calling function to make decisions appropriate for the show command
616 * that is being parsed.
618 * The show commands are generally of the form:
619 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
620 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
622 * Since we use argv_find if the show command in particular doesn't have:
624 * [<view|vrf> VIEWVRFNAME]
625 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
626 * The command parsing should still be ok.
628 * vty -> The vty for the command so we can output some useful data in
629 * the event of a parse error in the vrf.
630 * argv -> The command tokens
631 * argc -> How many command tokens we have
632 * idx -> The current place in the command, generally should be 0 for this
634 * afi -> The parsed afi if it was included in the show command, returned here
635 * safi -> The parsed safi if it was included in the show command, returned here
636 * bgp -> Pointer to the bgp data structure we need to fill in.
637 * use_json -> json is configured or not
639 * The function returns the correct location in the parse tree for the
642 * Returns 0 for failure to parse correctly, else the idx position of where
643 * it found the last token.
645 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
646 struct cmd_token
**argv
, int argc
,
647 int *idx
, afi_t
*afi
, safi_t
*safi
,
648 struct bgp
**bgp
, bool use_json
)
650 char *vrf_name
= NULL
;
656 if (argv_find(argv
, argc
, "ip", idx
))
659 if (argv_find(argv
, argc
, "view", idx
))
660 vrf_name
= argv
[*idx
+ 1]->arg
;
661 else if (argv_find(argv
, argc
, "vrf", idx
)) {
662 vrf_name
= argv
[*idx
+ 1]->arg
;
663 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
667 if (strmatch(vrf_name
, "all"))
670 *bgp
= bgp_lookup_by_name(vrf_name
);
673 json_object
*json
= NULL
;
674 json
= json_object_new_object();
675 json_object_string_add(
677 "View/Vrf is unknown");
681 vty_out(vty
, "View/Vrf %s is unknown\n",
688 *bgp
= bgp_get_default();
691 json_object
*json
= NULL
;
692 json
= json_object_new_object();
693 json_object_string_add(
695 "Default BGP instance not found");
700 "Default BGP instance not found\n");
706 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
707 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
713 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
715 struct interface
*ifp
= NULL
;
716 struct listnode
*node
;
717 struct bgp_listener
*listener
;
718 union sockunion all_su
;
720 if (su
->sa
.sa_family
== AF_INET
) {
721 (void)str2sockunion("0.0.0.0", &all_su
);
722 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
723 } else if (su
->sa
.sa_family
== AF_INET6
) {
724 (void)str2sockunion("::", &all_su
);
725 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
726 su
->sin6
.sin6_scope_id
,
731 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
732 if (sockunion_family(su
) !=
733 sockunion_family(&listener
->su
))
736 /* If 0.0.0.0/:: is a listener, then treat as self and
739 if (!sockunion_cmp(&listener
->su
, su
) ||
740 !sockunion_cmp(&listener
->su
, &all_su
))
748 /* Utility function for looking up peer from VTY. */
749 /* This is used only for configuration, so disallow if attempted on
750 * a dynamic neighbor.
752 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
754 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
763 ret
= str2sockunion(ip_str
, &su
);
765 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
767 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
770 "%% Malformed address or name: %s\n",
776 peer
= peer_lookup(bgp
, &su
);
779 "%% Specify remote-as or peer-group commands first\n");
782 if (peer_dynamic_neighbor(peer
)) {
784 "%% Operation not allowed on a dynamic neighbor\n");
791 /* Utility function for looking up peer or peer group. */
792 /* This is used only for configuration, so disallow if attempted on
793 * a dynamic neighbor.
795 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
797 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
800 struct peer
*peer
= NULL
;
801 struct peer_group
*group
= NULL
;
807 ret
= str2sockunion(peer_str
, &su
);
809 /* IP address, locate peer. */
810 peer
= peer_lookup(bgp
, &su
);
812 /* Not IP, could match either peer configured on interface or a
814 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
816 group
= peer_group_lookup(bgp
, peer_str
);
820 if (peer_dynamic_neighbor(peer
)) {
822 "%% Operation not allowed on a dynamic neighbor\n");
832 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
837 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
839 const char *str
= NULL
;
844 case BGP_GR_NO_OPERATION
:
846 case BGP_ERR_INVALID_VALUE
:
847 str
= "Invalid value";
849 case BGP_ERR_INVALID_FLAG
:
850 str
= "Invalid flag";
852 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
853 str
= "Peer-group has been shutdown. Activate the peer-group first";
855 case BGP_ERR_PEER_FLAG_CONFLICT
:
856 str
= "Can't set override-capability and strict-capability-match at the same time";
858 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
859 str
= "Specify remote-as or peer-group remote AS first";
861 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
862 str
= "Cannot change the peer-group. Deconfigure first";
864 case BGP_ERR_PEER_GROUP_MISMATCH
:
865 str
= "Peer is not a member of this peer-group";
867 case BGP_ERR_PEER_FILTER_CONFLICT
:
868 str
= "Prefix/distribute list can not co-exist";
870 case BGP_ERR_NOT_INTERNAL_PEER
:
871 str
= "Invalid command. Not an internal neighbor";
873 case BGP_ERR_REMOVE_PRIVATE_AS
:
874 str
= "remove-private-AS cannot be configured for IBGP peers";
876 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
877 str
= "Local-AS allowed only for EBGP peers";
879 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
880 str
= "Cannot have local-as same as BGP AS number";
882 case BGP_ERR_TCPSIG_FAILED
:
883 str
= "Error while applying TCP-Sig to session(s)";
885 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
886 str
= "ebgp-multihop and ttl-security cannot be configured together";
888 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
889 str
= "ttl-security only allowed for EBGP peers";
891 case BGP_ERR_AS_OVERRIDE
:
892 str
= "as-override cannot be configured for IBGP peers";
894 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
895 str
= "Invalid limit for number of dynamic neighbors";
897 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
898 str
= "Dynamic neighbor listen range already exists";
900 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
901 str
= "Operation not allowed on a dynamic neighbor";
903 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
904 str
= "Operation not allowed on a directly connected neighbor";
906 case BGP_ERR_PEER_SAFI_CONFLICT
:
907 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
909 case BGP_ERR_GR_INVALID_CMD
:
910 str
= "The Graceful Restart command used is not valid at this moment.";
912 case BGP_ERR_GR_OPERATION_FAILED
:
913 str
= "The Graceful Restart Operation failed due to an err.";
915 case BGP_ERR_PEER_GROUP_MEMBER
:
916 str
= "Peer-group member cannot override remote-as of peer-group.";
918 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
919 str
= "Peer-group members must be all internal or all external.";
921 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
922 str
= "Range specified cannot be deleted because it is not part of current config.";
924 case BGP_ERR_INSTANCE_MISMATCH
:
925 str
= "Instance specified does not match the current instance.";
927 case BGP_ERR_NO_INTERFACE_CONFIG
:
928 str
= "Interface specified is not being used for interface based peer.";
930 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
931 str
= "No configuration already specified for soft reconfiguration.";
933 case BGP_ERR_AS_MISMATCH
:
934 str
= "BGP is already running.";
936 case BGP_ERR_AF_UNCONFIGURED
:
937 str
= "AFI/SAFI specified is not currently configured.";
939 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS
:
940 str
= "AS specified for local as is the same as the remote as and this is not allowed.";
942 case BGP_ERR_INVALID_AS
:
943 str
= "Confederation AS specified is the same AS as our AS.";
945 case BGP_ERR_INVALID_ROLE_NAME
:
946 str
= "Invalid role name";
948 case BGP_ERR_INVALID_INTERNAL_ROLE
:
949 str
= "External roles can be set only on eBGP session";
953 vty_out(vty
, "%% %s\n", str
);
954 return CMD_WARNING_CONFIG_FAILED
;
959 /* BGP clear sort. */
968 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
969 safi_t safi
, int error
)
972 case BGP_ERR_AF_UNCONFIGURED
:
975 "%% BGP: Enable %s address family for the neighbor %s\n",
976 get_afi_safi_str(afi
, safi
, false), peer
->host
);
979 "%% BGP: Enable %s address family for the neighbor %s",
980 get_afi_safi_str(afi
, safi
, false), peer
->host
);
982 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
985 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
989 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
997 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
998 struct listnode
**nnode
, enum bgp_clear_type stype
)
1001 struct peer_af
*paf
;
1003 /* if afi/.safi not specified, spin thru all of them */
1004 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1007 enum bgp_af_index index
;
1009 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1010 paf
= peer
->peer_af_array
[index
];
1014 if (paf
&& paf
->subgroup
)
1015 SET_FLAG(paf
->subgroup
->sflags
,
1016 SUBGRP_STATUS_FORCE_UPDATES
);
1019 tmp_safi
= paf
->safi
;
1020 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1023 if (stype
== BGP_CLEAR_SOFT_NONE
)
1024 ret
= peer_clear(peer
, nnode
);
1026 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1029 /* if afi specified and safi not, spin thru safis on this afi */
1030 } else if (safi
== SAFI_UNSPEC
) {
1033 for (tmp_safi
= SAFI_UNICAST
;
1034 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1035 if (!peer
->afc
[afi
][tmp_safi
])
1038 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1039 if (paf
&& paf
->subgroup
)
1040 SET_FLAG(paf
->subgroup
->sflags
,
1041 SUBGRP_STATUS_FORCE_UPDATES
);
1043 if (stype
== BGP_CLEAR_SOFT_NONE
)
1044 ret
= peer_clear(peer
, nnode
);
1046 ret
= peer_clear_soft(peer
, afi
,
1049 /* both afi/safi specified, let the caller know if not defined */
1051 if (!peer
->afc
[afi
][safi
])
1054 paf
= peer_af_find(peer
, afi
, safi
);
1055 if (paf
&& paf
->subgroup
)
1056 SET_FLAG(paf
->subgroup
->sflags
,
1057 SUBGRP_STATUS_FORCE_UPDATES
);
1059 if (stype
== BGP_CLEAR_SOFT_NONE
)
1060 ret
= peer_clear(peer
, nnode
);
1062 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1068 /* `clear ip bgp' functions. */
1069 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1070 enum clear_sort sort
, enum bgp_clear_type stype
,
1077 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1079 /* Clear all neighbors. */
1081 * Pass along pointer to next node to peer_clear() when walking all
1082 * nodes on the BGP instance as that may get freed if it is a
1085 if (sort
== clear_all
) {
1086 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1088 bgp_peer_gr_flags_update(peer
);
1090 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1091 gr_router_detected
= true;
1093 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1097 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1100 if (gr_router_detected
1101 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1102 bgp_zebra_send_capabilities(bgp
, false);
1103 } else if (!gr_router_detected
1104 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1105 bgp_zebra_send_capabilities(bgp
, true);
1108 /* This is to apply read-only mode on this clear. */
1109 if (stype
== BGP_CLEAR_SOFT_NONE
)
1110 bgp
->update_delay_over
= 0;
1115 /* Clear specified neighbor. */
1116 if (sort
== clear_peer
) {
1119 /* Make sockunion for lookup. */
1120 ret
= str2sockunion(arg
, &su
);
1122 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1124 peer
= peer_lookup_by_hostname(bgp
, arg
);
1127 "Malformed address or name: %s\n",
1133 peer
= peer_lookup(bgp
, &su
);
1136 "%% BGP: Unknown neighbor - \"%s\"\n",
1142 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1143 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1145 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1147 /* if afi/safi not defined for this peer, let caller know */
1149 ret
= BGP_ERR_AF_UNCONFIGURED
;
1152 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1157 /* Clear all neighbors belonging to a specific peer-group. */
1158 if (sort
== clear_group
) {
1159 struct peer_group
*group
;
1161 group
= peer_group_lookup(bgp
, arg
);
1163 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1167 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1168 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1171 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1178 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1179 get_afi_safi_str(afi
, safi
, false), arg
);
1184 /* Clear all external (eBGP) neighbors. */
1185 if (sort
== clear_external
) {
1186 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1187 if (peer
->sort
== BGP_PEER_IBGP
)
1190 bgp_peer_gr_flags_update(peer
);
1192 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1193 gr_router_detected
= true;
1195 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1198 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1203 if (gr_router_detected
1204 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1205 bgp_zebra_send_capabilities(bgp
, false);
1206 } else if (!gr_router_detected
1207 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1208 bgp_zebra_send_capabilities(bgp
, true);
1213 "%% BGP: No external %s peer is configured\n",
1214 get_afi_safi_str(afi
, safi
, false));
1219 /* Clear all neighbors belonging to a specific AS. */
1220 if (sort
== clear_as
) {
1221 as_t as
= strtoul(arg
, NULL
, 10);
1223 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1227 bgp_peer_gr_flags_update(peer
);
1229 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1230 gr_router_detected
= true;
1232 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1235 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1240 if (gr_router_detected
1241 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1242 bgp_zebra_send_capabilities(bgp
, false);
1243 } else if (!gr_router_detected
1244 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1245 bgp_zebra_send_capabilities(bgp
, true);
1250 "%% BGP: No %s peer is configured with AS %s\n",
1251 get_afi_safi_str(afi
, safi
, false), arg
);
1259 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1260 safi_t safi
, enum clear_sort sort
,
1261 enum bgp_clear_type stype
, const char *arg
)
1265 /* BGP structure lookup. */
1267 bgp
= bgp_lookup_by_name(name
);
1269 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1273 bgp
= bgp_get_default();
1275 vty_out(vty
, "No BGP process is configured\n");
1280 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1283 /* clear soft inbound */
1284 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1289 FOREACH_AFI_SAFI (afi
, safi
)
1290 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1291 BGP_CLEAR_SOFT_IN
, NULL
);
1294 /* clear soft outbound */
1295 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1300 FOREACH_AFI_SAFI (afi
, safi
)
1301 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1302 BGP_CLEAR_SOFT_OUT
, NULL
);
1306 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1308 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1311 #ifndef VTYSH_EXTRACT_PL
1312 #include "bgpd/bgp_vty_clippy.c"
1315 DEFUN_HIDDEN (bgp_local_mac
,
1317 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1319 "Local MAC config\n"
1320 "VxLAN Network Identifier\n"
1324 "mac-mobility sequence\n"
1334 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1335 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1336 vty_out(vty
, "%% Malformed MAC address\n");
1339 memset(&ip
, 0, sizeof(ip
));
1340 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1342 bgp
= bgp_get_default();
1344 vty_out(vty
, "Default BGP instance is not there\n");
1348 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1351 vty_out(vty
, "Internal error\n");
1358 DEFUN_HIDDEN (no_bgp_local_mac
,
1359 no_bgp_local_mac_cmd
,
1360 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1363 "Local MAC config\n"
1364 "VxLAN Network Identifier\n"
1375 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1376 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1377 vty_out(vty
, "%% Malformed MAC address\n");
1380 memset(&ip
, 0, sizeof(ip
));
1382 bgp
= bgp_get_default();
1384 vty_out(vty
, "Default BGP instance is not there\n");
1388 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1390 vty_out(vty
, "Internal error\n");
1397 DEFUN (no_synchronization
,
1398 no_synchronization_cmd
,
1399 "no synchronization",
1401 "Perform IGP synchronization\n")
1406 DEFUN (no_auto_summary
,
1407 no_auto_summary_cmd
,
1410 "Enable automatic network number summarization\n")
1415 /* "router bgp" commands. */
1416 DEFUN_NOSH (router_bgp
,
1418 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1422 BGP_INSTANCE_HELP_STR
)
1425 int idx_view_vrf
= 3;
1431 const char *name
= NULL
;
1432 enum bgp_instance_type inst_type
;
1434 // "router bgp" without an ASN
1436 // Pending: Make VRF option available for ASN less config
1437 bgp
= bgp_get_default();
1440 vty_out(vty
, "%% No BGP process is configured\n");
1441 return CMD_WARNING_CONFIG_FAILED
;
1444 if (listcount(bm
->bgp
) > 1) {
1445 vty_out(vty
, "%% Please specify ASN and VRF\n");
1446 return CMD_WARNING_CONFIG_FAILED
;
1452 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1454 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1455 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1456 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1458 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1460 name
= argv
[idx_vrf
]->arg
;
1462 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1463 if (strmatch(name
, VRF_DEFAULT_NAME
))
1466 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1467 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1468 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1471 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1472 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1474 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1476 case BGP_ERR_AS_MISMATCH
:
1477 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1478 return CMD_WARNING_CONFIG_FAILED
;
1479 case BGP_ERR_INSTANCE_MISMATCH
:
1481 "BGP instance name and AS number mismatch\n");
1483 "BGP instance is already running; AS is %u\n",
1485 return CMD_WARNING_CONFIG_FAILED
;
1489 * If we just instantiated the default instance, complete
1490 * any pending VRF-VPN leaking that was configured via
1491 * earlier "router bgp X vrf FOO" blocks.
1493 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1494 vpn_leak_postchange_all();
1496 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1497 bgp_vpn_leak_export(bgp
);
1498 /* Pending: handle when user tries to change a view to vrf n vv.
1502 /* unset the auto created flag as the user config is now present */
1503 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1504 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1509 /* "no router bgp" commands. */
1510 DEFUN (no_router_bgp
,
1512 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1517 BGP_INSTANCE_HELP_STR
)
1523 const char *name
= NULL
;
1525 // "no router bgp" without an ASN
1527 // Pending: Make VRF option available for ASN less config
1528 bgp
= bgp_get_default();
1531 vty_out(vty
, "%% No BGP process is configured\n");
1532 return CMD_WARNING_CONFIG_FAILED
;
1535 if (listcount(bm
->bgp
) > 1) {
1536 vty_out(vty
, "%% Please specify ASN and VRF\n");
1537 return CMD_WARNING_CONFIG_FAILED
;
1541 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1543 return CMD_WARNING_CONFIG_FAILED
;
1546 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1549 name
= argv
[idx_vrf
]->arg
;
1550 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1551 && strmatch(name
, VRF_DEFAULT_NAME
))
1555 /* Lookup bgp structure. */
1556 bgp
= bgp_lookup(as
, name
);
1558 vty_out(vty
, "%% Can't find BGP instance\n");
1559 return CMD_WARNING_CONFIG_FAILED
;
1563 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1565 return CMD_WARNING_CONFIG_FAILED
;
1568 /* Cannot delete default instance if vrf instances exist */
1569 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1570 struct listnode
*node
;
1571 struct bgp
*tmp_bgp
;
1573 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1574 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1576 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1577 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1578 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1579 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1581 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1582 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1583 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1584 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1585 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1586 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1587 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1588 (bgp
== bgp_get_evpn() &&
1589 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1590 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1591 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1592 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1593 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1594 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1595 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1596 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1597 (hashcount(tmp_bgp
->vnihash
))) {
1599 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1600 return CMD_WARNING_CONFIG_FAILED
;
1611 /* bgp session-dscp */
1613 DEFPY (bgp_session_dscp
,
1614 bgp_session_dscp_cmd
,
1615 "bgp session-dscp (0-63)$dscp",
1617 "Override default (C6) bgp TCP session DSCP value\n"
1618 "Manually configured dscp parameter\n")
1620 bm
->tcp_dscp
= dscp
<< 2;
1625 DEFPY (no_bgp_session_dscp
,
1626 no_bgp_session_dscp_cmd
,
1627 "no bgp session-dscp [(0-63)]",
1630 "Override default (C6) bgp TCP session DSCP value\n"
1631 "Manually configured dscp parameter\n")
1633 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1638 /* BGP router-id. */
1640 DEFPY (bgp_router_id
,
1642 "bgp router-id A.B.C.D",
1644 "Override configured router identifier\n"
1645 "Manually configured router identifier\n")
1647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1648 bgp_router_id_static_set(bgp
, router_id
);
1652 DEFPY (no_bgp_router_id
,
1653 no_bgp_router_id_cmd
,
1654 "no bgp router-id [A.B.C.D]",
1657 "Override configured router identifier\n"
1658 "Manually configured router identifier\n")
1660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1662 if (router_id_str
) {
1663 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1664 vty_out(vty
, "%% BGP router-id doesn't match\n");
1665 return CMD_WARNING_CONFIG_FAILED
;
1669 router_id
.s_addr
= 0;
1670 bgp_router_id_static_set(bgp
, router_id
);
1675 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1676 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1678 "Add community specific parameters\n"
1679 "Create an alias for a community\n"
1680 "Community (AA:BB or AA:BB:CC)\n"
1683 struct community_alias ca
= {};
1684 struct community_alias
*lookup_community
;
1685 struct community_alias
*lookup_alias
;
1686 struct community
*comm
;
1687 struct lcommunity
*lcomm
;
1688 uint8_t invalid
= 0;
1690 comm
= community_str2com(community
);
1693 community_free(&comm
);
1695 lcomm
= lcommunity_str2com(community
);
1698 lcommunity_free(&lcomm
);
1701 vty_out(vty
, "Invalid community format\n");
1705 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1706 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1708 lookup_community
= bgp_ca_community_lookup(&ca
);
1709 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1712 bgp_ca_alias_delete(&ca
);
1713 bgp_ca_community_delete(&ca
);
1716 /* Lookup if community hash table has an item
1717 * with the same alias name.
1719 strlcpy(ca
.community
, lookup_alias
->community
,
1720 sizeof(ca
.community
));
1721 if (bgp_ca_community_lookup(&ca
)) {
1723 "community (%s) already has this alias (%s)\n",
1724 lookup_alias
->community
,
1725 lookup_alias
->alias
);
1728 bgp_ca_alias_delete(&ca
);
1731 if (lookup_community
) {
1732 /* Lookup if alias hash table has an item
1733 * with the same community.
1735 strlcpy(ca
.alias
, lookup_community
->alias
,
1737 if (bgp_ca_alias_lookup(&ca
)) {
1739 "alias (%s) already has this community (%s)\n",
1740 lookup_community
->alias
,
1741 lookup_community
->community
);
1744 bgp_ca_community_delete(&ca
);
1747 bgp_ca_alias_insert(&ca
);
1748 bgp_ca_community_insert(&ca
);
1754 DEFPY (bgp_global_suppress_fib_pending
,
1755 bgp_global_suppress_fib_pending_cmd
,
1756 "[no] bgp suppress-fib-pending",
1759 "Advertise only routes that are programmed in kernel to peers globally\n")
1761 bm_wait_for_fib_set(!no
);
1766 DEFPY (bgp_suppress_fib_pending
,
1767 bgp_suppress_fib_pending_cmd
,
1768 "[no] bgp suppress-fib-pending",
1771 "Advertise only routes that are programmed in kernel to peers\n")
1773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1775 bgp_suppress_fib_pending_set(bgp
, !no
);
1780 /* BGP Cluster ID. */
1781 DEFUN (bgp_cluster_id
,
1783 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1785 "Configure Route-Reflector Cluster-id\n"
1786 "Route-Reflector Cluster-id in IP address format\n"
1787 "Route-Reflector Cluster-id as 32 bit quantity\n")
1789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1792 struct in_addr cluster
;
1794 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1796 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1797 return CMD_WARNING_CONFIG_FAILED
;
1800 bgp_cluster_id_set(bgp
, &cluster
);
1801 bgp_clear_star_soft_out(vty
, bgp
->name
);
1806 DEFUN (no_bgp_cluster_id
,
1807 no_bgp_cluster_id_cmd
,
1808 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1811 "Configure Route-Reflector Cluster-id\n"
1812 "Route-Reflector Cluster-id in IP address format\n"
1813 "Route-Reflector Cluster-id as 32 bit quantity\n")
1815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1816 bgp_cluster_id_unset(bgp
);
1817 bgp_clear_star_soft_out(vty
, bgp
->name
);
1826 "Disable BGP route installation to RIB (Zebra)\n")
1828 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1830 "%% No-RIB option is already set, nothing to do here.\n");
1834 bgp_option_norib_set_runtime();
1839 DEFPY (no_bgp_norib
,
1844 "Disable BGP route installation to RIB (Zebra)\n")
1846 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1848 "%% No-RIB option is not set, nothing to do here.\n");
1852 bgp_option_norib_unset_runtime();
1857 DEFPY (no_bgp_send_extra_data
,
1858 no_bgp_send_extra_data_cmd
,
1859 "[no] bgp send-extra-data zebra",
1862 "Extra data to Zebra for display/use\n"
1866 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1868 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1873 DEFUN (bgp_confederation_identifier
,
1874 bgp_confederation_identifier_cmd
,
1875 "bgp confederation identifier (1-4294967295)",
1877 "AS confederation parameters\n"
1879 "Set routing domain confederation AS\n")
1881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1885 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1887 bgp_confederation_id_set(bgp
, as
);
1892 DEFUN (no_bgp_confederation_identifier
,
1893 no_bgp_confederation_identifier_cmd
,
1894 "no bgp confederation identifier [(1-4294967295)]",
1897 "AS confederation parameters\n"
1899 "Set routing domain confederation AS\n")
1901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1902 bgp_confederation_id_unset(bgp
);
1907 DEFUN (bgp_confederation_peers
,
1908 bgp_confederation_peers_cmd
,
1909 "bgp confederation peers (1-4294967295)...",
1911 "AS confederation parameters\n"
1912 "Peer ASs in BGP confederation\n"
1915 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1920 for (i
= idx_asn
; i
< argc
; i
++) {
1921 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1923 if (bgp
->as
== as
) {
1925 "%% Local member-AS not allowed in confed peer list\n");
1929 bgp_confederation_peers_add(bgp
, as
);
1934 DEFUN (no_bgp_confederation_peers
,
1935 no_bgp_confederation_peers_cmd
,
1936 "no bgp confederation peers (1-4294967295)...",
1939 "AS confederation parameters\n"
1940 "Peer ASs in BGP confederation\n"
1943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1948 for (i
= idx_asn
; i
< argc
; i
++) {
1949 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1951 bgp_confederation_peers_remove(bgp
, as
);
1957 * Central routine for maximum-paths configuration.
1958 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1959 * @set: 1 for setting values, 0 for removing the max-paths config.
1961 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1962 const char *mpaths
, uint16_t options
,
1965 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1966 uint16_t maxpaths
= 0;
1971 afi
= bgp_node_afi(vty
);
1972 safi
= bgp_node_safi(vty
);
1975 maxpaths
= strtol(mpaths
, NULL
, 10);
1976 if (maxpaths
> multipath_num
) {
1978 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1979 maxpaths
, multipath_num
);
1980 return CMD_WARNING_CONFIG_FAILED
;
1982 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1985 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1989 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1990 (set
== 1) ? "" : "un",
1991 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1992 maxpaths
, afi
, safi
);
1993 return CMD_WARNING_CONFIG_FAILED
;
1996 bgp_recalculate_all_bestpaths(bgp
);
2001 DEFUN (bgp_maxmed_admin
,
2002 bgp_maxmed_admin_cmd
,
2003 "bgp max-med administrative ",
2005 "Advertise routes with max-med\n"
2006 "Administratively applied, for an indefinite period\n")
2008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2010 bgp
->v_maxmed_admin
= 1;
2011 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2013 bgp_maxmed_update(bgp
);
2018 DEFUN (bgp_maxmed_admin_medv
,
2019 bgp_maxmed_admin_medv_cmd
,
2020 "bgp max-med administrative (0-4294967295)",
2022 "Advertise routes with max-med\n"
2023 "Administratively applied, for an indefinite period\n"
2024 "Max MED value to be used\n")
2026 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 bgp
->v_maxmed_admin
= 1;
2030 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2032 bgp_maxmed_update(bgp
);
2037 DEFUN (no_bgp_maxmed_admin
,
2038 no_bgp_maxmed_admin_cmd
,
2039 "no bgp max-med administrative [(0-4294967295)]",
2042 "Advertise routes with max-med\n"
2043 "Administratively applied, for an indefinite period\n"
2044 "Max MED value to be used\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2047 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2048 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2049 bgp_maxmed_update(bgp
);
2054 DEFUN (bgp_maxmed_onstartup
,
2055 bgp_maxmed_onstartup_cmd
,
2056 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2058 "Advertise routes with max-med\n"
2059 "Effective on a startup\n"
2060 "Time (seconds) period for max-med\n"
2061 "Max MED value to be used\n")
2063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2066 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2067 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2068 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2069 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2071 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2073 bgp_maxmed_update(bgp
);
2078 DEFUN (no_bgp_maxmed_onstartup
,
2079 no_bgp_maxmed_onstartup_cmd
,
2080 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2083 "Advertise routes with max-med\n"
2084 "Effective on a startup\n"
2085 "Time (seconds) period for max-med\n"
2086 "Max MED value to be used\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 /* Cancel max-med onstartup if its on */
2091 if (bgp
->t_maxmed_onstartup
) {
2092 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2093 bgp
->maxmed_onstartup_over
= 1;
2096 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2097 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2099 bgp_maxmed_update(bgp
);
2104 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2105 uint16_t update_delay
,
2106 uint16_t establish_wait
)
2108 struct listnode
*node
, *nnode
;
2110 bool vrf_cfg
= false;
2113 * See if update-delay is set per-vrf and warn user to delete it
2114 * Note that we only need to check this if this is the first time
2115 * setting the global config.
2117 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2118 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2119 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2121 "%% update-delay configuration found in vrf %s\n",
2122 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2132 "%%Failed: global update-delay config not permitted\n");
2136 if (!establish_wait
) { /* update-delay <delay> */
2137 bm
->v_update_delay
= update_delay
;
2138 bm
->v_establish_wait
= bm
->v_update_delay
;
2140 /* update-delay <delay> <establish-wait> */
2141 if (update_delay
< establish_wait
) {
2143 "%%Failed: update-delay less than the establish-wait!\n");
2144 return CMD_WARNING_CONFIG_FAILED
;
2147 bm
->v_update_delay
= update_delay
;
2148 bm
->v_establish_wait
= establish_wait
;
2151 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2152 bgp
->v_update_delay
= bm
->v_update_delay
;
2153 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2159 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2161 struct listnode
*node
, *nnode
;
2164 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2165 bm
->v_establish_wait
= bm
->v_update_delay
;
2167 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2168 bgp
->v_update_delay
= bm
->v_update_delay
;
2169 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2175 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2176 uint16_t establish_wait
)
2178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2180 /* if configured globally, per-instance config is not allowed */
2181 if (bm
->v_update_delay
) {
2183 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2184 return CMD_WARNING_CONFIG_FAILED
;
2188 if (!establish_wait
) /* update-delay <delay> */
2190 bgp
->v_update_delay
= update_delay
;
2191 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2195 /* update-delay <delay> <establish-wait> */
2196 if (update_delay
< establish_wait
) {
2198 "%%Failed: update-delay less than the establish-wait!\n");
2199 return CMD_WARNING_CONFIG_FAILED
;
2202 bgp
->v_update_delay
= update_delay
;
2203 bgp
->v_establish_wait
= establish_wait
;
2208 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2212 /* If configured globally, cannot remove from one bgp instance */
2213 if (bm
->v_update_delay
) {
2215 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2216 return CMD_WARNING_CONFIG_FAILED
;
2218 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2219 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2224 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2226 /* If configured globally, no need to display per-instance value */
2227 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2228 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2229 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2230 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2235 /* Global update-delay configuration */
2236 DEFPY (bgp_global_update_delay
,
2237 bgp_global_update_delay_cmd
,
2238 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2240 "Force initial delay for best-path and updates for all bgp instances\n"
2241 "Max delay in seconds\n"
2242 "Establish wait in seconds\n")
2244 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2247 /* Global update-delay deconfiguration */
2248 DEFPY (no_bgp_global_update_delay
,
2249 no_bgp_global_update_delay_cmd
,
2250 "no bgp update-delay [(0-3600) [(1-3600)]]",
2253 "Force initial delay for best-path and updates\n"
2254 "Max delay in seconds\n"
2255 "Establish wait in seconds\n")
2257 return bgp_global_update_delay_deconfig_vty(vty
);
2260 /* Update-delay configuration */
2262 DEFPY (bgp_update_delay
,
2263 bgp_update_delay_cmd
,
2264 "update-delay (0-3600)$delay [(1-3600)$wait]",
2265 "Force initial delay for best-path and updates\n"
2266 "Max delay in seconds\n"
2267 "Establish wait in seconds\n")
2269 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2272 /* Update-delay deconfiguration */
2273 DEFPY (no_bgp_update_delay
,
2274 no_bgp_update_delay_cmd
,
2275 "no update-delay [(0-3600) [(1-3600)]]",
2277 "Force initial delay for best-path and updates\n"
2278 "Max delay in seconds\n"
2279 "Establish wait in seconds\n")
2281 return bgp_update_delay_deconfig_vty(vty
);
2285 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2290 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2291 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2296 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2302 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2307 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2310 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2311 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2312 vty_out(vty
, " write-quanta %d\n", quanta
);
2315 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2318 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2319 if (quanta
!= BGP_READ_PACKET_MAX
)
2320 vty_out(vty
, " read-quanta %d\n", quanta
);
2323 /* Packet quanta configuration
2325 * XXX: The value set here controls the size of a stack buffer in the IO
2326 * thread. When changing these limits be careful to prevent stack overflow.
2328 * Furthermore, the maximums used here should correspond to
2329 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2331 DEFPY (bgp_wpkt_quanta
,
2332 bgp_wpkt_quanta_cmd
,
2333 "[no] write-quanta (1-64)$quanta",
2335 "How many packets to write to peer socket per run\n"
2336 "Number of packets\n")
2338 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2341 DEFPY (bgp_rpkt_quanta
,
2342 bgp_rpkt_quanta_cmd
,
2343 "[no] read-quanta (1-10)$quanta",
2345 "How many packets to read from peer socket per I/O cycle\n"
2346 "Number of packets\n")
2348 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2351 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2353 if (!bgp
->heuristic_coalesce
)
2354 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2358 DEFUN (bgp_coalesce_time
,
2359 bgp_coalesce_time_cmd
,
2360 "coalesce-time (0-4294967295)",
2361 "Subgroup coalesce timer\n"
2362 "Subgroup coalesce timer value (in ms)\n")
2364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2368 bgp
->heuristic_coalesce
= false;
2370 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2371 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2376 DEFUN (no_bgp_coalesce_time
,
2377 no_bgp_coalesce_time_cmd
,
2378 "no coalesce-time (0-4294967295)",
2380 "Subgroup coalesce timer\n"
2381 "Subgroup coalesce timer value (in ms)\n")
2383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2385 bgp
->heuristic_coalesce
= true;
2386 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2390 /* Maximum-paths configuration */
2391 DEFUN (bgp_maxpaths
,
2393 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2394 "Forward packets over multiple paths\n"
2395 "Number of paths\n")
2398 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2399 argv
[idx_number
]->arg
, 0, 1);
2402 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2403 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2404 "Forward packets over multiple paths\n"
2405 "Number of paths\n")
2407 DEFUN (bgp_maxpaths_ibgp
,
2408 bgp_maxpaths_ibgp_cmd
,
2409 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2410 "Forward packets over multiple paths\n"
2412 "Number of paths\n")
2415 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2416 argv
[idx_number
]->arg
, 0, 1);
2419 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2420 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2421 "Forward packets over multiple paths\n"
2423 "Number of paths\n")
2425 DEFUN (bgp_maxpaths_ibgp_cluster
,
2426 bgp_maxpaths_ibgp_cluster_cmd
,
2427 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2428 "Forward packets over multiple paths\n"
2431 "Match the cluster length\n")
2434 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2435 argv
[idx_number
]->arg
, true, 1);
2438 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2439 "maximum-paths ibgp " CMD_RANGE_STR(
2440 1, MULTIPATH_NUM
) " equal-cluster-length",
2441 "Forward packets over multiple paths\n"
2444 "Match the cluster length\n")
2446 DEFUN (no_bgp_maxpaths
,
2447 no_bgp_maxpaths_cmd
,
2448 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2450 "Forward packets over multiple paths\n"
2451 "Number of paths\n")
2453 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2456 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2457 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2458 "Forward packets over multiple paths\n"
2459 "Number of paths\n")
2461 DEFUN (no_bgp_maxpaths_ibgp
,
2462 no_bgp_maxpaths_ibgp_cmd
,
2463 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2465 "Forward packets over multiple paths\n"
2468 "Match the cluster length\n")
2470 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2473 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2474 "no maximum-paths ibgp [" CMD_RANGE_STR(
2475 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2477 "Forward packets over multiple paths\n"
2480 "Match the cluster length\n")
2482 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2483 afi_t afi
, safi_t safi
)
2485 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2486 vty_out(vty
, " maximum-paths %d\n",
2487 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2490 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2491 vty_out(vty
, " maximum-paths ibgp %d",
2492 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2493 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2494 vty_out(vty
, " equal-cluster-length");
2503 "timers bgp (0-65535) (0-65535)",
2504 "Adjust routing timers\n"
2506 "Keepalive interval\n"
2509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2511 int idx_number_2
= 3;
2512 unsigned long keepalive
= 0;
2513 unsigned long holdtime
= 0;
2515 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2516 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2518 /* Holdtime value check. */
2519 if (holdtime
< 3 && holdtime
!= 0) {
2521 "%% hold time value must be either 0 or greater than 3\n");
2522 return CMD_WARNING_CONFIG_FAILED
;
2525 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2526 BGP_DEFAULT_DELAYOPEN
);
2531 DEFUN (no_bgp_timers
,
2533 "no timers bgp [(0-65535) (0-65535)]",
2535 "Adjust routing timers\n"
2537 "Keepalive interval\n"
2540 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2541 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2542 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2547 /* BGP minimum holdtime. */
2549 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2550 "bgp minimum-holdtime (1-65535)",
2551 "BGP specific commands\n"
2552 "BGP minimum holdtime\n"
2555 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2557 unsigned long min_holdtime
;
2559 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2561 bgp
->default_min_holdtime
= min_holdtime
;
2566 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2567 "no bgp minimum-holdtime [(1-65535)]",
2569 "BGP specific commands\n"
2570 "BGP minimum holdtime\n"
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 bgp
->default_min_holdtime
= 0;
2580 DEFUN (bgp_client_to_client_reflection
,
2581 bgp_client_to_client_reflection_cmd
,
2582 "bgp client-to-client reflection",
2584 "Configure client to client route reflection\n"
2585 "reflection of routes allowed\n")
2587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2588 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2589 bgp_clear_star_soft_out(vty
, bgp
->name
);
2594 DEFUN (no_bgp_client_to_client_reflection
,
2595 no_bgp_client_to_client_reflection_cmd
,
2596 "no bgp client-to-client reflection",
2599 "Configure client to client route reflection\n"
2600 "reflection of routes allowed\n")
2602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2603 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2604 bgp_clear_star_soft_out(vty
, bgp
->name
);
2609 /* "bgp always-compare-med" configuration. */
2610 DEFUN (bgp_always_compare_med
,
2611 bgp_always_compare_med_cmd
,
2612 "bgp always-compare-med",
2614 "Allow comparing MED from different neighbors\n")
2616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2617 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2618 bgp_recalculate_all_bestpaths(bgp
);
2623 DEFUN (no_bgp_always_compare_med
,
2624 no_bgp_always_compare_med_cmd
,
2625 "no bgp always-compare-med",
2628 "Allow comparing MED from different neighbors\n")
2630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2631 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2632 bgp_recalculate_all_bestpaths(bgp
);
2638 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2639 "bgp ebgp-requires-policy",
2641 "Require in and out policy for eBGP peers (RFC8212)\n")
2643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2644 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2648 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2649 "no bgp ebgp-requires-policy",
2652 "Require in and out policy for eBGP peers (RFC8212)\n")
2654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2655 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2659 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2660 "bgp suppress-duplicates",
2662 "Suppress duplicate updates if the route actually not changed\n")
2664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2665 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2669 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2670 "no bgp suppress-duplicates",
2673 "Suppress duplicate updates if the route actually not changed\n")
2675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2676 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2680 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2681 "bgp reject-as-sets",
2683 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2685 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2686 struct listnode
*node
, *nnode
;
2689 bgp
->reject_as_sets
= true;
2691 /* Reset existing BGP sessions to reject routes
2692 * with aspath containing AS_SET or AS_CONFED_SET.
2694 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2695 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2696 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2697 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2698 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2705 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2706 "no bgp reject-as-sets",
2709 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2712 struct listnode
*node
, *nnode
;
2715 bgp
->reject_as_sets
= false;
2717 /* Reset existing BGP sessions to reject routes
2718 * with aspath containing AS_SET or AS_CONFED_SET.
2720 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2721 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2722 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2723 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2724 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2731 /* "bgp deterministic-med" configuration. */
2732 DEFUN (bgp_deterministic_med
,
2733 bgp_deterministic_med_cmd
,
2734 "bgp deterministic-med",
2736 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2738 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2740 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2741 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2742 bgp_recalculate_all_bestpaths(bgp
);
2748 DEFUN (no_bgp_deterministic_med
,
2749 no_bgp_deterministic_med_cmd
,
2750 "no bgp deterministic-med",
2753 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2756 int bestpath_per_as_used
;
2760 struct listnode
*node
, *nnode
;
2762 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2763 bestpath_per_as_used
= 0;
2765 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2766 FOREACH_AFI_SAFI (afi
, safi
)
2767 if (bgp_addpath_dmed_required(
2768 peer
->addpath_type
[afi
][safi
])) {
2769 bestpath_per_as_used
= 1;
2773 if (bestpath_per_as_used
)
2777 if (bestpath_per_as_used
) {
2779 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2780 return CMD_WARNING_CONFIG_FAILED
;
2782 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2783 bgp_recalculate_all_bestpaths(bgp
);
2790 /* "bgp graceful-restart mode" configuration. */
2791 DEFUN (bgp_graceful_restart
,
2792 bgp_graceful_restart_cmd
,
2793 "bgp graceful-restart",
2798 int ret
= BGP_GR_FAILURE
;
2800 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2801 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2805 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2807 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2810 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2811 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2813 "Graceful restart configuration changed, reset all peers to take effect\n");
2814 return bgp_vty_return(vty
, ret
);
2817 DEFUN (no_bgp_graceful_restart
,
2818 no_bgp_graceful_restart_cmd
,
2819 "no bgp graceful-restart",
2825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2827 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2828 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2830 int ret
= BGP_GR_FAILURE
;
2832 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2834 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2837 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2838 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2840 "Graceful restart configuration changed, reset all peers to take effect\n");
2842 return bgp_vty_return(vty
, ret
);
2845 DEFUN (bgp_graceful_restart_stalepath_time
,
2846 bgp_graceful_restart_stalepath_time_cmd
,
2847 "bgp graceful-restart stalepath-time (1-4095)",
2849 "Graceful restart capability parameters\n"
2850 "Set the max time to hold onto restarting peer's stale paths\n"
2851 "Delay value (seconds)\n")
2853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2857 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2858 bgp
->stalepath_time
= stalepath
;
2862 DEFUN (bgp_graceful_restart_restart_time
,
2863 bgp_graceful_restart_restart_time_cmd
,
2864 "bgp graceful-restart restart-time (0-4095)",
2866 "Graceful restart capability parameters\n"
2867 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2868 "Delay value (seconds)\n")
2870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2874 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2875 bgp
->restart_time
= restart
;
2879 DEFUN (bgp_graceful_restart_select_defer_time
,
2880 bgp_graceful_restart_select_defer_time_cmd
,
2881 "bgp graceful-restart select-defer-time (0-3600)",
2883 "Graceful restart capability parameters\n"
2884 "Set the time to defer the BGP route selection after restart\n"
2885 "Delay value (seconds, 0 - disable)\n")
2887 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2889 uint32_t defer_time
;
2891 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2892 bgp
->select_defer_time
= defer_time
;
2893 if (defer_time
== 0)
2894 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2896 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2901 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2902 no_bgp_graceful_restart_stalepath_time_cmd
,
2903 "no bgp graceful-restart stalepath-time [(1-4095)]",
2906 "Graceful restart capability parameters\n"
2907 "Set the max time to hold onto restarting peer's stale paths\n"
2908 "Delay value (seconds)\n")
2910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2912 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2916 DEFUN (no_bgp_graceful_restart_restart_time
,
2917 no_bgp_graceful_restart_restart_time_cmd
,
2918 "no bgp graceful-restart restart-time [(0-4095)]",
2921 "Graceful restart capability parameters\n"
2922 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2923 "Delay value (seconds)\n")
2925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2927 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2931 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2932 no_bgp_graceful_restart_select_defer_time_cmd
,
2933 "no bgp graceful-restart select-defer-time [(0-3600)]",
2936 "Graceful restart capability parameters\n"
2937 "Set the time to defer the BGP route selection after restart\n"
2938 "Delay value (seconds)\n")
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2942 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2943 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2948 DEFUN (bgp_graceful_restart_preserve_fw
,
2949 bgp_graceful_restart_preserve_fw_cmd
,
2950 "bgp graceful-restart preserve-fw-state",
2952 "Graceful restart capability parameters\n"
2953 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2956 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2960 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2961 no_bgp_graceful_restart_preserve_fw_cmd
,
2962 "no bgp graceful-restart preserve-fw-state",
2965 "Graceful restart capability parameters\n"
2966 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2969 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2973 DEFPY (bgp_graceful_restart_notification
,
2974 bgp_graceful_restart_notification_cmd
,
2975 "[no$no] bgp graceful-restart notification",
2978 "Graceful restart capability parameters\n"
2979 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
2981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2984 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2986 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
2991 DEFPY (bgp_administrative_reset
,
2992 bgp_administrative_reset_cmd
,
2993 "[no$no] bgp hard-administrative-reset",
2996 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
2998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3001 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3003 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3008 DEFUN (bgp_graceful_restart_disable
,
3009 bgp_graceful_restart_disable_cmd
,
3010 "bgp graceful-restart-disable",
3014 int ret
= BGP_GR_FAILURE
;
3016 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3018 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3022 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3024 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3027 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3029 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3031 "Graceful restart configuration changed, reset all peers to take effect\n");
3033 return bgp_vty_return(vty
, ret
);
3036 DEFUN (no_bgp_graceful_restart_disable
,
3037 no_bgp_graceful_restart_disable_cmd
,
3038 "no bgp graceful-restart-disable",
3044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3046 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3048 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3050 int ret
= BGP_GR_FAILURE
;
3052 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3054 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3057 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3059 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3061 "Graceful restart configuration changed, reset all peers to take effect\n");
3063 return bgp_vty_return(vty
, ret
);
3066 DEFUN (bgp_neighbor_graceful_restart_set
,
3067 bgp_neighbor_graceful_restart_set_cmd
,
3068 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3076 int ret
= BGP_GR_FAILURE
;
3078 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3080 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3082 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3084 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3086 return CMD_WARNING_CONFIG_FAILED
;
3088 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3090 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3091 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3093 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3095 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3097 "Graceful restart configuration changed, reset this peer to take effect\n");
3099 return bgp_vty_return(vty
, ret
);
3102 DEFUN (no_bgp_neighbor_graceful_restart
,
3103 no_bgp_neighbor_graceful_restart_set_cmd
,
3104 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3112 int ret
= BGP_GR_FAILURE
;
3115 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3117 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3119 return CMD_WARNING_CONFIG_FAILED
;
3121 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3123 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3125 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3127 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3128 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3130 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3132 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3134 "Graceful restart configuration changed, reset this peer to take effect\n");
3136 return bgp_vty_return(vty
, ret
);
3139 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3140 bgp_neighbor_graceful_restart_helper_set_cmd
,
3141 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3144 GR_NEIGHBOR_HELPER_CMD
3149 int ret
= BGP_GR_FAILURE
;
3151 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3153 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3155 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3157 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3160 return CMD_WARNING_CONFIG_FAILED
;
3163 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3165 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3166 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3168 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3170 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3172 "Graceful restart configuration changed, reset this peer to take effect\n");
3174 return bgp_vty_return(vty
, ret
);
3177 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3178 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3179 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3183 NO_GR_NEIGHBOR_HELPER_CMD
3187 int ret
= BGP_GR_FAILURE
;
3190 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3192 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3194 return CMD_WARNING_CONFIG_FAILED
;
3196 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3198 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3200 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3202 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3203 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3205 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3207 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3209 "Graceful restart configuration changed, reset this peer to take effect\n");
3211 return bgp_vty_return(vty
, ret
);
3214 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3215 bgp_neighbor_graceful_restart_disable_set_cmd
,
3216 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3219 GR_NEIGHBOR_DISABLE_CMD
3224 int ret
= BGP_GR_FAILURE
;
3226 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3228 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3230 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3232 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3234 return CMD_WARNING_CONFIG_FAILED
;
3236 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3238 if (peer
->bgp
->t_startup
)
3239 bgp_peer_gr_flags_update(peer
);
3241 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3242 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3244 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3246 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3248 "Graceful restart configuration changed, reset this peer to take effect\n");
3250 return bgp_vty_return(vty
, ret
);
3253 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3254 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3255 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3259 NO_GR_NEIGHBOR_DISABLE_CMD
3263 int ret
= BGP_GR_FAILURE
;
3266 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3268 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3270 return CMD_WARNING_CONFIG_FAILED
;
3272 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3274 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3276 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3278 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3279 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3281 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3283 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3285 "Graceful restart configuration changed, reset this peer to take effect\n");
3287 return bgp_vty_return(vty
, ret
);
3290 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3291 bgp_graceful_restart_disable_eor_cmd
,
3292 "bgp graceful-restart disable-eor",
3294 "Graceful restart configuration parameters\n"
3295 "Disable EOR Check\n")
3297 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3298 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3303 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3304 no_bgp_graceful_restart_disable_eor_cmd
,
3305 "no bgp graceful-restart disable-eor",
3308 "Graceful restart configuration parameters\n"
3309 "Disable EOR Check\n")
3311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3312 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3317 DEFUN (bgp_graceful_restart_rib_stale_time
,
3318 bgp_graceful_restart_rib_stale_time_cmd
,
3319 "bgp graceful-restart rib-stale-time (1-3600)",
3321 "Graceful restart configuration parameters\n"
3322 "Specify the stale route removal timer in rib\n"
3323 "Delay value (seconds)\n")
3325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3327 uint32_t stale_time
;
3329 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3330 bgp
->rib_stale_time
= stale_time
;
3331 /* Send the stale timer update message to RIB */
3332 if (bgp_zebra_stale_timer_update(bgp
))
3338 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3339 no_bgp_graceful_restart_rib_stale_time_cmd
,
3340 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3343 "Graceful restart configuration parameters\n"
3344 "Specify the stale route removal timer in rib\n"
3345 "Delay value (seconds)\n")
3347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3349 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3350 /* Send the stale timer update message to RIB */
3351 if (bgp_zebra_stale_timer_update(bgp
))
3357 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3358 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3360 "Enable Long-lived Graceful Restart\n"
3361 "Specifies maximum time to wait before purging long-lived stale routes\n"
3362 "Stale time value (seconds)\n")
3364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3366 uint32_t llgr_stale_time
;
3368 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3369 bgp
->llgr_stale_time
= llgr_stale_time
;
3374 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3375 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3377 "Enable Long-lived Graceful Restart\n"
3378 "Specifies maximum time to wait before purging long-lived stale routes\n"
3379 "Stale time value (seconds)\n")
3381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3383 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3388 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3391 bgp_static_redo_import_check(bgp
);
3392 bgp_redistribute_redo(bgp
);
3393 bgp_clear_star_soft_out(vty
, bgp
->name
);
3394 bgp_clear_star_soft_in(vty
, bgp
->name
);
3397 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3399 struct listnode
*node
, *nnode
;
3401 bool vrf_cfg
= false;
3403 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3406 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3407 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3408 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3410 "%% graceful-shutdown configuration found in vrf %s\n",
3411 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3412 VRF_DEFAULT_NAME
: bgp
->name
);
3419 "%%Failed: global graceful-shutdown not permitted\n");
3423 /* Set flag globally */
3424 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3426 /* Initiate processing for all BGP instances. */
3427 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3428 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3433 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3435 struct listnode
*node
, *nnode
;
3438 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3441 /* Unset flag globally */
3442 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3444 /* Initiate processing for all BGP instances. */
3445 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3446 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3451 /* "bgp graceful-shutdown" configuration */
3452 DEFUN (bgp_graceful_shutdown
,
3453 bgp_graceful_shutdown_cmd
,
3454 "bgp graceful-shutdown",
3456 "Graceful shutdown parameters\n")
3458 if (vty
->node
== CONFIG_NODE
)
3459 return bgp_global_graceful_shutdown_config_vty(vty
);
3461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3463 /* if configured globally, per-instance config is not allowed */
3464 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3466 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3467 return CMD_WARNING_CONFIG_FAILED
;
3470 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3471 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3472 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3478 DEFUN (no_bgp_graceful_shutdown
,
3479 no_bgp_graceful_shutdown_cmd
,
3480 "no bgp graceful-shutdown",
3483 "Graceful shutdown parameters\n")
3485 if (vty
->node
== CONFIG_NODE
)
3486 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3490 /* If configured globally, cannot remove from one bgp instance */
3491 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3493 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3494 return CMD_WARNING_CONFIG_FAILED
;
3497 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3498 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3499 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3505 /* "bgp fast-external-failover" configuration. */
3506 DEFUN (bgp_fast_external_failover
,
3507 bgp_fast_external_failover_cmd
,
3508 "bgp fast-external-failover",
3510 "Immediately reset session if a link to a directly connected external peer goes down\n")
3512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3513 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3517 DEFUN (no_bgp_fast_external_failover
,
3518 no_bgp_fast_external_failover_cmd
,
3519 "no bgp fast-external-failover",
3522 "Immediately reset session if a link to a directly connected external peer goes down\n")
3524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3525 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3529 /* "bgp bestpath compare-routerid" configuration. */
3530 DEFUN (bgp_bestpath_compare_router_id
,
3531 bgp_bestpath_compare_router_id_cmd
,
3532 "bgp bestpath compare-routerid",
3534 "Change the default bestpath selection\n"
3535 "Compare router-id for identical EBGP paths\n")
3537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3538 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3539 bgp_recalculate_all_bestpaths(bgp
);
3544 DEFUN (no_bgp_bestpath_compare_router_id
,
3545 no_bgp_bestpath_compare_router_id_cmd
,
3546 "no bgp bestpath compare-routerid",
3549 "Change the default bestpath selection\n"
3550 "Compare router-id for identical EBGP paths\n")
3552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3553 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3554 bgp_recalculate_all_bestpaths(bgp
);
3559 /* "bgp bestpath as-path ignore" configuration. */
3560 DEFUN (bgp_bestpath_aspath_ignore
,
3561 bgp_bestpath_aspath_ignore_cmd
,
3562 "bgp bestpath as-path ignore",
3564 "Change the default bestpath selection\n"
3565 "AS-path attribute\n"
3566 "Ignore as-path length in selecting a route\n")
3568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3569 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3570 bgp_recalculate_all_bestpaths(bgp
);
3575 DEFUN (no_bgp_bestpath_aspath_ignore
,
3576 no_bgp_bestpath_aspath_ignore_cmd
,
3577 "no bgp bestpath as-path ignore",
3580 "Change the default bestpath selection\n"
3581 "AS-path attribute\n"
3582 "Ignore as-path length in selecting a route\n")
3584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3585 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3586 bgp_recalculate_all_bestpaths(bgp
);
3591 /* "bgp bestpath as-path confed" configuration. */
3592 DEFUN (bgp_bestpath_aspath_confed
,
3593 bgp_bestpath_aspath_confed_cmd
,
3594 "bgp bestpath as-path confed",
3596 "Change the default bestpath selection\n"
3597 "AS-path attribute\n"
3598 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3601 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3602 bgp_recalculate_all_bestpaths(bgp
);
3607 DEFUN (no_bgp_bestpath_aspath_confed
,
3608 no_bgp_bestpath_aspath_confed_cmd
,
3609 "no bgp bestpath as-path confed",
3612 "Change the default bestpath selection\n"
3613 "AS-path attribute\n"
3614 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3617 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3618 bgp_recalculate_all_bestpaths(bgp
);
3623 /* "bgp bestpath as-path multipath-relax" configuration. */
3624 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3625 bgp_bestpath_aspath_multipath_relax_cmd
,
3626 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3628 "Change the default bestpath selection\n"
3629 "AS-path attribute\n"
3630 "Allow load sharing across routes that have different AS paths (but same length)\n"
3631 "Generate an AS_SET\n"
3632 "Do not generate an AS_SET\n")
3634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3636 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3638 /* no-as-set is now the default behavior so we can silently
3640 if (argv_find(argv
, argc
, "as-set", &idx
))
3641 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3643 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3645 bgp_recalculate_all_bestpaths(bgp
);
3650 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3651 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3652 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3655 "Change the default bestpath selection\n"
3656 "AS-path attribute\n"
3657 "Allow load sharing across routes that have different AS paths (but same length)\n"
3658 "Generate an AS_SET\n"
3659 "Do not generate an AS_SET\n")
3661 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3662 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3663 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3664 bgp_recalculate_all_bestpaths(bgp
);
3669 /* "bgp bestpath peer-type multipath-relax" configuration. */
3670 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3671 bgp_bestpath_peer_type_multipath_relax_cmd
,
3672 "bgp bestpath peer-type multipath-relax",
3674 "Change the default bestpath selection\n"
3676 "Allow load sharing across routes learned from different peer types\n")
3678 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3679 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3680 bgp_recalculate_all_bestpaths(bgp
);
3685 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3686 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3687 "no bgp bestpath peer-type multipath-relax",
3689 "Change the default bestpath selection\n"
3691 "Allow load sharing across routes learned from different peer types\n")
3693 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3694 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3695 bgp_recalculate_all_bestpaths(bgp
);
3700 /* "bgp log-neighbor-changes" configuration. */
3701 DEFUN (bgp_log_neighbor_changes
,
3702 bgp_log_neighbor_changes_cmd
,
3703 "bgp log-neighbor-changes",
3705 "Log neighbor up/down and reset reason\n")
3707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3708 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3712 DEFUN (no_bgp_log_neighbor_changes
,
3713 no_bgp_log_neighbor_changes_cmd
,
3714 "no bgp log-neighbor-changes",
3717 "Log neighbor up/down and reset reason\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3724 /* "bgp bestpath med" configuration. */
3725 DEFUN (bgp_bestpath_med
,
3726 bgp_bestpath_med_cmd
,
3727 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3729 "Change the default bestpath selection\n"
3731 "Compare MED among confederation paths\n"
3732 "Treat missing MED as the least preferred one\n"
3733 "Treat missing MED as the least preferred one\n"
3734 "Compare MED among confederation paths\n")
3736 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3739 if (argv_find(argv
, argc
, "confed", &idx
))
3740 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3742 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3743 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3745 bgp_recalculate_all_bestpaths(bgp
);
3750 DEFUN (no_bgp_bestpath_med
,
3751 no_bgp_bestpath_med_cmd
,
3752 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3755 "Change the default bestpath selection\n"
3757 "Compare MED among confederation paths\n"
3758 "Treat missing MED as the least preferred one\n"
3759 "Treat missing MED as the least preferred one\n"
3760 "Compare MED among confederation paths\n")
3762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3765 if (argv_find(argv
, argc
, "confed", &idx
))
3766 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3768 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3769 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3771 bgp_recalculate_all_bestpaths(bgp
);
3776 /* "bgp bestpath bandwidth" configuration. */
3777 DEFPY (bgp_bestpath_bw
,
3778 bgp_bestpath_bw_cmd
,
3779 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3781 "Change the default bestpath selection\n"
3782 "Link Bandwidth attribute\n"
3783 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3784 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3785 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3792 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3793 return CMD_ERR_INCOMPLETE
;
3795 if (!strcmp(bw_cfg
, "ignore"))
3796 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3797 else if (!strcmp(bw_cfg
, "skip-missing"))
3798 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3799 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3800 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3802 return CMD_ERR_NO_MATCH
;
3804 /* This config is used in route install, so redo that. */
3805 FOREACH_AFI_SAFI (afi
, safi
) {
3806 if (!bgp_fibupd_safi(safi
))
3808 bgp_zebra_announce_table(bgp
, afi
, safi
);
3814 DEFPY (no_bgp_bestpath_bw
,
3815 no_bgp_bestpath_bw_cmd
,
3816 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3819 "Change the default bestpath selection\n"
3820 "Link Bandwidth attribute\n"
3821 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3822 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3823 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3829 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3831 /* This config is used in route install, so redo that. */
3832 FOREACH_AFI_SAFI (afi
, safi
) {
3833 if (!bgp_fibupd_safi(safi
))
3835 bgp_zebra_announce_table(bgp
, afi
, safi
);
3840 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3841 "[no] bgp default <ipv4-unicast|"
3844 "ipv4-labeled-unicast|"
3849 "ipv6-labeled-unicast|"
3851 "l2vpn-evpn>$afi_safi",
3854 "Configure BGP defaults\n"
3855 "Activate ipv4-unicast for a peer by default\n"
3856 "Activate ipv4-multicast for a peer by default\n"
3857 "Activate ipv4-vpn for a peer by default\n"
3858 "Activate ipv4-labeled-unicast for a peer by default\n"
3859 "Activate ipv4-flowspec for a peer by default\n"
3860 "Activate ipv6-unicast for a peer by default\n"
3861 "Activate ipv6-multicast for a peer by default\n"
3862 "Activate ipv6-vpn for a peer by default\n"
3863 "Activate ipv6-labeled-unicast for a peer by default\n"
3864 "Activate ipv6-flowspec for a peer by default\n"
3865 "Activate l2vpn-evpn for a peer by default\n")
3867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3868 char afi_safi_str
[strlen(afi_safi
) + 1];
3869 char *afi_safi_str_tok
;
3871 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3872 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3873 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3874 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3878 * Impossible situation but making coverity happy
3880 assert(afi
!= AFI_MAX
);
3882 if (strmatch(safi_str
, "labeled"))
3883 safi
= bgp_vty_safi_from_str("labeled-unicast");
3885 safi
= bgp_vty_safi_from_str(safi_str
);
3887 assert(safi
!= SAFI_MAX
);
3889 bgp
->default_af
[afi
][safi
] = false;
3891 if ((safi
== SAFI_LABELED_UNICAST
3892 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3893 || (safi
== SAFI_UNICAST
3894 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3895 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3897 bgp
->default_af
[afi
][safi
] = true;
3903 /* Display hostname in certain command outputs */
3904 DEFUN (bgp_default_show_hostname
,
3905 bgp_default_show_hostname_cmd
,
3906 "bgp default show-hostname",
3908 "Configure BGP defaults\n"
3909 "Show hostname in certain command outputs\n")
3911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3912 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3916 DEFUN (no_bgp_default_show_hostname
,
3917 no_bgp_default_show_hostname_cmd
,
3918 "no bgp default show-hostname",
3921 "Configure BGP defaults\n"
3922 "Show hostname in certain command outputs\n")
3924 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3925 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3929 /* Display hostname in certain command outputs */
3930 DEFUN (bgp_default_show_nexthop_hostname
,
3931 bgp_default_show_nexthop_hostname_cmd
,
3932 "bgp default show-nexthop-hostname",
3934 "Configure BGP defaults\n"
3935 "Show hostname for nexthop in certain command outputs\n")
3937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3938 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3942 DEFUN (no_bgp_default_show_nexthop_hostname
,
3943 no_bgp_default_show_nexthop_hostname_cmd
,
3944 "no bgp default show-nexthop-hostname",
3947 "Configure BGP defaults\n"
3948 "Show hostname for nexthop in certain command outputs\n")
3950 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3951 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3955 /* "bgp network import-check" configuration. */
3956 DEFUN (bgp_network_import_check
,
3957 bgp_network_import_check_cmd
,
3958 "bgp network import-check",
3960 "BGP network command\n"
3961 "Check BGP network route exists in IGP\n")
3963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3964 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3965 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3966 bgp_static_redo_import_check(bgp
);
3972 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3973 "bgp network import-check exact",
3975 "BGP network command\n"
3976 "Check BGP network route exists in IGP\n"
3977 "Match route precisely\n")
3979 DEFUN (no_bgp_network_import_check
,
3980 no_bgp_network_import_check_cmd
,
3981 "no bgp network import-check",
3984 "BGP network command\n"
3985 "Check BGP network route exists in IGP\n")
3987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3988 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3989 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3990 bgp_static_redo_import_check(bgp
);
3996 DEFUN (bgp_default_local_preference
,
3997 bgp_default_local_preference_cmd
,
3998 "bgp default local-preference (0-4294967295)",
4000 "Configure BGP defaults\n"
4001 "local preference (higher=more preferred)\n"
4002 "Configure default local preference value\n")
4004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4006 uint32_t local_pref
;
4008 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4010 bgp_default_local_preference_set(bgp
, local_pref
);
4011 bgp_clear_star_soft_in(vty
, bgp
->name
);
4016 DEFUN (no_bgp_default_local_preference
,
4017 no_bgp_default_local_preference_cmd
,
4018 "no bgp default local-preference [(0-4294967295)]",
4021 "Configure BGP defaults\n"
4022 "local preference (higher=more preferred)\n"
4023 "Configure default local preference value\n")
4025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4026 bgp_default_local_preference_unset(bgp
);
4027 bgp_clear_star_soft_in(vty
, bgp
->name
);
4033 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4034 bgp_default_subgroup_pkt_queue_max_cmd
,
4035 "bgp default subgroup-pkt-queue-max (20-100)",
4037 "Configure BGP defaults\n"
4038 "subgroup-pkt-queue-max\n"
4039 "Configure subgroup packet queue max\n")
4041 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4045 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4047 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4052 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4053 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4054 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4057 "Configure BGP defaults\n"
4058 "subgroup-pkt-queue-max\n"
4059 "Configure subgroup packet queue max\n")
4061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4062 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4067 DEFUN (bgp_rr_allow_outbound_policy
,
4068 bgp_rr_allow_outbound_policy_cmd
,
4069 "bgp route-reflector allow-outbound-policy",
4071 "Allow modifications made by out route-map\n"
4072 "on ibgp neighbors\n")
4074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4076 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4077 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4078 update_group_announce_rrclients(bgp
);
4079 bgp_clear_star_soft_out(vty
, bgp
->name
);
4085 DEFUN (no_bgp_rr_allow_outbound_policy
,
4086 no_bgp_rr_allow_outbound_policy_cmd
,
4087 "no bgp route-reflector allow-outbound-policy",
4090 "Allow modifications made by out route-map\n"
4091 "on ibgp neighbors\n")
4093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4095 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4096 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4097 update_group_announce_rrclients(bgp
);
4098 bgp_clear_star_soft_out(vty
, bgp
->name
);
4104 DEFUN (bgp_listen_limit
,
4105 bgp_listen_limit_cmd
,
4106 "bgp listen limit (1-65535)",
4108 "BGP Dynamic Neighbors listen commands\n"
4109 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4110 "Configure Dynamic Neighbors listen limit value\n")
4112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4116 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4118 bgp_listen_limit_set(bgp
, listen_limit
);
4123 DEFUN (no_bgp_listen_limit
,
4124 no_bgp_listen_limit_cmd
,
4125 "no bgp listen limit [(1-65535)]",
4128 "BGP Dynamic Neighbors listen commands\n"
4129 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4130 "Configure Dynamic Neighbors listen limit value\n")
4132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4133 bgp_listen_limit_unset(bgp
);
4139 * Check if this listen range is already configured. Check for exact
4140 * match or overlap based on input.
4142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4143 struct prefix
*range
, int exact
)
4145 struct listnode
*node
, *nnode
;
4146 struct listnode
*node1
, *nnode1
;
4147 struct peer_group
*group
;
4152 afi
= family2afi(range
->family
);
4153 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4154 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4157 match
= prefix_same(range
, lr
);
4159 match
= (prefix_match(range
, lr
)
4160 || prefix_match(lr
, range
));
4169 DEFUN (bgp_listen_range
,
4170 bgp_listen_range_cmd
,
4171 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4173 "Configure BGP dynamic neighbors listen range\n"
4174 "Configure BGP dynamic neighbors listen range\n"
4176 "Member of the peer-group\n"
4177 "Peer-group name\n")
4179 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4180 struct prefix range
;
4181 struct peer_group
*group
, *existing_group
;
4186 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4187 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4188 char *prefix
= argv
[idx
]->arg
;
4189 argv_find(argv
, argc
, "PGNAME", &idx
);
4190 char *peergroup
= argv
[idx
]->arg
;
4192 /* Convert IP prefix string to struct prefix. */
4193 ret
= str2prefix(prefix
, &range
);
4195 vty_out(vty
, "%% Malformed listen range\n");
4196 return CMD_WARNING_CONFIG_FAILED
;
4199 afi
= family2afi(range
.family
);
4201 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4203 "%% Malformed listen range (link-local address)\n");
4204 return CMD_WARNING_CONFIG_FAILED
;
4209 /* Check if same listen range is already configured. */
4210 existing_group
= listen_range_exists(bgp
, &range
, 1);
4211 if (existing_group
) {
4212 if (strcmp(existing_group
->name
, peergroup
) == 0)
4216 "%% Same listen range is attached to peer-group %s\n",
4217 existing_group
->name
);
4218 return CMD_WARNING_CONFIG_FAILED
;
4222 /* Check if an overlapping listen range exists. */
4223 if (listen_range_exists(bgp
, &range
, 0)) {
4225 "%% Listen range overlaps with existing listen range\n");
4226 return CMD_WARNING_CONFIG_FAILED
;
4229 group
= peer_group_lookup(bgp
, peergroup
);
4231 vty_out(vty
, "%% Configure the peer-group first\n");
4232 return CMD_WARNING_CONFIG_FAILED
;
4235 ret
= peer_group_listen_range_add(group
, &range
);
4236 return bgp_vty_return(vty
, ret
);
4239 DEFUN (no_bgp_listen_range
,
4240 no_bgp_listen_range_cmd
,
4241 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4244 "Unconfigure BGP dynamic neighbors listen range\n"
4245 "Unconfigure BGP dynamic neighbors listen range\n"
4247 "Member of the peer-group\n"
4248 "Peer-group name\n")
4250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4251 struct prefix range
;
4252 struct peer_group
*group
;
4257 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4258 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4259 char *prefix
= argv
[idx
]->arg
;
4260 argv_find(argv
, argc
, "PGNAME", &idx
);
4261 char *peergroup
= argv
[idx
]->arg
;
4263 /* Convert IP prefix string to struct prefix. */
4264 ret
= str2prefix(prefix
, &range
);
4266 vty_out(vty
, "%% Malformed listen range\n");
4267 return CMD_WARNING_CONFIG_FAILED
;
4270 afi
= family2afi(range
.family
);
4272 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4274 "%% Malformed listen range (link-local address)\n");
4275 return CMD_WARNING_CONFIG_FAILED
;
4280 group
= peer_group_lookup(bgp
, peergroup
);
4282 vty_out(vty
, "%% Peer-group does not exist\n");
4283 return CMD_WARNING_CONFIG_FAILED
;
4286 ret
= peer_group_listen_range_del(group
, &range
);
4287 return bgp_vty_return(vty
, ret
);
4290 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4292 struct peer_group
*group
;
4293 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4294 struct prefix
*range
;
4297 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4298 vty_out(vty
, " bgp listen limit %d\n",
4299 bgp
->dynamic_neighbors_limit
);
4301 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4302 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4303 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4306 " bgp listen range %pFX peer-group %s\n",
4307 range
, group
->name
);
4314 DEFUN (bgp_disable_connected_route_check
,
4315 bgp_disable_connected_route_check_cmd
,
4316 "bgp disable-ebgp-connected-route-check",
4318 "Disable checking if nexthop is connected on ebgp sessions\n")
4320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4321 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4322 bgp_clear_star_soft_in(vty
, bgp
->name
);
4327 DEFUN (no_bgp_disable_connected_route_check
,
4328 no_bgp_disable_connected_route_check_cmd
,
4329 "no bgp disable-ebgp-connected-route-check",
4332 "Disable checking if nexthop is connected on ebgp sessions\n")
4334 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4335 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4336 bgp_clear_star_soft_in(vty
, bgp
->name
);
4342 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4348 int as_type
= AS_SPECIFIED
;
4351 if (as_str
[0] == 'i') {
4353 as_type
= AS_INTERNAL
;
4354 } else if (as_str
[0] == 'e') {
4356 as_type
= AS_EXTERNAL
;
4358 /* Get AS number. */
4359 as
= strtoul(as_str
, NULL
, 10);
4362 /* If peer is peer group or interface peer, call proper function. */
4363 ret
= str2sockunion(peer_str
, &su
);
4367 /* Check if existing interface peer */
4368 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4370 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4372 /* if not interface peer, check peer-group settings */
4373 if (ret
< 0 && !peer
) {
4374 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4377 "%% Create the peer-group or interface first\n");
4378 return CMD_WARNING_CONFIG_FAILED
;
4383 if (peer_address_self_check(bgp
, &su
)) {
4385 "%% Can not configure the local system as neighbor\n");
4386 return CMD_WARNING_CONFIG_FAILED
;
4388 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4391 return bgp_vty_return(vty
, ret
);
4394 DEFUN (bgp_default_shutdown
,
4395 bgp_default_shutdown_cmd
,
4396 "[no] bgp default shutdown",
4399 "Configure BGP defaults\n"
4400 "Apply administrative shutdown to newly configured peers\n")
4402 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4403 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4407 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4409 "Administrative shutdown of the BGP instance\n"
4410 "Add a shutdown message (RFC 8203)\n"
4411 "Shutdown message\n")
4413 char *msgstr
= NULL
;
4415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4418 msgstr
= argv_concat(argv
, argc
, 3);
4420 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4421 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4422 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4423 return CMD_WARNING_CONFIG_FAILED
;
4426 bgp_shutdown_enable(bgp
, msgstr
);
4427 XFREE(MTYPE_TMP
, msgstr
);
4432 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4433 BGP_STR
"Administrative shutdown of the BGP instance\n")
4435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4437 bgp_shutdown_enable(bgp
, NULL
);
4442 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4443 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4447 bgp_shutdown_disable(bgp
);
4452 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4453 "no bgp shutdown message MSG...", NO_STR BGP_STR
4454 "Administrative shutdown of the BGP instance\n"
4455 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4457 DEFUN (neighbor_remote_as
,
4458 neighbor_remote_as_cmd
,
4459 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4462 "Specify a BGP neighbor\n"
4464 "Internal BGP peer\n"
4465 "External BGP peer\n")
4468 int idx_remote_as
= 3;
4469 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4470 argv
[idx_remote_as
]->arg
);
4473 DEFPY (bgp_allow_martian
,
4474 bgp_allow_martian_cmd
,
4475 "[no]$no bgp allow-martian-nexthop",
4478 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4483 bgp
->allow_martian
= false;
4485 bgp
->allow_martian
= true;
4490 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4491 * sessions do not wait for hold timer expiry to bring down the sessions
4492 * when nexthop becomes unreachable
4494 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4495 BGP_STR
"Fast convergence for bgp sessions\n")
4497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4498 bgp
->fast_convergence
= true;
4503 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4504 "no bgp fast-convergence",
4505 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4508 bgp
->fast_convergence
= false;
4513 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4515 const char *peer_group_name
,
4518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4520 int as_type
= AS_UNSPECIFIED
;
4522 struct peer_group
*group
;
4525 group
= peer_group_lookup(bgp
, conf_if
);
4528 vty_out(vty
, "%% Name conflict with peer-group \n");
4529 return CMD_WARNING_CONFIG_FAILED
;
4533 if (as_str
[0] == 'i') {
4534 as_type
= AS_INTERNAL
;
4535 } else if (as_str
[0] == 'e') {
4536 as_type
= AS_EXTERNAL
;
4538 /* Get AS number. */
4539 as
= strtoul(as_str
, NULL
, 10);
4540 as_type
= AS_SPECIFIED
;
4544 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4547 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4549 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4553 vty_out(vty
, "%% BGP failed to create peer\n");
4554 return CMD_WARNING_CONFIG_FAILED
;
4558 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4560 /* Request zebra to initiate IPv6 RAs on this interface. We do
4562 * any unnumbered peer in order to not worry about run-time
4564 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4566 * gets deleted later etc.)
4569 bgp_zebra_initiate_radv(bgp
, peer
);
4572 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4573 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4575 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4577 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4579 /* v6only flag changed. Reset bgp seesion */
4580 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4581 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4582 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4583 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4585 bgp_session_reset(peer
);
4588 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4589 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4590 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4591 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4594 if (peer_group_name
) {
4595 group
= peer_group_lookup(bgp
, peer_group_name
);
4597 vty_out(vty
, "%% Configure the peer-group first\n");
4598 return CMD_WARNING_CONFIG_FAILED
;
4601 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4604 return bgp_vty_return(vty
, ret
);
4607 DEFUN (neighbor_interface_config
,
4608 neighbor_interface_config_cmd
,
4609 "neighbor WORD interface [peer-group PGNAME]",
4611 "Interface name or neighbor tag\n"
4612 "Enable BGP on interface\n"
4613 "Member of the peer-group\n"
4614 "Peer-group name\n")
4617 int idx_peer_group_word
= 4;
4619 if (argc
> idx_peer_group_word
)
4620 return peer_conf_interface_get(
4621 vty
, argv
[idx_word
]->arg
, 0,
4622 argv
[idx_peer_group_word
]->arg
, NULL
);
4624 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4628 DEFUN (neighbor_interface_config_v6only
,
4629 neighbor_interface_config_v6only_cmd
,
4630 "neighbor WORD interface v6only [peer-group PGNAME]",
4632 "Interface name or neighbor tag\n"
4633 "Enable BGP on interface\n"
4634 "Enable BGP with v6 link-local only\n"
4635 "Member of the peer-group\n"
4636 "Peer-group name\n")
4639 int idx_peer_group_word
= 5;
4641 if (argc
> idx_peer_group_word
)
4642 return peer_conf_interface_get(
4643 vty
, argv
[idx_word
]->arg
, 1,
4644 argv
[idx_peer_group_word
]->arg
, NULL
);
4646 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4650 DEFUN (neighbor_interface_config_remote_as
,
4651 neighbor_interface_config_remote_as_cmd
,
4652 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4654 "Interface name or neighbor tag\n"
4655 "Enable BGP on interface\n"
4656 "Specify a BGP neighbor\n"
4658 "Internal BGP peer\n"
4659 "External BGP peer\n")
4662 int idx_remote_as
= 4;
4663 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4664 argv
[idx_remote_as
]->arg
);
4667 DEFUN (neighbor_interface_v6only_config_remote_as
,
4668 neighbor_interface_v6only_config_remote_as_cmd
,
4669 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4671 "Interface name or neighbor tag\n"
4672 "Enable BGP with v6 link-local only\n"
4673 "Enable BGP on interface\n"
4674 "Specify a BGP neighbor\n"
4676 "Internal BGP peer\n"
4677 "External BGP peer\n")
4680 int idx_remote_as
= 5;
4681 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4682 argv
[idx_remote_as
]->arg
);
4685 DEFUN (neighbor_peer_group
,
4686 neighbor_peer_group_cmd
,
4687 "neighbor WORD peer-group",
4689 "Interface name or neighbor tag\n"
4690 "Configure peer-group\n")
4692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4695 struct peer_group
*group
;
4697 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4699 vty_out(vty
, "%% Name conflict with interface: \n");
4700 return CMD_WARNING_CONFIG_FAILED
;
4703 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4705 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4706 return CMD_WARNING_CONFIG_FAILED
;
4714 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4718 "Specify a BGP neighbor\n"
4720 "Internal BGP peer\n"
4721 "External BGP peer\n")
4723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4727 struct peer_group
*group
;
4731 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4733 /* look up for neighbor by interface name config. */
4734 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4736 /* Request zebra to terminate IPv6 RAs on this
4739 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4740 peer_notify_unconfig(peer
);
4745 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4747 peer_group_notify_unconfig(group
);
4748 peer_group_delete(group
);
4750 vty_out(vty
, "%% Create the peer-group first\n");
4751 return CMD_WARNING_CONFIG_FAILED
;
4754 peer
= peer_lookup(bgp
, &su
);
4756 if (peer_dynamic_neighbor(peer
)) {
4758 "%% Operation not allowed on a dynamic neighbor\n");
4759 return CMD_WARNING_CONFIG_FAILED
;
4762 other
= peer
->doppelganger
;
4764 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4765 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4767 peer_notify_unconfig(peer
);
4769 if (other
&& other
->status
!= Deleted
) {
4770 peer_notify_unconfig(other
);
4779 DEFUN (no_neighbor_interface_config
,
4780 no_neighbor_interface_config_cmd
,
4781 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4785 "Configure BGP on interface\n"
4786 "Enable BGP with v6 link-local only\n"
4787 "Member of the peer-group\n"
4789 "Specify a BGP neighbor\n"
4791 "Internal BGP peer\n"
4792 "External BGP peer\n")
4794 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4798 /* look up for neighbor by interface name config. */
4799 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4801 /* Request zebra to terminate IPv6 RAs on this interface. */
4803 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4804 peer_notify_unconfig(peer
);
4807 vty_out(vty
, "%% Create the bgp interface first\n");
4808 return CMD_WARNING_CONFIG_FAILED
;
4813 DEFUN (no_neighbor_peer_group
,
4814 no_neighbor_peer_group_cmd
,
4815 "no neighbor WORD peer-group",
4819 "Configure peer-group\n")
4821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4823 struct peer_group
*group
;
4825 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4827 peer_group_notify_unconfig(group
);
4828 peer_group_delete(group
);
4830 vty_out(vty
, "%% Create the peer-group first\n");
4831 return CMD_WARNING_CONFIG_FAILED
;
4836 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4837 no_neighbor_interface_peer_group_remote_as_cmd
,
4838 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4841 "Interface name or neighbor tag\n"
4842 "Specify a BGP neighbor\n"
4844 "Internal BGP peer\n"
4845 "External BGP peer\n")
4847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4849 struct peer_group
*group
;
4852 /* look up for neighbor by interface name config. */
4853 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4855 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4859 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4861 peer_group_remote_as_delete(group
);
4863 vty_out(vty
, "%% Create the peer-group or interface first\n");
4864 return CMD_WARNING_CONFIG_FAILED
;
4869 DEFUN (neighbor_local_as
,
4870 neighbor_local_as_cmd
,
4871 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4874 "Specify a local-as number\n"
4875 "AS number used as local AS\n")
4883 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4885 return CMD_WARNING_CONFIG_FAILED
;
4887 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4888 ret
= peer_local_as_set(peer
, as
, 0, 0);
4889 return bgp_vty_return(vty
, ret
);
4892 DEFUN (neighbor_local_as_no_prepend
,
4893 neighbor_local_as_no_prepend_cmd
,
4894 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4897 "Specify a local-as number\n"
4898 "AS number used as local AS\n"
4899 "Do not prepend local-as to updates from ebgp peers\n")
4907 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4909 return CMD_WARNING_CONFIG_FAILED
;
4911 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4912 ret
= peer_local_as_set(peer
, as
, 1, 0);
4913 return bgp_vty_return(vty
, ret
);
4916 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4917 neighbor_local_as_no_prepend_replace_as_cmd
,
4918 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4921 "Specify a local-as number\n"
4922 "AS number used as local AS\n"
4923 "Do not prepend local-as to updates from ebgp peers\n"
4924 "Do not prepend local-as to updates from ibgp peers\n")
4932 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4934 return CMD_WARNING_CONFIG_FAILED
;
4936 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4937 ret
= peer_local_as_set(peer
, as
, 1, 1);
4938 return bgp_vty_return(vty
, ret
);
4941 DEFUN (no_neighbor_local_as
,
4942 no_neighbor_local_as_cmd
,
4943 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4947 "Specify a local-as number\n"
4948 "AS number used as local AS\n"
4949 "Do not prepend local-as to updates from ebgp peers\n"
4950 "Do not prepend local-as to updates from ibgp peers\n")
4956 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4958 return CMD_WARNING_CONFIG_FAILED
;
4960 ret
= peer_local_as_unset(peer
);
4961 return bgp_vty_return(vty
, ret
);
4965 DEFUN (neighbor_solo
,
4967 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4970 "Solo peer - part of its own update group\n")
4976 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4978 return CMD_WARNING_CONFIG_FAILED
;
4980 ret
= update_group_adjust_soloness(peer
, 1);
4981 return bgp_vty_return(vty
, ret
);
4984 DEFUN (no_neighbor_solo
,
4985 no_neighbor_solo_cmd
,
4986 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4990 "Solo peer - part of its own update group\n")
4996 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4998 return CMD_WARNING_CONFIG_FAILED
;
5000 ret
= update_group_adjust_soloness(peer
, 0);
5001 return bgp_vty_return(vty
, ret
);
5004 DEFUN (neighbor_password
,
5005 neighbor_password_cmd
,
5006 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5017 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5019 return CMD_WARNING_CONFIG_FAILED
;
5021 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5022 return bgp_vty_return(vty
, ret
);
5025 DEFUN (no_neighbor_password
,
5026 no_neighbor_password_cmd
,
5027 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5038 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5040 return CMD_WARNING_CONFIG_FAILED
;
5042 ret
= peer_password_unset(peer
);
5043 return bgp_vty_return(vty
, ret
);
5046 DEFUN (neighbor_activate
,
5047 neighbor_activate_cmd
,
5048 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5051 "Enable the Address Family for this Neighbor\n")
5057 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5059 return CMD_WARNING_CONFIG_FAILED
;
5061 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5062 return bgp_vty_return(vty
, ret
);
5065 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5066 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5067 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5068 "Enable the Address Family for this Neighbor\n")
5070 DEFUN (no_neighbor_activate
,
5071 no_neighbor_activate_cmd
,
5072 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5076 "Enable the Address Family for this Neighbor\n")
5083 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5085 return CMD_WARNING_CONFIG_FAILED
;
5087 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5088 return bgp_vty_return(vty
, ret
);
5091 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5093 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5094 "Enable the Address Family for this Neighbor\n")
5096 DEFUN (neighbor_set_peer_group
,
5097 neighbor_set_peer_group_cmd
,
5098 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5101 "Member of the peer-group\n"
5102 "Peer-group name\n")
5104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5111 struct peer_group
*group
;
5113 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5115 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5117 vty_out(vty
, "%% Malformed address or name: %s\n",
5118 argv
[idx_peer
]->arg
);
5119 return CMD_WARNING_CONFIG_FAILED
;
5122 if (peer_address_self_check(bgp
, &su
)) {
5124 "%% Can not configure the local system as neighbor\n");
5125 return CMD_WARNING_CONFIG_FAILED
;
5128 /* Disallow for dynamic neighbor. */
5129 peer
= peer_lookup(bgp
, &su
);
5130 if (peer
&& peer_dynamic_neighbor(peer
)) {
5132 "%% Operation not allowed on a dynamic neighbor\n");
5133 return CMD_WARNING_CONFIG_FAILED
;
5137 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5139 vty_out(vty
, "%% Configure the peer-group first\n");
5140 return CMD_WARNING_CONFIG_FAILED
;
5143 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5145 return bgp_vty_return(vty
, ret
);
5148 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5149 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5150 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5151 "Member of the peer-group\n"
5152 "Peer-group name\n")
5154 DEFUN (no_neighbor_set_peer_group
,
5155 no_neighbor_set_peer_group_cmd
,
5156 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5160 "Member of the peer-group\n"
5161 "Peer-group name\n")
5163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5168 struct peer_group
*group
;
5170 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5172 return CMD_WARNING_CONFIG_FAILED
;
5174 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5176 vty_out(vty
, "%% Configure the peer-group first\n");
5177 return CMD_WARNING_CONFIG_FAILED
;
5180 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5181 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5183 peer_notify_unconfig(peer
);
5184 ret
= peer_delete(peer
);
5186 return bgp_vty_return(vty
, ret
);
5189 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5190 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5191 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5192 "Member of the peer-group\n"
5193 "Peer-group name\n")
5195 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5196 uint64_t flag
, int set
)
5201 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5203 return CMD_WARNING_CONFIG_FAILED
;
5206 * If 'neighbor <interface>', then this is for directly connected peers,
5207 * we should not accept disable-connected-check.
5209 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5211 "%s is directly connected peer, cannot accept disable-connected-check\n",
5213 return CMD_WARNING_CONFIG_FAILED
;
5216 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5217 peer_tx_shutdown_message_unset(peer
);
5220 ret
= peer_flag_set(peer
, flag
);
5222 ret
= peer_flag_unset(peer
, flag
);
5224 return bgp_vty_return(vty
, ret
);
5227 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5229 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5232 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5235 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5238 /* neighbor passive. */
5239 DEFUN (neighbor_passive
,
5240 neighbor_passive_cmd
,
5241 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5244 "Don't send open messages to this neighbor\n")
5247 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5250 DEFUN (no_neighbor_passive
,
5251 no_neighbor_passive_cmd
,
5252 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5256 "Don't send open messages to this neighbor\n")
5259 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5262 /* neighbor shutdown. */
5263 DEFUN (neighbor_shutdown_msg
,
5264 neighbor_shutdown_msg_cmd
,
5265 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5268 "Administratively shut down this neighbor\n"
5269 "Add a shutdown message (RFC 8203)\n"
5270 "Shutdown message\n")
5276 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5280 return CMD_WARNING_CONFIG_FAILED
;
5281 message
= argv_concat(argv
, argc
, 4);
5282 peer_tx_shutdown_message_set(peer
, message
);
5283 XFREE(MTYPE_TMP
, message
);
5286 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5289 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5290 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5291 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5292 "Administratively shut down this neighbor\n")
5294 DEFUN (no_neighbor_shutdown_msg
,
5295 no_neighbor_shutdown_msg_cmd
,
5296 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5300 "Administratively shut down this neighbor\n"
5301 "Remove a shutdown message (RFC 8203)\n"
5302 "Shutdown message\n")
5306 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5307 PEER_FLAG_SHUTDOWN
);
5310 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5311 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5312 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5313 "Administratively shut down this neighbor\n")
5315 DEFUN(neighbor_shutdown_rtt
,
5316 neighbor_shutdown_rtt_cmd
,
5317 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5320 "Administratively shut down this neighbor\n"
5321 "Shutdown if round-trip-time is higher than expected\n"
5322 "Round-trip-time in milliseconds\n"
5323 "Specify the number of keepalives before shutdown\n"
5324 "The number of keepalives with higher RTT to shutdown\n")
5331 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5334 return CMD_WARNING_CONFIG_FAILED
;
5336 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5338 if (argv_find(argv
, argc
, "count", &idx_count
))
5339 peer
->rtt_keepalive_conf
=
5340 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5342 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5343 PEER_FLAG_RTT_SHUTDOWN
);
5346 DEFUN(no_neighbor_shutdown_rtt
,
5347 no_neighbor_shutdown_rtt_cmd
,
5348 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5352 "Administratively shut down this neighbor\n"
5353 "Shutdown if round-trip-time is higher than expected\n"
5354 "Round-trip-time in milliseconds\n"
5355 "Specify the number of keepalives before shutdown\n"
5356 "The number of keepalives with higher RTT to shutdown\n")
5361 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5364 return CMD_WARNING_CONFIG_FAILED
;
5366 peer
->rtt_expected
= 0;
5367 peer
->rtt_keepalive_conf
= 1;
5369 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5370 PEER_FLAG_RTT_SHUTDOWN
);
5373 /* neighbor capability dynamic. */
5374 DEFUN (neighbor_capability_dynamic
,
5375 neighbor_capability_dynamic_cmd
,
5376 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5379 "Advertise capability to the peer\n"
5380 "Advertise dynamic capability to this neighbor\n")
5383 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5384 PEER_FLAG_DYNAMIC_CAPABILITY
);
5387 DEFUN (no_neighbor_capability_dynamic
,
5388 no_neighbor_capability_dynamic_cmd
,
5389 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5393 "Advertise capability to the peer\n"
5394 "Advertise dynamic capability to this neighbor\n")
5397 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5398 PEER_FLAG_DYNAMIC_CAPABILITY
);
5401 /* neighbor dont-capability-negotiate */
5402 DEFUN (neighbor_dont_capability_negotiate
,
5403 neighbor_dont_capability_negotiate_cmd
,
5404 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5407 "Do not perform capability negotiation\n")
5410 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5411 PEER_FLAG_DONT_CAPABILITY
);
5414 DEFUN (no_neighbor_dont_capability_negotiate
,
5415 no_neighbor_dont_capability_negotiate_cmd
,
5416 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5420 "Do not perform capability negotiation\n")
5423 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5424 PEER_FLAG_DONT_CAPABILITY
);
5427 /* neighbor capability extended next hop encoding */
5428 DEFUN (neighbor_capability_enhe
,
5429 neighbor_capability_enhe_cmd
,
5430 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5433 "Advertise capability to the peer\n"
5434 "Advertise extended next-hop capability to the peer\n")
5439 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5440 if (peer
&& peer
->conf_if
)
5443 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5444 PEER_FLAG_CAPABILITY_ENHE
);
5447 DEFUN (no_neighbor_capability_enhe
,
5448 no_neighbor_capability_enhe_cmd
,
5449 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5453 "Advertise capability to the peer\n"
5454 "Advertise extended next-hop capability to the peer\n")
5459 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5460 if (peer
&& peer
->conf_if
) {
5462 "Peer %s cannot have capability extended-nexthop turned off\n",
5463 argv
[idx_peer
]->arg
);
5464 return CMD_WARNING_CONFIG_FAILED
;
5467 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5468 PEER_FLAG_CAPABILITY_ENHE
);
5471 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5472 afi_t afi
, safi_t safi
, uint32_t flag
,
5478 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5480 return CMD_WARNING_CONFIG_FAILED
;
5483 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5485 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5487 return bgp_vty_return(vty
, ret
);
5490 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5491 afi_t afi
, safi_t safi
, uint32_t flag
)
5493 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5496 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5497 afi_t afi
, safi_t safi
, uint32_t flag
)
5499 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5502 /* neighbor capability orf prefix-list. */
5503 DEFUN (neighbor_capability_orf_prefix
,
5504 neighbor_capability_orf_prefix_cmd
,
5505 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5508 "Advertise capability to the peer\n"
5509 "Advertise ORF capability to the peer\n"
5510 "Advertise prefixlist ORF capability to this neighbor\n"
5511 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5512 "Capability to RECEIVE the ORF from this neighbor\n"
5513 "Capability to SEND the ORF to this neighbor\n")
5515 int idx_send_recv
= 5;
5516 char *peer_str
= argv
[1]->arg
;
5518 afi_t afi
= bgp_node_afi(vty
);
5519 safi_t safi
= bgp_node_safi(vty
);
5521 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5523 return CMD_WARNING_CONFIG_FAILED
;
5525 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5526 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5527 PEER_FLAG_ORF_PREFIX_SM
);
5529 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5530 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5531 PEER_FLAG_ORF_PREFIX_RM
);
5533 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5534 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5535 PEER_FLAG_ORF_PREFIX_SM
)
5536 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5537 PEER_FLAG_ORF_PREFIX_RM
);
5539 return CMD_WARNING_CONFIG_FAILED
;
5543 neighbor_capability_orf_prefix
,
5544 neighbor_capability_orf_prefix_hidden_cmd
,
5545 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5546 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5547 "Advertise capability to the peer\n"
5548 "Advertise ORF capability to the peer\n"
5549 "Advertise prefixlist ORF capability to this neighbor\n"
5550 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5551 "Capability to RECEIVE the ORF from this neighbor\n"
5552 "Capability to SEND the ORF to this neighbor\n")
5554 DEFUN (no_neighbor_capability_orf_prefix
,
5555 no_neighbor_capability_orf_prefix_cmd
,
5556 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5560 "Advertise capability to the peer\n"
5561 "Advertise ORF capability to the peer\n"
5562 "Advertise prefixlist ORF capability to this neighbor\n"
5563 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5564 "Capability to RECEIVE the ORF from this neighbor\n"
5565 "Capability to SEND the ORF to this neighbor\n")
5567 int idx_send_recv
= 6;
5568 char *peer_str
= argv
[2]->arg
;
5570 afi_t afi
= bgp_node_afi(vty
);
5571 safi_t safi
= bgp_node_safi(vty
);
5573 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5575 return CMD_WARNING_CONFIG_FAILED
;
5577 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5578 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5579 PEER_FLAG_ORF_PREFIX_SM
);
5581 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5582 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5583 PEER_FLAG_ORF_PREFIX_RM
);
5585 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5586 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5587 PEER_FLAG_ORF_PREFIX_SM
)
5588 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5589 PEER_FLAG_ORF_PREFIX_RM
);
5591 return CMD_WARNING_CONFIG_FAILED
;
5595 no_neighbor_capability_orf_prefix
,
5596 no_neighbor_capability_orf_prefix_hidden_cmd
,
5597 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5599 "Advertise capability to the peer\n"
5600 "Advertise ORF capability to the peer\n"
5601 "Advertise prefixlist ORF capability to this neighbor\n"
5602 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5603 "Capability to RECEIVE the ORF from this neighbor\n"
5604 "Capability to SEND the ORF to this neighbor\n")
5606 /* neighbor next-hop-self. */
5607 DEFUN (neighbor_nexthop_self
,
5608 neighbor_nexthop_self_cmd
,
5609 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5612 "Disable the next hop calculation for this neighbor\n")
5615 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5616 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5619 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5620 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5621 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5622 "Disable the next hop calculation for this neighbor\n")
5624 /* neighbor next-hop-self. */
5625 DEFUN (neighbor_nexthop_self_force
,
5626 neighbor_nexthop_self_force_cmd
,
5627 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5630 "Disable the next hop calculation for this neighbor\n"
5631 "Set the next hop to self for reflected routes\n")
5634 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5636 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5639 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5640 neighbor_nexthop_self_force_hidden_cmd
,
5641 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5642 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5643 "Disable the next hop calculation for this neighbor\n"
5644 "Set the next hop to self for reflected routes\n")
5646 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5647 neighbor_nexthop_self_all_hidden_cmd
,
5648 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5649 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5650 "Disable the next hop calculation for this neighbor\n"
5651 "Set the next hop to self for reflected routes\n")
5653 DEFUN (no_neighbor_nexthop_self
,
5654 no_neighbor_nexthop_self_cmd
,
5655 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5659 "Disable the next hop calculation for this neighbor\n")
5662 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5663 bgp_node_afi(vty
), bgp_node_safi(vty
),
5664 PEER_FLAG_NEXTHOP_SELF
);
5667 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5668 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5669 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5670 "Disable the next hop calculation for this neighbor\n")
5672 DEFUN (no_neighbor_nexthop_self_force
,
5673 no_neighbor_nexthop_self_force_cmd
,
5674 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5678 "Disable the next hop calculation for this neighbor\n"
5679 "Set the next hop to self for reflected routes\n")
5682 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5683 bgp_node_afi(vty
), bgp_node_safi(vty
),
5684 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5687 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5688 no_neighbor_nexthop_self_force_hidden_cmd
,
5689 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5690 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5691 "Disable the next hop calculation for this neighbor\n"
5692 "Set the next hop to self for reflected routes\n")
5694 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5695 no_neighbor_nexthop_self_all_hidden_cmd
,
5696 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5697 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5698 "Disable the next hop calculation for this neighbor\n"
5699 "Set the next hop to self for reflected routes\n")
5701 /* neighbor as-override */
5702 DEFUN (neighbor_as_override
,
5703 neighbor_as_override_cmd
,
5704 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5707 "Override ASNs in outbound updates if aspath equals remote-as\n")
5710 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5711 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5714 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5715 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5716 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5717 "Override ASNs in outbound updates if aspath equals remote-as\n")
5719 DEFUN (no_neighbor_as_override
,
5720 no_neighbor_as_override_cmd
,
5721 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5725 "Override ASNs in outbound updates if aspath equals remote-as\n")
5728 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5729 bgp_node_afi(vty
), bgp_node_safi(vty
),
5730 PEER_FLAG_AS_OVERRIDE
);
5733 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5734 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5735 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Override ASNs in outbound updates if aspath equals remote-as\n")
5738 /* neighbor remove-private-AS. */
5739 DEFUN (neighbor_remove_private_as
,
5740 neighbor_remove_private_as_cmd
,
5741 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5744 "Remove private ASNs in outbound updates\n")
5747 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5749 PEER_FLAG_REMOVE_PRIVATE_AS
);
5752 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5753 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5754 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5755 "Remove private ASNs in outbound updates\n")
5757 DEFUN (neighbor_remove_private_as_all
,
5758 neighbor_remove_private_as_all_cmd
,
5759 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5762 "Remove private ASNs in outbound updates\n"
5763 "Apply to all AS numbers\n")
5766 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5768 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5771 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5772 neighbor_remove_private_as_all_hidden_cmd
,
5773 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5774 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5775 "Remove private ASNs in outbound updates\n"
5776 "Apply to all AS numbers")
5778 DEFUN (neighbor_remove_private_as_replace_as
,
5779 neighbor_remove_private_as_replace_as_cmd
,
5780 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5783 "Remove private ASNs in outbound updates\n"
5784 "Replace private ASNs with our ASN in outbound updates\n")
5787 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5789 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5792 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5793 neighbor_remove_private_as_replace_as_hidden_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5795 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5796 "Remove private ASNs in outbound updates\n"
5797 "Replace private ASNs with our ASN in outbound updates\n")
5799 DEFUN (neighbor_remove_private_as_all_replace_as
,
5800 neighbor_remove_private_as_all_replace_as_cmd
,
5801 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5804 "Remove private ASNs in outbound updates\n"
5805 "Apply to all AS numbers\n"
5806 "Replace private ASNs with our ASN in outbound updates\n")
5809 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5811 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5815 neighbor_remove_private_as_all_replace_as
,
5816 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5817 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5818 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5819 "Remove private ASNs in outbound updates\n"
5820 "Apply to all AS numbers\n"
5821 "Replace private ASNs with our ASN in outbound updates\n")
5823 DEFUN (no_neighbor_remove_private_as
,
5824 no_neighbor_remove_private_as_cmd
,
5825 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5829 "Remove private ASNs in outbound updates\n")
5832 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5833 bgp_node_afi(vty
), bgp_node_safi(vty
),
5834 PEER_FLAG_REMOVE_PRIVATE_AS
);
5837 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5838 no_neighbor_remove_private_as_hidden_cmd
,
5839 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5840 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5841 "Remove private ASNs in outbound updates\n")
5843 DEFUN (no_neighbor_remove_private_as_all
,
5844 no_neighbor_remove_private_as_all_cmd
,
5845 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5849 "Remove private ASNs in outbound updates\n"
5850 "Apply to all AS numbers\n")
5853 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5854 bgp_node_afi(vty
), bgp_node_safi(vty
),
5855 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5858 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5859 no_neighbor_remove_private_as_all_hidden_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5861 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5862 "Remove private ASNs in outbound updates\n"
5863 "Apply to all AS numbers\n")
5865 DEFUN (no_neighbor_remove_private_as_replace_as
,
5866 no_neighbor_remove_private_as_replace_as_cmd
,
5867 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5871 "Remove private ASNs in outbound updates\n"
5872 "Replace private ASNs with our ASN in outbound updates\n")
5875 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5876 bgp_node_afi(vty
), bgp_node_safi(vty
),
5877 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5880 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5881 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5882 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5883 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5884 "Remove private ASNs in outbound updates\n"
5885 "Replace private ASNs with our ASN in outbound updates\n")
5887 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5888 no_neighbor_remove_private_as_all_replace_as_cmd
,
5889 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5893 "Remove private ASNs in outbound updates\n"
5894 "Apply to all AS numbers\n"
5895 "Replace private ASNs with our ASN in outbound updates\n")
5898 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5899 bgp_node_afi(vty
), bgp_node_safi(vty
),
5900 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5904 no_neighbor_remove_private_as_all_replace_as
,
5905 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5906 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5907 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5908 "Remove private ASNs in outbound updates\n"
5909 "Apply to all AS numbers\n"
5910 "Replace private ASNs with our ASN in outbound updates\n")
5913 /* neighbor send-community. */
5914 DEFUN (neighbor_send_community
,
5915 neighbor_send_community_cmd
,
5916 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5919 "Send Community attribute to this neighbor\n")
5923 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5925 PEER_FLAG_SEND_COMMUNITY
);
5928 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5929 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5931 "Send Community attribute to this neighbor\n")
5933 DEFUN (no_neighbor_send_community
,
5934 no_neighbor_send_community_cmd
,
5935 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5939 "Send Community attribute to this neighbor\n")
5943 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5944 bgp_node_afi(vty
), bgp_node_safi(vty
),
5945 PEER_FLAG_SEND_COMMUNITY
);
5948 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5949 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5950 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5951 "Send Community attribute to this neighbor\n")
5953 /* neighbor send-community extended. */
5954 DEFUN (neighbor_send_community_type
,
5955 neighbor_send_community_type_cmd
,
5956 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5959 "Send Community attribute to this neighbor\n"
5960 "Send Standard and Extended Community attributes\n"
5961 "Send Standard, Large and Extended Community attributes\n"
5962 "Send Extended Community attributes\n"
5963 "Send Standard Community attributes\n"
5964 "Send Large Community attributes\n")
5966 const char *type
= argv
[argc
- 1]->text
;
5967 char *peer_str
= argv
[1]->arg
;
5969 afi_t afi
= bgp_node_afi(vty
);
5970 safi_t safi
= bgp_node_safi(vty
);
5972 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5974 return CMD_WARNING_CONFIG_FAILED
;
5976 if (strmatch(type
, "standard"))
5977 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5978 PEER_FLAG_SEND_COMMUNITY
);
5980 if (strmatch(type
, "extended"))
5981 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5982 PEER_FLAG_SEND_EXT_COMMUNITY
);
5984 if (strmatch(type
, "large"))
5985 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5986 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5988 if (strmatch(type
, "both")) {
5989 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5990 PEER_FLAG_SEND_COMMUNITY
)
5991 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5992 PEER_FLAG_SEND_EXT_COMMUNITY
);
5994 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5995 PEER_FLAG_SEND_COMMUNITY
)
5996 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5997 PEER_FLAG_SEND_EXT_COMMUNITY
)
5998 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5999 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6003 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6005 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6006 "Send Community attribute to this neighbor\n"
6007 "Send Standard and Extended Community attributes\n"
6008 "Send Standard, Large and Extended Community attributes\n"
6009 "Send Extended Community attributes\n"
6010 "Send Standard Community attributes\n"
6011 "Send Large Community attributes\n")
6013 DEFUN (no_neighbor_send_community_type
,
6014 no_neighbor_send_community_type_cmd
,
6015 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6019 "Send Community attribute to this neighbor\n"
6020 "Send Standard and Extended Community attributes\n"
6021 "Send Standard, Large and Extended Community attributes\n"
6022 "Send Extended Community attributes\n"
6023 "Send Standard Community attributes\n"
6024 "Send Large Community attributes\n")
6026 const char *type
= argv
[argc
- 1]->text
;
6027 char *peer_str
= argv
[2]->arg
;
6029 afi_t afi
= bgp_node_afi(vty
);
6030 safi_t safi
= bgp_node_safi(vty
);
6032 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6034 return CMD_WARNING_CONFIG_FAILED
;
6036 if (strmatch(type
, "standard"))
6037 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6038 PEER_FLAG_SEND_COMMUNITY
);
6040 if (strmatch(type
, "extended"))
6041 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6042 PEER_FLAG_SEND_EXT_COMMUNITY
);
6044 if (strmatch(type
, "large"))
6045 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6046 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6048 if (strmatch(type
, "both")) {
6050 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6051 PEER_FLAG_SEND_COMMUNITY
)
6052 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6053 PEER_FLAG_SEND_EXT_COMMUNITY
);
6056 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6057 PEER_FLAG_SEND_COMMUNITY
)
6058 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6059 PEER_FLAG_SEND_EXT_COMMUNITY
)
6060 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6061 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6065 no_neighbor_send_community_type
,
6066 no_neighbor_send_community_type_hidden_cmd
,
6067 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6068 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6069 "Send Community attribute to this neighbor\n"
6070 "Send Standard and Extended Community attributes\n"
6071 "Send Standard, Large and Extended Community attributes\n"
6072 "Send Extended Community attributes\n"
6073 "Send Standard Community attributes\n"
6074 "Send Large Community attributes\n")
6076 /* neighbor soft-reconfig. */
6077 DEFUN (neighbor_soft_reconfiguration
,
6078 neighbor_soft_reconfiguration_cmd
,
6079 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6082 "Per neighbor soft reconfiguration\n"
6083 "Allow inbound soft reconfiguration for this neighbor\n")
6086 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6088 PEER_FLAG_SOFT_RECONFIG
);
6091 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6092 neighbor_soft_reconfiguration_hidden_cmd
,
6093 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6094 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6095 "Per neighbor soft reconfiguration\n"
6096 "Allow inbound soft reconfiguration for this neighbor\n")
6098 DEFUN (no_neighbor_soft_reconfiguration
,
6099 no_neighbor_soft_reconfiguration_cmd
,
6100 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6104 "Per neighbor soft reconfiguration\n"
6105 "Allow inbound soft reconfiguration for this neighbor\n")
6108 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6109 bgp_node_afi(vty
), bgp_node_safi(vty
),
6110 PEER_FLAG_SOFT_RECONFIG
);
6113 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6114 no_neighbor_soft_reconfiguration_hidden_cmd
,
6115 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6116 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6117 "Per neighbor soft reconfiguration\n"
6118 "Allow inbound soft reconfiguration for this neighbor\n")
6120 DEFUN (neighbor_route_reflector_client
,
6121 neighbor_route_reflector_client_cmd
,
6122 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6125 "Configure a neighbor as Route Reflector client\n")
6131 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6133 return CMD_WARNING_CONFIG_FAILED
;
6135 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6137 PEER_FLAG_REFLECTOR_CLIENT
);
6140 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6141 neighbor_route_reflector_client_hidden_cmd
,
6142 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6143 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6144 "Configure a neighbor as Route Reflector client\n")
6146 DEFUN (no_neighbor_route_reflector_client
,
6147 no_neighbor_route_reflector_client_cmd
,
6148 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6152 "Configure a neighbor as Route Reflector client\n")
6155 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6156 bgp_node_afi(vty
), bgp_node_safi(vty
),
6157 PEER_FLAG_REFLECTOR_CLIENT
);
6160 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6161 no_neighbor_route_reflector_client_hidden_cmd
,
6162 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6163 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6164 "Configure a neighbor as Route Reflector client\n")
6166 /* neighbor route-server-client. */
6167 DEFUN (neighbor_route_server_client
,
6168 neighbor_route_server_client_cmd
,
6169 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6172 "Configure a neighbor as Route Server client\n")
6177 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6179 return CMD_WARNING_CONFIG_FAILED
;
6180 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6182 PEER_FLAG_RSERVER_CLIENT
);
6185 ALIAS_HIDDEN(neighbor_route_server_client
,
6186 neighbor_route_server_client_hidden_cmd
,
6187 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6188 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6189 "Configure a neighbor as Route Server client\n")
6191 DEFUN (no_neighbor_route_server_client
,
6192 no_neighbor_route_server_client_cmd
,
6193 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6197 "Configure a neighbor as Route Server client\n")
6200 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6201 bgp_node_afi(vty
), bgp_node_safi(vty
),
6202 PEER_FLAG_RSERVER_CLIENT
);
6205 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6206 no_neighbor_route_server_client_hidden_cmd
,
6207 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6208 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6209 "Configure a neighbor as Route Server client\n")
6211 DEFUN (neighbor_nexthop_local_unchanged
,
6212 neighbor_nexthop_local_unchanged_cmd
,
6213 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6216 "Configure treatment of outgoing link-local nexthop attribute\n"
6217 "Leave link-local nexthop unchanged for this peer\n")
6220 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6222 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6225 DEFUN (no_neighbor_nexthop_local_unchanged
,
6226 no_neighbor_nexthop_local_unchanged_cmd
,
6227 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6231 "Configure treatment of outgoing link-local-nexthop attribute\n"
6232 "Leave link-local nexthop unchanged for this peer\n")
6235 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6236 bgp_node_afi(vty
), bgp_node_safi(vty
),
6237 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6240 DEFUN (neighbor_attr_unchanged
,
6241 neighbor_attr_unchanged_cmd
,
6242 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6245 "BGP attribute is propagated unchanged to this neighbor\n"
6246 "As-path attribute\n"
6247 "Nexthop attribute\n"
6251 char *peer_str
= argv
[1]->arg
;
6253 bool aspath
= false;
6254 bool nexthop
= false;
6256 afi_t afi
= bgp_node_afi(vty
);
6257 safi_t safi
= bgp_node_safi(vty
);
6260 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6262 return CMD_WARNING_CONFIG_FAILED
;
6264 if (argv_find(argv
, argc
, "as-path", &idx
))
6268 if (argv_find(argv
, argc
, "next-hop", &idx
))
6272 if (argv_find(argv
, argc
, "med", &idx
))
6275 /* no flags means all of them! */
6276 if (!aspath
&& !nexthop
&& !med
) {
6277 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6278 PEER_FLAG_AS_PATH_UNCHANGED
);
6279 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6280 PEER_FLAG_NEXTHOP_UNCHANGED
);
6281 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6282 PEER_FLAG_MED_UNCHANGED
);
6285 if (peer_af_flag_check(peer
, afi
, safi
,
6286 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6287 ret
|= peer_af_flag_unset_vty(
6288 vty
, peer_str
, afi
, safi
,
6289 PEER_FLAG_AS_PATH_UNCHANGED
);
6292 ret
|= peer_af_flag_set_vty(
6293 vty
, peer_str
, afi
, safi
,
6294 PEER_FLAG_AS_PATH_UNCHANGED
);
6297 if (peer_af_flag_check(peer
, afi
, safi
,
6298 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6299 ret
|= peer_af_flag_unset_vty(
6300 vty
, peer_str
, afi
, safi
,
6301 PEER_FLAG_NEXTHOP_UNCHANGED
);
6304 ret
|= peer_af_flag_set_vty(
6305 vty
, peer_str
, afi
, safi
,
6306 PEER_FLAG_NEXTHOP_UNCHANGED
);
6309 if (peer_af_flag_check(peer
, afi
, safi
,
6310 PEER_FLAG_MED_UNCHANGED
)) {
6311 ret
|= peer_af_flag_unset_vty(
6312 vty
, peer_str
, afi
, safi
,
6313 PEER_FLAG_MED_UNCHANGED
);
6316 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6317 PEER_FLAG_MED_UNCHANGED
);
6324 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6325 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6327 "BGP attribute is propagated unchanged to this neighbor\n"
6328 "As-path attribute\n"
6329 "Nexthop attribute\n"
6332 DEFUN (no_neighbor_attr_unchanged
,
6333 no_neighbor_attr_unchanged_cmd
,
6334 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6338 "BGP attribute is propagated unchanged to this neighbor\n"
6339 "As-path attribute\n"
6340 "Nexthop attribute\n"
6344 char *peer_str
= argv
[2]->arg
;
6346 bool aspath
= false;
6347 bool nexthop
= false;
6349 afi_t afi
= bgp_node_afi(vty
);
6350 safi_t safi
= bgp_node_safi(vty
);
6353 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6355 return CMD_WARNING_CONFIG_FAILED
;
6357 if (argv_find(argv
, argc
, "as-path", &idx
))
6361 if (argv_find(argv
, argc
, "next-hop", &idx
))
6365 if (argv_find(argv
, argc
, "med", &idx
))
6368 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6369 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6370 PEER_FLAG_AS_PATH_UNCHANGED
)
6371 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6372 PEER_FLAG_NEXTHOP_UNCHANGED
)
6373 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6374 PEER_FLAG_MED_UNCHANGED
);
6377 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6378 PEER_FLAG_AS_PATH_UNCHANGED
);
6381 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6382 PEER_FLAG_NEXTHOP_UNCHANGED
);
6385 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6386 PEER_FLAG_MED_UNCHANGED
);
6392 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6393 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6394 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6395 "BGP attribute is propagated unchanged to this neighbor\n"
6396 "As-path attribute\n"
6397 "Nexthop attribute\n"
6400 /* EBGP multihop configuration. */
6401 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6402 const char *ttl_str
)
6407 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6409 return CMD_WARNING_CONFIG_FAILED
;
6412 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6417 ttl
= strtoul(ttl_str
, NULL
, 10);
6419 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6422 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6426 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6428 return CMD_WARNING_CONFIG_FAILED
;
6430 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6433 /* neighbor ebgp-multihop. */
6434 DEFUN (neighbor_ebgp_multihop
,
6435 neighbor_ebgp_multihop_cmd
,
6436 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6439 "Allow EBGP neighbors not on directly connected networks\n")
6442 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6445 DEFUN (neighbor_ebgp_multihop_ttl
,
6446 neighbor_ebgp_multihop_ttl_cmd
,
6447 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6450 "Allow EBGP neighbors not on directly connected networks\n"
6451 "maximum hop count\n")
6455 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6456 argv
[idx_number
]->arg
);
6459 DEFUN (no_neighbor_ebgp_multihop
,
6460 no_neighbor_ebgp_multihop_cmd
,
6461 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6465 "Allow EBGP neighbors not on directly connected networks\n"
6466 "maximum hop count\n")
6469 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6472 static uint8_t get_role_by_name(const char *role_str
)
6474 if (strncmp(role_str
, "peer", 2) == 0)
6476 if (strncmp(role_str
, "provider", 2) == 0)
6477 return ROLE_PROVIDER
;
6478 if (strncmp(role_str
, "customer", 2) == 0)
6479 return ROLE_CUSTOMER
;
6480 if (strncmp(role_str
, "rs-server", 4) == 0)
6481 return ROLE_RS_SERVER
;
6482 if (strncmp(role_str
, "rs-client", 4) == 0)
6483 return ROLE_RS_CLIENT
;
6484 return ROLE_UNDEFINED
;
6487 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6488 const char *role_str
, bool strict_mode
)
6492 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6494 return CMD_WARNING_CONFIG_FAILED
;
6495 uint8_t role
= get_role_by_name(role_str
);
6497 if (role
== ROLE_UNDEFINED
)
6498 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6499 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6502 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6506 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6508 return CMD_WARNING_CONFIG_FAILED
;
6509 return bgp_vty_return(vty
, peer_role_unset(peer
));
6512 DEFPY(neighbor_role
,
6514 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6517 "Set session role\n"
6523 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6527 DEFPY(neighbor_role_strict
,
6528 neighbor_role_strict_cmd
,
6529 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6532 "Set session role\n"
6534 "Use additional restriction on peer\n")
6539 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6543 DEFPY(no_neighbor_role
,
6544 no_neighbor_role_cmd
,
6545 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6549 "Set session role\n"
6551 "Use additional restriction on peer\n")
6555 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6558 /* disable-connected-check */
6559 DEFUN (neighbor_disable_connected_check
,
6560 neighbor_disable_connected_check_cmd
,
6561 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6564 "one-hop away EBGP peer using loopback address\n"
6565 "Enforce EBGP neighbors perform multihop\n")
6568 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6569 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6572 DEFUN (no_neighbor_disable_connected_check
,
6573 no_neighbor_disable_connected_check_cmd
,
6574 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6578 "one-hop away EBGP peer using loopback address\n"
6579 "Enforce EBGP neighbors perform multihop\n")
6582 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6583 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6586 /* disable-link-bw-encoding-ieee */
6587 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6588 neighbor_disable_link_bw_encoding_ieee_cmd
,
6589 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6590 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6591 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6595 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6596 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6599 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6600 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6601 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6602 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6603 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6607 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6608 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6611 /* extended-optional-parameters */
6612 DEFUN(neighbor_extended_optional_parameters
,
6613 neighbor_extended_optional_parameters_cmd
,
6614 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6615 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6616 "Force the extended optional parameters format for OPEN messages\n")
6620 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6621 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6624 DEFUN(no_neighbor_extended_optional_parameters
,
6625 no_neighbor_extended_optional_parameters_cmd
,
6626 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6627 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6628 "Force the extended optional parameters format for OPEN messages\n")
6632 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6633 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6636 /* enforce-first-as */
6637 DEFUN (neighbor_enforce_first_as
,
6638 neighbor_enforce_first_as_cmd
,
6639 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6642 "Enforce the first AS for EBGP routes\n")
6646 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6647 PEER_FLAG_ENFORCE_FIRST_AS
);
6650 DEFUN (no_neighbor_enforce_first_as
,
6651 no_neighbor_enforce_first_as_cmd
,
6652 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6656 "Enforce the first AS for EBGP routes\n")
6660 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6661 PEER_FLAG_ENFORCE_FIRST_AS
);
6665 DEFUN (neighbor_description
,
6666 neighbor_description_cmd
,
6667 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6670 "Neighbor specific description\n"
6671 "Up to 80 characters describing this neighbor\n")
6678 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6680 return CMD_WARNING_CONFIG_FAILED
;
6682 str
= argv_concat(argv
, argc
, idx_line
);
6684 peer_description_set(peer
, str
);
6686 XFREE(MTYPE_TMP
, str
);
6691 DEFUN (no_neighbor_description
,
6692 no_neighbor_description_cmd
,
6693 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6697 "Neighbor specific description\n")
6702 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6704 return CMD_WARNING_CONFIG_FAILED
;
6706 peer_description_unset(peer
);
6711 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6712 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6713 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6714 "Neighbor specific description\n"
6715 "Up to 80 characters describing this neighbor\n")
6717 /* Neighbor update-source. */
6718 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6719 const char *source_str
)
6725 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6727 return CMD_WARNING_CONFIG_FAILED
;
6733 if (str2sockunion(source_str
, &su
) == 0)
6734 peer_update_source_addr_set(peer
, &su
);
6736 if (str2prefix(source_str
, &p
)) {
6738 "%% Invalid update-source, remove prefix length \n");
6739 return CMD_WARNING_CONFIG_FAILED
;
6741 peer_update_source_if_set(peer
, source_str
);
6744 peer_update_source_unset(peer
);
6749 #define BGP_UPDATE_SOURCE_HELP_STR \
6752 "Interface name (requires zebra to be running)\n"
6754 DEFUN (neighbor_update_source
,
6755 neighbor_update_source_cmd
,
6756 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6759 "Source of routing updates\n"
6760 BGP_UPDATE_SOURCE_HELP_STR
)
6764 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6765 argv
[idx_peer_2
]->arg
);
6768 DEFUN (no_neighbor_update_source
,
6769 no_neighbor_update_source_cmd
,
6770 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6774 "Source of routing updates\n"
6775 BGP_UPDATE_SOURCE_HELP_STR
)
6778 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6781 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6782 afi_t afi
, safi_t safi
,
6783 const char *rmap
, int set
)
6787 struct route_map
*route_map
= NULL
;
6789 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6791 return CMD_WARNING_CONFIG_FAILED
;
6795 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6796 ret
= peer_default_originate_set(peer
, afi
, safi
,
6799 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6801 return bgp_vty_return(vty
, ret
);
6804 /* neighbor default-originate. */
6805 DEFUN (neighbor_default_originate
,
6806 neighbor_default_originate_cmd
,
6807 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6810 "Originate default route to this neighbor\n")
6813 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6815 bgp_node_safi(vty
), NULL
, 1);
6818 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6819 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6820 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6821 "Originate default route to this neighbor\n")
6823 DEFUN (neighbor_default_originate_rmap
,
6824 neighbor_default_originate_rmap_cmd
,
6825 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6828 "Originate default route to this neighbor\n"
6829 "Route-map to specify criteria to originate default\n"
6834 return peer_default_originate_set_vty(
6835 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6836 argv
[idx_word
]->arg
, 1);
6840 neighbor_default_originate_rmap
,
6841 neighbor_default_originate_rmap_hidden_cmd
,
6842 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6843 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6844 "Originate default route to this neighbor\n"
6845 "Route-map to specify criteria to originate default\n"
6848 DEFUN (no_neighbor_default_originate
,
6849 no_neighbor_default_originate_cmd
,
6850 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6854 "Originate default route to this neighbor\n"
6855 "Route-map to specify criteria to originate default\n"
6859 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6861 bgp_node_safi(vty
), NULL
, 0);
6865 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6866 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6867 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6868 "Originate default route to this neighbor\n"
6869 "Route-map to specify criteria to originate default\n"
6873 /* Set neighbor's BGP port. */
6874 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6875 const char *port_str
)
6881 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6883 return CMD_WARNING_CONFIG_FAILED
;
6886 sp
= getservbyname("bgp", "tcp");
6887 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6889 port
= strtoul(port_str
, NULL
, 10);
6892 peer_port_set(peer
, port
);
6897 /* Set specified peer's BGP port. */
6898 DEFUN (neighbor_port
,
6900 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6903 "Neighbor's BGP port\n"
6904 "TCP port number\n")
6908 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6909 argv
[idx_number
]->arg
);
6912 DEFUN (no_neighbor_port
,
6913 no_neighbor_port_cmd
,
6914 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6918 "Neighbor's BGP port\n"
6919 "TCP port number\n")
6922 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6926 /* neighbor weight. */
6927 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6928 safi_t safi
, const char *weight_str
)
6932 unsigned long weight
;
6934 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6936 return CMD_WARNING_CONFIG_FAILED
;
6938 weight
= strtoul(weight_str
, NULL
, 10);
6940 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6941 return bgp_vty_return(vty
, ret
);
6944 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6950 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6952 return CMD_WARNING_CONFIG_FAILED
;
6954 ret
= peer_weight_unset(peer
, afi
, safi
);
6955 return bgp_vty_return(vty
, ret
);
6958 DEFUN (neighbor_weight
,
6959 neighbor_weight_cmd
,
6960 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6963 "Set default weight for routes from this neighbor\n"
6968 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6969 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6972 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6973 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6975 "Set default weight for routes from this neighbor\n"
6978 DEFUN (no_neighbor_weight
,
6979 no_neighbor_weight_cmd
,
6980 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6984 "Set default weight for routes from this neighbor\n"
6988 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6989 bgp_node_afi(vty
), bgp_node_safi(vty
));
6992 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6993 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6994 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6995 "Set default weight for routes from this neighbor\n"
6999 /* Override capability negotiation. */
7000 DEFUN (neighbor_override_capability
,
7001 neighbor_override_capability_cmd
,
7002 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7005 "Override capability negotiation result\n")
7008 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7009 PEER_FLAG_OVERRIDE_CAPABILITY
);
7012 DEFUN (no_neighbor_override_capability
,
7013 no_neighbor_override_capability_cmd
,
7014 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7018 "Override capability negotiation result\n")
7021 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7022 PEER_FLAG_OVERRIDE_CAPABILITY
);
7025 DEFUN (neighbor_strict_capability
,
7026 neighbor_strict_capability_cmd
,
7027 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7030 "Strict capability negotiation match\n")
7034 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7035 PEER_FLAG_STRICT_CAP_MATCH
);
7038 DEFUN (no_neighbor_strict_capability
,
7039 no_neighbor_strict_capability_cmd
,
7040 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7044 "Strict capability negotiation match\n")
7048 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7049 PEER_FLAG_STRICT_CAP_MATCH
);
7052 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7053 const char *keep_str
, const char *hold_str
)
7060 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7062 return CMD_WARNING_CONFIG_FAILED
;
7064 keepalive
= strtoul(keep_str
, NULL
, 10);
7065 holdtime
= strtoul(hold_str
, NULL
, 10);
7067 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7069 return bgp_vty_return(vty
, ret
);
7072 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7077 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7079 return CMD_WARNING_CONFIG_FAILED
;
7081 ret
= peer_timers_unset(peer
);
7083 return bgp_vty_return(vty
, ret
);
7086 DEFUN (neighbor_timers
,
7087 neighbor_timers_cmd
,
7088 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7091 "BGP per neighbor timers\n"
7092 "Keepalive interval\n"
7097 int idx_number_2
= 4;
7098 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7099 argv
[idx_number
]->arg
,
7100 argv
[idx_number_2
]->arg
);
7103 DEFUN (no_neighbor_timers
,
7104 no_neighbor_timers_cmd
,
7105 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7109 "BGP per neighbor timers\n"
7110 "Keepalive interval\n"
7114 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7118 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7119 const char *time_str
)
7125 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7127 return CMD_WARNING_CONFIG_FAILED
;
7129 connect
= strtoul(time_str
, NULL
, 10);
7131 ret
= peer_timers_connect_set(peer
, connect
);
7133 return bgp_vty_return(vty
, ret
);
7136 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7141 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7143 return CMD_WARNING_CONFIG_FAILED
;
7145 ret
= peer_timers_connect_unset(peer
);
7147 return bgp_vty_return(vty
, ret
);
7150 DEFUN (neighbor_timers_connect
,
7151 neighbor_timers_connect_cmd
,
7152 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7155 "BGP per neighbor timers\n"
7156 "BGP connect timer\n"
7161 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7162 argv
[idx_number
]->arg
);
7165 DEFUN (no_neighbor_timers_connect
,
7166 no_neighbor_timers_connect_cmd
,
7167 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7171 "BGP per neighbor timers\n"
7172 "BGP connect timer\n"
7176 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7179 DEFPY (neighbor_timers_delayopen
,
7180 neighbor_timers_delayopen_cmd
,
7181 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7184 "BGP per neighbor timers\n"
7185 "RFC 4271 DelayOpenTimer\n"
7186 "DelayOpenTime timer interval\n")
7190 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7192 return CMD_WARNING_CONFIG_FAILED
;
7195 if (peer_timers_delayopen_unset(peer
))
7196 return CMD_WARNING_CONFIG_FAILED
;
7198 if (peer_timers_delayopen_set(peer
, interval
))
7199 return CMD_WARNING_CONFIG_FAILED
;
7205 DEFPY (no_neighbor_timers_delayopen
,
7206 no_neighbor_timers_delayopen_cmd
,
7207 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7211 "BGP per neighbor timers\n"
7212 "RFC 4271 DelayOpenTimer\n"
7213 "DelayOpenTime timer interval\n")
7217 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7219 return CMD_WARNING_CONFIG_FAILED
;
7221 if (peer_timers_delayopen_unset(peer
))
7222 return CMD_WARNING_CONFIG_FAILED
;
7227 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7228 const char *time_str
, int set
)
7232 uint32_t routeadv
= 0;
7234 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7236 return CMD_WARNING_CONFIG_FAILED
;
7239 routeadv
= strtoul(time_str
, NULL
, 10);
7242 ret
= peer_advertise_interval_set(peer
, routeadv
);
7244 ret
= peer_advertise_interval_unset(peer
);
7246 return bgp_vty_return(vty
, ret
);
7249 DEFUN (neighbor_advertise_interval
,
7250 neighbor_advertise_interval_cmd
,
7251 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7254 "Minimum interval between sending BGP routing updates\n"
7255 "time in seconds\n")
7259 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7260 argv
[idx_number
]->arg
, 1);
7263 DEFUN (no_neighbor_advertise_interval
,
7264 no_neighbor_advertise_interval_cmd
,
7265 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7269 "Minimum interval between sending BGP routing updates\n"
7270 "time in seconds\n")
7273 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7277 /* Time to wait before processing route-map updates */
7278 DEFUN (bgp_set_route_map_delay_timer
,
7279 bgp_set_route_map_delay_timer_cmd
,
7280 "bgp route-map delay-timer (0-600)",
7282 "BGP route-map delay timer\n"
7283 "Time in secs to wait before processing route-map changes\n"
7284 "0 disables the timer, no route updates happen when route-maps change\n")
7287 uint32_t rmap_delay_timer
;
7289 if (argv
[idx_number
]->arg
) {
7290 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7291 bm
->rmap_update_timer
= rmap_delay_timer
;
7293 /* if the dynamic update handling is being disabled, and a timer
7295 * running, stop the timer and act as if the timer has already
7298 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7299 THREAD_OFF(bm
->t_rmap_update
);
7300 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7305 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7306 return CMD_WARNING_CONFIG_FAILED
;
7310 DEFUN (no_bgp_set_route_map_delay_timer
,
7311 no_bgp_set_route_map_delay_timer_cmd
,
7312 "no bgp route-map delay-timer [(0-600)]",
7315 "Default BGP route-map delay timer\n"
7316 "Reset to default time to wait for processing route-map changes\n"
7317 "0 disables the timer, no route updates happen when route-maps change\n")
7320 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7325 /* neighbor interface */
7326 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7331 peer
= peer_lookup_vty(vty
, ip_str
);
7332 if (!peer
|| peer
->conf_if
) {
7333 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7334 return CMD_WARNING_CONFIG_FAILED
;
7338 peer_interface_set(peer
, str
);
7340 peer_interface_unset(peer
);
7345 DEFUN (neighbor_interface
,
7346 neighbor_interface_cmd
,
7347 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7356 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7359 DEFUN (no_neighbor_interface
,
7360 no_neighbor_interface_cmd
,
7361 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7370 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7373 DEFUN (neighbor_distribute_list
,
7374 neighbor_distribute_list_cmd
,
7375 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7378 "Filter updates to/from this neighbor\n"
7379 "IP Access-list name\n"
7380 "Filter incoming updates\n"
7381 "Filter outgoing updates\n")
7388 const char *pstr
= argv
[idx_peer
]->arg
;
7389 const char *acl
= argv
[idx_acl
]->arg
;
7390 const char *inout
= argv
[argc
- 1]->text
;
7392 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7394 return CMD_WARNING_CONFIG_FAILED
;
7396 /* Check filter direction. */
7397 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7398 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7401 return bgp_vty_return(vty
, ret
);
7405 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7406 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7407 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7408 "Filter updates to/from this neighbor\n"
7409 "IP Access-list name\n"
7410 "Filter incoming updates\n"
7411 "Filter outgoing updates\n")
7413 DEFUN (no_neighbor_distribute_list
,
7414 no_neighbor_distribute_list_cmd
,
7415 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7419 "Filter updates to/from this neighbor\n"
7420 "IP Access-list name\n"
7421 "Filter incoming updates\n"
7422 "Filter outgoing updates\n")
7428 const char *pstr
= argv
[idx_peer
]->arg
;
7429 const char *inout
= argv
[argc
- 1]->text
;
7431 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7433 return CMD_WARNING_CONFIG_FAILED
;
7435 /* Check filter direction. */
7436 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7437 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7440 return bgp_vty_return(vty
, ret
);
7444 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7445 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7446 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7447 "Filter updates to/from this neighbor\n"
7448 "IP Access-list name\n"
7449 "Filter incoming updates\n"
7450 "Filter outgoing updates\n")
7452 /* Set prefix list to the peer. */
7453 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7454 afi_t afi
, safi_t safi
,
7455 const char *name_str
,
7456 const char *direct_str
)
7459 int direct
= FILTER_IN
;
7462 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7464 return CMD_WARNING_CONFIG_FAILED
;
7466 /* Check filter direction. */
7467 if (strncmp(direct_str
, "i", 1) == 0)
7469 else if (strncmp(direct_str
, "o", 1) == 0)
7470 direct
= FILTER_OUT
;
7472 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7474 return bgp_vty_return(vty
, ret
);
7477 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7478 afi_t afi
, safi_t safi
,
7479 const char *direct_str
)
7483 int direct
= FILTER_IN
;
7485 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7487 return CMD_WARNING_CONFIG_FAILED
;
7489 /* Check filter direction. */
7490 if (strncmp(direct_str
, "i", 1) == 0)
7492 else if (strncmp(direct_str
, "o", 1) == 0)
7493 direct
= FILTER_OUT
;
7495 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7497 return bgp_vty_return(vty
, ret
);
7500 DEFUN (neighbor_prefix_list
,
7501 neighbor_prefix_list_cmd
,
7502 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7505 "Filter updates to/from this neighbor\n"
7506 "Name of a prefix list\n"
7507 "Filter incoming updates\n"
7508 "Filter outgoing updates\n")
7513 return peer_prefix_list_set_vty(
7514 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7515 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7518 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7519 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7520 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7521 "Filter updates to/from this neighbor\n"
7522 "Name of a prefix list\n"
7523 "Filter incoming updates\n"
7524 "Filter outgoing updates\n")
7526 DEFUN (no_neighbor_prefix_list
,
7527 no_neighbor_prefix_list_cmd
,
7528 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7532 "Filter updates to/from this neighbor\n"
7533 "Name of a prefix list\n"
7534 "Filter incoming updates\n"
7535 "Filter outgoing updates\n")
7539 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7540 bgp_node_afi(vty
), bgp_node_safi(vty
),
7541 argv
[idx_in_out
]->arg
);
7544 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7545 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7546 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7547 "Filter updates to/from this neighbor\n"
7548 "Name of a prefix list\n"
7549 "Filter incoming updates\n"
7550 "Filter outgoing updates\n")
7552 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7553 safi_t safi
, const char *name_str
,
7554 const char *direct_str
)
7558 int direct
= FILTER_IN
;
7560 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7562 return CMD_WARNING_CONFIG_FAILED
;
7564 /* Check filter direction. */
7565 if (strncmp(direct_str
, "i", 1) == 0)
7567 else if (strncmp(direct_str
, "o", 1) == 0)
7568 direct
= FILTER_OUT
;
7570 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7572 return bgp_vty_return(vty
, ret
);
7575 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7576 safi_t safi
, const char *direct_str
)
7580 int direct
= FILTER_IN
;
7582 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7584 return CMD_WARNING_CONFIG_FAILED
;
7586 /* Check filter direction. */
7587 if (strncmp(direct_str
, "i", 1) == 0)
7589 else if (strncmp(direct_str
, "o", 1) == 0)
7590 direct
= FILTER_OUT
;
7592 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7594 return bgp_vty_return(vty
, ret
);
7597 DEFUN (neighbor_filter_list
,
7598 neighbor_filter_list_cmd
,
7599 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7602 "Establish BGP filters\n"
7603 "AS path access-list name\n"
7604 "Filter incoming routes\n"
7605 "Filter outgoing routes\n")
7610 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7611 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7612 argv
[idx_in_out
]->arg
);
7615 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7616 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7617 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7618 "Establish BGP filters\n"
7619 "AS path access-list name\n"
7620 "Filter incoming routes\n"
7621 "Filter outgoing routes\n")
7623 DEFUN (no_neighbor_filter_list
,
7624 no_neighbor_filter_list_cmd
,
7625 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7629 "Establish BGP filters\n"
7630 "AS path access-list name\n"
7631 "Filter incoming routes\n"
7632 "Filter outgoing routes\n")
7636 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7637 bgp_node_afi(vty
), bgp_node_safi(vty
),
7638 argv
[idx_in_out
]->arg
);
7641 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7642 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7643 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7644 "Establish BGP filters\n"
7645 "AS path access-list name\n"
7646 "Filter incoming routes\n"
7647 "Filter outgoing routes\n")
7649 /* Set advertise-map to the peer. */
7650 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7651 afi_t afi
, safi_t safi
,
7652 const char *advertise_str
,
7653 const char *condition_str
, bool condition
,
7656 int ret
= CMD_WARNING_CONFIG_FAILED
;
7658 struct route_map
*advertise_map
;
7659 struct route_map
*condition_map
;
7661 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7665 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7666 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7669 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7670 advertise_map
, condition_str
,
7671 condition_map
, condition
);
7673 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7674 advertise_map
, condition_str
,
7675 condition_map
, condition
);
7677 return bgp_vty_return(vty
, ret
);
7680 DEFPY (bgp_condadv_period
,
7681 bgp_condadv_period_cmd
,
7682 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7685 "Conditional advertisement settings\n"
7686 "Set period to rescan BGP table to check if condition is met\n"
7687 "Period between BGP table scans, in seconds; default 60\n")
7689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7691 bgp
->condition_check_period
=
7692 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7697 DEFPY (neighbor_advertise_map
,
7698 neighbor_advertise_map_cmd
,
7699 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7703 "Route-map to conditionally advertise routes\n"
7704 "Name of advertise map\n"
7705 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7706 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7707 "Name of the exist or non exist map\n")
7709 bool condition
= CONDITION_EXIST
;
7711 if (!strcmp(exist
, "non-exist-map"))
7712 condition
= CONDITION_NON_EXIST
;
7714 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7715 bgp_node_safi(vty
), advertise_str
,
7716 condition_str
, condition
, !no
);
7719 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7720 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7721 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7722 "Route-map to conditionally advertise routes\n"
7723 "Name of advertise map\n"
7724 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7725 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7726 "Name of the exist or non exist map\n")
7728 /* Set route-map to the peer. */
7729 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7730 afi_t afi
, safi_t safi
, const char *name_str
,
7731 const char *direct_str
)
7735 int direct
= RMAP_IN
;
7736 struct route_map
*route_map
;
7738 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7740 return CMD_WARNING_CONFIG_FAILED
;
7742 /* Check filter direction. */
7743 if (strncmp(direct_str
, "in", 2) == 0)
7745 else if (strncmp(direct_str
, "o", 1) == 0)
7748 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7749 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7751 return bgp_vty_return(vty
, ret
);
7754 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7755 afi_t afi
, safi_t safi
,
7756 const char *direct_str
)
7760 int direct
= RMAP_IN
;
7762 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7764 return CMD_WARNING_CONFIG_FAILED
;
7766 /* Check filter direction. */
7767 if (strncmp(direct_str
, "in", 2) == 0)
7769 else if (strncmp(direct_str
, "o", 1) == 0)
7772 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7774 return bgp_vty_return(vty
, ret
);
7777 DEFUN (neighbor_route_map
,
7778 neighbor_route_map_cmd
,
7779 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7782 "Apply route map to neighbor\n"
7783 "Name of route map\n"
7784 "Apply map to incoming routes\n"
7785 "Apply map to outbound routes\n")
7790 return peer_route_map_set_vty(
7791 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7792 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7795 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7796 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7797 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7798 "Apply route map to neighbor\n"
7799 "Name of route map\n"
7800 "Apply map to incoming routes\n"
7801 "Apply map to outbound routes\n")
7803 DEFUN (no_neighbor_route_map
,
7804 no_neighbor_route_map_cmd
,
7805 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7809 "Apply route map to neighbor\n"
7810 "Name of route map\n"
7811 "Apply map to incoming routes\n"
7812 "Apply map to outbound routes\n")
7816 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7817 bgp_node_afi(vty
), bgp_node_safi(vty
),
7818 argv
[idx_in_out
]->arg
);
7821 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7822 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7823 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7824 "Apply route map to neighbor\n"
7825 "Name of route map\n"
7826 "Apply map to incoming routes\n"
7827 "Apply map to outbound routes\n")
7829 /* Set unsuppress-map to the peer. */
7830 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7831 afi_t afi
, safi_t safi
,
7832 const char *name_str
)
7836 struct route_map
*route_map
;
7838 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7840 return CMD_WARNING_CONFIG_FAILED
;
7842 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7843 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7845 return bgp_vty_return(vty
, ret
);
7848 /* Unset route-map from the peer. */
7849 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7850 afi_t afi
, safi_t safi
)
7855 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7857 return CMD_WARNING_CONFIG_FAILED
;
7859 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7861 return bgp_vty_return(vty
, ret
);
7864 DEFUN (neighbor_unsuppress_map
,
7865 neighbor_unsuppress_map_cmd
,
7866 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7869 "Route-map to selectively unsuppress suppressed routes\n"
7870 "Name of route map\n")
7874 return peer_unsuppress_map_set_vty(
7875 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7876 argv
[idx_word
]->arg
);
7879 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7880 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7882 "Route-map to selectively unsuppress suppressed routes\n"
7883 "Name of route map\n")
7885 DEFUN (no_neighbor_unsuppress_map
,
7886 no_neighbor_unsuppress_map_cmd
,
7887 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7891 "Route-map to selectively unsuppress suppressed routes\n"
7892 "Name of route map\n")
7895 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7897 bgp_node_safi(vty
));
7900 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7901 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7902 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7903 "Route-map to selectively unsuppress suppressed routes\n"
7904 "Name of route map\n")
7906 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7907 afi_t afi
, safi_t safi
,
7908 const char *num_str
,
7909 const char *threshold_str
, int warning
,
7910 const char *restart_str
,
7911 const char *force_str
)
7919 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7921 return CMD_WARNING_CONFIG_FAILED
;
7923 max
= strtoul(num_str
, NULL
, 10);
7925 threshold
= atoi(threshold_str
);
7927 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7930 restart
= atoi(restart_str
);
7934 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7935 restart
, force_str
? true : false);
7937 return bgp_vty_return(vty
, ret
);
7940 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7941 afi_t afi
, safi_t safi
)
7946 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7948 return CMD_WARNING_CONFIG_FAILED
;
7950 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7952 return bgp_vty_return(vty
, ret
);
7955 /* Maximum number of prefix to be sent to the neighbor. */
7956 DEFUN(neighbor_maximum_prefix_out
,
7957 neighbor_maximum_prefix_out_cmd
,
7958 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7961 "Maximum number of prefixes to be sent to this peer\n"
7962 "Maximum no. of prefix limit\n")
7969 afi_t afi
= bgp_node_afi(vty
);
7970 safi_t safi
= bgp_node_safi(vty
);
7972 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7974 return CMD_WARNING_CONFIG_FAILED
;
7976 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7978 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
7980 return bgp_vty_return(vty
, ret
);
7983 DEFUN(no_neighbor_maximum_prefix_out
,
7984 no_neighbor_maximum_prefix_out_cmd
,
7985 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
7989 "Maximum number of prefixes to be sent to this peer\n"
7990 "Maximum no. of prefix limit\n")
7995 afi_t afi
= bgp_node_afi(vty
);
7996 safi_t safi
= bgp_node_safi(vty
);
7998 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8000 return CMD_WARNING_CONFIG_FAILED
;
8002 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8004 return bgp_vty_return(vty
, ret
);
8007 /* Maximum number of prefix configuration. Prefix count is different
8008 for each peer configuration. So this configuration can be set for
8009 each peer configuration. */
8010 DEFUN (neighbor_maximum_prefix
,
8011 neighbor_maximum_prefix_cmd
,
8012 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8015 "Maximum number of prefix accept from this peer\n"
8016 "maximum no. of prefix limit\n"
8017 "Force checking all received routes not only accepted\n")
8024 if (argv_find(argv
, argc
, "force", &idx_force
))
8025 force
= argv
[idx_force
]->arg
;
8027 return peer_maximum_prefix_set_vty(
8028 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8029 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8032 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8033 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8034 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8035 "Maximum number of prefix accept from this peer\n"
8036 "maximum no. of prefix limit\n"
8037 "Force checking all received routes not only accepted\n")
8039 DEFUN (neighbor_maximum_prefix_threshold
,
8040 neighbor_maximum_prefix_threshold_cmd
,
8041 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8044 "Maximum number of prefix accept from this peer\n"
8045 "maximum no. of prefix limit\n"
8046 "Threshold value (%) at which to generate a warning msg\n"
8047 "Force checking all received routes not only accepted\n")
8051 int idx_number_2
= 4;
8055 if (argv_find(argv
, argc
, "force", &idx_force
))
8056 force
= argv
[idx_force
]->arg
;
8058 return peer_maximum_prefix_set_vty(
8059 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8060 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8064 neighbor_maximum_prefix_threshold
,
8065 neighbor_maximum_prefix_threshold_hidden_cmd
,
8066 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8067 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8068 "Maximum number of prefix accept from this peer\n"
8069 "maximum no. of prefix limit\n"
8070 "Threshold value (%) at which to generate a warning msg\n"
8071 "Force checking all received routes not only accepted\n")
8073 DEFUN (neighbor_maximum_prefix_warning
,
8074 neighbor_maximum_prefix_warning_cmd
,
8075 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8078 "Maximum number of prefix accept from this peer\n"
8079 "maximum no. of prefix limit\n"
8080 "Only give warning message when limit is exceeded\n"
8081 "Force checking all received routes not only accepted\n")
8088 if (argv_find(argv
, argc
, "force", &idx_force
))
8089 force
= argv
[idx_force
]->arg
;
8091 return peer_maximum_prefix_set_vty(
8092 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8093 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8097 neighbor_maximum_prefix_warning
,
8098 neighbor_maximum_prefix_warning_hidden_cmd
,
8099 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8100 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8101 "Maximum number of prefix accept from this peer\n"
8102 "maximum no. of prefix limit\n"
8103 "Only give warning message when limit is exceeded\n"
8104 "Force checking all received routes not only accepted\n")
8106 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8107 neighbor_maximum_prefix_threshold_warning_cmd
,
8108 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8111 "Maximum number of prefix accept from this peer\n"
8112 "maximum no. of prefix limit\n"
8113 "Threshold value (%) at which to generate a warning msg\n"
8114 "Only give warning message when limit is exceeded\n"
8115 "Force checking all received routes not only accepted\n")
8119 int idx_number_2
= 4;
8123 if (argv_find(argv
, argc
, "force", &idx_force
))
8124 force
= argv
[idx_force
]->arg
;
8126 return peer_maximum_prefix_set_vty(
8127 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8128 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8132 neighbor_maximum_prefix_threshold_warning
,
8133 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8134 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8135 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8136 "Maximum number of prefix accept from this peer\n"
8137 "maximum no. of prefix limit\n"
8138 "Threshold value (%) at which to generate a warning msg\n"
8139 "Only give warning message when limit is exceeded\n"
8140 "Force checking all received routes not only accepted\n")
8142 DEFUN (neighbor_maximum_prefix_restart
,
8143 neighbor_maximum_prefix_restart_cmd
,
8144 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8147 "Maximum number of prefix accept from this peer\n"
8148 "maximum no. of prefix limit\n"
8149 "Restart bgp connection after limit is exceeded\n"
8150 "Restart interval in minutes\n"
8151 "Force checking all received routes not only accepted\n")
8155 int idx_number_2
= 5;
8159 if (argv_find(argv
, argc
, "force", &idx_force
))
8160 force
= argv
[idx_force
]->arg
;
8162 return peer_maximum_prefix_set_vty(
8163 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8164 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8168 neighbor_maximum_prefix_restart
,
8169 neighbor_maximum_prefix_restart_hidden_cmd
,
8170 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8171 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8172 "Maximum number of prefix accept from this peer\n"
8173 "maximum no. of prefix limit\n"
8174 "Restart bgp connection after limit is exceeded\n"
8175 "Restart interval in minutes\n"
8176 "Force checking all received routes not only accepted\n")
8178 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8179 neighbor_maximum_prefix_threshold_restart_cmd
,
8180 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8183 "Maximum number of prefixes to accept from this peer\n"
8184 "maximum no. of prefix limit\n"
8185 "Threshold value (%) at which to generate a warning msg\n"
8186 "Restart bgp connection after limit is exceeded\n"
8187 "Restart interval in minutes\n"
8188 "Force checking all received routes not only accepted\n")
8192 int idx_number_2
= 4;
8193 int idx_number_3
= 6;
8197 if (argv_find(argv
, argc
, "force", &idx_force
))
8198 force
= argv
[idx_force
]->arg
;
8200 return peer_maximum_prefix_set_vty(
8201 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8202 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8203 argv
[idx_number_3
]->arg
, force
);
8207 neighbor_maximum_prefix_threshold_restart
,
8208 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8209 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8210 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8211 "Maximum number of prefixes to accept from this peer\n"
8212 "maximum no. of prefix limit\n"
8213 "Threshold value (%) at which to generate a warning msg\n"
8214 "Restart bgp connection after limit is exceeded\n"
8215 "Restart interval in minutes\n"
8216 "Force checking all received routes not only accepted\n")
8218 DEFUN (no_neighbor_maximum_prefix
,
8219 no_neighbor_maximum_prefix_cmd
,
8220 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8224 "Maximum number of prefixes to accept from this peer\n"
8225 "maximum no. of prefix limit\n"
8226 "Threshold value (%) at which to generate a warning msg\n"
8227 "Restart bgp connection after limit is exceeded\n"
8228 "Restart interval in minutes\n"
8229 "Only give warning message when limit is exceeded\n"
8230 "Force checking all received routes not only accepted\n")
8233 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8235 bgp_node_safi(vty
));
8239 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8240 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8241 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8242 "Maximum number of prefixes to accept from this peer\n"
8243 "maximum no. of prefix limit\n"
8244 "Threshold value (%) at which to generate a warning msg\n"
8245 "Restart bgp connection after limit is exceeded\n"
8246 "Restart interval in minutes\n"
8247 "Only give warning message when limit is exceeded\n"
8248 "Force checking all received routes not only accepted\n")
8250 /* "neighbor soo" */
8251 DEFPY (neighbor_soo
,
8253 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8256 "Set the Site-of-Origin (SoO) extended community\n"
8257 "VPN extended community\n")
8260 afi_t afi
= bgp_node_afi(vty
);
8261 safi_t safi
= bgp_node_safi(vty
);
8262 struct ecommunity
*ecomm_soo
;
8264 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8266 return CMD_WARNING_CONFIG_FAILED
;
8268 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8270 vty_out(vty
, "%% Malformed SoO extended community\n");
8273 ecommunity_str(ecomm_soo
);
8275 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8276 ecommunity_free(&peer
->soo
[afi
][safi
]);
8277 peer
->soo
[afi
][safi
] = ecomm_soo
;
8278 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8281 return bgp_vty_return(vty
,
8282 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8285 DEFPY (no_neighbor_soo
,
8286 no_neighbor_soo_cmd
,
8287 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8291 "Set the Site-of-Origin (SoO) extended community\n"
8292 "VPN extended community\n")
8295 afi_t afi
= bgp_node_afi(vty
);
8296 safi_t safi
= bgp_node_safi(vty
);
8298 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8300 return CMD_WARNING_CONFIG_FAILED
;
8302 ecommunity_free(&peer
->soo
[afi
][safi
]);
8304 return bgp_vty_return(
8305 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8308 /* "neighbor allowas-in" */
8309 DEFUN (neighbor_allowas_in
,
8310 neighbor_allowas_in_cmd
,
8311 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8314 "Accept as-path with my AS present in it\n"
8315 "Number of occurrences of AS number\n"
8316 "Only accept my AS in the as-path if the route was originated in my AS\n")
8319 int idx_number_origin
= 3;
8325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8327 return CMD_WARNING_CONFIG_FAILED
;
8329 if (argc
<= idx_number_origin
)
8332 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8335 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8338 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8341 return bgp_vty_return(vty
, ret
);
8345 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8346 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8347 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8348 "Accept as-path with my AS present in it\n"
8349 "Number of occurrences of AS number\n"
8350 "Only accept my AS in the as-path if the route was originated in my AS\n")
8352 DEFUN (no_neighbor_allowas_in
,
8353 no_neighbor_allowas_in_cmd
,
8354 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8358 "allow local ASN appears in aspath attribute\n"
8359 "Number of occurrences of AS number\n"
8360 "Only accept my AS in the as-path if the route was originated in my AS\n")
8366 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8368 return CMD_WARNING_CONFIG_FAILED
;
8370 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8371 bgp_node_safi(vty
));
8373 return bgp_vty_return(vty
, ret
);
8377 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8378 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8379 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8380 "allow local ASN appears in aspath attribute\n"
8381 "Number of occurrences of AS number\n"
8382 "Only accept my AS in the as-path if the route was originated in my AS\n")
8384 DEFUN (neighbor_ttl_security
,
8385 neighbor_ttl_security_cmd
,
8386 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8389 "BGP ttl-security parameters\n"
8390 "Specify the maximum number of hops to the BGP peer\n"
8391 "Number of hops to BGP peer\n")
8398 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8400 return CMD_WARNING_CONFIG_FAILED
;
8402 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8405 * If 'neighbor swpX', then this is for directly connected peers,
8406 * we should not accept a ttl-security hops value greater than 1.
8408 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8410 "%s is directly connected peer, hops cannot exceed 1\n",
8411 argv
[idx_peer
]->arg
);
8412 return CMD_WARNING_CONFIG_FAILED
;
8415 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8418 DEFUN (no_neighbor_ttl_security
,
8419 no_neighbor_ttl_security_cmd
,
8420 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8424 "BGP ttl-security parameters\n"
8425 "Specify the maximum number of hops to the BGP peer\n"
8426 "Number of hops to BGP peer\n")
8431 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8433 return CMD_WARNING_CONFIG_FAILED
;
8435 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8438 /* disable-addpath-rx */
8439 DEFUN(neighbor_disable_addpath_rx
,
8440 neighbor_disable_addpath_rx_cmd
,
8441 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8444 "Do not accept additional paths\n")
8446 char *peer_str
= argv
[1]->arg
;
8448 afi_t afi
= bgp_node_afi(vty
);
8449 safi_t safi
= bgp_node_safi(vty
);
8451 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8453 return CMD_WARNING_CONFIG_FAILED
;
8455 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8456 PEER_FLAG_DISABLE_ADDPATH_RX
);
8459 DEFUN(no_neighbor_disable_addpath_rx
,
8460 no_neighbor_disable_addpath_rx_cmd
,
8461 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8465 "Do not accept additional paths\n")
8467 char *peer_str
= argv
[2]->arg
;
8469 afi_t afi
= bgp_node_afi(vty
);
8470 safi_t safi
= bgp_node_safi(vty
);
8472 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8474 return CMD_WARNING_CONFIG_FAILED
;
8476 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8477 PEER_FLAG_DISABLE_ADDPATH_RX
);
8480 DEFUN (neighbor_addpath_tx_all_paths
,
8481 neighbor_addpath_tx_all_paths_cmd
,
8482 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8485 "Use addpath to advertise all paths to a neighbor\n")
8490 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8492 return CMD_WARNING_CONFIG_FAILED
;
8494 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8499 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8500 neighbor_addpath_tx_all_paths_hidden_cmd
,
8501 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8502 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8503 "Use addpath to advertise all paths to a neighbor\n")
8505 DEFUN (no_neighbor_addpath_tx_all_paths
,
8506 no_neighbor_addpath_tx_all_paths_cmd
,
8507 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8511 "Use addpath to advertise all paths to a neighbor\n")
8516 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8518 return CMD_WARNING_CONFIG_FAILED
;
8520 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8521 != BGP_ADDPATH_ALL
) {
8523 "%% Peer not currently configured to transmit all paths.");
8524 return CMD_WARNING_CONFIG_FAILED
;
8527 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8533 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8534 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8535 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8536 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8537 "Use addpath to advertise all paths to a neighbor\n")
8539 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8540 neighbor_addpath_tx_bestpath_per_as_cmd
,
8541 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8544 "Use addpath to advertise the bestpath per each neighboring AS\n")
8549 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8551 return CMD_WARNING_CONFIG_FAILED
;
8553 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8554 BGP_ADDPATH_BEST_PER_AS
);
8559 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8560 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8561 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8562 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8563 "Use addpath to advertise the bestpath per each neighboring AS\n")
8565 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8566 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8567 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8571 "Use addpath to advertise the bestpath per each neighboring AS\n")
8576 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8578 return CMD_WARNING_CONFIG_FAILED
;
8580 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8581 != BGP_ADDPATH_BEST_PER_AS
) {
8583 "%% Peer not currently configured to transmit all best path per as.");
8584 return CMD_WARNING_CONFIG_FAILED
;
8587 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8593 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8594 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8595 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8596 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8597 "Use addpath to advertise the bestpath per each neighboring AS\n")
8600 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8601 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8604 "Detect AS loops before sending to neighbor\n")
8608 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8610 return CMD_WARNING_CONFIG_FAILED
;
8612 peer
->as_path_loop_detection
= true;
8618 no_neighbor_aspath_loop_detection
,
8619 no_neighbor_aspath_loop_detection_cmd
,
8620 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8624 "Detect AS loops before sending to neighbor\n")
8628 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8630 return CMD_WARNING_CONFIG_FAILED
;
8632 peer
->as_path_loop_detection
= false;
8637 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8638 struct ecommunity
**list
, bool is_rt6
)
8640 struct ecommunity
*ecom
= NULL
;
8641 struct ecommunity
*ecomadd
;
8643 for (; argc
; --argc
, ++argv
) {
8645 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8646 ECOMMUNITY_ROUTE_TARGET
,
8649 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8650 ECOMMUNITY_ROUTE_TARGET
,
8653 vty_out(vty
, "Malformed community-list value\n");
8655 ecommunity_free(&ecom
);
8656 return CMD_WARNING_CONFIG_FAILED
;
8660 ecommunity_merge(ecom
, ecomadd
);
8661 ecommunity_free(&ecomadd
);
8668 ecommunity_free(&*list
);
8676 * v2vimport is true if we are handling a `import vrf ...` command
8678 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8682 switch (vty
->node
) {
8691 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8696 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8697 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8698 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8699 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8701 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8705 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8706 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8707 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8708 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8710 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8717 DEFPY (af_rd_vpn_export
,
8718 af_rd_vpn_export_cmd
,
8719 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8721 "Specify route distinguisher\n"
8722 "Between current address-family and vpn\n"
8723 "For routes leaked from current address-family to vpn\n"
8724 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8727 struct prefix_rd prd
;
8733 if (argv_find(argv
, argc
, "no", &idx
))
8737 ret
= str2prefix_rd(rd_str
, &prd
);
8739 vty_out(vty
, "%% Malformed rd\n");
8740 return CMD_WARNING_CONFIG_FAILED
;
8744 afi
= vpn_policy_getafi(vty
, bgp
, false);
8746 return CMD_WARNING_CONFIG_FAILED
;
8749 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8751 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8752 bgp_get_default(), bgp
);
8755 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8756 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8757 BGP_VPN_POLICY_TOVPN_RD_SET
);
8759 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8760 BGP_VPN_POLICY_TOVPN_RD_SET
);
8763 /* post-change: re-export vpn routes */
8764 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8765 bgp_get_default(), bgp
);
8770 ALIAS (af_rd_vpn_export
,
8771 af_no_rd_vpn_export_cmd
,
8774 "Specify route distinguisher\n"
8775 "Between current address-family and vpn\n"
8776 "For routes leaked from current address-family to vpn\n")
8778 DEFPY (af_label_vpn_export
,
8779 af_label_vpn_export_cmd
,
8780 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8782 "label value for VRF\n"
8783 "Between current address-family and vpn\n"
8784 "For routes leaked from current address-family to vpn\n"
8785 "Label Value <0-1048575>\n"
8786 "Automatically assign a label\n")
8788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8789 mpls_label_t label
= MPLS_LABEL_NONE
;
8794 if (argv_find(argv
, argc
, "no", &idx
))
8797 /* If "no ...", squash trailing parameter */
8803 label
= label_val
; /* parser should force unsigned */
8806 afi
= vpn_policy_getafi(vty
, bgp
, false);
8808 return CMD_WARNING_CONFIG_FAILED
;
8811 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8812 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8817 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8819 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8820 bgp_get_default(), bgp
);
8822 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8823 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8825 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8828 * label has previously been automatically
8829 * assigned by labelpool: release it
8831 * NB if tovpn_label == MPLS_LABEL_NONE it
8832 * means the automatic assignment is in flight
8833 * and therefore the labelpool callback must
8834 * detect that the auto label is not needed.
8837 bgp_lp_release(LP_TYPE_VRF
,
8838 &bgp
->vpn_policy
[afi
],
8839 bgp
->vpn_policy
[afi
].tovpn_label
);
8841 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8842 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8845 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8847 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8848 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8849 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8850 vpn_leak_label_callback
);
8853 /* post-change: re-export vpn routes */
8854 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8855 bgp_get_default(), bgp
);
8857 hook_call(bgp_snmp_update_last_changed
, bgp
);
8861 DEFPY (af_sid_vpn_export
,
8862 af_sid_vpn_export_cmd
,
8863 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8865 "sid value for VRF\n"
8866 "Between current address-family and vpn\n"
8867 "For routes leaked from current address-family to vpn\n"
8868 "Sid allocation index\n"
8869 "Automatically assign a label\n")
8871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8877 if (argv_find(argv
, argc
, "no", &idx
))
8879 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8880 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8882 afi
= vpn_policy_getafi(vty
, bgp
, false);
8884 return CMD_WARNING_CONFIG_FAILED
;
8888 vty_out(vty
, "It's not implemented\n");
8889 return CMD_WARNING_CONFIG_FAILED
;
8892 /* skip when it's already configured */
8893 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8894 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8895 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8899 * mode change between sid_idx and sid_auto isn't supported.
8900 * user must negate sid vpn export when they want to change the mode
8902 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8903 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8904 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8905 vty_out(vty
, "it's already configured as %s.\n",
8906 sid_auto
? "auto-mode" : "idx-mode");
8907 return CMD_WARNING_CONFIG_FAILED
;
8911 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8912 bgp_get_default(), bgp
);
8915 /* SID allocation auto-mode */
8917 zlog_debug("%s: auto sid alloc.", __func__
);
8918 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8919 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8921 /* SID allocation index-mode */
8923 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8924 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8928 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8929 bgp_get_default(), bgp
);
8933 ALIAS (af_label_vpn_export
,
8934 af_no_label_vpn_export_cmd
,
8935 "no label vpn export",
8937 "label value for VRF\n"
8938 "Between current address-family and vpn\n"
8939 "For routes leaked from current address-family to vpn\n")
8941 DEFPY (af_nexthop_vpn_export
,
8942 af_nexthop_vpn_export_cmd
,
8943 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8945 "Specify next hop to use for VRF advertised prefixes\n"
8946 "Between current address-family and vpn\n"
8947 "For routes leaked from current address-family to vpn\n"
8951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8957 vty_out(vty
, "%% Nexthop required\n");
8958 return CMD_WARNING_CONFIG_FAILED
;
8960 if (!sockunion2hostprefix(nexthop_su
, &p
))
8961 return CMD_WARNING_CONFIG_FAILED
;
8964 afi
= vpn_policy_getafi(vty
, bgp
, false);
8966 return CMD_WARNING_CONFIG_FAILED
;
8969 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8971 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8972 bgp_get_default(), bgp
);
8975 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8976 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8977 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8979 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8980 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8983 /* post-change: re-export vpn routes */
8984 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8985 bgp_get_default(), bgp
);
8990 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8992 if (!strcmp(dstr
, "import")) {
8993 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8994 } else if (!strcmp(dstr
, "export")) {
8995 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8996 } else if (!strcmp(dstr
, "both")) {
8997 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8998 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9000 vty_out(vty
, "%% direction parse error\n");
9001 return CMD_WARNING_CONFIG_FAILED
;
9006 DEFPY (af_rt_vpn_imexport
,
9007 af_rt_vpn_imexport_cmd
,
9008 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9010 "Specify route target list\n"
9011 "Specify route target list\n"
9012 "Between current address-family and vpn\n"
9013 "For routes leaked from vpn to current address-family: match any\n"
9014 "For routes leaked from current address-family to vpn: set\n"
9015 "both import: match any and export: set\n"
9016 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9020 struct ecommunity
*ecom
= NULL
;
9021 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9022 enum vpn_policy_direction dir
;
9027 if (argv_find(argv
, argc
, "no", &idx
))
9030 afi
= vpn_policy_getafi(vty
, bgp
, false);
9032 return CMD_WARNING_CONFIG_FAILED
;
9034 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9035 if (ret
!= CMD_SUCCESS
)
9039 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9040 vty_out(vty
, "%% Missing RTLIST\n");
9041 return CMD_WARNING_CONFIG_FAILED
;
9043 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9044 if (ret
!= CMD_SUCCESS
) {
9049 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9053 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9056 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9058 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9059 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9060 ecommunity_dup(ecom
);
9062 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9064 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9065 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9068 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9072 ecommunity_free(&ecom
);
9077 ALIAS (af_rt_vpn_imexport
,
9078 af_no_rt_vpn_imexport_cmd
,
9079 "no <rt|route-target> vpn <import|export|both>$direction_str",
9081 "Specify route target list\n"
9082 "Specify route target list\n"
9083 "Between current address-family and vpn\n"
9084 "For routes leaked from vpn to current address-family\n"
9085 "For routes leaked from current address-family to vpn\n"
9086 "both import and export\n")
9088 DEFPY (af_route_map_vpn_imexport
,
9089 af_route_map_vpn_imexport_cmd
,
9090 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9091 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9093 "Specify route map\n"
9094 "Between current address-family and vpn\n"
9095 "For routes leaked from vpn to current address-family\n"
9096 "For routes leaked from current address-family to vpn\n"
9097 "name of route-map\n")
9099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9101 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9102 enum vpn_policy_direction dir
;
9107 if (argv_find(argv
, argc
, "no", &idx
))
9110 afi
= vpn_policy_getafi(vty
, bgp
, false);
9112 return CMD_WARNING_CONFIG_FAILED
;
9114 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9115 if (ret
!= CMD_SUCCESS
)
9118 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9122 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9125 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9126 XFREE(MTYPE_ROUTE_MAP_NAME
,
9127 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9128 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9129 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9130 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9131 route_map_lookup_warn_noexist(vty
, rmap_str
);
9132 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9135 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9136 XFREE(MTYPE_ROUTE_MAP_NAME
,
9137 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9138 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9139 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9142 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9148 ALIAS (af_route_map_vpn_imexport
,
9149 af_no_route_map_vpn_imexport_cmd
,
9150 "no route-map vpn <import|export>$direction_str",
9152 "Specify route map\n"
9153 "Between current address-family and vpn\n"
9154 "For routes leaked from vpn to current address-family\n"
9155 "For routes leaked from current address-family to vpn\n")
9157 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9158 "import vrf route-map RMAP$rmap_str",
9159 "Import routes from another VRF\n"
9160 "Vrf routes being filtered\n"
9161 "Specify route map\n"
9162 "name of route-map\n")
9164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9165 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9167 struct bgp
*bgp_default
;
9169 afi
= vpn_policy_getafi(vty
, bgp
, true);
9171 return CMD_WARNING_CONFIG_FAILED
;
9173 bgp_default
= bgp_get_default();
9178 /* Auto-create assuming the same AS */
9179 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9180 BGP_INSTANCE_TYPE_DEFAULT
);
9184 "VRF default is not configured as a bgp instance\n");
9189 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9191 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9192 XFREE(MTYPE_ROUTE_MAP_NAME
,
9193 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9194 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9195 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9196 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9197 route_map_lookup_warn_noexist(vty
, rmap_str
);
9198 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9201 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9202 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9204 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9209 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9210 "no import vrf route-map [RMAP$rmap_str]",
9212 "Import routes from another VRF\n"
9213 "Vrf routes being filtered\n"
9214 "Specify route map\n"
9215 "name of route-map\n")
9217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9218 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9221 afi
= vpn_policy_getafi(vty
, bgp
, true);
9223 return CMD_WARNING_CONFIG_FAILED
;
9225 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9227 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9228 XFREE(MTYPE_ROUTE_MAP_NAME
,
9229 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9230 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9231 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9233 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9234 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9235 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9237 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9242 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9243 "[no] import vrf VIEWVRFNAME$import_name",
9245 "Import routes from another VRF\n"
9246 "VRF to import from\n"
9247 "The name of the VRF\n")
9249 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9250 struct listnode
*node
;
9251 struct bgp
*vrf_bgp
, *bgp_default
;
9254 bool remove
= false;
9257 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9261 if (import_name
== NULL
) {
9262 vty_out(vty
, "%% Missing import name\n");
9266 if (strcmp(import_name
, "route-map") == 0) {
9267 vty_out(vty
, "%% Must include route-map name\n");
9271 if (argv_find(argv
, argc
, "no", &idx
))
9274 afi
= vpn_policy_getafi(vty
, bgp
, true);
9276 return CMD_WARNING_CONFIG_FAILED
;
9278 safi
= bgp_node_safi(vty
);
9280 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9281 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9282 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9283 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9284 remove
? "unimport" : "import", import_name
);
9288 bgp_default
= bgp_get_default();
9290 /* Auto-create assuming the same AS */
9291 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9292 BGP_INSTANCE_TYPE_DEFAULT
);
9296 "VRF default is not configured as a bgp instance\n");
9301 vrf_bgp
= bgp_lookup_by_name(import_name
);
9303 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9304 vrf_bgp
= bgp_default
;
9306 /* Auto-create assuming the same AS */
9307 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9311 "VRF %s is not configured as a bgp instance\n",
9318 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9320 /* Already importing from "import_vrf"? */
9321 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9323 if (strcmp(vname
, import_name
) == 0)
9327 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9333 /* This command is valid only in a bgp vrf instance or the default instance */
9334 DEFPY (bgp_imexport_vpn
,
9335 bgp_imexport_vpn_cmd
,
9336 "[no] <import|export>$direction_str vpn",
9338 "Import routes to this address-family\n"
9339 "Export routes from this address-family\n"
9340 "to/from default instance VPN RIB\n")
9342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9349 enum vpn_policy_direction dir
;
9351 if (argv_find(argv
, argc
, "no", &idx
))
9354 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9355 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9357 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9358 return CMD_WARNING_CONFIG_FAILED
;
9361 afi
= bgp_node_afi(vty
);
9362 safi
= bgp_node_safi(vty
);
9363 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9364 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9365 return CMD_WARNING_CONFIG_FAILED
;
9368 if (!strcmp(direction_str
, "import")) {
9369 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9370 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9371 } else if (!strcmp(direction_str
, "export")) {
9372 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9373 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9375 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9376 return CMD_WARNING_CONFIG_FAILED
;
9379 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9382 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9383 if (!previous_state
) {
9384 /* trigger export current vrf */
9385 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9388 if (previous_state
) {
9389 /* trigger un-export current vrf */
9390 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9392 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9395 hook_call(bgp_snmp_init_stats
, bgp
);
9400 DEFPY (af_routetarget_import
,
9401 af_routetarget_import_cmd
,
9402 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9404 "Specify route target list\n"
9405 "Specify route target list\n"
9406 "Specify route target list\n"
9407 "Specify route target list\n"
9408 "Flow-spec redirect type route target\n"
9409 "Import routes to this address-family\n"
9410 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9414 struct ecommunity
*ecom
= NULL
;
9416 int idx
= 0, idx_unused
= 0;
9420 if (argv_find(argv
, argc
, "no", &idx
))
9423 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9424 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9427 afi
= vpn_policy_getafi(vty
, bgp
, false);
9429 return CMD_WARNING_CONFIG_FAILED
;
9431 if (rt6
&& afi
!= AFI_IP6
)
9432 return CMD_WARNING_CONFIG_FAILED
;
9435 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9436 vty_out(vty
, "%% Missing RTLIST\n");
9437 return CMD_WARNING_CONFIG_FAILED
;
9439 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9440 if (ret
!= CMD_SUCCESS
)
9445 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9446 ecommunity_free(&bgp
->vpn_policy
[afi
]
9447 .import_redirect_rtlist
);
9448 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9449 ecommunity_dup(ecom
);
9451 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9452 ecommunity_free(&bgp
->vpn_policy
[afi
]
9453 .import_redirect_rtlist
);
9454 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9458 ecommunity_free(&ecom
);
9463 DEFUN_NOSH (address_family_ipv4_safi
,
9464 address_family_ipv4_safi_cmd
,
9465 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9466 "Enter Address Family command mode\n"
9468 BGP_SAFI_WITH_LABEL_HELP_STR
)
9472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9473 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9474 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9475 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9476 && safi
!= SAFI_EVPN
) {
9478 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9479 return CMD_WARNING_CONFIG_FAILED
;
9481 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9483 vty
->node
= BGP_IPV4_NODE
;
9488 DEFUN_NOSH (address_family_ipv6_safi
,
9489 address_family_ipv6_safi_cmd
,
9490 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9491 "Enter Address Family command mode\n"
9493 BGP_SAFI_WITH_LABEL_HELP_STR
)
9496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9497 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9498 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9499 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9500 && safi
!= SAFI_EVPN
) {
9502 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9503 return CMD_WARNING_CONFIG_FAILED
;
9505 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9507 vty
->node
= BGP_IPV6_NODE
;
9512 #ifdef KEEP_OLD_VPN_COMMANDS
9513 DEFUN_NOSH (address_family_vpnv4
,
9514 address_family_vpnv4_cmd
,
9515 "address-family vpnv4 [unicast]",
9516 "Enter Address Family command mode\n"
9518 BGP_AF_MODIFIER_STR
)
9520 vty
->node
= BGP_VPNV4_NODE
;
9524 DEFUN_NOSH (address_family_vpnv6
,
9525 address_family_vpnv6_cmd
,
9526 "address-family vpnv6 [unicast]",
9527 "Enter Address Family command mode\n"
9529 BGP_AF_MODIFIER_STR
)
9531 vty
->node
= BGP_VPNV6_NODE
;
9534 #endif /* KEEP_OLD_VPN_COMMANDS */
9536 DEFUN_NOSH (address_family_evpn
,
9537 address_family_evpn_cmd
,
9538 "address-family l2vpn evpn",
9539 "Enter Address Family command mode\n"
9541 BGP_AF_MODIFIER_STR
)
9543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9544 vty
->node
= BGP_EVPN_NODE
;
9548 DEFUN_NOSH (bgp_segment_routing_srv6
,
9549 bgp_segment_routing_srv6_cmd
,
9550 "segment-routing srv6",
9551 "Segment-Routing configuration\n"
9552 "Segment-Routing SRv6 configuration\n")
9554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9555 bgp
->srv6_enabled
= true;
9556 vty
->node
= BGP_SRV6_NODE
;
9560 DEFUN (no_bgp_segment_routing_srv6
,
9561 no_bgp_segment_routing_srv6_cmd
,
9562 "no segment-routing srv6",
9564 "Segment-Routing configuration\n"
9565 "Segment-Routing SRv6 configuration\n")
9567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9569 if (strlen(bgp
->srv6_locator_name
) > 0)
9570 if (bgp_srv6_locator_unset(bgp
) < 0)
9571 return CMD_WARNING_CONFIG_FAILED
;
9573 bgp
->srv6_enabled
= false;
9577 DEFPY (bgp_srv6_locator
,
9578 bgp_srv6_locator_cmd
,
9579 "locator NAME$name",
9580 "Specify SRv6 locator\n"
9581 "Specify SRv6 locator\n")
9583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9586 if (strlen(bgp
->srv6_locator_name
) > 0
9587 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9588 vty_out(vty
, "srv6 locator is already configured\n");
9589 return CMD_WARNING_CONFIG_FAILED
;
9592 snprintf(bgp
->srv6_locator_name
,
9593 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9595 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9597 return CMD_WARNING_CONFIG_FAILED
;
9602 DEFPY (no_bgp_srv6_locator
,
9603 no_bgp_srv6_locator_cmd
,
9604 "no locator NAME$name",
9606 "Specify SRv6 locator\n"
9607 "Specify SRv6 locator\n")
9609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9611 /* when locator isn't configured, do nothing */
9612 if (strlen(bgp
->srv6_locator_name
) < 1)
9615 /* name validation */
9616 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9617 vty_out(vty
, "%% No srv6 locator is configured\n");
9618 return CMD_WARNING_CONFIG_FAILED
;
9622 if (bgp_srv6_locator_unset(bgp
) < 0)
9623 return CMD_WARNING_CONFIG_FAILED
;
9628 DEFPY (show_bgp_srv6
,
9630 "show bgp segment-routing srv6",
9633 "BGP Segment Routing\n"
9634 "BGP Segment Routing SRv6\n")
9637 struct listnode
*node
;
9638 struct srv6_locator_chunk
*chunk
;
9639 struct bgp_srv6_function
*func
;
9640 struct in6_addr
*tovpn4_sid
;
9641 struct in6_addr
*tovpn6_sid
;
9643 char buf_tovpn4_sid
[256];
9644 char buf_tovpn6_sid
[256];
9646 bgp
= bgp_get_default();
9650 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9651 vty_out(vty
, "locator_chunks:\n");
9652 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9653 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9655 vty_out(vty
, "functions:\n");
9656 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9657 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9658 vty_out(vty
, "- sid: %s\n", buf
);
9659 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9662 vty_out(vty
, "bgps:\n");
9663 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9664 vty_out(vty
, "- name: %s\n",
9665 bgp
->name
? bgp
->name
: "default");
9667 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9668 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9670 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9671 sizeof(buf_tovpn4_sid
));
9673 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9674 sizeof(buf_tovpn6_sid
));
9676 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9677 tovpn4_sid
? buf_tovpn4_sid
: "none");
9678 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9679 tovpn6_sid
? buf_tovpn6_sid
: "none");
9685 DEFUN_NOSH (exit_address_family
,
9686 exit_address_family_cmd
,
9687 "exit-address-family",
9688 "Exit from Address Family configuration mode\n")
9690 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9691 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9692 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9693 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9694 || vty
->node
== BGP_EVPN_NODE
9695 || vty
->node
== BGP_FLOWSPECV4_NODE
9696 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9697 vty
->node
= BGP_NODE
;
9701 /* Recalculate bestpath and re-advertise a prefix */
9702 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9703 const char *ip_str
, afi_t afi
, safi_t safi
,
9704 struct prefix_rd
*prd
)
9707 struct prefix match
;
9708 struct bgp_dest
*dest
;
9709 struct bgp_dest
*rm
;
9711 struct bgp_table
*table
;
9712 struct bgp_table
*rib
;
9714 /* BGP structure lookup. */
9716 bgp
= bgp_lookup_by_name(view_name
);
9718 vty_out(vty
, "%% Can't find BGP instance %s\n",
9723 bgp
= bgp_get_default();
9725 vty_out(vty
, "%% No BGP process is configured\n");
9730 /* Check IP address argument. */
9731 ret
= str2prefix(ip_str
, &match
);
9733 vty_out(vty
, "%% address is malformed\n");
9737 match
.family
= afi2family(afi
);
9738 rib
= bgp
->rib
[afi
][safi
];
9740 if (safi
== SAFI_MPLS_VPN
) {
9741 for (dest
= bgp_table_top(rib
); dest
;
9742 dest
= bgp_route_next(dest
)) {
9743 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9745 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9748 table
= bgp_dest_get_bgp_table_info(dest
);
9752 rm
= bgp_node_match(table
, &match
);
9754 const struct prefix
*rm_p
=
9755 bgp_dest_get_prefix(rm
);
9757 if (rm_p
->prefixlen
== match
.prefixlen
) {
9759 BGP_NODE_USER_CLEAR
);
9760 bgp_process(bgp
, rm
, afi
, safi
);
9762 bgp_dest_unlock_node(rm
);
9766 dest
= bgp_node_match(rib
, &match
);
9768 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9770 if (dest_p
->prefixlen
== match
.prefixlen
) {
9771 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9772 bgp_process(bgp
, dest
, afi
, safi
);
9774 bgp_dest_unlock_node(dest
);
9781 /* one clear bgp command to rule them all */
9782 DEFUN (clear_ip_bgp_all
,
9783 clear_ip_bgp_all_cmd
,
9784 "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>]",
9788 BGP_INSTANCE_HELP_STR
9791 BGP_SAFI_WITH_LABEL_HELP_STR
9794 "BGP IPv4 neighbor to clear\n"
9795 "BGP IPv6 neighbor to clear\n"
9796 "BGP neighbor on interface to clear\n"
9797 "Clear peers with the AS number\n"
9798 "Clear all external peers\n"
9799 "Clear all members of peer-group\n"
9800 "BGP peer-group name\n"
9805 "Push out prefix-list ORF and do inbound soft reconfig\n"
9807 "Reset message statistics\n")
9811 afi_t afi
= AFI_UNSPEC
;
9812 safi_t safi
= SAFI_UNSPEC
;
9813 enum clear_sort clr_sort
= clear_peer
;
9814 enum bgp_clear_type clr_type
;
9815 char *clr_arg
= NULL
;
9819 /* clear [ip] bgp */
9820 if (argv_find(argv
, argc
, "ip", &idx
))
9823 /* [<vrf> VIEWVRFNAME] */
9824 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9825 vrf
= argv
[idx
+ 1]->arg
;
9827 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9829 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9830 /* [<view> VIEWVRFNAME] */
9831 vrf
= argv
[idx
+ 1]->arg
;
9834 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9835 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9836 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9838 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9839 if (argv_find(argv
, argc
, "*", &idx
)) {
9840 clr_sort
= clear_all
;
9841 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9842 clr_sort
= clear_peer
;
9843 clr_arg
= argv
[idx
]->arg
;
9844 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9845 clr_sort
= clear_peer
;
9846 clr_arg
= argv
[idx
]->arg
;
9847 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9848 clr_sort
= clear_group
;
9850 clr_arg
= argv
[idx
]->arg
;
9851 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9852 clr_sort
= clear_peer
;
9853 clr_arg
= argv
[idx
]->arg
;
9854 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9855 clr_sort
= clear_peer
;
9856 clr_arg
= argv
[idx
]->arg
;
9857 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9858 clr_sort
= clear_as
;
9859 clr_arg
= argv
[idx
]->arg
;
9860 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9861 clr_sort
= clear_external
;
9864 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9865 if (argv_find(argv
, argc
, "soft", &idx
)) {
9866 if (argv_find(argv
, argc
, "in", &idx
)
9867 || argv_find(argv
, argc
, "out", &idx
))
9868 clr_type
= strmatch(argv
[idx
]->text
, "in")
9870 : BGP_CLEAR_SOFT_OUT
;
9872 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9873 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9874 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9875 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9876 : BGP_CLEAR_SOFT_IN
;
9877 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9878 clr_type
= BGP_CLEAR_SOFT_OUT
;
9879 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9880 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9882 clr_type
= BGP_CLEAR_SOFT_NONE
;
9884 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9887 DEFUN (clear_ip_bgp_prefix
,
9888 clear_ip_bgp_prefix_cmd
,
9889 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9893 BGP_INSTANCE_HELP_STR
9894 "Clear bestpath and re-advertise\n"
9898 char *prefix
= NULL
;
9902 /* [<view|vrf> VIEWVRFNAME] */
9903 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9904 vrf
= argv
[idx
+ 1]->arg
;
9906 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9908 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9909 /* [<view> VIEWVRFNAME] */
9910 vrf
= argv
[idx
+ 1]->arg
;
9914 prefix
= argv
[argc
- 1]->arg
;
9916 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9919 DEFUN (clear_bgp_ipv6_safi_prefix
,
9920 clear_bgp_ipv6_safi_prefix_cmd
,
9921 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9927 "Clear bestpath and re-advertise\n"
9931 int idx_ipv6_prefix
= 0;
9932 safi_t safi
= SAFI_UNICAST
;
9933 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9934 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9936 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9937 return bgp_clear_prefix(
9938 vty
, NULL
, prefix
, AFI_IP6
,
9942 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9943 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9944 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9948 BGP_INSTANCE_HELP_STR
9951 "Clear bestpath and re-advertise\n"
9955 int idx_vrfview
= 0;
9956 int idx_ipv6_prefix
= 0;
9957 safi_t safi
= SAFI_UNICAST
;
9958 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9959 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9960 char *vrfview
= NULL
;
9962 /* [<view|vrf> VIEWVRFNAME] */
9963 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9964 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9965 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9967 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9968 /* [<view> VIEWVRFNAME] */
9969 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9971 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9973 return bgp_clear_prefix(
9974 vty
, vrfview
, prefix
,
9975 AFI_IP6
, safi
, NULL
);
9978 DEFUN (show_bgp_views
,
9980 "show [ip] bgp views",
9984 "Show the defined BGP views\n")
9986 struct list
*inst
= bm
->bgp
;
9987 struct listnode
*node
;
9990 vty_out(vty
, "Defined BGP views:\n");
9991 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9993 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9995 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10002 DEFUN (show_bgp_vrfs
,
10004 "show [ip] bgp vrfs [json]",
10011 char buf
[ETHER_ADDR_STRLEN
];
10012 struct list
*inst
= bm
->bgp
;
10013 struct listnode
*node
;
10015 bool uj
= use_json(argc
, argv
);
10016 json_object
*json
= NULL
;
10017 json_object
*json_vrfs
= NULL
;
10021 json
= json_object_new_object();
10022 json_vrfs
= json_object_new_object();
10025 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10026 const char *name
, *type
;
10028 struct listnode
*node2
, *nnode2
;
10029 int peers_cfg
, peers_estb
;
10030 json_object
*json_vrf
= NULL
;
10033 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10037 if (!uj
&& count
== 1) {
10039 "%4s %-5s %-16s %9s %10s %-37s\n",
10040 "Type", "Id", "routerId", "#PeersCfg",
10041 "#PeersEstb", "Name");
10042 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10043 "L3-VNI", "RouterMAC", "Interface");
10046 peers_cfg
= peers_estb
= 0;
10048 json_vrf
= json_object_new_object();
10051 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10052 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10055 if (peer_established(peer
))
10059 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10060 name
= VRF_DEFAULT_NAME
;
10069 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10071 : (int64_t)bgp
->vrf_id
;
10072 char buf
[BUFSIZ
] = {0};
10074 json_object_string_add(json_vrf
, "type", type
);
10075 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10076 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10078 json_object_int_add(json_vrf
, "numConfiguredPeers",
10080 json_object_int_add(json_vrf
, "numEstablishedPeers",
10083 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10084 json_object_string_add(
10086 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10087 json_object_string_add(json_vrf
, "interface",
10088 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10090 json_object_object_add(json_vrfs
, name
, json_vrf
);
10092 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10094 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10095 : (int)bgp
->vrf_id
,
10096 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10097 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10099 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10100 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10106 json_object_object_add(json
, "vrfs", json_vrfs
);
10108 json_object_int_add(json
, "totalVrfs", count
);
10110 vty_json(vty
, json
);
10114 "\nTotal number of VRFs (including default): %d\n",
10118 return CMD_SUCCESS
;
10121 DEFUN (show_bgp_mac_hash
,
10122 show_bgp_mac_hash_cmd
,
10123 "show bgp mac hash",
10127 "Mac Address database\n")
10129 bgp_mac_dump_table(vty
);
10131 return CMD_SUCCESS
;
10134 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10136 struct vty
*vty
= (struct vty
*)args
;
10137 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10139 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10142 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10144 vty_out(vty
, "self nexthop database:\n");
10145 bgp_nexthop_show_address_hash(vty
, bgp
);
10147 vty_out(vty
, "Tunnel-ip database:\n");
10148 hash_iterate(bgp
->tip_hash
,
10149 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10153 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10154 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10155 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10156 "martian next-hops\n"
10157 "martian next-hop database\n")
10159 struct bgp
*bgp
= NULL
;
10163 /* [<vrf> VIEWVRFNAME] */
10164 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10165 name
= argv
[idx
+ 1]->arg
;
10166 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10168 } else if (argv_find(argv
, argc
, "view", &idx
))
10169 /* [<view> VIEWVRFNAME] */
10170 name
= argv
[idx
+ 1]->arg
;
10172 bgp
= bgp_lookup_by_name(name
);
10174 bgp
= bgp_get_default();
10177 vty_out(vty
, "%% No BGP process is configured\n");
10178 return CMD_WARNING
;
10180 bgp_show_martian_nexthops(vty
, bgp
);
10182 return CMD_SUCCESS
;
10185 DEFUN (show_bgp_memory
,
10186 show_bgp_memory_cmd
,
10187 "show [ip] bgp memory",
10191 "Global BGP memory statistics\n")
10193 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10194 unsigned long count
;
10196 /* RIB related usage stats */
10197 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10198 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10199 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10200 count
* sizeof(struct bgp_dest
)));
10202 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10203 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10204 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10205 count
* sizeof(struct bgp_path_info
)));
10206 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10207 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10210 memstrbuf
, sizeof(memstrbuf
),
10211 count
* sizeof(struct bgp_path_info_extra
)));
10213 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10214 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10215 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10216 count
* sizeof(struct bgp_static
)));
10218 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10219 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10220 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10221 count
* sizeof(struct bpacket
)));
10224 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10225 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10226 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10227 count
* sizeof(struct bgp_adj_in
)));
10228 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10229 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10230 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10231 count
* sizeof(struct bgp_adj_out
)));
10233 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10234 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10236 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10237 count
* sizeof(struct bgp_nexthop_cache
)));
10239 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10240 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10242 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10243 count
* sizeof(struct bgp_damp_info
)));
10246 count
= attr_count();
10247 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10248 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10249 count
* sizeof(struct attr
)));
10251 if ((count
= attr_unknown_count()))
10252 vty_out(vty
, "%ld unknown attributes\n", count
);
10254 /* AS_PATH attributes */
10255 count
= aspath_count();
10256 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10257 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10258 count
* sizeof(struct aspath
)));
10260 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10261 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10262 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10263 count
* sizeof(struct assegment
)));
10265 /* Other attributes */
10266 if ((count
= community_count()))
10267 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10268 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10269 count
* sizeof(struct community
)));
10270 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10272 "%ld BGP ext-community entries, using %s of memory\n",
10274 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10275 count
* sizeof(struct ecommunity
)));
10276 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10278 "%ld BGP large-community entries, using %s of memory\n",
10279 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10280 count
* sizeof(struct lcommunity
)));
10282 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10283 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10284 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10285 count
* sizeof(struct cluster_list
)));
10287 /* Peer related usage */
10288 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10289 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10290 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10291 count
* sizeof(struct peer
)));
10293 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10294 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10295 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10296 count
* sizeof(struct peer_group
)));
10299 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10300 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10301 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10302 count
* sizeof(regex_t
)));
10303 return CMD_SUCCESS
;
10306 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10308 json_object
*bestpath
= json_object_new_object();
10310 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10311 json_object_string_add(bestpath
, "asPath", "ignore");
10313 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10314 json_object_string_add(bestpath
, "asPath", "confed");
10316 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10317 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10318 json_object_string_add(bestpath
, "multiPathRelax",
10321 json_object_string_add(bestpath
, "multiPathRelax",
10324 json_object_string_add(bestpath
, "multiPathRelax", "false");
10326 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10327 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10329 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10330 json_object_string_add(bestpath
, "compareRouterId", "true");
10331 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10332 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10333 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10334 json_object_string_add(bestpath
, "med", "confed");
10335 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10336 json_object_string_add(bestpath
, "med",
10337 "missing-as-worst");
10339 json_object_string_add(bestpath
, "med", "true");
10342 json_object_object_add(json
, "bestPath", bestpath
);
10345 /* Print the error code/subcode for why the peer is down */
10346 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10347 json_object
*json_peer
, bool use_json
)
10349 const char *code_str
;
10350 const char *subcode_str
;
10353 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10354 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10355 char errorcodesubcode_hexstr
[5];
10356 char errorcodesubcode_str
[256];
10358 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10359 subcode_str
= bgp_notify_subcode_str(
10361 peer
->notify
.subcode
);
10363 snprintf(errorcodesubcode_hexstr
,
10364 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10365 peer
->notify
.code
, peer
->notify
.subcode
);
10366 json_object_string_add(json_peer
,
10367 "lastErrorCodeSubcode",
10368 errorcodesubcode_hexstr
);
10369 snprintf(errorcodesubcode_str
, 255, "%s%s",
10370 code_str
, subcode_str
);
10371 json_object_string_add(json_peer
,
10372 "lastNotificationReason",
10373 errorcodesubcode_str
);
10374 json_object_boolean_add(json_peer
,
10375 "lastNotificationHardReset",
10376 peer
->notify
.hard_reset
);
10377 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10378 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10379 && (peer
->notify
.subcode
10380 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10381 || peer
->notify
.subcode
10382 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10383 && peer
->notify
.length
) {
10385 const char *msg_str
;
10387 msg_str
= bgp_notify_admin_message(
10388 msgbuf
, sizeof(msgbuf
),
10389 (uint8_t *)peer
->notify
.data
,
10390 peer
->notify
.length
);
10392 json_object_string_add(
10394 "lastShutdownDescription",
10399 json_object_string_add(json_peer
, "lastResetDueTo",
10400 peer_down_str
[(int)peer
->last_reset
]);
10401 json_object_int_add(json_peer
, "lastResetCode",
10404 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10405 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10406 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10408 bgp_notify_subcode_str(peer
->notify
.code
,
10409 peer
->notify
.subcode
);
10410 vty_out(vty
, " Notification %s (%s%s%s)\n",
10411 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10414 code_str
, subcode_str
,
10415 peer
->notify
.hard_reset
10416 ? bgp_notify_subcode_str(
10418 BGP_NOTIFY_CEASE_HARD_RESET
)
10421 vty_out(vty
, " %s\n",
10422 peer_down_str
[(int)peer
->last_reset
]);
10427 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10430 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10433 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10434 struct peer
*peer
, json_object
*json_peer
,
10435 int max_neighbor_width
, bool use_json
)
10437 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10441 if (peer_dynamic_neighbor(peer
))
10442 json_object_boolean_true_add(json_peer
,
10444 if (peer
->hostname
)
10445 json_object_string_add(json_peer
, "hostname",
10448 if (peer
->domainname
)
10449 json_object_string_add(json_peer
, "domainname",
10451 json_object_int_add(json_peer
, "connectionsEstablished",
10452 peer
->established
);
10453 json_object_int_add(json_peer
, "connectionsDropped",
10455 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10456 use_json
, json_peer
);
10457 if (peer_established(peer
))
10458 json_object_string_add(json_peer
, "lastResetDueTo",
10459 "AFI/SAFI Not Negotiated");
10461 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10464 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10466 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10467 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10468 peer
->hostname
, peer
->host
);
10470 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10472 /* pad the neighbor column with spaces */
10473 if (len
< max_neighbor_width
)
10474 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10476 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10478 peer_uptime(peer
->uptime
, timebuf
,
10479 BGP_UPTIME_LEN
, 0, NULL
));
10480 if (peer_established(peer
))
10481 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10483 bgp_show_peer_reset(vty
, peer
, NULL
,
10488 /* Strip peer's description to the given size. */
10489 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10491 static char stripped
[BUFSIZ
];
10493 uint32_t last_space
= 0;
10496 if (*(desc
+ i
) == 0) {
10497 stripped
[i
] = '\0';
10500 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10502 stripped
[i
] = *(desc
+ i
);
10506 if (last_space
> size
)
10507 stripped
[size
+ 1] = '\0';
10509 stripped
[last_space
] = '\0';
10514 /* Determine whether var peer should be filtered out of the summary. */
10515 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10516 struct peer
*fpeer
, int as_type
,
10520 /* filter neighbor XXXX */
10521 if (fpeer
&& fpeer
!= peer
)
10524 /* filter remote-as (internal|external) */
10525 if (as_type
!= AS_UNSPECIFIED
) {
10526 if (peer
->as_type
== AS_SPECIFIED
) {
10527 if (as_type
== AS_INTERNAL
) {
10528 if (peer
->as
!= peer
->local_as
)
10530 } else if (peer
->as
== peer
->local_as
)
10532 } else if (as_type
!= peer
->as_type
)
10534 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10540 /* Show BGP peer's summary information.
10542 * Peer's description is stripped according to if `wide` option is given
10545 * When adding new columns to `show bgp summary` output, please make
10546 * sure `Desc` is the lastest column to show because it can contain
10547 * whitespaces and the whole output will be tricky.
10549 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10550 struct peer
*fpeer
, int as_type
, as_t as
,
10551 uint16_t show_flags
)
10554 struct listnode
*node
, *nnode
;
10555 unsigned int count
= 0, dn_count
= 0;
10556 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10557 char neighbor_buf
[VTY_BUFSIZ
];
10558 int neighbor_col_default_width
= 16;
10559 int len
, failed_count
= 0;
10560 unsigned int filtered_count
= 0;
10561 int max_neighbor_width
= 0;
10563 json_object
*json
= NULL
;
10564 json_object
*json_peer
= NULL
;
10565 json_object
*json_peers
= NULL
;
10566 struct peer_af
*paf
;
10567 struct bgp_filter
*filter
;
10568 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10569 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10570 bool show_established
=
10571 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10572 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10573 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10575 /* labeled-unicast routes are installed in the unicast table so in order
10577 * display the correct PfxRcd value we must look at SAFI_UNICAST
10580 if (safi
== SAFI_LABELED_UNICAST
)
10581 pfx_rcd_safi
= SAFI_UNICAST
;
10583 pfx_rcd_safi
= safi
;
10586 json
= json_object_new_object();
10587 json_peers
= json_object_new_object();
10588 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10589 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10596 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10599 if (peer
->afc
[afi
][safi
]) {
10600 /* See if we have at least a single failed peer */
10601 if (bgp_has_peer_failed(peer
, afi
, safi
))
10605 if (peer_dynamic_neighbor(peer
))
10610 /* Loop over all neighbors that will be displayed to determine
10612 * characters are needed for the Neighbor column
10614 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10615 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10622 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10625 if (peer
->afc
[afi
][safi
]) {
10626 memset(dn_flag
, '\0', sizeof(dn_flag
));
10627 if (peer_dynamic_neighbor(peer
))
10631 && CHECK_FLAG(bgp
->flags
,
10632 BGP_FLAG_SHOW_HOSTNAME
))
10633 snprintf(neighbor_buf
,
10634 sizeof(neighbor_buf
),
10635 "%s%s(%s) ", dn_flag
,
10636 peer
->hostname
, peer
->host
);
10638 snprintf(neighbor_buf
,
10639 sizeof(neighbor_buf
), "%s%s ",
10640 dn_flag
, peer
->host
);
10642 len
= strlen(neighbor_buf
);
10644 if (len
> max_neighbor_width
)
10645 max_neighbor_width
= len
;
10647 /* See if we have at least a single failed peer */
10648 if (bgp_has_peer_failed(peer
, afi
, safi
))
10654 /* Originally we displayed the Neighbor column as 16
10655 * characters wide so make that the default
10657 if (max_neighbor_width
< neighbor_col_default_width
)
10658 max_neighbor_width
= neighbor_col_default_width
;
10661 if (show_failed
&& !failed_count
) {
10663 json_object_int_add(json
, "failedPeersCount", 0);
10664 json_object_int_add(json
, "dynamicPeers", dn_count
);
10665 json_object_int_add(json
, "totalPeers", count
);
10667 vty_json(vty
, json
);
10669 vty_out(vty
, "%% No failed BGP neighbors found\n");
10671 return CMD_SUCCESS
;
10674 count
= 0; /* Reset the value as its used again */
10675 filtered_count
= 0;
10677 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10678 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10681 if (!peer
->afc
[afi
][safi
])
10685 unsigned long ents
;
10686 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10689 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10691 : (int64_t)bgp
->vrf_id
;
10693 /* Usage summary and header */
10695 json_object_string_addf(json
, "routerId",
10698 json_object_int_add(json
, "as", bgp
->as
);
10699 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10700 json_object_string_add(
10703 == BGP_INSTANCE_TYPE_DEFAULT
)
10708 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10709 &bgp
->router_id
, bgp
->as
,
10710 bgp
->vrf_id
== VRF_UNKNOWN
10712 : (int)bgp
->vrf_id
);
10713 vty_out(vty
, "\n");
10716 if (bgp_update_delay_configured(bgp
)) {
10718 json_object_int_add(
10719 json
, "updateDelayLimit",
10720 bgp
->v_update_delay
);
10722 if (bgp
->v_update_delay
10723 != bgp
->v_establish_wait
)
10724 json_object_int_add(
10726 "updateDelayEstablishWait",
10727 bgp
->v_establish_wait
);
10729 if (bgp_update_delay_active(bgp
)) {
10730 json_object_string_add(
10732 "updateDelayFirstNeighbor",
10733 bgp
->update_delay_begin_time
);
10734 json_object_boolean_true_add(
10736 "updateDelayInProgress");
10738 if (bgp
->update_delay_over
) {
10739 json_object_string_add(
10741 "updateDelayFirstNeighbor",
10742 bgp
->update_delay_begin_time
);
10743 json_object_string_add(
10745 "updateDelayBestpathResumed",
10746 bgp
->update_delay_end_time
);
10747 json_object_string_add(
10749 "updateDelayZebraUpdateResume",
10750 bgp
->update_delay_zebra_resume_time
);
10751 json_object_string_add(
10753 "updateDelayPeerUpdateResume",
10754 bgp
->update_delay_peers_resume_time
);
10759 "Read-only mode update-delay limit: %d seconds\n",
10760 bgp
->v_update_delay
);
10761 if (bgp
->v_update_delay
10762 != bgp
->v_establish_wait
)
10764 " Establish wait: %d seconds\n",
10765 bgp
->v_establish_wait
);
10767 if (bgp_update_delay_active(bgp
)) {
10769 " First neighbor established: %s\n",
10770 bgp
->update_delay_begin_time
);
10772 " Delay in progress\n");
10774 if (bgp
->update_delay_over
) {
10776 " First neighbor established: %s\n",
10777 bgp
->update_delay_begin_time
);
10779 " Best-paths resumed: %s\n",
10780 bgp
->update_delay_end_time
);
10782 " zebra update resumed: %s\n",
10783 bgp
->update_delay_zebra_resume_time
);
10785 " peers update resumed: %s\n",
10786 bgp
->update_delay_peers_resume_time
);
10793 if (bgp_maxmed_onstartup_configured(bgp
)
10794 && bgp
->maxmed_active
)
10795 json_object_boolean_true_add(
10796 json
, "maxMedOnStartup");
10797 if (bgp
->v_maxmed_admin
)
10798 json_object_boolean_true_add(
10799 json
, "maxMedAdministrative");
10801 json_object_int_add(
10802 json
, "tableVersion",
10803 bgp_table_version(bgp
->rib
[afi
][safi
]));
10805 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10806 json_object_int_add(json
, "ribCount", ents
);
10807 json_object_int_add(
10809 ents
* sizeof(struct bgp_dest
));
10811 ents
= bgp
->af_peer_count
[afi
][safi
];
10812 json_object_int_add(json
, "peerCount", ents
);
10813 json_object_int_add(json
, "peerMemory",
10814 ents
* sizeof(struct peer
));
10816 if ((ents
= listcount(bgp
->group
))) {
10817 json_object_int_add(
10818 json
, "peerGroupCount", ents
);
10819 json_object_int_add(
10820 json
, "peerGroupMemory",
10821 ents
* sizeof(struct
10825 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10826 BGP_CONFIG_DAMPENING
))
10827 json_object_boolean_true_add(
10828 json
, "dampeningEnabled");
10831 if (bgp_maxmed_onstartup_configured(bgp
)
10832 && bgp
->maxmed_active
)
10834 "Max-med on-startup active\n");
10835 if (bgp
->v_maxmed_admin
)
10837 "Max-med administrative active\n");
10840 "BGP table version %" PRIu64
10843 bgp
->rib
[afi
][safi
]));
10845 ents
= bgp_table_count(
10846 bgp
->rib
[afi
][safi
]);
10848 "RIB entries %ld, using %s of memory\n",
10858 /* Peer related usage */
10859 ents
= bgp
->af_peer_count
[afi
][safi
];
10861 "Peers %ld, using %s of memory\n",
10871 if ((ents
= listcount(bgp
->group
)))
10873 "Peer groups %ld, using %s of memory\n",
10883 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10884 BGP_CONFIG_DAMPENING
))
10886 "Dampening enabled.\n");
10889 vty_out(vty
, "\n");
10891 /* Subtract 8 here because 'Neighbor' is
10893 vty_out(vty
, "Neighbor");
10894 vty_out(vty
, "%*s",
10895 max_neighbor_width
- 8, " ");
10897 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10902 paf
= peer_af_find(peer
, afi
, safi
);
10903 filter
= &peer
->filter
[afi
][safi
];
10906 /* Works for both failed & successful cases */
10907 if (peer_dynamic_neighbor(peer
))
10912 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10918 bgp_has_peer_failed(peer
, afi
, safi
)) {
10919 json_peer
= json_object_new_object();
10920 bgp_show_failed_summary(vty
, bgp
, peer
,
10921 json_peer
, 0, use_json
);
10922 } else if (!show_failed
) {
10923 if (show_established
10924 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10929 json_peer
= json_object_new_object();
10930 if (peer_dynamic_neighbor(peer
)) {
10931 json_object_boolean_true_add(json_peer
,
10935 if (peer
->hostname
)
10936 json_object_string_add(json_peer
, "hostname",
10939 if (peer
->domainname
)
10940 json_object_string_add(json_peer
, "domainname",
10943 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10944 json_object_int_add(
10945 json_peer
, "localAs",
10946 peer
->change_local_as
10947 ? peer
->change_local_as
10949 json_object_int_add(json_peer
, "version", 4);
10950 json_object_int_add(json_peer
, "msgRcvd",
10951 PEER_TOTAL_RX(peer
));
10952 json_object_int_add(json_peer
, "msgSent",
10953 PEER_TOTAL_TX(peer
));
10955 atomic_size_t outq_count
, inq_count
;
10956 outq_count
= atomic_load_explicit(
10957 &peer
->obuf
->count
,
10958 memory_order_relaxed
);
10959 inq_count
= atomic_load_explicit(
10960 &peer
->ibuf
->count
,
10961 memory_order_relaxed
);
10963 json_object_int_add(json_peer
, "tableVersion",
10964 peer
->version
[afi
][safi
]);
10965 json_object_int_add(json_peer
, "outq",
10967 json_object_int_add(json_peer
, "inq",
10969 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10970 use_json
, json_peer
);
10972 json_object_int_add(json_peer
, "pfxRcd",
10973 peer
->pcount
[afi
][pfx_rcd_safi
]);
10975 if (paf
&& PAF_SUBGRP(paf
))
10976 json_object_int_add(
10977 json_peer
, "pfxSnt",
10978 (PAF_SUBGRP(paf
))->scount
);
10980 json_object_int_add(json_peer
, "pfxSnt",
10983 /* BGP FSM state */
10984 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10985 || CHECK_FLAG(peer
->bgp
->flags
,
10986 BGP_FLAG_SHUTDOWN
))
10987 json_object_string_add(json_peer
,
10990 else if (peer
->afc_recv
[afi
][safi
])
10991 json_object_string_add(
10992 json_peer
, "state",
10993 lookup_msg(bgp_status_msg
,
10994 peer
->status
, NULL
));
10995 else if (CHECK_FLAG(
10997 PEER_STATUS_PREFIX_OVERFLOW
))
10998 json_object_string_add(json_peer
,
11002 json_object_string_add(
11003 json_peer
, "state",
11004 lookup_msg(bgp_status_msg
,
11005 peer
->status
, NULL
));
11007 /* BGP peer state */
11008 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11009 || CHECK_FLAG(peer
->bgp
->flags
,
11010 BGP_FLAG_SHUTDOWN
))
11011 json_object_string_add(json_peer
,
11014 else if (CHECK_FLAG(
11016 PEER_STATUS_PREFIX_OVERFLOW
))
11017 json_object_string_add(json_peer
,
11020 else if (CHECK_FLAG(peer
->flags
,
11021 PEER_FLAG_PASSIVE
))
11022 json_object_string_add(json_peer
,
11025 else if (CHECK_FLAG(peer
->sflags
,
11026 PEER_STATUS_NSF_WAIT
))
11027 json_object_string_add(json_peer
,
11030 else if (CHECK_FLAG(
11032 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11033 && (!bgp_inbound_policy_exists(peer
,
11035 || !bgp_outbound_policy_exists(
11037 json_object_string_add(json_peer
,
11041 json_object_string_add(
11042 json_peer
, "peerState", "OK");
11044 json_object_int_add(json_peer
, "connectionsEstablished",
11045 peer
->established
);
11046 json_object_int_add(json_peer
, "connectionsDropped",
11049 json_object_string_add(
11050 json_peer
, "desc", peer
->desc
);
11052 /* Avoid creating empty peer dicts in JSON */
11053 if (json_peer
== NULL
)
11057 json_object_string_add(json_peer
, "idType",
11059 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11060 json_object_string_add(json_peer
, "idType",
11062 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11063 json_object_string_add(json_peer
, "idType",
11065 json_object_object_add(json_peers
, peer
->host
,
11068 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11074 bgp_has_peer_failed(peer
, afi
, safi
)) {
11075 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11076 max_neighbor_width
,
11078 } else if (!show_failed
) {
11079 if (show_established
11080 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11085 if ((count
- filtered_count
) == 1) {
11086 /* display headline before the first
11088 vty_out(vty
, "\n");
11090 /* Subtract 8 here because 'Neighbor' is
11092 vty_out(vty
, "Neighbor");
11093 vty_out(vty
, "%*s",
11094 max_neighbor_width
- 8, " ");
11097 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11098 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11101 memset(dn_flag
, '\0', sizeof(dn_flag
));
11102 if (peer_dynamic_neighbor(peer
)) {
11107 && CHECK_FLAG(bgp
->flags
,
11108 BGP_FLAG_SHOW_HOSTNAME
))
11109 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11113 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11115 /* pad the neighbor column with spaces */
11116 if (len
< max_neighbor_width
)
11117 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11120 atomic_size_t outq_count
, inq_count
;
11121 outq_count
= atomic_load_explicit(
11122 &peer
->obuf
->count
,
11123 memory_order_relaxed
);
11124 inq_count
= atomic_load_explicit(
11125 &peer
->ibuf
->count
,
11126 memory_order_relaxed
);
11130 "4 %10u %10u %9u %9u %8" PRIu64
11133 peer
->change_local_as
11134 ? peer
->change_local_as
11136 PEER_TOTAL_RX(peer
),
11137 PEER_TOTAL_TX(peer
),
11138 peer
->version
[afi
][safi
],
11139 inq_count
, outq_count
,
11140 peer_uptime(peer
->uptime
,
11145 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11147 peer
->as
, PEER_TOTAL_RX(peer
),
11148 PEER_TOTAL_TX(peer
),
11149 peer
->version
[afi
][safi
],
11150 inq_count
, outq_count
,
11151 peer_uptime(peer
->uptime
,
11156 if (peer_established(peer
)) {
11157 if (peer
->afc_recv
[afi
][safi
]) {
11160 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11161 && !bgp_inbound_policy_exists(
11163 vty_out(vty
, " %12s",
11172 vty_out(vty
, " NoNeg");
11175 if (paf
&& PAF_SUBGRP(paf
)) {
11178 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11179 && !bgp_outbound_policy_exists(
11181 vty_out(vty
, " %8s",
11190 vty_out(vty
, " NoNeg");
11193 if (CHECK_FLAG(peer
->flags
,
11194 PEER_FLAG_SHUTDOWN
)
11195 || CHECK_FLAG(peer
->bgp
->flags
,
11196 BGP_FLAG_SHUTDOWN
))
11197 vty_out(vty
, " Idle (Admin)");
11198 else if (CHECK_FLAG(
11200 PEER_STATUS_PREFIX_OVERFLOW
))
11201 vty_out(vty
, " Idle (PfxCt)");
11203 vty_out(vty
, " %12s",
11204 lookup_msg(bgp_status_msg
,
11205 peer
->status
, NULL
));
11207 vty_out(vty
, " %8u", 0);
11209 /* Make sure `Desc` column is the lastest in
11213 vty_out(vty
, " %s",
11214 bgp_peer_description_stripped(
11216 show_wide
? 64 : 20));
11218 vty_out(vty
, " N/A");
11219 vty_out(vty
, "\n");
11226 json_object_object_add(json
, "peers", json_peers
);
11227 json_object_int_add(json
, "failedPeers", failed_count
);
11228 json_object_int_add(json
, "displayedPeers",
11229 count
- filtered_count
);
11230 json_object_int_add(json
, "totalPeers", count
);
11231 json_object_int_add(json
, "dynamicPeers", dn_count
);
11234 bgp_show_bestpath_json(bgp
, json
);
11236 vty_json(vty
, json
);
11239 if (filtered_count
== count
)
11240 vty_out(vty
, "\n%% No matching neighbor\n");
11243 vty_out(vty
, "\nDisplayed neighbors %d",
11245 else if (as_type
!= AS_UNSPECIFIED
|| as
11246 || fpeer
|| show_established
)
11247 vty_out(vty
, "\nDisplayed neighbors %d",
11248 count
- filtered_count
);
11250 vty_out(vty
, "\nTotal number of neighbors %d\n",
11254 vty_out(vty
, "No %s neighbor is configured\n",
11255 get_afi_safi_str(afi
, safi
, false));
11259 vty_out(vty
, "* - dynamic neighbor\n");
11260 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11261 dn_count
, bgp
->dynamic_neighbors_limit
);
11265 return CMD_SUCCESS
;
11268 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11269 int safi
, struct peer
*fpeer
, int as_type
,
11270 as_t as
, uint16_t show_flags
)
11273 int afi_wildcard
= (afi
== AFI_MAX
);
11274 int safi_wildcard
= (safi
== SAFI_MAX
);
11275 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11276 bool nbr_output
= false;
11277 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11279 if (use_json
&& is_wildcard
)
11280 vty_out(vty
, "{\n");
11282 afi
= 1; /* AFI_IP */
11283 while (afi
< AFI_MAX
) {
11285 safi
= 1; /* SAFI_UNICAST */
11286 while (safi
< SAFI_MAX
) {
11287 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11292 * So limit output to those afi/safi
11294 * actualy have something interesting in
11299 vty_out(vty
, ",\n");
11303 vty_out(vty
, "\"%s\":",
11304 get_afi_safi_str(afi
,
11309 "\n%s Summary (%s):\n",
11310 get_afi_safi_str(afi
,
11316 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11317 as_type
, as
, show_flags
);
11320 if (!safi_wildcard
)
11328 if (use_json
&& is_wildcard
)
11329 vty_out(vty
, "}\n");
11330 else if (!nbr_output
) {
11332 vty_out(vty
, "{}\n");
11334 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11339 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11341 const char *neighbor
,
11342 int as_type
, as_t as
,
11343 uint16_t show_flags
)
11345 struct listnode
*node
, *nnode
;
11347 struct peer
*fpeer
= NULL
;
11349 bool nbr_output
= false;
11350 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11353 vty_out(vty
, "{\n");
11355 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11359 vty_out(vty
, ",\n");
11363 vty_out(vty
, "\"%s\":",
11364 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11369 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11374 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11379 vty_out(vty
, "}\n");
11380 else if (!nbr_output
)
11381 vty_out(vty
, "%% BGP instance not found\n");
11384 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11385 safi_t safi
, const char *neighbor
, int as_type
,
11386 as_t as
, uint16_t show_flags
)
11389 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11390 struct peer
*fpeer
= NULL
;
11393 if (strmatch(name
, "all")) {
11394 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11397 return CMD_SUCCESS
;
11399 bgp
= bgp_lookup_by_name(name
);
11403 vty_out(vty
, "{}\n");
11406 "%% BGP instance not found\n");
11407 return CMD_WARNING
;
11411 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11414 return CMD_WARNING
;
11416 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11417 as_type
, as
, show_flags
);
11418 return CMD_SUCCESS
;
11422 bgp
= bgp_get_default();
11426 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11429 return CMD_WARNING
;
11431 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11435 vty_out(vty
, "{}\n");
11437 vty_out(vty
, "%% BGP instance not found\n");
11438 return CMD_WARNING
;
11441 return CMD_SUCCESS
;
11444 /* `show [ip] bgp summary' commands. */
11445 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11446 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11447 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11448 "]] [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]",
11449 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11450 BGP_SAFI_WITH_LABEL_HELP_STR
11451 "Display the entries for all address families\n"
11452 "Summary of BGP neighbor status\n"
11453 "Show only sessions in Established state\n"
11454 "Show only sessions not in Established state\n"
11455 "Show only the specified neighbor session\n"
11456 "Neighbor to display information about\n"
11457 "Neighbor to display information about\n"
11458 "Neighbor on BGP configured interface\n"
11459 "Show only the specified remote AS sessions\n"
11461 "Internal (iBGP) AS sessions\n"
11462 "External (eBGP) AS sessions\n"
11463 "Shorten the information on BGP instances\n"
11464 "Increase table width for longer output\n" JSON_STR
)
11467 afi_t afi
= AFI_MAX
;
11468 safi_t safi
= SAFI_MAX
;
11469 as_t as
= 0; /* 0 means AS filter not set */
11470 int as_type
= AS_UNSPECIFIED
;
11471 uint16_t show_flags
= 0;
11475 /* show [ip] bgp */
11476 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11478 /* [<vrf> VIEWVRFNAME] */
11479 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11480 vrf
= argv
[idx
+ 1]->arg
;
11481 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11483 } else if (argv_find(argv
, argc
, "view", &idx
))
11484 /* [<view> VIEWVRFNAME] */
11485 vrf
= argv
[idx
+ 1]->arg
;
11486 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11487 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11488 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11491 if (argv_find(argv
, argc
, "failed", &idx
))
11492 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11494 if (argv_find(argv
, argc
, "established", &idx
))
11495 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11497 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11498 if (argv
[idx
+ 1]->arg
[0] == 'i')
11499 as_type
= AS_INTERNAL
;
11500 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11501 as_type
= AS_EXTERNAL
;
11503 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11506 if (argv_find(argv
, argc
, "terse", &idx
))
11507 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11509 if (argv_find(argv
, argc
, "wide", &idx
))
11510 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11512 if (argv_find(argv
, argc
, "json", &idx
))
11513 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11515 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11519 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11522 return get_afi_safi_json_str(afi
, safi
);
11524 return get_afi_safi_vty_str(afi
, safi
);
11528 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11529 afi_t afi
, safi_t safi
,
11530 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11531 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11532 bool use_json
, json_object
*json_pref
)
11535 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11536 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11538 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11539 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11540 json_object_string_add(json_pref
, "sendMode",
11541 "advertisedAndReceived");
11542 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11543 json_object_string_add(json_pref
, "sendMode",
11545 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11546 json_object_string_add(json_pref
, "sendMode",
11549 vty_out(vty
, " Send-mode: ");
11550 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11551 vty_out(vty
, "advertised");
11552 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11553 vty_out(vty
, "%sreceived",
11554 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11558 vty_out(vty
, "\n");
11563 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11564 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11566 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11567 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11568 json_object_string_add(json_pref
, "recvMode",
11569 "advertisedAndReceived");
11570 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11571 json_object_string_add(json_pref
, "recvMode",
11573 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11574 json_object_string_add(json_pref
, "recvMode",
11577 vty_out(vty
, " Receive-mode: ");
11578 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11579 vty_out(vty
, "advertised");
11580 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11581 vty_out(vty
, "%sreceived",
11582 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11586 vty_out(vty
, "\n");
11591 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11599 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11600 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11601 && (peer_established(p
))) {
11602 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11603 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11607 json_object_boolean_add(json
, "rBit", rbit
);
11608 json_object_boolean_add(json
, "nBit", nbit
);
11610 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11611 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11615 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11620 const char *mode
= "NotApplicable";
11623 vty_out(vty
, "\n Remote GR Mode: ");
11625 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11626 && (peer_established(peer
))) {
11628 if ((peer
->nsf_af_count
== 0)
11629 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11633 } else if (peer
->nsf_af_count
== 0
11634 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11638 } else if (peer
->nsf_af_count
!= 0
11639 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11646 json_object_string_add(json
, "remoteGrMode", mode
);
11648 vty_out(vty
, mode
, "\n");
11651 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11656 const char *mode
= "Invalid";
11659 vty_out(vty
, " Local GR Mode: ");
11661 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11663 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11665 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11667 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11668 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11670 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11672 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11679 json_object_string_add(json
, "localGrMode", mode
);
11681 vty_out(vty
, mode
, "\n");
11685 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11686 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11690 json_object
*json_afi_safi
= NULL
;
11691 json_object
*json_timer
= NULL
;
11692 json_object
*json_endofrib_status
= NULL
;
11693 bool eor_flag
= false;
11695 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11696 if (!peer
->afc
[afi
][safi
])
11699 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11700 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11704 json_afi_safi
= json_object_new_object();
11705 json_endofrib_status
= json_object_new_object();
11706 json_timer
= json_object_new_object();
11709 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11715 vty_out(vty
, " %s:\n",
11716 get_afi_safi_str(afi
, safi
, false));
11718 vty_out(vty
, " F bit: ");
11721 if (peer
->nsf
[afi
][safi
] &&
11722 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11723 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11726 json_object_boolean_true_add(json_afi_safi
,
11729 vty_out(vty
, "True\n");
11732 json_object_boolean_false_add(json_afi_safi
,
11735 vty_out(vty
, "False\n");
11739 vty_out(vty
, " End-of-RIB sent: ");
11741 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11742 PEER_STATUS_EOR_SEND
)) {
11744 json_object_boolean_true_add(
11745 json_endofrib_status
, "endOfRibSend");
11747 PRINT_EOR_JSON(eor_flag
);
11749 vty_out(vty
, "Yes\n");
11751 " End-of-RIB sent after update: ");
11753 PRINT_EOR(eor_flag
);
11757 json_object_boolean_false_add(
11758 json_endofrib_status
, "endOfRibSend");
11759 json_object_boolean_false_add(
11760 json_endofrib_status
,
11761 "endOfRibSentAfterUpdate");
11763 vty_out(vty
, "No\n");
11765 " End-of-RIB sent after update: ");
11766 vty_out(vty
, "No\n");
11771 vty_out(vty
, " End-of-RIB received: ");
11773 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11774 PEER_STATUS_EOR_RECEIVED
)) {
11776 json_object_boolean_true_add(
11777 json_endofrib_status
, "endOfRibRecv");
11779 vty_out(vty
, "Yes\n");
11782 json_object_boolean_false_add(
11783 json_endofrib_status
, "endOfRibRecv");
11785 vty_out(vty
, "No\n");
11789 json_object_int_add(json_timer
, "stalePathTimer",
11790 peer
->bgp
->stalepath_time
);
11792 if (peer
->t_gr_stale
!= NULL
) {
11793 json_object_int_add(json_timer
,
11794 "stalePathTimerRemaining",
11795 thread_timer_remain_second(
11796 peer
->t_gr_stale
));
11799 /* Display Configured Selection
11800 * Deferral only when when
11801 * Gr mode is enabled.
11803 if (CHECK_FLAG(peer
->flags
,
11804 PEER_FLAG_GRACEFUL_RESTART
)) {
11805 json_object_int_add(json_timer
,
11806 "selectionDeferralTimer",
11807 peer
->bgp
->stalepath_time
);
11810 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11813 json_object_int_add(
11815 "selectionDeferralTimerRemaining",
11816 thread_timer_remain_second(
11817 peer
->bgp
->gr_info
[afi
][safi
]
11818 .t_select_deferral
));
11821 vty_out(vty
, " Timers:\n");
11823 " Configured Stale Path Time(sec): %u\n",
11824 peer
->bgp
->stalepath_time
);
11826 if (peer
->t_gr_stale
!= NULL
)
11828 " Stale Path Remaining(sec): %ld\n",
11829 thread_timer_remain_second(
11830 peer
->t_gr_stale
));
11831 /* Display Configured Selection
11832 * Deferral only when when
11833 * Gr mode is enabled.
11835 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11837 " Configured Selection Deferral Time(sec): %u\n",
11838 peer
->bgp
->select_defer_time
);
11840 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11843 " Selection Deferral Time Remaining(sec): %ld\n",
11844 thread_timer_remain_second(
11845 peer
->bgp
->gr_info
[afi
][safi
]
11846 .t_select_deferral
));
11849 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11850 json_endofrib_status
);
11851 json_object_object_add(json_afi_safi
, "timers",
11853 json_object_object_add(
11854 json
, get_afi_safi_str(afi
, safi
, true),
11860 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11866 json_object
*json_timer
= NULL
;
11868 json_timer
= json_object_new_object();
11870 json_object_int_add(json_timer
, "configuredRestartTimer",
11871 p
->bgp
->restart_time
);
11873 json_object_int_add(json_timer
, "receivedRestartTimer",
11876 if (p
->t_gr_restart
!= NULL
)
11877 json_object_int_add(
11878 json_timer
, "restartTimerRemaining",
11879 thread_timer_remain_second(p
->t_gr_restart
));
11881 json_object_object_add(json
, "timers", json_timer
);
11884 vty_out(vty
, " Timers:\n");
11885 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11886 p
->bgp
->restart_time
);
11888 vty_out(vty
, " Received Restart Time(sec): %u\n",
11890 if (p
->t_gr_restart
!= NULL
)
11891 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11892 thread_timer_remain_second(p
->t_gr_restart
));
11893 if (p
->t_gr_restart
!= NULL
) {
11894 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11895 thread_timer_remain_second(p
->t_gr_restart
));
11900 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11901 bool use_json
, json_object
*json
)
11903 char dn_flag
[2] = {0};
11904 /* '*' + v6 address of neighbor */
11905 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11907 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11912 json_object_string_addf(json
, "neighborAddr", "%pSU",
11915 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11918 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11922 json_object_string_add(json
, "neighborAddr",
11925 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11928 /* more gr info in new format */
11929 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11932 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11933 safi_t safi
, bool use_json
,
11934 json_object
*json_neigh
)
11936 struct bgp_filter
*filter
;
11937 struct peer_af
*paf
;
11938 char orf_pfx_name
[BUFSIZ
];
11940 json_object
*json_af
= NULL
;
11941 json_object
*json_prefA
= NULL
;
11942 json_object
*json_prefB
= NULL
;
11943 json_object
*json_addr
= NULL
;
11944 json_object
*json_advmap
= NULL
;
11947 json_addr
= json_object_new_object();
11948 json_af
= json_object_new_object();
11949 filter
= &p
->filter
[afi
][safi
];
11951 if (peer_group_active(p
))
11952 json_object_string_add(json_addr
, "peerGroupMember",
11955 paf
= peer_af_find(p
, afi
, safi
);
11956 if (paf
&& PAF_SUBGRP(paf
)) {
11957 json_object_int_add(json_addr
, "updateGroupId",
11958 PAF_UPDGRP(paf
)->id
);
11959 json_object_int_add(json_addr
, "subGroupId",
11960 PAF_SUBGRP(paf
)->id
);
11961 json_object_int_add(json_addr
, "packetQueueLength",
11962 bpacket_queue_virtual_length(paf
));
11965 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11966 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11967 PEER_CAP_ORF_PREFIX_SM_RCV
)
11968 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11969 PEER_CAP_ORF_PREFIX_RM_ADV
)
11970 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11971 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11972 json_object_int_add(json_af
, "orfType",
11974 json_prefA
= json_object_new_object();
11975 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11976 PEER_CAP_ORF_PREFIX_SM_ADV
,
11977 PEER_CAP_ORF_PREFIX_RM_ADV
,
11978 PEER_CAP_ORF_PREFIX_SM_RCV
,
11979 PEER_CAP_ORF_PREFIX_RM_RCV
,
11980 use_json
, json_prefA
);
11981 json_object_object_add(json_af
, "orfPrefixList",
11985 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11986 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11987 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11988 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11989 PEER_CAP_ORF_PREFIX_RM_ADV
)
11990 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11991 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11992 json_object_int_add(json_af
, "orfOldType",
11993 ORF_TYPE_PREFIX_OLD
);
11994 json_prefB
= json_object_new_object();
11995 bgp_show_peer_afi_orf_cap(
11996 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11997 PEER_CAP_ORF_PREFIX_RM_ADV
,
11998 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11999 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12001 json_object_object_add(json_af
, "orfOldPrefixList",
12005 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12006 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12007 PEER_CAP_ORF_PREFIX_SM_RCV
)
12008 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12009 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12010 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12011 PEER_CAP_ORF_PREFIX_RM_ADV
)
12012 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12013 PEER_CAP_ORF_PREFIX_RM_RCV
)
12014 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12015 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12016 json_object_object_add(json_addr
, "afDependentCap",
12019 json_object_free(json_af
);
12021 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12022 p
->host
, afi
, safi
);
12023 orf_pfx_count
= prefix_bgp_show_prefix_list(
12024 NULL
, afi
, orf_pfx_name
, use_json
);
12026 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12027 PEER_STATUS_ORF_PREFIX_SEND
)
12028 || orf_pfx_count
) {
12029 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12030 PEER_STATUS_ORF_PREFIX_SEND
))
12031 json_object_boolean_true_add(json_neigh
,
12034 json_object_int_add(json_addr
, "orfRecvCounter",
12037 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12038 PEER_STATUS_ORF_WAIT_REFRESH
))
12039 json_object_string_add(
12040 json_addr
, "orfFirstUpdate",
12041 "deferredUntilORFOrRouteRefreshRecvd");
12043 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12044 PEER_FLAG_REFLECTOR_CLIENT
))
12045 json_object_boolean_true_add(json_addr
,
12046 "routeReflectorClient");
12047 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12048 PEER_FLAG_RSERVER_CLIENT
))
12049 json_object_boolean_true_add(json_addr
,
12050 "routeServerClient");
12051 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12052 json_object_boolean_true_add(json_addr
,
12053 "inboundSoftConfigPermit");
12055 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12056 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12057 json_object_boolean_true_add(
12059 "privateAsNumsAllReplacedInUpdatesToNbr");
12060 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12061 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12062 json_object_boolean_true_add(
12064 "privateAsNumsReplacedInUpdatesToNbr");
12065 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12066 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12067 json_object_boolean_true_add(
12069 "privateAsNumsAllRemovedInUpdatesToNbr");
12070 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12071 PEER_FLAG_REMOVE_PRIVATE_AS
))
12072 json_object_boolean_true_add(
12074 "privateAsNumsRemovedInUpdatesToNbr");
12076 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12077 json_object_boolean_true_add(
12079 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12082 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12083 json_object_string_add(json_addr
,
12084 "overrideASNsInOutboundUpdates",
12085 "ifAspathEqualRemoteAs");
12087 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12088 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12089 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12090 json_object_boolean_true_add(json_addr
,
12091 "routerAlwaysNextHop");
12092 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12093 PEER_FLAG_AS_PATH_UNCHANGED
))
12094 json_object_boolean_true_add(
12095 json_addr
, "unchangedAsPathPropogatedToNbr");
12096 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12097 PEER_FLAG_NEXTHOP_UNCHANGED
))
12098 json_object_boolean_true_add(
12099 json_addr
, "unchangedNextHopPropogatedToNbr");
12100 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12101 json_object_boolean_true_add(
12102 json_addr
, "unchangedMedPropogatedToNbr");
12103 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12104 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12105 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12106 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12107 PEER_FLAG_SEND_COMMUNITY
)
12108 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12109 PEER_FLAG_SEND_EXT_COMMUNITY
))
12110 json_object_string_add(json_addr
,
12111 "commAttriSentToNbr",
12112 "extendedAndStandard");
12113 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12114 PEER_FLAG_SEND_EXT_COMMUNITY
))
12115 json_object_string_add(json_addr
,
12116 "commAttriSentToNbr",
12119 json_object_string_add(json_addr
,
12120 "commAttriSentToNbr",
12123 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12124 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12125 if (p
->default_rmap
[afi
][safi
].name
)
12126 json_object_string_add(
12127 json_addr
, "defaultRouteMap",
12128 p
->default_rmap
[afi
][safi
].name
);
12130 if (paf
&& PAF_SUBGRP(paf
)
12131 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12132 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12133 json_object_boolean_true_add(json_addr
,
12136 json_object_boolean_true_add(json_addr
,
12140 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12141 if (is_evpn_enabled())
12142 json_object_boolean_true_add(
12143 json_addr
, "advertiseAllVnis");
12146 if (filter
->plist
[FILTER_IN
].name
12147 || filter
->dlist
[FILTER_IN
].name
12148 || filter
->aslist
[FILTER_IN
].name
12149 || filter
->map
[RMAP_IN
].name
)
12150 json_object_boolean_true_add(json_addr
,
12151 "inboundPathPolicyConfig");
12152 if (filter
->plist
[FILTER_OUT
].name
12153 || filter
->dlist
[FILTER_OUT
].name
12154 || filter
->aslist
[FILTER_OUT
].name
12155 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12156 json_object_boolean_true_add(
12157 json_addr
, "outboundPathPolicyConfig");
12160 if (filter
->plist
[FILTER_IN
].name
)
12161 json_object_string_add(json_addr
,
12162 "incomingUpdatePrefixFilterList",
12163 filter
->plist
[FILTER_IN
].name
);
12164 if (filter
->plist
[FILTER_OUT
].name
)
12165 json_object_string_add(json_addr
,
12166 "outgoingUpdatePrefixFilterList",
12167 filter
->plist
[FILTER_OUT
].name
);
12169 /* distribute-list */
12170 if (filter
->dlist
[FILTER_IN
].name
)
12171 json_object_string_add(
12172 json_addr
, "incomingUpdateNetworkFilterList",
12173 filter
->dlist
[FILTER_IN
].name
);
12174 if (filter
->dlist
[FILTER_OUT
].name
)
12175 json_object_string_add(
12176 json_addr
, "outgoingUpdateNetworkFilterList",
12177 filter
->dlist
[FILTER_OUT
].name
);
12180 if (filter
->aslist
[FILTER_IN
].name
)
12181 json_object_string_add(json_addr
,
12182 "incomingUpdateAsPathFilterList",
12183 filter
->aslist
[FILTER_IN
].name
);
12184 if (filter
->aslist
[FILTER_OUT
].name
)
12185 json_object_string_add(json_addr
,
12186 "outgoingUpdateAsPathFilterList",
12187 filter
->aslist
[FILTER_OUT
].name
);
12190 if (filter
->map
[RMAP_IN
].name
)
12191 json_object_string_add(
12192 json_addr
, "routeMapForIncomingAdvertisements",
12193 filter
->map
[RMAP_IN
].name
);
12194 if (filter
->map
[RMAP_OUT
].name
)
12195 json_object_string_add(
12196 json_addr
, "routeMapForOutgoingAdvertisements",
12197 filter
->map
[RMAP_OUT
].name
);
12199 /* ebgp-requires-policy (inbound) */
12200 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12201 && !bgp_inbound_policy_exists(p
, filter
))
12202 json_object_string_add(
12203 json_addr
, "inboundEbgpRequiresPolicy",
12204 "Inbound updates discarded due to missing policy");
12206 /* ebgp-requires-policy (outbound) */
12207 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12208 && (!bgp_outbound_policy_exists(p
, filter
)))
12209 json_object_string_add(
12210 json_addr
, "outboundEbgpRequiresPolicy",
12211 "Outbound updates discarded due to missing policy");
12213 /* unsuppress-map */
12214 if (filter
->usmap
.name
)
12215 json_object_string_add(json_addr
,
12216 "selectiveUnsuppressRouteMap",
12217 filter
->usmap
.name
);
12219 /* advertise-map */
12220 if (filter
->advmap
.aname
) {
12221 json_advmap
= json_object_new_object();
12222 json_object_string_add(json_advmap
, "condition",
12223 filter
->advmap
.condition
12226 json_object_string_add(json_advmap
, "conditionMap",
12227 filter
->advmap
.cname
);
12228 json_object_string_add(json_advmap
, "advertiseMap",
12229 filter
->advmap
.aname
);
12230 json_object_string_add(
12231 json_advmap
, "advertiseStatus",
12232 filter
->advmap
.update_type
==
12233 UPDATE_TYPE_ADVERTISE
12236 json_object_object_add(json_addr
, "advertiseMap",
12240 /* Receive prefix count */
12241 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12242 p
->pcount
[afi
][safi
]);
12243 if (paf
&& PAF_SUBGRP(paf
))
12244 json_object_int_add(json_addr
, "sentPrefixCounter",
12245 (PAF_SUBGRP(paf
))->scount
);
12247 /* Maximum prefix */
12248 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12249 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12250 p
->pmax_out
[afi
][safi
]);
12252 /* Maximum prefix */
12253 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12254 json_object_int_add(json_addr
, "prefixAllowedMax",
12255 p
->pmax
[afi
][safi
]);
12256 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12257 PEER_FLAG_MAX_PREFIX_WARNING
))
12258 json_object_boolean_true_add(
12259 json_addr
, "prefixAllowedMaxWarning");
12260 json_object_int_add(json_addr
,
12261 "prefixAllowedWarningThresh",
12262 p
->pmax_threshold
[afi
][safi
]);
12263 if (p
->pmax_restart
[afi
][safi
])
12264 json_object_int_add(
12266 "prefixAllowedRestartIntervalMsecs",
12267 p
->pmax_restart
[afi
][safi
] * 60000);
12269 json_object_object_add(json_neigh
,
12270 get_afi_safi_str(afi
, safi
, true),
12274 filter
= &p
->filter
[afi
][safi
];
12276 vty_out(vty
, " For address family: %s\n",
12277 get_afi_safi_str(afi
, safi
, false));
12279 if (peer_group_active(p
))
12280 vty_out(vty
, " %s peer-group member\n",
12283 paf
= peer_af_find(p
, afi
, safi
);
12284 if (paf
&& PAF_SUBGRP(paf
)) {
12285 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12286 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12287 vty_out(vty
, " Packet Queue length %d\n",
12288 bpacket_queue_virtual_length(paf
));
12290 vty_out(vty
, " Not part of any update group\n");
12292 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12293 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12294 PEER_CAP_ORF_PREFIX_SM_RCV
)
12295 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12296 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12297 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12298 PEER_CAP_ORF_PREFIX_RM_ADV
)
12299 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12300 PEER_CAP_ORF_PREFIX_RM_RCV
)
12301 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12302 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12303 vty_out(vty
, " AF-dependant capabilities:\n");
12305 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12306 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12307 PEER_CAP_ORF_PREFIX_SM_RCV
)
12308 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12309 PEER_CAP_ORF_PREFIX_RM_ADV
)
12310 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12311 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12313 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12315 bgp_show_peer_afi_orf_cap(
12316 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12317 PEER_CAP_ORF_PREFIX_RM_ADV
,
12318 PEER_CAP_ORF_PREFIX_SM_RCV
,
12319 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12321 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12322 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12323 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12324 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12325 PEER_CAP_ORF_PREFIX_RM_ADV
)
12326 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12327 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12329 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12330 ORF_TYPE_PREFIX_OLD
);
12331 bgp_show_peer_afi_orf_cap(
12332 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12333 PEER_CAP_ORF_PREFIX_RM_ADV
,
12334 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12335 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12338 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12339 p
->host
, afi
, safi
);
12340 orf_pfx_count
= prefix_bgp_show_prefix_list(
12341 NULL
, afi
, orf_pfx_name
, use_json
);
12343 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12344 PEER_STATUS_ORF_PREFIX_SEND
)
12345 || orf_pfx_count
) {
12346 vty_out(vty
, " Outbound Route Filter (ORF):");
12347 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12348 PEER_STATUS_ORF_PREFIX_SEND
))
12349 vty_out(vty
, " sent;");
12351 vty_out(vty
, " received (%d entries)",
12353 vty_out(vty
, "\n");
12355 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12356 PEER_STATUS_ORF_WAIT_REFRESH
))
12358 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12360 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12361 PEER_FLAG_REFLECTOR_CLIENT
))
12362 vty_out(vty
, " Route-Reflector Client\n");
12363 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12364 PEER_FLAG_RSERVER_CLIENT
))
12365 vty_out(vty
, " Route-Server Client\n");
12366 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12368 " Inbound soft reconfiguration allowed\n");
12370 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12371 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12373 " Private AS numbers (all) replaced in updates to this neighbor\n");
12374 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12375 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12377 " Private AS numbers replaced in updates to this neighbor\n");
12378 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12379 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12381 " Private AS numbers (all) removed in updates to this neighbor\n");
12382 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12383 PEER_FLAG_REMOVE_PRIVATE_AS
))
12385 " Private AS numbers removed in updates to this neighbor\n");
12387 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12388 vty_out(vty
, " %s\n",
12389 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12390 ->human_description
);
12392 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12394 " Override ASNs in outbound updates if aspath equals remote-as\n");
12396 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12397 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12398 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12399 vty_out(vty
, " NEXT_HOP is always this router\n");
12400 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12401 PEER_FLAG_AS_PATH_UNCHANGED
))
12403 " AS_PATH is propagated unchanged to this neighbor\n");
12404 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12405 PEER_FLAG_NEXTHOP_UNCHANGED
))
12407 " NEXT_HOP is propagated unchanged to this neighbor\n");
12408 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12410 " MED is propagated unchanged to this neighbor\n");
12411 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12412 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12413 PEER_FLAG_SEND_EXT_COMMUNITY
)
12414 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12417 " Community attribute sent to this neighbor");
12418 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12419 PEER_FLAG_SEND_COMMUNITY
)
12420 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12421 PEER_FLAG_SEND_EXT_COMMUNITY
)
12422 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12424 vty_out(vty
, "(all)\n");
12425 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12426 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12427 vty_out(vty
, "(large)\n");
12428 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12429 PEER_FLAG_SEND_EXT_COMMUNITY
))
12430 vty_out(vty
, "(extended)\n");
12432 vty_out(vty
, "(standard)\n");
12434 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12435 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12436 vty_out(vty
, " Default information originate,");
12438 if (p
->default_rmap
[afi
][safi
].name
)
12439 vty_out(vty
, " default route-map %s%s,",
12440 p
->default_rmap
[afi
][safi
].map
? "*"
12442 p
->default_rmap
[afi
][safi
].name
);
12443 if (paf
&& PAF_SUBGRP(paf
)
12444 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12445 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12446 vty_out(vty
, " default sent\n");
12448 vty_out(vty
, " default not sent\n");
12451 /* advertise-vni-all */
12452 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12453 if (is_evpn_enabled())
12454 vty_out(vty
, " advertise-all-vni\n");
12457 if (filter
->plist
[FILTER_IN
].name
12458 || filter
->dlist
[FILTER_IN
].name
12459 || filter
->aslist
[FILTER_IN
].name
12460 || filter
->map
[RMAP_IN
].name
)
12461 vty_out(vty
, " Inbound path policy configured\n");
12462 if (filter
->plist
[FILTER_OUT
].name
12463 || filter
->dlist
[FILTER_OUT
].name
12464 || filter
->aslist
[FILTER_OUT
].name
12465 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12466 vty_out(vty
, " Outbound path policy configured\n");
12469 if (filter
->plist
[FILTER_IN
].name
)
12471 " Incoming update prefix filter list is %s%s\n",
12472 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12473 filter
->plist
[FILTER_IN
].name
);
12474 if (filter
->plist
[FILTER_OUT
].name
)
12476 " Outgoing update prefix filter list is %s%s\n",
12477 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12478 filter
->plist
[FILTER_OUT
].name
);
12480 /* distribute-list */
12481 if (filter
->dlist
[FILTER_IN
].name
)
12483 " Incoming update network filter list is %s%s\n",
12484 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12485 filter
->dlist
[FILTER_IN
].name
);
12486 if (filter
->dlist
[FILTER_OUT
].name
)
12488 " Outgoing update network filter list is %s%s\n",
12489 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12490 filter
->dlist
[FILTER_OUT
].name
);
12493 if (filter
->aslist
[FILTER_IN
].name
)
12495 " Incoming update AS path filter list is %s%s\n",
12496 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12497 filter
->aslist
[FILTER_IN
].name
);
12498 if (filter
->aslist
[FILTER_OUT
].name
)
12500 " Outgoing update AS path filter list is %s%s\n",
12501 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12502 filter
->aslist
[FILTER_OUT
].name
);
12505 if (filter
->map
[RMAP_IN
].name
)
12507 " Route map for incoming advertisements is %s%s\n",
12508 filter
->map
[RMAP_IN
].map
? "*" : "",
12509 filter
->map
[RMAP_IN
].name
);
12510 if (filter
->map
[RMAP_OUT
].name
)
12512 " Route map for outgoing advertisements is %s%s\n",
12513 filter
->map
[RMAP_OUT
].map
? "*" : "",
12514 filter
->map
[RMAP_OUT
].name
);
12516 /* ebgp-requires-policy (inbound) */
12517 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12518 && !bgp_inbound_policy_exists(p
, filter
))
12520 " Inbound updates discarded due to missing policy\n");
12522 /* ebgp-requires-policy (outbound) */
12523 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12524 && !bgp_outbound_policy_exists(p
, filter
))
12526 " Outbound updates discarded due to missing policy\n");
12528 /* unsuppress-map */
12529 if (filter
->usmap
.name
)
12531 " Route map for selective unsuppress is %s%s\n",
12532 filter
->usmap
.map
? "*" : "",
12533 filter
->usmap
.name
);
12535 /* advertise-map */
12536 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12538 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12539 filter
->advmap
.condition
? "EXIST"
12541 filter
->advmap
.cmap
? "*" : "",
12542 filter
->advmap
.cname
,
12543 filter
->advmap
.amap
? "*" : "",
12544 filter
->advmap
.aname
,
12545 filter
->advmap
.update_type
==
12546 UPDATE_TYPE_ADVERTISE
12550 /* Receive prefix count */
12551 vty_out(vty
, " %u accepted prefixes\n",
12552 p
->pcount
[afi
][safi
]);
12554 /* maximum-prefix-out */
12555 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12556 PEER_FLAG_MAX_PREFIX_OUT
))
12558 " Maximum allowed prefixes sent %u\n",
12559 p
->pmax_out
[afi
][safi
]);
12561 /* Maximum prefix */
12562 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12564 " Maximum prefixes allowed %u%s\n",
12565 p
->pmax
[afi
][safi
],
12566 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12567 PEER_FLAG_MAX_PREFIX_WARNING
)
12568 ? " (warning-only)"
12570 vty_out(vty
, " Threshold for warning message %d%%",
12571 p
->pmax_threshold
[afi
][safi
]);
12572 if (p
->pmax_restart
[afi
][safi
])
12573 vty_out(vty
, ", restart interval %d min",
12574 p
->pmax_restart
[afi
][safi
]);
12575 vty_out(vty
, "\n");
12578 vty_out(vty
, "\n");
12582 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12586 char buf1
[PREFIX2STR_BUFFER
];
12587 char timebuf
[BGP_UPTIME_LEN
];
12593 json_object
*json_neigh
= NULL
;
12595 uint32_t sync_tcp_mss
;
12600 json_neigh
= json_object_new_object();
12602 memset(dn_flag
, '\0', sizeof(dn_flag
));
12603 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12607 if (p
->conf_if
) /* Configured interface name. */
12608 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12610 else /* Configured IP address. */
12611 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12616 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12617 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12619 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12620 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12623 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12625 if (p
->change_local_as
)
12626 json_object_int_add(json_neigh
, "localAs",
12627 p
->change_local_as
);
12629 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12631 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12632 json_object_boolean_true_add(json_neigh
,
12633 "localAsNoPrepend");
12635 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12636 json_object_boolean_true_add(json_neigh
,
12637 "localAsReplaceAs");
12639 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12640 || (p
->as_type
== AS_INTERNAL
))
12641 vty_out(vty
, "remote AS %u, ", p
->as
);
12643 vty_out(vty
, "remote AS Unspecified, ");
12644 vty_out(vty
, "local AS %u%s%s, ",
12645 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12646 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12649 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12653 /* peer type internal or confed-internal */
12654 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12656 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12657 json_object_boolean_true_add(
12658 json_neigh
, "nbrConfedInternalLink");
12660 json_object_boolean_true_add(json_neigh
,
12661 "nbrInternalLink");
12663 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12664 vty_out(vty
, "confed-internal link\n");
12666 vty_out(vty
, "internal link\n");
12668 /* peer type external or confed-external */
12669 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12671 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12672 json_object_boolean_true_add(
12673 json_neigh
, "nbrConfedExternalLink");
12675 json_object_boolean_true_add(json_neigh
,
12676 "nbrExternalLink");
12678 if (bgp_confederation_peers_check(bgp
, p
->as
))
12679 vty_out(vty
, "confed-external link\n");
12681 vty_out(vty
, "external link\n");
12685 json_object_boolean_true_add(json_neigh
,
12686 "nbrUnspecifiedLink");
12688 vty_out(vty
, "unspecified link\n");
12693 json_object_string_add(json_neigh
, "localRole",
12694 bgp_get_name_by_role(p
->local_role
));
12695 json_object_string_add(json_neigh
, "remoteRole",
12696 bgp_get_name_by_role(p
->remote_role
));
12698 vty_out(vty
, " Local Role: %s\n",
12699 bgp_get_name_by_role(p
->local_role
));
12700 vty_out(vty
, " Remote Role: %s\n",
12701 bgp_get_name_by_role(p
->remote_role
));
12708 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12710 vty_out(vty
, " Description: %s\n", p
->desc
);
12716 json_object_string_add(json_neigh
, "hostname",
12720 json_object_string_add(json_neigh
, "domainname",
12723 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12724 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12727 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12734 json_object_string_add(json_neigh
, "peerGroup",
12738 struct prefix prefix
, *range
= NULL
;
12740 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12741 range
= peer_group_lookup_dynamic_neighbor_range(
12742 p
->group
, &prefix
);
12745 json_object_string_addf(
12747 "peerSubnetRangeGroup", "%pFX",
12753 " Member of peer-group %s for session parameters\n",
12757 struct prefix prefix
, *range
= NULL
;
12759 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12760 range
= peer_group_lookup_dynamic_neighbor_range(
12761 p
->group
, &prefix
);
12765 " Belongs to the subnet range group: %pFX\n",
12773 /* Administrative shutdown. */
12774 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12775 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12776 json_object_boolean_true_add(json_neigh
,
12780 json_object_int_add(json_neigh
, "bgpVersion", 4);
12781 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12783 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12786 /* Confederation */
12787 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12788 && bgp_confederation_peers_check(bgp
, p
->as
))
12789 json_object_boolean_true_add(json_neigh
,
12793 json_object_string_add(
12794 json_neigh
, "bgpState",
12795 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12797 if (peer_established(p
)) {
12800 uptime
= monotime(NULL
);
12801 uptime
-= p
->uptime
;
12802 epoch_tbuf
= time(NULL
) - uptime
;
12804 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12806 json_object_string_add(json_neigh
, "bgpTimerUpString",
12807 peer_uptime(p
->uptime
, timebuf
,
12810 json_object_int_add(json_neigh
,
12811 "bgpTimerUpEstablishedEpoch",
12815 else if (p
->status
== Active
) {
12816 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12817 json_object_string_add(json_neigh
, "bgpStateIs",
12819 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12820 json_object_string_add(json_neigh
, "bgpStateIs",
12828 uptime
= monotime(NULL
);
12829 uptime
-= p
->readtime
;
12830 gmtime_r(&uptime
, &tm
);
12832 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12833 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12834 + (tm
.tm_hour
* 3600000));
12836 uptime
= monotime(NULL
);
12837 uptime
-= p
->last_write
;
12838 gmtime_r(&uptime
, &tm
);
12840 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12841 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12842 + (tm
.tm_hour
* 3600000));
12844 uptime
= monotime(NULL
);
12845 uptime
-= p
->update_time
;
12846 gmtime_r(&uptime
, &tm
);
12848 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12849 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12850 + (tm
.tm_hour
* 3600000));
12852 /* Configured timer values. */
12853 json_object_int_add(json_neigh
,
12854 "bgpTimerConfiguredHoldTimeMsecs",
12855 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12856 ? p
->holdtime
* 1000
12857 : bgp
->default_holdtime
* 1000);
12858 json_object_int_add(json_neigh
,
12859 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12860 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12861 ? p
->keepalive
* 1000
12862 : bgp
->default_keepalive
* 1000);
12863 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12864 p
->v_holdtime
* 1000);
12865 json_object_int_add(json_neigh
,
12866 "bgpTimerKeepAliveIntervalMsecs",
12867 p
->v_keepalive
* 1000);
12868 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12869 json_object_int_add(json_neigh
,
12870 "bgpTimerDelayOpenTimeMsecs",
12871 p
->v_delayopen
* 1000);
12874 /* Configured and Synced tcp-mss value for peer */
12875 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12876 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12877 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12879 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12883 /* Extended Optional Parameters Length for BGP OPEN Message */
12884 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12885 json_object_boolean_true_add(
12886 json_neigh
, "extendedOptionalParametersLength");
12888 json_object_boolean_false_add(
12889 json_neigh
, "extendedOptionalParametersLength");
12891 /* Conditional advertisements */
12892 json_object_int_add(
12894 "bgpTimerConfiguredConditionalAdvertisementsSec",
12895 bgp
->condition_check_period
);
12896 if (thread_is_scheduled(bgp
->t_condition_check
))
12897 json_object_int_add(
12899 "bgpTimerUntilConditionalAdvertisementsSec",
12900 thread_timer_remain_second(
12901 bgp
->t_condition_check
));
12903 /* Administrative shutdown. */
12904 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12905 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12906 vty_out(vty
, " Administratively shut down\n");
12909 vty_out(vty
, " BGP version 4");
12910 vty_out(vty
, ", remote router ID %s",
12911 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12912 vty_out(vty
, ", local router ID %s\n",
12913 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12916 /* Confederation */
12917 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12918 && bgp_confederation_peers_check(bgp
, p
->as
))
12920 " Neighbor under common administration\n");
12923 vty_out(vty
, " BGP state = %s",
12924 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12926 if (peer_established(p
))
12927 vty_out(vty
, ", up for %8s",
12928 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12931 else if (p
->status
== Active
) {
12932 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12933 vty_out(vty
, " (passive)");
12934 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12935 vty_out(vty
, " (NSF passive)");
12937 vty_out(vty
, "\n");
12940 vty_out(vty
, " Last read %s",
12941 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12943 vty_out(vty
, ", Last write %s\n",
12944 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12947 /* Configured timer values. */
12949 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12950 p
->v_holdtime
, p
->v_keepalive
);
12951 vty_out(vty
, " Configured hold time is %d seconds",
12952 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12954 : bgp
->default_holdtime
);
12955 vty_out(vty
, ", keepalive interval is %d seconds\n",
12956 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12958 : bgp
->default_keepalive
);
12959 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12961 " Configured DelayOpenTime is %d seconds\n",
12964 /* Configured and synced tcp-mss value for peer */
12965 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12966 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12967 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12968 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12971 /* Extended Optional Parameters Length for BGP OPEN Message */
12972 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12974 " Extended Optional Parameters Length is enabled\n");
12976 /* Conditional advertisements */
12978 " Configured conditional advertisements interval is %d seconds\n",
12979 bgp
->condition_check_period
);
12980 if (thread_is_scheduled(bgp
->t_condition_check
))
12982 " Time until conditional advertisements begin is %lu seconds\n",
12983 thread_timer_remain_second(
12984 bgp
->t_condition_check
));
12987 if (peer_established(p
) &&
12988 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12990 json_object
*json_cap
= NULL
;
12992 json_cap
= json_object_new_object();
12995 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12996 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12997 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12998 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12999 json_object_string_add(
13000 json_cap
, "4byteAs",
13001 "advertisedAndReceived");
13002 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13003 json_object_string_add(json_cap
,
13006 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13007 json_object_string_add(json_cap
,
13012 /* Extended Message Support */
13013 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13014 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13015 json_object_string_add(json_cap
,
13017 "advertisedAndReceived");
13018 else if (CHECK_FLAG(p
->cap
,
13019 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13020 json_object_string_add(json_cap
,
13023 else if (CHECK_FLAG(p
->cap
,
13024 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13025 json_object_string_add(json_cap
,
13030 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13031 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13032 json_object
*json_add
= NULL
;
13033 const char *print_store
;
13035 json_add
= json_object_new_object();
13037 FOREACH_AFI_SAFI (afi
, safi
) {
13038 json_object
*json_sub
= NULL
;
13039 json_sub
= json_object_new_object();
13040 print_store
= get_afi_safi_str(
13044 p
->af_cap
[afi
][safi
],
13045 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13047 p
->af_cap
[afi
][safi
],
13048 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13052 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13056 PEER_CAP_ADDPATH_AF_TX_RCV
))
13057 json_object_boolean_true_add(
13059 "txAdvertisedAndReceived");
13064 PEER_CAP_ADDPATH_AF_TX_ADV
))
13065 json_object_boolean_true_add(
13072 PEER_CAP_ADDPATH_AF_TX_RCV
))
13073 json_object_boolean_true_add(
13079 p
->af_cap
[afi
][safi
],
13080 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13082 p
->af_cap
[afi
][safi
],
13083 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13087 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13091 PEER_CAP_ADDPATH_AF_RX_RCV
))
13092 json_object_boolean_true_add(
13094 "rxAdvertisedAndReceived");
13099 PEER_CAP_ADDPATH_AF_RX_ADV
))
13100 json_object_boolean_true_add(
13107 PEER_CAP_ADDPATH_AF_RX_RCV
))
13108 json_object_boolean_true_add(
13114 p
->af_cap
[afi
][safi
],
13115 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13117 p
->af_cap
[afi
][safi
],
13118 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13120 p
->af_cap
[afi
][safi
],
13121 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13123 p
->af_cap
[afi
][safi
],
13124 PEER_CAP_ADDPATH_AF_RX_RCV
))
13125 json_object_object_add(
13126 json_add
, print_store
,
13129 json_object_free(json_sub
);
13132 json_object_object_add(json_cap
, "addPath",
13137 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13138 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13139 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13140 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13141 json_object_string_add(
13142 json_cap
, "dynamic",
13143 "advertisedAndReceived");
13144 else if (CHECK_FLAG(p
->cap
,
13145 PEER_CAP_DYNAMIC_ADV
))
13146 json_object_string_add(json_cap
,
13149 else if (CHECK_FLAG(p
->cap
,
13150 PEER_CAP_DYNAMIC_RCV
))
13151 json_object_string_add(json_cap
,
13157 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13158 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13159 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13160 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13161 json_object_string_add(
13163 "advertisedAndReceived");
13164 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13165 json_object_string_add(json_cap
, "role",
13167 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13168 json_object_string_add(json_cap
, "role",
13172 /* Extended nexthop */
13173 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13174 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13175 json_object
*json_nxt
= NULL
;
13176 const char *print_store
;
13179 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13180 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13181 json_object_string_add(
13182 json_cap
, "extendedNexthop",
13183 "advertisedAndReceived");
13184 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13185 json_object_string_add(
13186 json_cap
, "extendedNexthop",
13188 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13189 json_object_string_add(
13190 json_cap
, "extendedNexthop",
13193 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13194 json_nxt
= json_object_new_object();
13196 for (safi
= SAFI_UNICAST
;
13197 safi
< SAFI_MAX
; safi
++) {
13201 PEER_CAP_ENHE_AF_RCV
)) {
13207 json_object_string_add(
13210 "recieved"); /* misspelled for compatibility */
13213 json_object_object_add(
13215 "extendedNexthopFamililesByPeer",
13220 /* Long-lived Graceful Restart */
13221 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13222 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13223 json_object
*json_llgr
= NULL
;
13224 const char *afi_safi_str
;
13226 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13227 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13228 json_object_string_add(
13230 "longLivedGracefulRestart",
13231 "advertisedAndReceived");
13232 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13233 json_object_string_add(
13235 "longLivedGracefulRestart",
13237 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13238 json_object_string_add(
13240 "longLivedGracefulRestart",
13243 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13244 json_llgr
= json_object_new_object();
13246 FOREACH_AFI_SAFI (afi
, safi
) {
13250 PEER_CAP_ENHE_AF_RCV
)) {
13256 json_object_string_add(
13262 json_object_object_add(
13264 "longLivedGracefulRestartByPeer",
13269 /* Route Refresh */
13270 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13271 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13272 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13273 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13274 (CHECK_FLAG(p
->cap
,
13275 PEER_CAP_REFRESH_NEW_RCV
) ||
13277 PEER_CAP_REFRESH_OLD_RCV
))) {
13280 PEER_CAP_REFRESH_OLD_RCV
) &&
13283 PEER_CAP_REFRESH_NEW_RCV
))
13284 json_object_string_add(
13287 "advertisedAndReceivedOldNew");
13291 PEER_CAP_REFRESH_OLD_RCV
))
13292 json_object_string_add(
13295 "advertisedAndReceivedOld");
13297 json_object_string_add(
13300 "advertisedAndReceivedNew");
13302 } else if (CHECK_FLAG(p
->cap
,
13303 PEER_CAP_REFRESH_ADV
))
13304 json_object_string_add(json_cap
,
13307 else if (CHECK_FLAG(p
->cap
,
13308 PEER_CAP_REFRESH_NEW_RCV
) ||
13310 PEER_CAP_REFRESH_OLD_RCV
))
13311 json_object_string_add(json_cap
,
13316 /* Enhanced Route Refresh */
13317 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13318 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13319 if (CHECK_FLAG(p
->cap
,
13320 PEER_CAP_ENHANCED_RR_ADV
) &&
13322 PEER_CAP_ENHANCED_RR_RCV
))
13323 json_object_string_add(
13325 "enhancedRouteRefresh",
13326 "advertisedAndReceived");
13327 else if (CHECK_FLAG(p
->cap
,
13328 PEER_CAP_ENHANCED_RR_ADV
))
13329 json_object_string_add(
13331 "enhancedRouteRefresh",
13333 else if (CHECK_FLAG(p
->cap
,
13334 PEER_CAP_ENHANCED_RR_RCV
))
13335 json_object_string_add(
13337 "enhancedRouteRefresh",
13341 /* Multiprotocol Extensions */
13342 json_object
*json_multi
= NULL
;
13344 json_multi
= json_object_new_object();
13346 FOREACH_AFI_SAFI (afi
, safi
) {
13347 if (p
->afc_adv
[afi
][safi
] ||
13348 p
->afc_recv
[afi
][safi
]) {
13349 json_object
*json_exten
= NULL
;
13350 json_exten
= json_object_new_object();
13352 if (p
->afc_adv
[afi
][safi
] &&
13353 p
->afc_recv
[afi
][safi
])
13354 json_object_boolean_true_add(
13356 "advertisedAndReceived");
13357 else if (p
->afc_adv
[afi
][safi
])
13358 json_object_boolean_true_add(
13361 else if (p
->afc_recv
[afi
][safi
])
13362 json_object_boolean_true_add(
13363 json_exten
, "received");
13365 json_object_object_add(
13367 get_afi_safi_str(afi
, safi
,
13372 json_object_object_add(json_cap
,
13373 "multiprotocolExtensions",
13376 /* Hostname capabilities */
13377 json_object
*json_hname
= NULL
;
13379 json_hname
= json_object_new_object();
13381 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13382 json_object_string_add(
13383 json_hname
, "advHostName",
13384 bgp
->peer_self
->hostname
13385 ? bgp
->peer_self
->hostname
13387 json_object_string_add(
13388 json_hname
, "advDomainName",
13389 bgp
->peer_self
->domainname
13390 ? bgp
->peer_self
->domainname
13395 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13396 json_object_string_add(
13397 json_hname
, "rcvHostName",
13398 p
->hostname
? p
->hostname
: "n/a");
13399 json_object_string_add(
13400 json_hname
, "rcvDomainName",
13401 p
->domainname
? p
->domainname
: "n/a");
13404 json_object_object_add(json_cap
, "hostName",
13407 /* Graceful Restart */
13408 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13409 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13410 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13411 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13412 json_object_string_add(
13413 json_cap
, "gracefulRestart",
13414 "advertisedAndReceived");
13415 else if (CHECK_FLAG(p
->cap
,
13416 PEER_CAP_RESTART_ADV
))
13417 json_object_string_add(
13419 "gracefulRestartCapability",
13421 else if (CHECK_FLAG(p
->cap
,
13422 PEER_CAP_RESTART_RCV
))
13423 json_object_string_add(
13425 "gracefulRestartCapability",
13428 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13429 int restart_af_count
= 0;
13430 json_object
*json_restart
= NULL
;
13431 json_restart
= json_object_new_object();
13433 json_object_int_add(
13435 "gracefulRestartRemoteTimerMsecs",
13436 p
->v_gr_restart
* 1000);
13438 FOREACH_AFI_SAFI (afi
, safi
) {
13442 PEER_CAP_RESTART_AF_RCV
)) {
13443 json_object
*json_sub
=
13446 json_object_new_object();
13452 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13453 json_object_boolean_true_add(
13456 restart_af_count
++;
13457 json_object_object_add(
13466 if (!restart_af_count
) {
13467 json_object_string_add(
13469 "addressFamiliesByPeer",
13471 json_object_free(json_restart
);
13473 json_object_object_add(
13475 "addressFamiliesByPeer",
13479 json_object_object_add(
13480 json_neigh
, "neighborCapabilities", json_cap
);
13482 vty_out(vty
, " Neighbor capabilities:\n");
13485 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13486 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13487 vty_out(vty
, " 4 Byte AS:");
13488 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13489 vty_out(vty
, " advertised");
13490 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13491 vty_out(vty
, " %sreceived",
13496 vty_out(vty
, "\n");
13499 /* Extended Message Support */
13500 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13501 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13502 vty_out(vty
, " Extended Message:");
13503 if (CHECK_FLAG(p
->cap
,
13504 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13505 vty_out(vty
, " advertised");
13506 if (CHECK_FLAG(p
->cap
,
13507 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13508 vty_out(vty
, " %sreceived",
13511 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13514 vty_out(vty
, "\n");
13518 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13519 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13520 vty_out(vty
, " AddPath:\n");
13522 FOREACH_AFI_SAFI (afi
, safi
) {
13524 p
->af_cap
[afi
][safi
],
13525 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13527 p
->af_cap
[afi
][safi
],
13528 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13529 vty_out(vty
, " %s: TX ",
13537 PEER_CAP_ADDPATH_AF_TX_ADV
))
13544 PEER_CAP_ADDPATH_AF_TX_RCV
))
13551 PEER_CAP_ADDPATH_AF_TX_ADV
)
13555 vty_out(vty
, "\n");
13559 p
->af_cap
[afi
][safi
],
13560 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13562 p
->af_cap
[afi
][safi
],
13563 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13564 vty_out(vty
, " %s: RX ",
13572 PEER_CAP_ADDPATH_AF_RX_ADV
))
13579 PEER_CAP_ADDPATH_AF_RX_RCV
))
13586 PEER_CAP_ADDPATH_AF_RX_ADV
)
13590 vty_out(vty
, "\n");
13596 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13597 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13598 vty_out(vty
, " Dynamic:");
13599 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13600 vty_out(vty
, " advertised");
13601 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13602 vty_out(vty
, " %sreceived",
13604 PEER_CAP_DYNAMIC_ADV
)
13607 vty_out(vty
, "\n");
13611 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13612 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13613 vty_out(vty
, " Role:");
13614 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13615 vty_out(vty
, " advertised");
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13617 vty_out(vty
, " %sreceived",
13622 vty_out(vty
, "\n");
13625 /* Extended nexthop */
13626 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13627 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13628 vty_out(vty
, " Extended nexthop:");
13629 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13630 vty_out(vty
, " advertised");
13631 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13632 vty_out(vty
, " %sreceived",
13637 vty_out(vty
, "\n");
13639 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13641 " Address families by peer:\n ");
13642 for (safi
= SAFI_UNICAST
;
13643 safi
< SAFI_MAX
; safi
++)
13647 PEER_CAP_ENHE_AF_RCV
))
13657 /* Long-lived Graceful Restart */
13658 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13659 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13661 " Long-lived Graceful Restart:");
13662 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13663 vty_out(vty
, " advertised");
13664 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13665 vty_out(vty
, " %sreceived",
13670 vty_out(vty
, "\n");
13672 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13674 " Address families by peer:\n");
13675 FOREACH_AFI_SAFI (afi
, safi
)
13679 PEER_CAP_LLGR_AF_RCV
))
13689 /* Route Refresh */
13690 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13691 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13692 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13693 vty_out(vty
, " Route refresh:");
13694 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13695 vty_out(vty
, " advertised");
13696 if (CHECK_FLAG(p
->cap
,
13697 PEER_CAP_REFRESH_NEW_RCV
) ||
13699 PEER_CAP_REFRESH_OLD_RCV
))
13700 vty_out(vty
, " %sreceived(%s)",
13702 PEER_CAP_REFRESH_ADV
)
13707 PEER_CAP_REFRESH_OLD_RCV
) &&
13710 PEER_CAP_REFRESH_NEW_RCV
))
13714 PEER_CAP_REFRESH_OLD_RCV
)
13718 vty_out(vty
, "\n");
13721 /* Enhanced Route Refresh */
13722 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13723 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13724 vty_out(vty
, " Enhanced Route Refresh:");
13725 if (CHECK_FLAG(p
->cap
,
13726 PEER_CAP_ENHANCED_RR_ADV
))
13727 vty_out(vty
, " advertised");
13728 if (CHECK_FLAG(p
->cap
,
13729 PEER_CAP_ENHANCED_RR_RCV
))
13730 vty_out(vty
, " %sreceived",
13732 PEER_CAP_REFRESH_ADV
)
13735 vty_out(vty
, "\n");
13738 /* Multiprotocol Extensions */
13739 FOREACH_AFI_SAFI (afi
, safi
)
13740 if (p
->afc_adv
[afi
][safi
] ||
13741 p
->afc_recv
[afi
][safi
]) {
13742 vty_out(vty
, " Address Family %s:",
13743 get_afi_safi_str(afi
, safi
,
13745 if (p
->afc_adv
[afi
][safi
])
13746 vty_out(vty
, " advertised");
13747 if (p
->afc_recv
[afi
][safi
])
13748 vty_out(vty
, " %sreceived",
13749 p
->afc_adv
[afi
][safi
]
13752 vty_out(vty
, "\n");
13755 /* Hostname capability */
13756 vty_out(vty
, " Hostname Capability:");
13758 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13760 " advertised (name: %s,domain name: %s)",
13761 bgp
->peer_self
->hostname
13762 ? bgp
->peer_self
->hostname
13764 bgp
->peer_self
->domainname
13765 ? bgp
->peer_self
->domainname
13768 vty_out(vty
, " not advertised");
13771 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13773 " received (name: %s,domain name: %s)",
13774 p
->hostname
? p
->hostname
: "n/a",
13775 p
->domainname
? p
->domainname
: "n/a");
13777 vty_out(vty
, " not received");
13780 vty_out(vty
, "\n");
13782 /* Graceful Restart */
13783 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13784 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13786 " Graceful Restart Capability:");
13787 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13788 vty_out(vty
, " advertised");
13789 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13790 vty_out(vty
, " %sreceived",
13792 PEER_CAP_RESTART_ADV
)
13795 vty_out(vty
, "\n");
13797 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13798 int restart_af_count
= 0;
13801 " Remote Restart timer is %d seconds\n",
13804 " Address families by peer:\n ");
13806 FOREACH_AFI_SAFI (afi
, safi
)
13810 PEER_CAP_RESTART_AF_RCV
)) {
13811 vty_out(vty
, "%s%s(%s)",
13823 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13825 : "not preserved");
13826 restart_af_count
++;
13828 if (!restart_af_count
)
13829 vty_out(vty
, "none");
13830 vty_out(vty
, "\n");
13832 } /* Graceful Restart */
13836 /* graceful restart information */
13837 json_object
*json_grace
= NULL
;
13838 json_object
*json_grace_send
= NULL
;
13839 json_object
*json_grace_recv
= NULL
;
13840 int eor_send_af_count
= 0;
13841 int eor_receive_af_count
= 0;
13844 json_grace
= json_object_new_object();
13845 json_grace_send
= json_object_new_object();
13846 json_grace_recv
= json_object_new_object();
13848 if ((peer_established(p
)) &&
13849 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13850 FOREACH_AFI_SAFI (afi
, safi
) {
13851 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13852 PEER_STATUS_EOR_SEND
)) {
13853 json_object_boolean_true_add(
13855 get_afi_safi_str(afi
, safi
,
13857 eor_send_af_count
++;
13860 FOREACH_AFI_SAFI (afi
, safi
) {
13861 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13862 PEER_STATUS_EOR_RECEIVED
)) {
13863 json_object_boolean_true_add(
13865 get_afi_safi_str(afi
, safi
,
13867 eor_receive_af_count
++;
13871 json_object_object_add(json_grace
, "endOfRibSend",
13873 json_object_object_add(json_grace
, "endOfRibRecv",
13877 if (p
->t_gr_restart
)
13878 json_object_int_add(
13879 json_grace
, "gracefulRestartTimerMsecs",
13880 thread_timer_remain_second(p
->t_gr_restart
) *
13884 json_object_int_add(
13885 json_grace
, "gracefulStalepathTimerMsecs",
13886 thread_timer_remain_second(p
->t_gr_stale
) *
13888 /* more gr info in new format */
13889 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13890 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13893 vty_out(vty
, " Graceful restart information:\n");
13894 if ((peer_established(p
)) &&
13895 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13897 vty_out(vty
, " End-of-RIB send: ");
13898 FOREACH_AFI_SAFI (afi
, safi
) {
13899 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13900 PEER_STATUS_EOR_SEND
)) {
13901 vty_out(vty
, "%s%s",
13902 eor_send_af_count
? ", " : "",
13903 get_afi_safi_str(afi
, safi
,
13905 eor_send_af_count
++;
13908 vty_out(vty
, "\n");
13909 vty_out(vty
, " End-of-RIB received: ");
13910 FOREACH_AFI_SAFI (afi
, safi
) {
13911 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13912 PEER_STATUS_EOR_RECEIVED
)) {
13913 vty_out(vty
, "%s%s",
13914 eor_receive_af_count
? ", "
13916 get_afi_safi_str(afi
, safi
,
13918 eor_receive_af_count
++;
13921 vty_out(vty
, "\n");
13924 if (p
->t_gr_restart
)
13926 " The remaining time of restart timer is %ld\n",
13927 thread_timer_remain_second(p
->t_gr_restart
));
13931 " The remaining time of stalepath timer is %ld\n",
13932 thread_timer_remain_second(p
->t_gr_stale
));
13934 /* more gr info in new format */
13935 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13939 json_object
*json_stat
= NULL
;
13940 json_stat
= json_object_new_object();
13941 /* Packet counts. */
13943 atomic_size_t outq_count
, inq_count
;
13944 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13945 memory_order_relaxed
);
13946 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13947 memory_order_relaxed
);
13949 json_object_int_add(json_stat
, "depthInq",
13950 (unsigned long)inq_count
);
13951 json_object_int_add(json_stat
, "depthOutq",
13952 (unsigned long)outq_count
);
13953 json_object_int_add(json_stat
, "opensSent",
13954 atomic_load_explicit(&p
->open_out
,
13955 memory_order_relaxed
));
13956 json_object_int_add(json_stat
, "opensRecv",
13957 atomic_load_explicit(&p
->open_in
,
13958 memory_order_relaxed
));
13959 json_object_int_add(json_stat
, "notificationsSent",
13960 atomic_load_explicit(&p
->notify_out
,
13961 memory_order_relaxed
));
13962 json_object_int_add(json_stat
, "notificationsRecv",
13963 atomic_load_explicit(&p
->notify_in
,
13964 memory_order_relaxed
));
13965 json_object_int_add(json_stat
, "updatesSent",
13966 atomic_load_explicit(&p
->update_out
,
13967 memory_order_relaxed
));
13968 json_object_int_add(json_stat
, "updatesRecv",
13969 atomic_load_explicit(&p
->update_in
,
13970 memory_order_relaxed
));
13971 json_object_int_add(json_stat
, "keepalivesSent",
13972 atomic_load_explicit(&p
->keepalive_out
,
13973 memory_order_relaxed
));
13974 json_object_int_add(json_stat
, "keepalivesRecv",
13975 atomic_load_explicit(&p
->keepalive_in
,
13976 memory_order_relaxed
));
13977 json_object_int_add(json_stat
, "routeRefreshSent",
13978 atomic_load_explicit(&p
->refresh_out
,
13979 memory_order_relaxed
));
13980 json_object_int_add(json_stat
, "routeRefreshRecv",
13981 atomic_load_explicit(&p
->refresh_in
,
13982 memory_order_relaxed
));
13983 json_object_int_add(json_stat
, "capabilitySent",
13984 atomic_load_explicit(&p
->dynamic_cap_out
,
13985 memory_order_relaxed
));
13986 json_object_int_add(json_stat
, "capabilityRecv",
13987 atomic_load_explicit(&p
->dynamic_cap_in
,
13988 memory_order_relaxed
));
13989 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13990 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13991 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13993 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
13994 notify_out
, notify_in
, update_out
, update_in
,
13995 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
13996 dynamic_cap_out
, dynamic_cap_in
;
13997 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13998 memory_order_relaxed
);
13999 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14000 memory_order_relaxed
);
14001 open_out
= atomic_load_explicit(&p
->open_out
,
14002 memory_order_relaxed
);
14004 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14005 notify_out
= atomic_load_explicit(&p
->notify_out
,
14006 memory_order_relaxed
);
14007 notify_in
= atomic_load_explicit(&p
->notify_in
,
14008 memory_order_relaxed
);
14009 update_out
= atomic_load_explicit(&p
->update_out
,
14010 memory_order_relaxed
);
14011 update_in
= atomic_load_explicit(&p
->update_in
,
14012 memory_order_relaxed
);
14013 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14014 memory_order_relaxed
);
14015 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14016 memory_order_relaxed
);
14017 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14018 memory_order_relaxed
);
14019 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14020 memory_order_relaxed
);
14021 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14022 memory_order_relaxed
);
14023 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14024 memory_order_relaxed
);
14026 /* Packet counts. */
14027 vty_out(vty
, " Message statistics:\n");
14028 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14029 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14030 vty_out(vty
, " Sent Rcvd\n");
14031 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14033 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14035 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14037 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14039 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14041 vty_out(vty
, " Capability: %10zu %10zu\n",
14042 dynamic_cap_out
, dynamic_cap_in
);
14043 vty_out(vty
, " Total: %10u %10u\n",
14044 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14048 /* advertisement-interval */
14049 json_object_int_add(json_neigh
,
14050 "minBtwnAdvertisementRunsTimerMsecs",
14051 p
->v_routeadv
* 1000);
14053 /* Update-source. */
14054 if (p
->update_if
|| p
->update_source
) {
14056 json_object_string_add(json_neigh
,
14059 else if (p
->update_source
)
14060 json_object_string_addf(json_neigh
,
14061 "updateSource", "%pSU",
14065 /* advertisement-interval */
14067 " Minimum time between advertisement runs is %d seconds\n",
14070 /* Update-source. */
14071 if (p
->update_if
|| p
->update_source
) {
14072 vty_out(vty
, " Update source is ");
14074 vty_out(vty
, "%s", p
->update_if
);
14075 else if (p
->update_source
)
14076 vty_out(vty
, "%pSU", p
->update_source
);
14077 vty_out(vty
, "\n");
14080 vty_out(vty
, "\n");
14083 /* Address Family Information */
14084 json_object
*json_hold
= NULL
;
14087 json_hold
= json_object_new_object();
14089 FOREACH_AFI_SAFI (afi
, safi
)
14090 if (p
->afc
[afi
][safi
])
14091 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14095 json_object_object_add(json_neigh
, "addressFamilyInfo",
14097 json_object_int_add(json_neigh
, "connectionsEstablished",
14099 json_object_int_add(json_neigh
, "connectionsDropped",
14102 vty_out(vty
, " Connections established %d; dropped %d\n",
14103 p
->established
, p
->dropped
);
14105 if (!p
->last_reset
) {
14107 json_object_string_add(json_neigh
, "lastReset",
14110 vty_out(vty
, " Last reset never\n");
14116 uptime
= monotime(NULL
);
14117 uptime
-= p
->resettime
;
14118 gmtime_r(&uptime
, &tm
);
14120 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14122 + (tm
.tm_min
* 60000)
14123 + (tm
.tm_hour
* 3600000));
14124 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14126 vty_out(vty
, " Last reset %s, ",
14127 peer_uptime(p
->resettime
, timebuf
,
14128 BGP_UPTIME_LEN
, 0, NULL
));
14130 bgp_show_peer_reset(vty
, p
, NULL
, false);
14131 if (p
->last_reset_cause_size
) {
14132 msg
= p
->last_reset_cause
;
14134 " Message received that caused BGP to send a NOTIFICATION:\n ");
14135 for (i
= 1; i
<= p
->last_reset_cause_size
;
14137 vty_out(vty
, "%02X", *msg
++);
14139 if (i
!= p
->last_reset_cause_size
) {
14141 vty_out(vty
, "\n ");
14142 } else if (i
% 4 == 0) {
14147 vty_out(vty
, "\n");
14152 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14154 json_object_boolean_true_add(json_neigh
,
14155 "prefixesConfigExceedMax");
14158 " Peer had exceeded the max. no. of prefixes configured.\n");
14160 if (p
->t_pmax_restart
) {
14162 json_object_boolean_true_add(
14163 json_neigh
, "reducePrefixNumFrom");
14164 json_object_int_add(json_neigh
,
14165 "restartInTimerMsec",
14166 thread_timer_remain_second(
14171 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14172 p
->host
, thread_timer_remain_second(
14173 p
->t_pmax_restart
));
14176 json_object_boolean_true_add(
14178 "reducePrefixNumAndClearIpBgp");
14181 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14186 /* EBGP Multihop and GTSM */
14187 if (p
->sort
!= BGP_PEER_IBGP
) {
14189 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14190 json_object_int_add(json_neigh
,
14191 "externalBgpNbrMaxHopsAway",
14194 json_object_int_add(json_neigh
,
14195 "externalBgpNbrMaxHopsAway",
14198 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14200 " External BGP neighbor may be up to %d hops away.\n",
14204 " External BGP neighbor may be up to %d hops away.\n",
14209 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14210 json_object_int_add(json_neigh
,
14211 "internalBgpNbrMaxHopsAway",
14214 json_object_int_add(json_neigh
,
14215 "internalBgpNbrMaxHopsAway",
14218 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14220 " Internal BGP neighbor may be up to %d hops away.\n",
14224 " Internal BGP neighbor may be up to %d hops away.\n",
14229 /* Local address. */
14232 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14234 json_object_int_add(json_neigh
, "portLocal",
14235 ntohs(p
->su_local
->sin
.sin_port
));
14237 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14238 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14241 json_object_string_add(json_neigh
, "hostLocal",
14243 json_object_int_add(json_neigh
, "portLocal", -1);
14247 /* Remote address. */
14248 if (p
->su_remote
) {
14250 json_object_string_addf(json_neigh
, "hostForeign",
14251 "%pSU", p
->su_remote
);
14252 json_object_int_add(json_neigh
, "portForeign",
14253 ntohs(p
->su_remote
->sin
.sin_port
));
14255 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14257 ntohs(p
->su_remote
->sin
.sin_port
));
14260 json_object_string_add(json_neigh
, "hostForeign",
14262 json_object_int_add(json_neigh
, "portForeign", -1);
14266 /* Nexthop display. */
14269 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14271 json_object_string_addf(json_neigh
, "nexthopGlobal",
14272 "%pI6", &p
->nexthop
.v6_global
);
14273 json_object_string_addf(json_neigh
, "nexthopLocal",
14274 "%pI6", &p
->nexthop
.v6_local
);
14275 if (p
->shared_network
)
14276 json_object_string_add(json_neigh
,
14280 json_object_string_add(json_neigh
,
14282 "nonSharedNetwork");
14284 vty_out(vty
, "Nexthop: %s\n",
14285 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14287 vty_out(vty
, "Nexthop global: %s\n",
14288 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14290 vty_out(vty
, "Nexthop local: %s\n",
14291 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14293 vty_out(vty
, "BGP connection: %s\n",
14294 p
->shared_network
? "shared network"
14295 : "non shared network");
14299 /* Timer information. */
14301 json_object_int_add(json_neigh
, "connectRetryTimer",
14303 if (peer_established(p
) && p
->rtt
)
14304 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14307 json_object_int_add(
14308 json_neigh
, "nextStartTimerDueInMsecs",
14309 thread_timer_remain_second(p
->t_start
) * 1000);
14311 json_object_int_add(
14312 json_neigh
, "nextConnectTimerDueInMsecs",
14313 thread_timer_remain_second(p
->t_connect
)
14315 if (p
->t_routeadv
) {
14316 json_object_int_add(json_neigh
, "mraiInterval",
14318 json_object_int_add(
14319 json_neigh
, "mraiTimerExpireInMsecs",
14320 thread_timer_remain_second(p
->t_routeadv
)
14324 json_object_int_add(json_neigh
, "authenticationEnabled",
14328 json_object_string_add(json_neigh
, "readThread", "on");
14330 json_object_string_add(json_neigh
, "readThread", "off");
14332 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14333 json_object_string_add(json_neigh
, "writeThread", "on");
14335 json_object_string_add(json_neigh
, "writeThread",
14338 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14340 if (peer_established(p
) && p
->rtt
)
14341 vty_out(vty
, "Estimated round trip time: %d ms\n",
14344 vty_out(vty
, "Next start timer due in %ld seconds\n",
14345 thread_timer_remain_second(p
->t_start
));
14347 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14348 thread_timer_remain_second(p
->t_connect
));
14351 "MRAI (interval %u) timer expires in %ld seconds\n",
14353 thread_timer_remain_second(p
->t_routeadv
));
14355 vty_out(vty
, "Peer Authentication Enabled\n");
14357 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14358 p
->t_read
? "on" : "off",
14359 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14364 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14365 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14366 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14369 vty_out(vty
, "\n");
14371 /* BFD information. */
14373 bgp_bfd_show_info(vty
, p
, json_neigh
);
14376 if (p
->conf_if
) /* Configured interface name. */
14377 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14378 else /* Configured IP address. */
14379 json_object_object_add(json
, p
->host
, json_neigh
);
14383 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14384 enum show_type type
,
14385 union sockunion
*su
,
14386 const char *conf_if
, afi_t afi
,
14389 struct listnode
*node
, *nnode
;
14392 safi_t safi
= SAFI_UNICAST
;
14393 json_object
*json
= NULL
;
14394 json_object
*json_neighbor
= NULL
;
14397 json
= json_object_new_object();
14398 json_neighbor
= json_object_new_object();
14401 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14403 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14406 if ((peer
->afc
[afi
][safi
]) == 0)
14409 if (type
== show_all
) {
14410 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14414 json_object_object_add(json
, peer
->host
,
14416 json_neighbor
= NULL
;
14419 } else if (type
== show_peer
) {
14422 && !strcmp(peer
->conf_if
, conf_if
))
14424 && !strcmp(peer
->hostname
, conf_if
))) {
14426 bgp_show_peer_gr_status(vty
, peer
,
14431 if (sockunion_same(&peer
->su
, su
)) {
14433 bgp_show_peer_gr_status(vty
, peer
,
14438 if (use_json
&& find
)
14439 json_object_object_add(json
, peer
->host
,
14444 json_neighbor
= NULL
;
14449 if (type
== show_peer
&& !find
) {
14451 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14453 vty_out(vty
, "%% No such neighbor\n");
14457 json_object_free(json_neighbor
);
14458 vty_json(vty
, json
);
14460 vty_out(vty
, "\n");
14463 return CMD_SUCCESS
;
14466 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14467 enum show_type type
, union sockunion
*su
,
14468 const char *conf_if
, bool use_json
,
14471 struct listnode
*node
, *nnode
;
14474 bool nbr_output
= false;
14475 afi_t afi
= AFI_MAX
;
14476 safi_t safi
= SAFI_MAX
;
14478 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14480 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14484 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14485 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14490 bgp_show_peer(vty
, peer
, use_json
, json
);
14496 && !strcmp(peer
->conf_if
, conf_if
))
14498 && !strcmp(peer
->hostname
, conf_if
))) {
14500 bgp_show_peer(vty
, peer
, use_json
,
14504 if (sockunion_same(&peer
->su
, su
)) {
14506 bgp_show_peer(vty
, peer
, use_json
,
14511 case show_ipv4_peer
:
14512 case show_ipv6_peer
:
14513 FOREACH_SAFI (safi
) {
14514 if (peer
->afc
[afi
][safi
]) {
14517 && !strcmp(peer
->conf_if
, conf_if
))
14519 && !strcmp(peer
->hostname
, conf_if
))) {
14521 bgp_show_peer(vty
, peer
, use_json
,
14526 if (sockunion_same(&peer
->su
, su
)) {
14528 bgp_show_peer(vty
, peer
, use_json
,
14536 case show_ipv4_all
:
14537 case show_ipv6_all
:
14538 FOREACH_SAFI (safi
) {
14539 if (peer
->afc
[afi
][safi
]) {
14540 bgp_show_peer(vty
, peer
, use_json
, json
);
14549 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14550 type
== show_ipv6_peer
) && !find
) {
14552 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14554 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14557 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14558 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14559 vty_out(vty
, "%% No BGP neighbors found\n");
14562 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14563 json
, JSON_C_TO_STRING_PRETTY
));
14565 vty_out(vty
, "\n");
14568 return CMD_SUCCESS
;
14571 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14572 enum show_type type
,
14573 const char *ip_str
,
14574 afi_t afi
, bool use_json
)
14579 union sockunion su
;
14581 bgp
= bgp_get_default();
14587 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14591 ret
= str2sockunion(ip_str
, &su
);
14593 bgp_show_neighbor_graceful_restart(
14594 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14596 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14597 NULL
, afi
, use_json
);
14599 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14603 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14604 enum show_type type
,
14605 const char *ip_str
,
14608 struct listnode
*node
, *nnode
;
14610 union sockunion su
;
14611 json_object
*json
= NULL
;
14612 int ret
, is_first
= 1;
14613 bool nbr_output
= false;
14616 vty_out(vty
, "{\n");
14618 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14621 if (!(json
= json_object_new_object())) {
14623 EC_BGP_JSON_MEM_ERROR
,
14624 "Unable to allocate memory for JSON object");
14626 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14630 json_object_int_add(json
, "vrfId",
14631 (bgp
->vrf_id
== VRF_UNKNOWN
)
14633 : (int64_t)bgp
->vrf_id
);
14634 json_object_string_add(
14636 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14641 vty_out(vty
, ",\n");
14645 vty_out(vty
, "\"%s\":",
14646 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14650 vty_out(vty
, "\nInstance %s:\n",
14651 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14656 if (type
== show_peer
|| type
== show_ipv4_peer
||
14657 type
== show_ipv6_peer
) {
14658 ret
= str2sockunion(ip_str
, &su
);
14660 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14663 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14666 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14669 json_object_free(json
);
14674 vty_out(vty
, "}\n");
14675 else if (!nbr_output
)
14676 vty_out(vty
, "%% BGP instance not found\n");
14679 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14680 enum show_type type
, const char *ip_str
,
14685 union sockunion su
;
14686 json_object
*json
= NULL
;
14689 if (strmatch(name
, "all")) {
14690 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14692 return CMD_SUCCESS
;
14694 bgp
= bgp_lookup_by_name(name
);
14697 json
= json_object_new_object();
14698 vty_json(vty
, json
);
14701 "%% BGP instance not found\n");
14703 return CMD_WARNING
;
14707 bgp
= bgp_get_default();
14711 json
= json_object_new_object();
14713 ret
= str2sockunion(ip_str
, &su
);
14715 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14718 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14721 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14724 json_object_free(json
);
14727 vty_out(vty
, "{}\n");
14729 vty_out(vty
, "%% BGP instance not found\n");
14732 return CMD_SUCCESS
;
14737 /* "show [ip] bgp neighbors graceful-restart" commands. */
14738 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14739 show_ip_bgp_neighbors_graceful_restart_cmd
,
14740 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14746 "Neighbor to display information about\n"
14747 "Neighbor to display information about\n"
14748 "Neighbor on BGP configured interface\n"
14752 char *sh_arg
= NULL
;
14753 enum show_type sh_type
;
14755 afi_t afi
= AFI_MAX
;
14756 bool uj
= use_json(argc
, argv
);
14758 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14763 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14764 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14765 || argv_find(argv
, argc
, "WORD", &idx
)) {
14766 sh_type
= show_peer
;
14767 sh_arg
= argv
[idx
]->arg
;
14769 sh_type
= show_all
;
14771 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14772 return CMD_SUCCESS
;
14775 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14779 /* "show [ip] bgp neighbors" commands. */
14780 DEFUN (show_ip_bgp_neighbors
,
14781 show_ip_bgp_neighbors_cmd
,
14782 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14786 BGP_INSTANCE_HELP_STR
14789 "Detailed information on TCP and BGP neighbor connections\n"
14790 "Neighbor to display information about\n"
14791 "Neighbor to display information about\n"
14792 "Neighbor on BGP configured interface\n"
14796 char *sh_arg
= NULL
;
14797 enum show_type sh_type
;
14798 afi_t afi
= AFI_MAX
;
14800 bool uj
= use_json(argc
, argv
);
14804 /* [<vrf> VIEWVRFNAME] */
14805 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14806 vrf
= argv
[idx
+ 1]->arg
;
14807 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14809 } else if (argv_find(argv
, argc
, "view", &idx
))
14810 /* [<view> VIEWVRFNAME] */
14811 vrf
= argv
[idx
+ 1]->arg
;
14815 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14816 sh_type
= show_ipv4_all
;
14818 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14819 sh_type
= show_ipv6_all
;
14822 sh_type
= show_all
;
14825 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14826 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14827 || argv_find(argv
, argc
, "WORD", &idx
)) {
14828 sh_type
= show_peer
;
14829 sh_arg
= argv
[idx
]->arg
;
14832 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14833 sh_type
= show_ipv4_peer
;
14834 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14835 sh_type
= show_ipv6_peer
;
14838 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14841 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14842 paths' and `show ip mbgp paths'. Those functions results are the
14844 DEFUN (show_ip_bgp_paths
,
14845 show_ip_bgp_paths_cmd
,
14846 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14851 "Path information\n")
14853 vty_out(vty
, "Address Refcnt Path\n");
14854 aspath_print_all_vty(vty
);
14855 return CMD_SUCCESS
;
14860 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14863 struct community
*com
;
14865 com
= (struct community
*)bucket
->data
;
14866 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14867 community_str(com
, false, false));
14870 /* Show BGP's community internal data. */
14871 DEFUN (show_ip_bgp_community_info
,
14872 show_ip_bgp_community_info_cmd
,
14873 "show [ip] bgp community-info",
14877 "List all bgp community information\n")
14879 vty_out(vty
, "Address Refcnt Community\n");
14881 hash_iterate(community_hash(),
14882 (void (*)(struct hash_bucket
*,
14883 void *))community_show_all_iterator
,
14886 return CMD_SUCCESS
;
14889 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14892 struct lcommunity
*lcom
;
14894 lcom
= (struct lcommunity
*)bucket
->data
;
14895 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14896 lcommunity_str(lcom
, false, false));
14899 /* Show BGP's community internal data. */
14900 DEFUN (show_ip_bgp_lcommunity_info
,
14901 show_ip_bgp_lcommunity_info_cmd
,
14902 "show ip bgp large-community-info",
14906 "List all bgp large-community information\n")
14908 vty_out(vty
, "Address Refcnt Large-community\n");
14910 hash_iterate(lcommunity_hash(),
14911 (void (*)(struct hash_bucket
*,
14912 void *))lcommunity_show_all_iterator
,
14915 return CMD_SUCCESS
;
14917 /* Graceful Restart */
14919 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14926 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14928 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14930 switch (bgp_global_gr_mode
) {
14932 case GLOBAL_HELPER
:
14933 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14937 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14940 case GLOBAL_DISABLE
:
14941 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14944 case GLOBAL_INVALID
:
14946 "Global BGP GR Mode Invalid\n");
14949 vty_out(vty
, "\n");
14952 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14953 enum show_type type
,
14954 const char *ip_str
,
14955 afi_t afi
, bool use_json
)
14957 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14960 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14962 bgp_show_neighbor_graceful_restart_vty(
14963 vty
, type
, ip_str
, afi
, use_json
);
14966 } else if (afi
!= AFI_MAX
) {
14967 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14970 return CMD_ERR_INCOMPLETE
;
14973 return CMD_SUCCESS
;
14975 /* Graceful Restart */
14977 DEFUN (show_ip_bgp_attr_info
,
14978 show_ip_bgp_attr_info_cmd
,
14979 "show [ip] bgp attribute-info",
14983 "List all bgp attribute information\n")
14985 attr_show_all(vty
);
14986 return CMD_SUCCESS
;
14989 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14990 afi_t afi
, safi_t safi
,
14991 bool use_json
, json_object
*json
)
14994 struct listnode
*node
;
14997 enum vpn_policy_direction dir
;
15000 json_object
*json_import_vrfs
= NULL
;
15001 json_object
*json_export_vrfs
= NULL
;
15003 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15006 vty_json(vty
, json
);
15008 return CMD_WARNING
;
15011 /* Provide context for the block */
15012 json_object_string_add(json
, "vrf", name
? name
: "default");
15013 json_object_string_add(json
, "afiSafi",
15014 get_afi_safi_str(afi
, safi
, true));
15016 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15017 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15018 json_object_string_add(json
, "importFromVrfs", "none");
15019 json_object_string_add(json
, "importRts", "none");
15021 json_import_vrfs
= json_object_new_array();
15023 for (ALL_LIST_ELEMENTS_RO(
15024 bgp
->vpn_policy
[afi
].import_vrf
,
15026 json_object_array_add(json_import_vrfs
,
15027 json_object_new_string(vname
));
15029 json_object_object_add(json
, "importFromVrfs",
15031 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15032 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15033 ecom_str
= ecommunity_ecom2str(
15034 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15035 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15036 json_object_string_add(json
, "importRts",
15038 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15040 json_object_string_add(json
, "importRts",
15044 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15045 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15046 json_object_string_add(json
, "exportToVrfs", "none");
15047 json_object_string_add(json
, "routeDistinguisher",
15049 json_object_string_add(json
, "exportRts", "none");
15051 json_export_vrfs
= json_object_new_array();
15053 for (ALL_LIST_ELEMENTS_RO(
15054 bgp
->vpn_policy
[afi
].export_vrf
,
15056 json_object_array_add(json_export_vrfs
,
15057 json_object_new_string(vname
));
15058 json_object_object_add(json
, "exportToVrfs",
15060 json_object_string_addf(json
, "routeDistinguisher",
15062 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15064 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15065 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15066 ecom_str
= ecommunity_ecom2str(
15067 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15068 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15069 json_object_string_add(json
, "exportRts",
15071 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15073 json_object_string_add(json
, "exportRts",
15078 vty_json(vty
, json
);
15081 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15084 vty_out(vty
, "%% No such BGP instance exist\n");
15085 return CMD_WARNING
;
15088 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15089 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15091 "This VRF is not importing %s routes from any other VRF\n",
15092 get_afi_safi_str(afi
, safi
, false));
15095 "This VRF is importing %s routes from the following VRFs:\n",
15096 get_afi_safi_str(afi
, safi
, false));
15098 for (ALL_LIST_ELEMENTS_RO(
15099 bgp
->vpn_policy
[afi
].import_vrf
,
15101 vty_out(vty
, " %s\n", vname
);
15103 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15105 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15106 ecom_str
= ecommunity_ecom2str(
15107 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15108 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15109 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15111 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15113 vty_out(vty
, "Import RT(s):\n");
15116 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15117 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15119 "This VRF is not exporting %s routes to any other VRF\n",
15120 get_afi_safi_str(afi
, safi
, false));
15123 "This VRF is exporting %s routes to the following VRFs:\n",
15124 get_afi_safi_str(afi
, safi
, false));
15126 for (ALL_LIST_ELEMENTS_RO(
15127 bgp
->vpn_policy
[afi
].export_vrf
,
15129 vty_out(vty
, " %s\n", vname
);
15131 vty_out(vty
, "RD: %pRD\n",
15132 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15134 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15135 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15136 ecom_str
= ecommunity_ecom2str(
15137 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15138 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15139 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15140 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15142 vty_out(vty
, "Import RT(s):\n");
15146 return CMD_SUCCESS
;
15149 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15150 safi_t safi
, bool use_json
)
15152 struct listnode
*node
, *nnode
;
15154 char *vrf_name
= NULL
;
15155 json_object
*json
= NULL
;
15156 json_object
*json_vrf
= NULL
;
15157 json_object
*json_vrfs
= NULL
;
15160 json
= json_object_new_object();
15161 json_vrfs
= json_object_new_object();
15164 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15166 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15167 vrf_name
= bgp
->name
;
15170 json_vrf
= json_object_new_object();
15172 vty_out(vty
, "\nInstance %s:\n",
15173 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15174 ? VRF_DEFAULT_NAME
: bgp
->name
);
15176 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15178 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15179 json_object_object_add(json_vrfs
,
15180 VRF_DEFAULT_NAME
, json_vrf
);
15182 json_object_object_add(json_vrfs
, vrf_name
,
15188 json_object_object_add(json
, "vrfs", json_vrfs
);
15189 vty_json(vty
, json
);
15192 return CMD_SUCCESS
;
15195 /* "show [ip] bgp route-leak" command. */
15196 DEFUN (show_ip_bgp_route_leak
,
15197 show_ip_bgp_route_leak_cmd
,
15198 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15202 BGP_INSTANCE_HELP_STR
15205 "Route leaking information\n"
15209 afi_t afi
= AFI_MAX
;
15210 safi_t safi
= SAFI_MAX
;
15212 bool uj
= use_json(argc
, argv
);
15214 json_object
*json
= NULL
;
15216 /* show [ip] bgp */
15217 if (argv_find(argv
, argc
, "ip", &idx
)) {
15219 safi
= SAFI_UNICAST
;
15221 /* [vrf VIEWVRFNAME] */
15222 if (argv_find(argv
, argc
, "view", &idx
)) {
15224 "%% This command is not applicable to BGP views\n");
15225 return CMD_WARNING
;
15228 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15229 vrf
= argv
[idx
+ 1]->arg
;
15230 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15233 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15234 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15235 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15237 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15239 "%% This command is applicable only for unicast ipv4|ipv6\n");
15240 return CMD_WARNING
;
15243 if (vrf
&& strmatch(vrf
, "all"))
15244 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15247 json
= json_object_new_object();
15249 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15252 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15255 struct listnode
*node
, *nnode
;
15258 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15259 vty_out(vty
, "\nInstance %s:\n",
15260 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15263 update_group_show(bgp
, afi
, safi
, vty
, 0);
15267 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15268 int safi
, uint64_t subgrp_id
)
15273 if (strmatch(name
, "all")) {
15274 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15275 return CMD_SUCCESS
;
15277 bgp
= bgp_lookup_by_name(name
);
15280 bgp
= bgp_get_default();
15284 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15285 return CMD_SUCCESS
;
15288 DEFUN (show_ip_bgp_updgrps
,
15289 show_ip_bgp_updgrps_cmd
,
15290 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15294 BGP_INSTANCE_HELP_STR
15296 BGP_SAFI_WITH_LABEL_HELP_STR
15297 "Detailed info about dynamic update groups\n"
15298 "Specific subgroup to display detailed info for\n")
15301 afi_t afi
= AFI_IP6
;
15302 safi_t safi
= SAFI_UNICAST
;
15303 uint64_t subgrp_id
= 0;
15307 /* show [ip] bgp */
15308 if (argv_find(argv
, argc
, "ip", &idx
))
15310 /* [<vrf> VIEWVRFNAME] */
15311 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15312 vrf
= argv
[idx
+ 1]->arg
;
15313 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15315 } else if (argv_find(argv
, argc
, "view", &idx
))
15316 /* [<view> VIEWVRFNAME] */
15317 vrf
= argv
[idx
+ 1]->arg
;
15318 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15319 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15320 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15323 /* get subgroup id, if provided */
15325 if (argv
[idx
]->type
== VARIABLE_TKN
)
15326 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15328 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15331 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15332 show_bgp_instance_all_ipv6_updgrps_cmd
,
15333 "show [ip] bgp <view|vrf> all update-groups",
15337 BGP_INSTANCE_ALL_HELP_STR
15338 "Detailed info about dynamic update groups\n")
15340 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15341 return CMD_SUCCESS
;
15344 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15345 show_bgp_l2vpn_evpn_updgrps_cmd
,
15346 "show [ip] bgp l2vpn evpn update-groups",
15350 "l2vpn address family\n"
15351 "evpn sub-address family\n"
15352 "Detailed info about dynamic update groups\n")
15355 uint64_t subgrp_id
= 0;
15357 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15358 return CMD_SUCCESS
;
15361 DEFUN (show_bgp_updgrps_stats
,
15362 show_bgp_updgrps_stats_cmd
,
15363 "show [ip] bgp update-groups statistics",
15367 "Detailed info about dynamic update groups\n"
15372 bgp
= bgp_get_default();
15374 update_group_show_stats(bgp
, vty
);
15376 return CMD_SUCCESS
;
15379 DEFUN (show_bgp_instance_updgrps_stats
,
15380 show_bgp_instance_updgrps_stats_cmd
,
15381 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15385 BGP_INSTANCE_HELP_STR
15386 "Detailed info about dynamic update groups\n"
15392 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15394 update_group_show_stats(bgp
, vty
);
15396 return CMD_SUCCESS
;
15399 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15400 afi_t afi
, safi_t safi
,
15401 const char *what
, uint64_t subgrp_id
)
15406 bgp
= bgp_lookup_by_name(name
);
15408 bgp
= bgp_get_default();
15411 if (!strcmp(what
, "advertise-queue"))
15412 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15414 else if (!strcmp(what
, "advertised-routes"))
15415 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15417 else if (!strcmp(what
, "packet-queue"))
15418 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15423 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15424 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15425 "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",
15426 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15428 "Detailed info about dynamic update groups\n"
15429 "Specific subgroup to display info for\n"
15430 "Advertisement queue\n"
15431 "Announced routes\n"
15434 uint64_t subgrp_id
= 0;
15438 subgrp_id
= strtoull(sgid
, NULL
, 10);
15443 afiz
= bgp_vty_afi_from_str(afi
);
15447 afiz
= bgp_vty_afi_from_str(afi
);
15448 if (afiz
!= AFI_IP
)
15450 "%% Cannot specify both 'ip' and 'ipv6'\n");
15451 return CMD_WARNING
;
15454 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15456 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15457 return CMD_SUCCESS
;
15460 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15463 struct listnode
*node
, *nnode
;
15464 struct prefix
*range
;
15469 const char *peer_status
;
15473 json_object
*json_peer_group
= NULL
;
15474 json_object
*json_peer_group_afc
= NULL
;
15475 json_object
*json_peer_group_members
= NULL
;
15476 json_object
*json_peer_group_dynamic
= NULL
;
15477 json_object
*json_peer_group_dynamic_af
= NULL
;
15478 json_object
*json_peer_group_ranges
= NULL
;
15480 conf
= group
->conf
;
15483 json_peer_group
= json_object_new_object();
15484 json_peer_group_afc
= json_object_new_array();
15487 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15489 json_object_int_add(json_peer_group
, "remoteAs",
15492 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15493 group
->name
, conf
->as
);
15494 } else if (conf
->as_type
== AS_INTERNAL
) {
15496 json_object_int_add(json_peer_group
, "remoteAs",
15499 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15500 group
->name
, group
->bgp
->as
);
15503 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15506 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15508 json_object_string_add(json_peer_group
, "type",
15511 vty_out(vty
, " Peer-group type is internal\n");
15514 json_object_string_add(json_peer_group
, "type",
15517 vty_out(vty
, " Peer-group type is external\n");
15520 /* Display AFs configured. */
15522 vty_out(vty
, " Configured address-families:");
15524 FOREACH_AFI_SAFI (afi
, safi
) {
15525 if (conf
->afc
[afi
][safi
]) {
15528 json_object_array_add(
15529 json_peer_group_afc
,
15530 json_object_new_string(get_afi_safi_str(
15531 afi
, safi
, false)));
15533 vty_out(vty
, " %s;",
15534 get_afi_safi_str(afi
, safi
, false));
15539 json_object_object_add(json_peer_group
,
15540 "addressFamiliesConfigured",
15541 json_peer_group_afc
);
15544 vty_out(vty
, " none\n");
15546 vty_out(vty
, "\n");
15549 /* Display listen ranges (for dynamic neighbors), if any */
15550 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15551 lr_count
= listcount(group
->listen_range
[afi
]);
15554 if (!json_peer_group_dynamic
)
15555 json_peer_group_dynamic
=
15556 json_object_new_object();
15558 json_peer_group_dynamic_af
=
15559 json_object_new_object();
15560 json_peer_group_ranges
=
15561 json_object_new_array();
15562 json_object_int_add(json_peer_group_dynamic_af
,
15563 "count", lr_count
);
15565 vty_out(vty
, " %d %s listen range(s)\n",
15566 lr_count
, afi2str(afi
));
15569 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15574 snprintfrr(buf
, sizeof(buf
), "%pFX",
15577 json_object_array_add(
15578 json_peer_group_ranges
,
15579 json_object_new_string(buf
));
15581 vty_out(vty
, " %pFX\n", range
);
15586 json_object_object_add(
15587 json_peer_group_dynamic_af
, "ranges",
15588 json_peer_group_ranges
);
15590 json_object_object_add(
15591 json_peer_group_dynamic
, afi2str(afi
),
15592 json_peer_group_dynamic_af
);
15597 if (json_peer_group_dynamic
)
15598 json_object_object_add(json_peer_group
, "dynamicRanges",
15599 json_peer_group_dynamic
);
15601 /* Display group members and their status */
15602 if (listcount(group
->peer
)) {
15604 json_peer_group_members
= json_object_new_object();
15606 vty_out(vty
, " Peer-group members:\n");
15607 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15608 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15609 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15610 peer_status
= "Idle (Admin)";
15611 else if (CHECK_FLAG(peer
->sflags
,
15612 PEER_STATUS_PREFIX_OVERFLOW
))
15613 peer_status
= "Idle (PfxCt)";
15615 peer_status
= lookup_msg(bgp_status_msg
,
15616 peer
->status
, NULL
);
15618 dynamic
= peer_dynamic_neighbor(peer
);
15621 json_object
*json_peer_group_member
=
15622 json_object_new_object();
15624 json_object_string_add(json_peer_group_member
,
15625 "status", peer_status
);
15628 json_object_boolean_true_add(
15629 json_peer_group_member
,
15632 json_object_object_add(json_peer_group_members
,
15634 json_peer_group_member
);
15636 vty_out(vty
, " %s %s %s \n", peer
->host
,
15637 dynamic
? "(dynamic)" : "",
15642 json_object_object_add(json_peer_group
, "members",
15643 json_peer_group_members
);
15647 json_object_object_add(json
, group
->name
, json_peer_group
);
15649 return CMD_SUCCESS
;
15652 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15653 const char *group_name
, bool uj
)
15656 struct listnode
*node
, *nnode
;
15657 struct peer_group
*group
;
15658 bool found
= false;
15659 json_object
*json
= NULL
;
15662 json
= json_object_new_object();
15664 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15668 vty_json(vty
, json
);
15670 vty_out(vty
, "%% BGP instance not found\n");
15672 return CMD_WARNING
;
15675 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15677 if (strmatch(group
->name
, group_name
)) {
15678 bgp_show_one_peer_group(vty
, group
, json
);
15683 bgp_show_one_peer_group(vty
, group
, json
);
15687 if (group_name
&& !found
&& !uj
)
15688 vty_out(vty
, "%% No such peer-group\n");
15691 vty_json(vty
, json
);
15693 return CMD_SUCCESS
;
15696 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15697 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15698 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15699 "Detailed information on BGP peer groups\n"
15700 "Peer group name\n" JSON_STR
)
15704 bool uj
= use_json(argc
, argv
);
15706 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15708 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15710 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15714 /* Redistribute VTY commands. */
15716 DEFUN (bgp_redistribute_ipv4
,
15717 bgp_redistribute_ipv4_cmd
,
15718 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15719 "Redistribute information from another routing protocol\n"
15720 FRR_IP_REDIST_HELP_STR_BGPD
)
15722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15723 int idx_protocol
= 1;
15726 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15728 vty_out(vty
, "%% Invalid route type\n");
15729 return CMD_WARNING_CONFIG_FAILED
;
15732 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15733 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15737 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15738 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15739 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15741 DEFUN (bgp_redistribute_ipv4_rmap
,
15742 bgp_redistribute_ipv4_rmap_cmd
,
15743 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15744 "Redistribute information from another routing protocol\n"
15745 FRR_IP_REDIST_HELP_STR_BGPD
15746 "Route map reference\n"
15747 "Pointer to route-map entries\n")
15749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15750 int idx_protocol
= 1;
15753 struct bgp_redist
*red
;
15755 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15756 vty
, argv
[idx_word
]->arg
);
15758 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15760 vty_out(vty
, "%% Invalid route type\n");
15761 return CMD_WARNING_CONFIG_FAILED
;
15764 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15766 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15767 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15771 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15772 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15773 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15774 "Route map reference\n"
15775 "Pointer to route-map entries\n")
15777 DEFUN (bgp_redistribute_ipv4_metric
,
15778 bgp_redistribute_ipv4_metric_cmd
,
15779 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15780 "Redistribute information from another routing protocol\n"
15781 FRR_IP_REDIST_HELP_STR_BGPD
15782 "Metric for redistributed routes\n"
15783 "Default metric\n")
15785 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15786 int idx_protocol
= 1;
15787 int idx_number
= 3;
15790 struct bgp_redist
*red
;
15793 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15795 vty_out(vty
, "%% Invalid route type\n");
15796 return CMD_WARNING_CONFIG_FAILED
;
15798 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15800 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15801 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15802 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15806 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15807 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15808 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15809 "Metric for redistributed routes\n"
15810 "Default metric\n")
15812 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15813 bgp_redistribute_ipv4_rmap_metric_cmd
,
15814 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15815 "Redistribute information from another routing protocol\n"
15816 FRR_IP_REDIST_HELP_STR_BGPD
15817 "Route map reference\n"
15818 "Pointer to route-map entries\n"
15819 "Metric for redistributed routes\n"
15820 "Default metric\n")
15822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15823 int idx_protocol
= 1;
15825 int idx_number
= 5;
15828 struct bgp_redist
*red
;
15830 struct route_map
*route_map
=
15831 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15833 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15835 vty_out(vty
, "%% Invalid route type\n");
15836 return CMD_WARNING_CONFIG_FAILED
;
15838 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15840 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15842 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15843 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15844 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15848 bgp_redistribute_ipv4_rmap_metric
,
15849 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15850 "redistribute " FRR_IP_REDIST_STR_BGPD
15851 " route-map RMAP_NAME metric (0-4294967295)",
15852 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15853 "Route map reference\n"
15854 "Pointer to route-map entries\n"
15855 "Metric for redistributed routes\n"
15856 "Default metric\n")
15858 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15859 bgp_redistribute_ipv4_metric_rmap_cmd
,
15860 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15861 "Redistribute information from another routing protocol\n"
15862 FRR_IP_REDIST_HELP_STR_BGPD
15863 "Metric for redistributed routes\n"
15865 "Route map reference\n"
15866 "Pointer to route-map entries\n")
15868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15869 int idx_protocol
= 1;
15870 int idx_number
= 3;
15874 struct bgp_redist
*red
;
15876 struct route_map
*route_map
=
15877 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15879 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15881 vty_out(vty
, "%% Invalid route type\n");
15882 return CMD_WARNING_CONFIG_FAILED
;
15884 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15886 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15887 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15889 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15890 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15894 bgp_redistribute_ipv4_metric_rmap
,
15895 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15896 "redistribute " FRR_IP_REDIST_STR_BGPD
15897 " metric (0-4294967295) route-map RMAP_NAME",
15898 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15899 "Metric for redistributed routes\n"
15901 "Route map reference\n"
15902 "Pointer to route-map entries\n")
15904 DEFUN (bgp_redistribute_ipv4_ospf
,
15905 bgp_redistribute_ipv4_ospf_cmd
,
15906 "redistribute <ospf|table> (1-65535)",
15907 "Redistribute information from another routing protocol\n"
15908 "Open Shortest Path First (OSPFv2)\n"
15909 "Non-main Kernel Routing Table\n"
15910 "Instance ID/Table ID\n")
15912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15913 int idx_ospf_table
= 1;
15914 int idx_number
= 2;
15915 unsigned short instance
;
15916 unsigned short protocol
;
15918 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15920 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15921 protocol
= ZEBRA_ROUTE_OSPF
;
15923 protocol
= ZEBRA_ROUTE_TABLE
;
15925 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15926 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15929 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15930 "redistribute <ospf|table> (1-65535)",
15931 "Redistribute information from another routing protocol\n"
15932 "Open Shortest Path First (OSPFv2)\n"
15933 "Non-main Kernel Routing Table\n"
15934 "Instance ID/Table ID\n")
15936 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15937 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15938 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15939 "Redistribute information from another routing protocol\n"
15940 "Open Shortest Path First (OSPFv2)\n"
15941 "Non-main Kernel Routing Table\n"
15942 "Instance ID/Table ID\n"
15943 "Route map reference\n"
15944 "Pointer to route-map entries\n")
15946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15947 int idx_ospf_table
= 1;
15948 int idx_number
= 2;
15950 struct bgp_redist
*red
;
15951 unsigned short instance
;
15954 struct route_map
*route_map
=
15955 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15957 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15958 protocol
= ZEBRA_ROUTE_OSPF
;
15960 protocol
= ZEBRA_ROUTE_TABLE
;
15962 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15963 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15965 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15966 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15969 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15970 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15971 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15972 "Redistribute information from another routing protocol\n"
15973 "Open Shortest Path First (OSPFv2)\n"
15974 "Non-main Kernel Routing Table\n"
15975 "Instance ID/Table ID\n"
15976 "Route map reference\n"
15977 "Pointer to route-map entries\n")
15979 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15980 bgp_redistribute_ipv4_ospf_metric_cmd
,
15981 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15982 "Redistribute information from another routing protocol\n"
15983 "Open Shortest Path First (OSPFv2)\n"
15984 "Non-main Kernel Routing Table\n"
15985 "Instance ID/Table ID\n"
15986 "Metric for redistributed routes\n"
15987 "Default metric\n")
15989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15990 int idx_ospf_table
= 1;
15991 int idx_number
= 2;
15992 int idx_number_2
= 4;
15994 struct bgp_redist
*red
;
15995 unsigned short instance
;
15999 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16000 protocol
= ZEBRA_ROUTE_OSPF
;
16002 protocol
= ZEBRA_ROUTE_TABLE
;
16004 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16005 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16007 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16008 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16010 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16013 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16014 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16015 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16016 "Redistribute information from another routing protocol\n"
16017 "Open Shortest Path First (OSPFv2)\n"
16018 "Non-main Kernel Routing Table\n"
16019 "Instance ID/Table ID\n"
16020 "Metric for redistributed routes\n"
16021 "Default metric\n")
16023 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16024 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16025 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16026 "Redistribute information from another routing protocol\n"
16027 "Open Shortest Path First (OSPFv2)\n"
16028 "Non-main Kernel Routing Table\n"
16029 "Instance ID/Table ID\n"
16030 "Route map reference\n"
16031 "Pointer to route-map entries\n"
16032 "Metric for redistributed routes\n"
16033 "Default metric\n")
16035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16036 int idx_ospf_table
= 1;
16037 int idx_number
= 2;
16039 int idx_number_2
= 6;
16041 struct bgp_redist
*red
;
16042 unsigned short instance
;
16045 struct route_map
*route_map
=
16046 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16048 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16049 protocol
= ZEBRA_ROUTE_OSPF
;
16051 protocol
= ZEBRA_ROUTE_TABLE
;
16053 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16054 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16056 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16058 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16059 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16061 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16065 bgp_redistribute_ipv4_ospf_rmap_metric
,
16066 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16067 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16068 "Redistribute information from another routing protocol\n"
16069 "Open Shortest Path First (OSPFv2)\n"
16070 "Non-main Kernel Routing Table\n"
16071 "Instance ID/Table ID\n"
16072 "Route map reference\n"
16073 "Pointer to route-map entries\n"
16074 "Metric for redistributed routes\n"
16075 "Default metric\n")
16077 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16078 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16079 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16080 "Redistribute information from another routing protocol\n"
16081 "Open Shortest Path First (OSPFv2)\n"
16082 "Non-main Kernel Routing Table\n"
16083 "Instance ID/Table ID\n"
16084 "Metric for redistributed routes\n"
16086 "Route map reference\n"
16087 "Pointer to route-map entries\n")
16089 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16090 int idx_ospf_table
= 1;
16091 int idx_number
= 2;
16092 int idx_number_2
= 4;
16095 struct bgp_redist
*red
;
16096 unsigned short instance
;
16099 struct route_map
*route_map
=
16100 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16102 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16103 protocol
= ZEBRA_ROUTE_OSPF
;
16105 protocol
= ZEBRA_ROUTE_TABLE
;
16107 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16108 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16110 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16111 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16114 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16115 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16119 bgp_redistribute_ipv4_ospf_metric_rmap
,
16120 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16121 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16122 "Redistribute information from another routing protocol\n"
16123 "Open Shortest Path First (OSPFv2)\n"
16124 "Non-main Kernel Routing Table\n"
16125 "Instance ID/Table ID\n"
16126 "Metric for redistributed routes\n"
16128 "Route map reference\n"
16129 "Pointer to route-map entries\n")
16131 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16132 no_bgp_redistribute_ipv4_ospf_cmd
,
16133 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16135 "Redistribute information from another routing protocol\n"
16136 "Open Shortest Path First (OSPFv2)\n"
16137 "Non-main Kernel Routing Table\n"
16138 "Instance ID/Table ID\n"
16139 "Metric for redistributed routes\n"
16141 "Route map reference\n"
16142 "Pointer to route-map entries\n")
16144 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16145 int idx_ospf_table
= 2;
16146 int idx_number
= 3;
16147 unsigned short instance
;
16150 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16151 protocol
= ZEBRA_ROUTE_OSPF
;
16153 protocol
= ZEBRA_ROUTE_TABLE
;
16155 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16156 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16160 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16161 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16163 "Redistribute information from another routing protocol\n"
16164 "Open Shortest Path First (OSPFv2)\n"
16165 "Non-main Kernel Routing Table\n"
16166 "Instance ID/Table ID\n"
16167 "Metric for redistributed routes\n"
16169 "Route map reference\n"
16170 "Pointer to route-map entries\n")
16172 DEFUN (no_bgp_redistribute_ipv4
,
16173 no_bgp_redistribute_ipv4_cmd
,
16174 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16176 "Redistribute information from another routing protocol\n"
16177 FRR_IP_REDIST_HELP_STR_BGPD
16178 "Metric for redistributed routes\n"
16180 "Route map reference\n"
16181 "Pointer to route-map entries\n")
16183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16184 int idx_protocol
= 2;
16187 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16189 vty_out(vty
, "%% Invalid route type\n");
16190 return CMD_WARNING_CONFIG_FAILED
;
16192 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16196 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16197 "no redistribute " FRR_IP_REDIST_STR_BGPD
16198 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16200 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16201 "Metric for redistributed routes\n"
16203 "Route map reference\n"
16204 "Pointer to route-map entries\n")
16206 DEFUN (bgp_redistribute_ipv6
,
16207 bgp_redistribute_ipv6_cmd
,
16208 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16209 "Redistribute information from another routing protocol\n"
16210 FRR_IP6_REDIST_HELP_STR_BGPD
)
16212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16213 int idx_protocol
= 1;
16216 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16218 vty_out(vty
, "%% Invalid route type\n");
16219 return CMD_WARNING_CONFIG_FAILED
;
16222 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16223 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16226 DEFUN (bgp_redistribute_ipv6_rmap
,
16227 bgp_redistribute_ipv6_rmap_cmd
,
16228 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16229 "Redistribute information from another routing protocol\n"
16230 FRR_IP6_REDIST_HELP_STR_BGPD
16231 "Route map reference\n"
16232 "Pointer to route-map entries\n")
16234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16235 int idx_protocol
= 1;
16238 struct bgp_redist
*red
;
16240 struct route_map
*route_map
=
16241 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16243 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16245 vty_out(vty
, "%% Invalid route type\n");
16246 return CMD_WARNING_CONFIG_FAILED
;
16249 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16251 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16252 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16255 DEFUN (bgp_redistribute_ipv6_metric
,
16256 bgp_redistribute_ipv6_metric_cmd
,
16257 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16258 "Redistribute information from another routing protocol\n"
16259 FRR_IP6_REDIST_HELP_STR_BGPD
16260 "Metric for redistributed routes\n"
16261 "Default metric\n")
16263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16264 int idx_protocol
= 1;
16265 int idx_number
= 3;
16268 struct bgp_redist
*red
;
16271 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16273 vty_out(vty
, "%% Invalid route type\n");
16274 return CMD_WARNING_CONFIG_FAILED
;
16276 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16278 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16279 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16280 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16283 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16284 bgp_redistribute_ipv6_rmap_metric_cmd
,
16285 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16286 "Redistribute information from another routing protocol\n"
16287 FRR_IP6_REDIST_HELP_STR_BGPD
16288 "Route map reference\n"
16289 "Pointer to route-map entries\n"
16290 "Metric for redistributed routes\n"
16291 "Default metric\n")
16293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16294 int idx_protocol
= 1;
16296 int idx_number
= 5;
16299 struct bgp_redist
*red
;
16301 struct route_map
*route_map
=
16302 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16304 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16306 vty_out(vty
, "%% Invalid route type\n");
16307 return CMD_WARNING_CONFIG_FAILED
;
16309 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16311 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16313 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16314 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16316 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16319 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16320 bgp_redistribute_ipv6_metric_rmap_cmd
,
16321 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16322 "Redistribute information from another routing protocol\n"
16323 FRR_IP6_REDIST_HELP_STR_BGPD
16324 "Metric for redistributed routes\n"
16326 "Route map reference\n"
16327 "Pointer to route-map entries\n")
16329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16330 int idx_protocol
= 1;
16331 int idx_number
= 3;
16335 struct bgp_redist
*red
;
16337 struct route_map
*route_map
=
16338 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16340 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16342 vty_out(vty
, "%% Invalid route type\n");
16343 return CMD_WARNING_CONFIG_FAILED
;
16345 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16347 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16348 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16351 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16352 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16355 DEFUN (no_bgp_redistribute_ipv6
,
16356 no_bgp_redistribute_ipv6_cmd
,
16357 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16359 "Redistribute information from another routing protocol\n"
16360 FRR_IP6_REDIST_HELP_STR_BGPD
16361 "Metric for redistributed routes\n"
16363 "Route map reference\n"
16364 "Pointer to route-map entries\n")
16366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16367 int idx_protocol
= 2;
16370 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16372 vty_out(vty
, "%% Invalid route type\n");
16373 return CMD_WARNING_CONFIG_FAILED
;
16376 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16379 /* Neighbor update tcp-mss. */
16380 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16381 const char *tcp_mss_str
)
16384 uint32_t tcp_mss_val
= 0;
16386 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16388 return CMD_WARNING_CONFIG_FAILED
;
16391 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16392 peer_tcp_mss_set(peer
, tcp_mss_val
);
16394 peer_tcp_mss_unset(peer
);
16397 return CMD_SUCCESS
;
16400 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16401 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16402 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16403 "TCP max segment size\n"
16406 int peer_index
= 1;
16410 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16411 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16412 argv
[mss_index
]->arg
);
16415 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16416 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16417 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16418 "TCP max segment size\n"
16421 int peer_index
= 2;
16424 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16425 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16428 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16429 "[no$no] bgp retain route-target all",
16431 "Retain BGP updates\n"
16432 "Retain BGP updates based on route-target values\n"
16433 "Retain all BGP updates\n")
16436 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16438 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16439 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16440 if (check
!= !no
) {
16442 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16443 [bgp_node_safi(vty
)],
16444 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16446 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16447 [bgp_node_safi(vty
)],
16448 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16449 /* trigger a flush to re-sync with ADJ-RIB-in */
16450 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16451 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16453 return CMD_SUCCESS
;
16456 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16457 afi_t afi
, safi_t safi
)
16461 /* Unicast redistribution only. */
16462 if (safi
!= SAFI_UNICAST
)
16465 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16466 /* Redistribute BGP does not make sense. */
16467 if (i
!= ZEBRA_ROUTE_BGP
) {
16468 struct list
*red_list
;
16469 struct listnode
*node
;
16470 struct bgp_redist
*red
;
16472 red_list
= bgp
->redist
[afi
][i
];
16476 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16477 /* "redistribute" configuration. */
16478 vty_out(vty
, " redistribute %s",
16479 zebra_route_string(i
));
16481 vty_out(vty
, " %d", red
->instance
);
16482 if (red
->redist_metric_flag
)
16483 vty_out(vty
, " metric %u",
16484 red
->redist_metric
);
16485 if (red
->rmap
.name
)
16486 vty_out(vty
, " route-map %s",
16488 vty_out(vty
, "\n");
16494 /* peer-group helpers for config-write */
16496 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16498 if (!peer_group_active(peer
)) {
16499 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16500 return !CHECK_FLAG(peer
->flags
, flag
);
16502 return !!CHECK_FLAG(peer
->flags
, flag
);
16505 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16508 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16511 if (!peer_group_active(peer
)) {
16512 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16513 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16515 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16518 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16521 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16522 uint8_t type
, int direct
)
16524 struct bgp_filter
*filter
;
16526 if (peer_group_active(peer
))
16527 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16530 filter
= &peer
->filter
[afi
][safi
];
16532 case PEER_FT_DISTRIBUTE_LIST
:
16533 return !!(filter
->dlist
[direct
].name
);
16534 case PEER_FT_FILTER_LIST
:
16535 return !!(filter
->aslist
[direct
].name
);
16536 case PEER_FT_PREFIX_LIST
:
16537 return !!(filter
->plist
[direct
].name
);
16538 case PEER_FT_ROUTE_MAP
:
16539 return !!(filter
->map
[direct
].name
);
16540 case PEER_FT_UNSUPPRESS_MAP
:
16541 return !!(filter
->usmap
.name
);
16542 case PEER_FT_ADVERTISE_MAP
:
16543 return !!(filter
->advmap
.aname
16544 && ((filter
->advmap
.condition
== direct
)
16545 && filter
->advmap
.cname
));
16551 /* Return true if the addpath type is set for peer and different from
16554 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16557 enum bgp_addpath_strat type
, g_type
;
16559 type
= peer
->addpath_type
[afi
][safi
];
16561 if (type
!= BGP_ADDPATH_NONE
) {
16562 if (peer_group_active(peer
)) {
16563 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16565 if (type
!= g_type
)
16577 /* This is part of the address-family block (unicast only) */
16578 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16582 uint32_t tovpn_sid_index
= 0;
16584 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16585 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16586 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16587 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16588 bgp
->vpn_policy
[afi
]
16589 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16591 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16592 bgp
->vpn_policy
[afi
]
16593 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16595 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16596 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16597 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16598 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16601 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16602 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16604 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16607 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16608 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16609 bgp
->vpn_policy
[afi
].tovpn_label
);
16613 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16614 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16615 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16616 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16617 } else if (tovpn_sid_index
!= 0) {
16618 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16622 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16623 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16624 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16626 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16627 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16629 char buf
[PREFIX_STRLEN
];
16630 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16631 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16634 vty_out(vty
, "%*snexthop vpn export %s\n",
16638 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16639 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16641 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16642 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16644 char *b
= ecommunity_ecom2str(
16645 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16646 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16647 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16648 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16650 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16651 char *b
= ecommunity_ecom2str(
16652 bgp
->vpn_policy
[afi
]
16653 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16654 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16655 ECOMMUNITY_ROUTE_TARGET
);
16656 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16657 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16659 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16660 char *b
= ecommunity_ecom2str(
16661 bgp
->vpn_policy
[afi
]
16662 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16663 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16664 ECOMMUNITY_ROUTE_TARGET
);
16665 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16666 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16670 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16671 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16672 bgp
->vpn_policy
[afi
]
16673 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16675 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16676 char *b
= ecommunity_ecom2str(
16677 bgp
->vpn_policy
[afi
]
16678 .import_redirect_rtlist
,
16679 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16680 ECOMMUNITY_ROUTE_TARGET
);
16682 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16683 != ECOMMUNITY_SIZE
)
16684 vty_out(vty
, "%*srt6 redirect import %s\n",
16687 vty_out(vty
, "%*srt redirect import %s\n",
16689 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16693 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16694 afi_t afi
, safi_t safi
)
16696 struct bgp_filter
*filter
;
16700 filter
= &peer
->filter
[afi
][safi
];
16702 /* distribute-list. */
16703 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16705 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16706 filter
->dlist
[FILTER_IN
].name
);
16708 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16710 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16711 filter
->dlist
[FILTER_OUT
].name
);
16714 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16716 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16717 filter
->plist
[FILTER_IN
].name
);
16719 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16721 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16722 filter
->plist
[FILTER_OUT
].name
);
16725 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16726 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16727 filter
->map
[RMAP_IN
].name
);
16729 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16731 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16732 filter
->map
[RMAP_OUT
].name
);
16734 /* unsuppress-map */
16735 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16736 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16737 filter
->usmap
.name
);
16739 /* advertise-map : always applied in OUT direction*/
16740 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16741 CONDITION_NON_EXIST
))
16743 " neighbor %s advertise-map %s non-exist-map %s\n",
16744 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16746 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16748 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16749 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16752 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16754 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16755 filter
->aslist
[FILTER_IN
].name
);
16757 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16759 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16760 filter
->aslist
[FILTER_OUT
].name
);
16763 /* BGP peer configuration display function. */
16764 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16767 struct peer
*g_peer
= NULL
;
16769 int if_pg_printed
= false;
16770 int if_ras_printed
= false;
16772 /* Skip dynamic neighbors. */
16773 if (peer_dynamic_neighbor(peer
))
16777 addr
= peer
->conf_if
;
16781 /************************************
16782 ****** Global to the neighbor ******
16783 ************************************/
16784 if (peer
->conf_if
) {
16785 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16786 vty_out(vty
, " neighbor %s interface v6only", addr
);
16788 vty_out(vty
, " neighbor %s interface", addr
);
16790 if (peer_group_active(peer
)) {
16791 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16792 if_pg_printed
= true;
16793 } else if (peer
->as_type
== AS_SPECIFIED
) {
16794 vty_out(vty
, " remote-as %u", peer
->as
);
16795 if_ras_printed
= true;
16796 } else if (peer
->as_type
== AS_INTERNAL
) {
16797 vty_out(vty
, " remote-as internal");
16798 if_ras_printed
= true;
16799 } else if (peer
->as_type
== AS_EXTERNAL
) {
16800 vty_out(vty
, " remote-as external");
16801 if_ras_printed
= true;
16804 vty_out(vty
, "\n");
16807 /* remote-as and peer-group */
16808 /* peer is a member of a peer-group */
16809 if (peer_group_active(peer
)) {
16810 g_peer
= peer
->group
->conf
;
16812 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16813 if (peer
->as_type
== AS_SPECIFIED
) {
16814 vty_out(vty
, " neighbor %s remote-as %u\n",
16816 } else if (peer
->as_type
== AS_INTERNAL
) {
16818 " neighbor %s remote-as internal\n",
16820 } else if (peer
->as_type
== AS_EXTERNAL
) {
16822 " neighbor %s remote-as external\n",
16827 /* For swpX peers we displayed the peer-group
16828 * via 'neighbor swpX interface peer-group PGNAME' */
16829 if (!if_pg_printed
)
16830 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16831 peer
->group
->name
);
16834 /* peer is NOT a member of a peer-group */
16836 /* peer is a peer-group, declare the peer-group */
16837 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16838 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16841 if (!if_ras_printed
) {
16842 if (peer
->as_type
== AS_SPECIFIED
) {
16843 vty_out(vty
, " neighbor %s remote-as %u\n",
16845 } else if (peer
->as_type
== AS_INTERNAL
) {
16847 " neighbor %s remote-as internal\n",
16849 } else if (peer
->as_type
== AS_EXTERNAL
) {
16851 " neighbor %s remote-as external\n",
16858 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16859 vty_out(vty
, " neighbor %s local-as %u", addr
,
16860 peer
->change_local_as
);
16861 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16862 vty_out(vty
, " no-prepend");
16863 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16864 vty_out(vty
, " replace-as");
16865 vty_out(vty
, "\n");
16870 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16874 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16875 if (peer
->tx_shutdown_message
)
16876 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16877 peer
->tx_shutdown_message
);
16879 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16882 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16883 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16884 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16887 if (peer
->bfd_config
)
16888 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16891 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16892 vty_out(vty
, " neighbor %s password %s\n", addr
,
16895 /* neighbor solo */
16896 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16897 if (!peer_group_active(peer
)) {
16898 vty_out(vty
, " neighbor %s solo\n", addr
);
16903 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16904 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16907 /* Local interface name */
16908 if (peer
->ifname
) {
16909 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16912 /* TCP max segment size */
16913 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16914 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16917 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16918 vty_out(vty
, " neighbor %s passive\n", addr
);
16920 /* ebgp-multihop */
16921 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16922 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16923 && peer
->ttl
== MAXTTL
)) {
16924 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16925 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16931 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16932 peer
->local_role
!= ROLE_UNDEFINED
)
16933 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16934 bgp_get_name_by_role(peer
->local_role
),
16935 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16939 /* ttl-security hops */
16940 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16941 if (!peer_group_active(peer
)
16942 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16943 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16944 addr
, peer
->gtsm_hops
);
16948 /* disable-connected-check */
16949 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16950 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16952 /* link-bw-encoding-ieee */
16953 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16954 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16957 /* extended-optional-parameters */
16958 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16959 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16962 /* enforce-first-as */
16963 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16964 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16966 /* update-source */
16967 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16968 if (peer
->update_source
)
16969 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16970 peer
->update_source
);
16971 else if (peer
->update_if
)
16972 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16976 /* advertisement-interval */
16977 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16978 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16982 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16983 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16984 peer
->keepalive
, peer
->holdtime
);
16986 /* timers connect */
16987 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16988 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16990 /* need special-case handling for changed default values due to
16991 * config profile / version (because there is no "timers bgp connect"
16992 * command, we need to save this per-peer :/)
16994 else if (!peer_group_active(peer
) && !peer
->connect
&&
16995 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16996 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16997 peer
->bgp
->default_connect_retry
);
16999 /* timers delayopen */
17000 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17001 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17003 /* Save config even though flag is not set if default values have been
17006 else if (!peer_group_active(peer
) && !peer
->delayopen
17007 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17008 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17009 peer
->bgp
->default_delayopen
);
17011 /* capability dynamic */
17012 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17013 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17015 /* capability extended-nexthop */
17016 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17017 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17020 " no neighbor %s capability extended-nexthop\n",
17022 else if (!peer
->conf_if
)
17024 " neighbor %s capability extended-nexthop\n",
17028 /* dont-capability-negotiation */
17029 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17030 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17032 /* override-capability */
17033 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17034 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17036 /* strict-capability-match */
17037 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17038 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17040 /* Sender side AS path loop detection. */
17041 if (peer
->as_path_loop_detection
)
17042 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17045 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17046 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17048 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17049 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17051 " neighbor %s graceful-restart-helper\n", addr
);
17052 } else if (CHECK_FLAG(
17053 peer
->peer_gr_new_status_flag
,
17054 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17056 " neighbor %s graceful-restart\n", addr
);
17058 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17059 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17061 peer
->peer_gr_new_status_flag
,
17062 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17063 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17069 /* BGP peer configuration display function. */
17070 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17071 struct peer
*peer
, afi_t afi
, safi_t safi
)
17073 struct peer
*g_peer
= NULL
;
17075 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17077 /* Skip dynamic neighbors. */
17078 if (peer_dynamic_neighbor(peer
))
17082 addr
= peer
->conf_if
;
17086 /************************************
17087 ****** Per AF to the neighbor ******
17088 ************************************/
17089 if (peer_group_active(peer
)) {
17090 g_peer
= peer
->group
->conf
;
17092 /* If the peer-group is active but peer is not, print a 'no
17094 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17095 vty_out(vty
, " no neighbor %s activate\n", addr
);
17098 /* If the peer-group is not active but peer is, print an
17100 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17101 vty_out(vty
, " neighbor %s activate\n", addr
);
17104 if (peer
->afc
[afi
][safi
]) {
17105 if (safi
== SAFI_ENCAP
)
17106 vty_out(vty
, " neighbor %s activate\n", addr
);
17107 else if (!bgp
->default_af
[afi
][safi
])
17108 vty_out(vty
, " neighbor %s activate\n", addr
);
17110 if (bgp
->default_af
[afi
][safi
])
17111 vty_out(vty
, " no neighbor %s activate\n",
17116 /* addpath TX knobs */
17117 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17118 switch (peer
->addpath_type
[afi
][safi
]) {
17119 case BGP_ADDPATH_ALL
:
17120 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17123 case BGP_ADDPATH_BEST_PER_AS
:
17125 " neighbor %s addpath-tx-bestpath-per-AS\n",
17128 case BGP_ADDPATH_MAX
:
17129 case BGP_ADDPATH_NONE
:
17134 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17135 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17137 /* ORF capability. */
17138 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17139 || peergroup_af_flag_check(peer
, afi
, safi
,
17140 PEER_FLAG_ORF_PREFIX_RM
)) {
17141 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17143 if (peergroup_af_flag_check(peer
, afi
, safi
,
17144 PEER_FLAG_ORF_PREFIX_SM
)
17145 && peergroup_af_flag_check(peer
, afi
, safi
,
17146 PEER_FLAG_ORF_PREFIX_RM
))
17147 vty_out(vty
, " both");
17148 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17149 PEER_FLAG_ORF_PREFIX_SM
))
17150 vty_out(vty
, " send");
17152 vty_out(vty
, " receive");
17153 vty_out(vty
, "\n");
17156 /* Route reflector client. */
17157 if (peergroup_af_flag_check(peer
, afi
, safi
,
17158 PEER_FLAG_REFLECTOR_CLIENT
)) {
17159 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17162 /* next-hop-self force */
17163 if (peergroup_af_flag_check(peer
, afi
, safi
,
17164 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17165 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17168 /* next-hop-self */
17169 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17170 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17173 /* remove-private-AS */
17174 if (peergroup_af_flag_check(peer
, afi
, safi
,
17175 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17176 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17180 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17181 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17182 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17186 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17187 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17188 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17191 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17192 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17193 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17197 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17198 vty_out(vty
, " neighbor %s as-override\n", addr
);
17201 /* send-community print. */
17202 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17203 PEER_FLAG_SEND_COMMUNITY
);
17204 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17205 PEER_FLAG_SEND_EXT_COMMUNITY
);
17206 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17207 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17209 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17210 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17213 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17216 " no neighbor %s send-community extended\n",
17220 vty_out(vty
, " no neighbor %s send-community large\n",
17224 /* Default information */
17225 if (peergroup_af_flag_check(peer
, afi
, safi
,
17226 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17227 vty_out(vty
, " neighbor %s default-originate", addr
);
17229 if (peer
->default_rmap
[afi
][safi
].name
)
17230 vty_out(vty
, " route-map %s",
17231 peer
->default_rmap
[afi
][safi
].name
);
17233 vty_out(vty
, "\n");
17236 /* Soft reconfiguration inbound. */
17237 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17238 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17242 /* maximum-prefix. */
17243 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17244 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17245 peer
->pmax
[afi
][safi
]);
17247 if (peer
->pmax_threshold
[afi
][safi
]
17248 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17249 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17250 if (peer_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_MAX_PREFIX_WARNING
))
17252 vty_out(vty
, " warning-only");
17253 if (peer
->pmax_restart
[afi
][safi
])
17254 vty_out(vty
, " restart %u",
17255 peer
->pmax_restart
[afi
][safi
]);
17256 if (peer_af_flag_check(peer
, afi
, safi
,
17257 PEER_FLAG_MAX_PREFIX_FORCE
))
17258 vty_out(vty
, " force");
17260 vty_out(vty
, "\n");
17263 /* maximum-prefix-out */
17264 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17265 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17266 addr
, peer
->pmax_out
[afi
][safi
]);
17268 /* Route server client. */
17269 if (peergroup_af_flag_check(peer
, afi
, safi
,
17270 PEER_FLAG_RSERVER_CLIENT
)) {
17271 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17274 /* Nexthop-local unchanged. */
17275 if (peergroup_af_flag_check(peer
, afi
, safi
,
17276 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17277 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17280 /* allowas-in <1-10> */
17281 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17282 if (peer_af_flag_check(peer
, afi
, safi
,
17283 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17284 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17285 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17286 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17288 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17289 peer
->allowas_in
[afi
][safi
]);
17294 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17295 char *soo_str
= ecommunity_ecom2str(
17296 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17298 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17299 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17303 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17304 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17305 peer
->weight
[afi
][safi
]);
17308 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17310 /* atribute-unchanged. */
17311 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17312 || (safi
!= SAFI_EVPN
17313 && peer_af_flag_check(peer
, afi
, safi
,
17314 PEER_FLAG_NEXTHOP_UNCHANGED
))
17315 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17317 if (!peer_group_active(peer
)
17318 || peergroup_af_flag_check(peer
, afi
, safi
,
17319 PEER_FLAG_AS_PATH_UNCHANGED
)
17320 || peergroup_af_flag_check(peer
, afi
, safi
,
17321 PEER_FLAG_NEXTHOP_UNCHANGED
)
17322 || peergroup_af_flag_check(peer
, afi
, safi
,
17323 PEER_FLAG_MED_UNCHANGED
)) {
17326 " neighbor %s attribute-unchanged%s%s%s\n",
17328 peer_af_flag_check(peer
, afi
, safi
,
17329 PEER_FLAG_AS_PATH_UNCHANGED
)
17332 peer_af_flag_check(peer
, afi
, safi
,
17333 PEER_FLAG_NEXTHOP_UNCHANGED
)
17336 peer_af_flag_check(peer
, afi
, safi
,
17337 PEER_FLAG_MED_UNCHANGED
)
17344 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17347 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17348 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17349 vty_out(vty
, " no bgp retain route-target all\n");
17352 /* Address family based peer configuration display. */
17353 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17357 struct peer_group
*group
;
17358 struct listnode
*node
, *nnode
;
17361 vty_frame(vty
, " !\n address-family ");
17362 if (afi
== AFI_IP
) {
17363 if (safi
== SAFI_UNICAST
)
17364 vty_frame(vty
, "ipv4 unicast");
17365 else if (safi
== SAFI_LABELED_UNICAST
)
17366 vty_frame(vty
, "ipv4 labeled-unicast");
17367 else if (safi
== SAFI_MULTICAST
)
17368 vty_frame(vty
, "ipv4 multicast");
17369 else if (safi
== SAFI_MPLS_VPN
)
17370 vty_frame(vty
, "ipv4 vpn");
17371 else if (safi
== SAFI_ENCAP
)
17372 vty_frame(vty
, "ipv4 encap");
17373 else if (safi
== SAFI_FLOWSPEC
)
17374 vty_frame(vty
, "ipv4 flowspec");
17375 } else if (afi
== AFI_IP6
) {
17376 if (safi
== SAFI_UNICAST
)
17377 vty_frame(vty
, "ipv6 unicast");
17378 else if (safi
== SAFI_LABELED_UNICAST
)
17379 vty_frame(vty
, "ipv6 labeled-unicast");
17380 else if (safi
== SAFI_MULTICAST
)
17381 vty_frame(vty
, "ipv6 multicast");
17382 else if (safi
== SAFI_MPLS_VPN
)
17383 vty_frame(vty
, "ipv6 vpn");
17384 else if (safi
== SAFI_ENCAP
)
17385 vty_frame(vty
, "ipv6 encap");
17386 else if (safi
== SAFI_FLOWSPEC
)
17387 vty_frame(vty
, "ipv6 flowspec");
17388 } else if (afi
== AFI_L2VPN
) {
17389 if (safi
== SAFI_EVPN
)
17390 vty_frame(vty
, "l2vpn evpn");
17392 vty_frame(vty
, "\n");
17394 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17396 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17398 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17400 /* BGP flag dampening. */
17401 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17402 bgp_config_write_damp(vty
, afi
, safi
);
17404 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17405 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17407 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17408 /* Do not display doppelganger peers */
17409 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17410 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17413 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17414 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17416 if (safi
== SAFI_EVPN
)
17417 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17419 if (safi
== SAFI_FLOWSPEC
)
17420 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17422 if (safi
== SAFI_MPLS_VPN
)
17423 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17425 if (safi
== SAFI_UNICAST
) {
17426 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17427 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17428 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17430 vty_out(vty
, " export vpn\n");
17432 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17433 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17435 vty_out(vty
, " import vpn\n");
17437 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17438 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17441 for (ALL_LIST_ELEMENTS_RO(
17442 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17444 vty_out(vty
, " import vrf %s\n", name
);
17448 vty_endframe(vty
, " exit-address-family\n");
17451 int bgp_config_write(struct vty
*vty
)
17454 struct peer_group
*group
;
17456 struct listnode
*node
, *nnode
;
17457 struct listnode
*mnode
, *mnnode
;
17461 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17462 vty_out(vty
, "bgp route-map delay-timer %u\n",
17463 bm
->rmap_update_timer
);
17465 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17466 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17467 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17468 vty_out(vty
, " %d", bm
->v_establish_wait
);
17469 vty_out(vty
, "\n");
17472 if (bm
->wait_for_fib
)
17473 vty_out(vty
, "bgp suppress-fib-pending\n");
17475 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17476 vty_out(vty
, "bgp graceful-shutdown\n");
17478 /* No-RIB (Zebra) option flag configuration */
17479 if (bgp_option_check(BGP_OPT_NO_FIB
))
17480 vty_out(vty
, "bgp no-rib\n");
17482 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17483 vty_out(vty
, "bgp send-extra-data zebra\n");
17485 /* BGP session DSCP value */
17486 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17487 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17489 /* BGP configuration. */
17490 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17492 /* skip all auto created vrf as they dont have user config */
17493 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17496 /* Router bgp ASN */
17497 vty_out(vty
, "router bgp %u", bgp
->as
);
17500 vty_out(vty
, " %s %s",
17501 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17502 ? "view" : "vrf", bgp
->name
);
17503 vty_out(vty
, "\n");
17505 /* BGP fast-external-failover. */
17506 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17507 vty_out(vty
, " no bgp fast-external-failover\n");
17509 /* BGP router ID. */
17510 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17511 vty_out(vty
, " bgp router-id %pI4\n",
17512 &bgp
->router_id_static
);
17514 /* Suppress fib pending */
17515 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17516 vty_out(vty
, " bgp suppress-fib-pending\n");
17518 /* BGP log-neighbor-changes. */
17519 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17520 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17521 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17522 CHECK_FLAG(bgp
->flags
,
17523 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17527 /* BGP configuration. */
17528 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17529 vty_out(vty
, " bgp always-compare-med\n");
17531 /* RFC8212 default eBGP policy. */
17532 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17533 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17534 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17535 CHECK_FLAG(bgp
->flags
,
17536 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17540 /* draft-ietf-idr-deprecate-as-set-confed-set */
17541 if (bgp
->reject_as_sets
)
17542 vty_out(vty
, " bgp reject-as-sets\n");
17544 /* Suppress duplicate updates if the route actually not changed
17546 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17547 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17548 vty_out(vty
, " %sbgp suppress-duplicates\n",
17549 CHECK_FLAG(bgp
->flags
,
17550 BGP_FLAG_SUPPRESS_DUPLICATES
)
17554 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17556 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17557 SAVE_BGP_HARD_ADMIN_RESET
)
17558 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17559 CHECK_FLAG(bgp
->flags
,
17560 BGP_FLAG_HARD_ADMIN_RESET
)
17564 /* BGP default <afi>-<safi> */
17565 FOREACH_AFI_SAFI (afi
, safi
) {
17566 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17567 if (!bgp
->default_af
[afi
][safi
])
17568 vty_out(vty
, " no bgp default %s\n",
17569 get_bgp_default_af_flag(afi
,
17571 } else if (bgp
->default_af
[afi
][safi
])
17572 vty_out(vty
, " bgp default %s\n",
17573 get_bgp_default_af_flag(afi
, safi
));
17576 /* BGP default local-preference. */
17577 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17578 vty_out(vty
, " bgp default local-preference %u\n",
17579 bgp
->default_local_pref
);
17581 /* BGP default show-hostname */
17582 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17583 != SAVE_BGP_SHOW_HOSTNAME
)
17584 vty_out(vty
, " %sbgp default show-hostname\n",
17585 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17589 /* BGP default show-nexthop-hostname */
17590 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17591 != SAVE_BGP_SHOW_HOSTNAME
)
17592 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17593 CHECK_FLAG(bgp
->flags
,
17594 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17598 /* BGP default subgroup-pkt-queue-max. */
17599 if (bgp
->default_subgroup_pkt_queue_max
17600 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17601 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17602 bgp
->default_subgroup_pkt_queue_max
);
17604 /* BGP client-to-client reflection. */
17605 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17606 vty_out(vty
, " no bgp client-to-client reflection\n");
17608 /* BGP cluster ID. */
17609 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17610 vty_out(vty
, " bgp cluster-id %pI4\n",
17613 /* Disable ebgp connected nexthop check */
17614 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17616 " bgp disable-ebgp-connected-route-check\n");
17618 /* Confederation identifier*/
17619 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17620 vty_out(vty
, " bgp confederation identifier %u\n",
17623 /* Confederation peer */
17624 if (bgp
->confed_peers_cnt
> 0) {
17627 vty_out(vty
, " bgp confederation peers");
17629 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17630 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17632 vty_out(vty
, "\n");
17635 /* BGP deterministic-med. */
17636 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17637 != SAVE_BGP_DETERMINISTIC_MED
)
17638 vty_out(vty
, " %sbgp deterministic-med\n",
17639 CHECK_FLAG(bgp
->flags
,
17640 BGP_FLAG_DETERMINISTIC_MED
)
17644 /* BGP update-delay. */
17645 bgp_config_write_update_delay(vty
, bgp
);
17647 if (bgp
->v_maxmed_onstartup
17648 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17649 vty_out(vty
, " bgp max-med on-startup %u",
17650 bgp
->v_maxmed_onstartup
);
17651 if (bgp
->maxmed_onstartup_value
17652 != BGP_MAXMED_VALUE_DEFAULT
)
17653 vty_out(vty
, " %u",
17654 bgp
->maxmed_onstartup_value
);
17655 vty_out(vty
, "\n");
17657 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17658 vty_out(vty
, " bgp max-med administrative");
17659 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17660 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17661 vty_out(vty
, "\n");
17665 bgp_config_write_wpkt_quanta(vty
, bgp
);
17667 bgp_config_write_rpkt_quanta(vty
, bgp
);
17669 /* coalesce time */
17670 bgp_config_write_coalesce_time(vty
, bgp
);
17672 /* BGP per-instance graceful-shutdown */
17673 /* BGP-wide settings and per-instance settings are mutually
17676 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17677 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17678 vty_out(vty
, " bgp graceful-shutdown\n");
17680 /* Long-lived Graceful Restart */
17681 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17683 " bgp long-lived-graceful-restart stale-time %u\n",
17684 bgp
->llgr_stale_time
);
17686 /* BGP graceful-restart. */
17687 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17689 " bgp graceful-restart stalepath-time %u\n",
17690 bgp
->stalepath_time
);
17692 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17693 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17694 bgp
->restart_time
);
17696 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17697 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17698 vty_out(vty
, " %sbgp graceful-restart notification\n",
17699 CHECK_FLAG(bgp
->flags
,
17700 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17704 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17706 " bgp graceful-restart select-defer-time %u\n",
17707 bgp
->select_defer_time
);
17709 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17710 vty_out(vty
, " bgp graceful-restart\n");
17712 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17713 vty_out(vty
, " bgp graceful-restart-disable\n");
17715 /* BGP graceful-restart Preserve State F bit. */
17716 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17718 " bgp graceful-restart preserve-fw-state\n");
17720 /* Stale timer for RIB */
17721 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17723 " bgp graceful-restart rib-stale-time %u\n",
17724 bgp
->rib_stale_time
);
17726 /* BGP bestpath method. */
17727 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17728 vty_out(vty
, " bgp bestpath as-path ignore\n");
17729 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17730 vty_out(vty
, " bgp bestpath as-path confed\n");
17732 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17733 if (CHECK_FLAG(bgp
->flags
,
17734 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17736 " bgp bestpath as-path multipath-relax as-set\n");
17739 " bgp bestpath as-path multipath-relax\n");
17743 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17745 " bgp route-reflector allow-outbound-policy\n");
17747 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17748 vty_out(vty
, " bgp bestpath compare-routerid\n");
17749 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17750 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17751 vty_out(vty
, " bgp bestpath med");
17752 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17753 vty_out(vty
, " confed");
17754 if (CHECK_FLAG(bgp
->flags
,
17755 BGP_FLAG_MED_MISSING_AS_WORST
))
17756 vty_out(vty
, " missing-as-worst");
17757 vty_out(vty
, "\n");
17760 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17762 " bgp bestpath peer-type multipath-relax\n");
17764 /* Link bandwidth handling. */
17765 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17766 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17767 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17768 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17769 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17770 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17772 /* BGP network import check. */
17773 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17774 != SAVE_BGP_IMPORT_CHECK
)
17775 vty_out(vty
, " %sbgp network import-check\n",
17776 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17780 /* BGP timers configuration. */
17781 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17782 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17783 vty_out(vty
, " timers bgp %u %u\n",
17784 bgp
->default_keepalive
, bgp
->default_holdtime
);
17786 /* BGP minimum holdtime configuration. */
17787 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17788 && bgp
->default_min_holdtime
!= 0)
17789 vty_out(vty
, " bgp minimum-holdtime %u\n",
17790 bgp
->default_min_holdtime
);
17792 /* Conditional advertisement timer configuration */
17793 if (bgp
->condition_check_period
17794 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17796 " bgp conditional-advertisement timer %u\n",
17797 bgp
->condition_check_period
);
17800 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17801 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17804 /* Normal neighbor configuration. */
17805 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17806 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17807 bgp_config_write_peer_global(vty
, bgp
, peer
);
17810 /* listen range and limit for dynamic BGP neighbors */
17811 bgp_config_write_listen(vty
, bgp
);
17814 * BGP default autoshutdown neighbors
17816 * This must be placed after any peer and peer-group
17817 * configuration, to avoid setting all peers to shutdown after
17818 * a daemon restart, which is undesired behavior. (see #2286)
17820 if (bgp
->autoshutdown
)
17821 vty_out(vty
, " bgp default shutdown\n");
17823 /* BGP instance administrative shutdown */
17824 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17825 vty_out(vty
, " bgp shutdown\n");
17827 if (bgp
->allow_martian
)
17828 vty_out(vty
, " bgp allow-martian-nexthop\n");
17830 if (bgp
->fast_convergence
)
17831 vty_out(vty
, " bgp fast-convergence\n");
17833 if (bgp
->srv6_enabled
) {
17834 vty_frame(vty
, " !\n segment-routing srv6\n");
17835 if (strlen(bgp
->srv6_locator_name
))
17836 vty_out(vty
, " locator %s\n",
17837 bgp
->srv6_locator_name
);
17838 vty_endframe(vty
, " exit\n");
17842 /* IPv4 unicast configuration. */
17843 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17845 /* IPv4 multicast configuration. */
17846 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17848 /* IPv4 labeled-unicast configuration. */
17849 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17851 /* IPv4 VPN configuration. */
17852 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17854 /* ENCAPv4 configuration. */
17855 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17857 /* FLOWSPEC v4 configuration. */
17858 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17860 /* IPv6 unicast configuration. */
17861 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17863 /* IPv6 multicast configuration. */
17864 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17866 /* IPv6 labeled-unicast configuration. */
17867 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17868 SAFI_LABELED_UNICAST
);
17870 /* IPv6 VPN configuration. */
17871 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17873 /* ENCAPv6 configuration. */
17874 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17876 /* FLOWSPEC v6 configuration. */
17877 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17879 /* EVPN configuration. */
17880 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17882 hook_call(bgp_inst_config_write
, bgp
, vty
);
17884 #ifdef ENABLE_BGP_VNC
17885 bgp_rfapi_cfg_write(vty
, bgp
);
17888 vty_out(vty
, "exit\n");
17889 vty_out(vty
, "!\n");
17895 /* BGP node structure. */
17896 static struct cmd_node bgp_node
= {
17899 .parent_node
= CONFIG_NODE
,
17900 .prompt
= "%s(config-router)# ",
17901 .config_write
= bgp_config_write
,
17904 static struct cmd_node bgp_ipv4_unicast_node
= {
17905 .name
= "bgp ipv4 unicast",
17906 .node
= BGP_IPV4_NODE
,
17907 .parent_node
= BGP_NODE
,
17908 .prompt
= "%s(config-router-af)# ",
17912 static struct cmd_node bgp_ipv4_multicast_node
= {
17913 .name
= "bgp ipv4 multicast",
17914 .node
= BGP_IPV4M_NODE
,
17915 .parent_node
= BGP_NODE
,
17916 .prompt
= "%s(config-router-af)# ",
17920 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17921 .name
= "bgp ipv4 labeled unicast",
17922 .node
= BGP_IPV4L_NODE
,
17923 .parent_node
= BGP_NODE
,
17924 .prompt
= "%s(config-router-af)# ",
17928 static struct cmd_node bgp_ipv6_unicast_node
= {
17929 .name
= "bgp ipv6 unicast",
17930 .node
= BGP_IPV6_NODE
,
17931 .parent_node
= BGP_NODE
,
17932 .prompt
= "%s(config-router-af)# ",
17936 static struct cmd_node bgp_ipv6_multicast_node
= {
17937 .name
= "bgp ipv6 multicast",
17938 .node
= BGP_IPV6M_NODE
,
17939 .parent_node
= BGP_NODE
,
17940 .prompt
= "%s(config-router-af)# ",
17944 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17945 .name
= "bgp ipv6 labeled unicast",
17946 .node
= BGP_IPV6L_NODE
,
17947 .parent_node
= BGP_NODE
,
17948 .prompt
= "%s(config-router-af)# ",
17952 static struct cmd_node bgp_vpnv4_node
= {
17953 .name
= "bgp vpnv4",
17954 .node
= BGP_VPNV4_NODE
,
17955 .parent_node
= BGP_NODE
,
17956 .prompt
= "%s(config-router-af)# ",
17960 static struct cmd_node bgp_vpnv6_node
= {
17961 .name
= "bgp vpnv6",
17962 .node
= BGP_VPNV6_NODE
,
17963 .parent_node
= BGP_NODE
,
17964 .prompt
= "%s(config-router-af-vpnv6)# ",
17968 static struct cmd_node bgp_evpn_node
= {
17969 .name
= "bgp evpn",
17970 .node
= BGP_EVPN_NODE
,
17971 .parent_node
= BGP_NODE
,
17972 .prompt
= "%s(config-router-evpn)# ",
17976 static struct cmd_node bgp_evpn_vni_node
= {
17977 .name
= "bgp evpn vni",
17978 .node
= BGP_EVPN_VNI_NODE
,
17979 .parent_node
= BGP_EVPN_NODE
,
17980 .prompt
= "%s(config-router-af-vni)# ",
17983 static struct cmd_node bgp_flowspecv4_node
= {
17984 .name
= "bgp ipv4 flowspec",
17985 .node
= BGP_FLOWSPECV4_NODE
,
17986 .parent_node
= BGP_NODE
,
17987 .prompt
= "%s(config-router-af)# ",
17991 static struct cmd_node bgp_flowspecv6_node
= {
17992 .name
= "bgp ipv6 flowspec",
17993 .node
= BGP_FLOWSPECV6_NODE
,
17994 .parent_node
= BGP_NODE
,
17995 .prompt
= "%s(config-router-af-vpnv6)# ",
17999 static struct cmd_node bgp_srv6_node
= {
18000 .name
= "bgp srv6",
18001 .node
= BGP_SRV6_NODE
,
18002 .parent_node
= BGP_NODE
,
18003 .prompt
= "%s(config-router-srv6)# ",
18006 static void community_list_vty(void);
18008 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18011 struct peer_group
*group
;
18012 struct listnode
*lnbgp
, *lnpeer
;
18014 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18015 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18017 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18021 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18025 struct listnode
*lnbgp
, *lnpeer
;
18027 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18028 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18029 /* only provide suggestions on the appropriate input
18031 * they'll otherwise show up multiple times */
18032 enum cmd_token_type match_type
;
18033 char *name
= peer
->host
;
18035 if (peer
->conf_if
) {
18036 match_type
= VARIABLE_TKN
;
18037 name
= peer
->conf_if
;
18038 } else if (strchr(peer
->host
, ':'))
18039 match_type
= IPV6_TKN
;
18041 match_type
= IPV4_TKN
;
18043 if (token
->type
!= match_type
)
18046 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18051 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18053 bgp_ac_peer(comps
, token
);
18055 if (token
->type
== VARIABLE_TKN
)
18056 bgp_ac_peergroup(comps
, token
);
18059 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18060 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18061 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18062 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18063 {.completions
= NULL
}};
18065 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18066 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18067 {.completions
= NULL
} };
18069 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18071 static struct thread
*t_bgp_cfg
;
18073 bool bgp_config_inprocess(void)
18075 return thread_is_scheduled(t_bgp_cfg
);
18078 static void bgp_config_finish(struct thread
*t
)
18080 struct listnode
*node
;
18083 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18084 hook_call(bgp_config_end
, bgp
);
18087 static void bgp_config_start(void)
18089 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18090 THREAD_OFF(t_bgp_cfg
);
18091 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18092 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18095 /* When we receive a hook the configuration is read,
18096 * we start a timer to make sure we postpone sending
18097 * EoR before route-maps are processed.
18098 * This is especially valid if using `bgp route-map delay-timer`.
18100 static void bgp_config_end(void)
18102 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18103 uint32_t bgp_post_config_delay
=
18104 thread_is_scheduled(bm
->t_rmap_update
)
18105 ? thread_timer_remain_second(bm
->t_rmap_update
)
18106 : BGP_POST_CONFIG_DELAY_SECONDS
;
18108 /* If BGP config processing thread isn't running, then
18109 * we can return and rely it's properly handled.
18111 if (!bgp_config_inprocess())
18114 THREAD_OFF(t_bgp_cfg
);
18116 /* Start a new timer to make sure we don't send EoR
18117 * before route-maps are processed.
18119 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18120 bgp_post_config_delay
, &t_bgp_cfg
);
18123 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18126 struct interface
*ifp
;
18127 struct bgp_interface
*iifp
;
18129 FOR_ALL_INTERFACES (vrf
, ifp
) {
18134 if_vty_config_start(vty
, ifp
);
18136 if (CHECK_FLAG(iifp
->flags
,
18137 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18138 vty_out(vty
, " mpls bgp forwarding\n");
18142 if_vty_config_end(vty
);
18148 /* Configuration write function for bgpd. */
18149 static int config_write_interface(struct vty
*vty
)
18152 struct vrf
*vrf
= NULL
;
18154 /* Display all VRF aware OSPF interface configuration */
18155 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18156 write
+= config_write_interface_one(vty
, vrf
);
18162 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18163 "[no$no] mpls bgp forwarding",
18164 NO_STR MPLS_STR BGP_STR
18165 "Enable MPLS forwarding for eBGP directly connected peers\n")
18168 struct bgp_interface
*iifp
;
18170 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18173 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18174 return CMD_WARNING_CONFIG_FAILED
;
18176 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18177 if (check
!= !no
) {
18179 UNSET_FLAG(iifp
->flags
,
18180 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18182 SET_FLAG(iifp
->flags
,
18183 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18184 /* trigger a nht update on eBGP sessions */
18185 if (if_is_operative(ifp
))
18186 bgp_nht_ifp_up(ifp
);
18188 return CMD_SUCCESS
;
18191 /* Initialization of BGP interface. */
18192 static void bgp_vty_if_init(void)
18194 /* Install interface node. */
18195 if_cmd_init(config_write_interface
);
18197 /* "mpls bgp forwarding" commands. */
18198 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18201 void bgp_vty_init(void)
18203 cmd_variable_handler_register(bgp_var_neighbor
);
18204 cmd_variable_handler_register(bgp_var_peergroup
);
18206 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18208 /* Install bgp top node. */
18209 install_node(&bgp_node
);
18210 install_node(&bgp_ipv4_unicast_node
);
18211 install_node(&bgp_ipv4_multicast_node
);
18212 install_node(&bgp_ipv4_labeled_unicast_node
);
18213 install_node(&bgp_ipv6_unicast_node
);
18214 install_node(&bgp_ipv6_multicast_node
);
18215 install_node(&bgp_ipv6_labeled_unicast_node
);
18216 install_node(&bgp_vpnv4_node
);
18217 install_node(&bgp_vpnv6_node
);
18218 install_node(&bgp_evpn_node
);
18219 install_node(&bgp_evpn_vni_node
);
18220 install_node(&bgp_flowspecv4_node
);
18221 install_node(&bgp_flowspecv6_node
);
18222 install_node(&bgp_srv6_node
);
18224 /* Install default VTY commands to new nodes. */
18225 install_default(BGP_NODE
);
18226 install_default(BGP_IPV4_NODE
);
18227 install_default(BGP_IPV4M_NODE
);
18228 install_default(BGP_IPV4L_NODE
);
18229 install_default(BGP_IPV6_NODE
);
18230 install_default(BGP_IPV6M_NODE
);
18231 install_default(BGP_IPV6L_NODE
);
18232 install_default(BGP_VPNV4_NODE
);
18233 install_default(BGP_VPNV6_NODE
);
18234 install_default(BGP_FLOWSPECV4_NODE
);
18235 install_default(BGP_FLOWSPECV6_NODE
);
18236 install_default(BGP_EVPN_NODE
);
18237 install_default(BGP_EVPN_VNI_NODE
);
18238 install_default(BGP_SRV6_NODE
);
18240 /* "bgp local-mac" hidden commands. */
18241 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18242 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18244 /* "bgp suppress-fib-pending" global */
18245 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18247 /* bgp route-map delay-timer commands. */
18248 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18249 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18251 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18253 /* bgp fast-convergence command */
18254 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18255 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18257 /* global bgp update-delay command */
18258 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18259 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18261 /* global bgp graceful-shutdown command */
18262 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18263 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18265 /* Dummy commands (Currently not supported) */
18266 install_element(BGP_NODE
, &no_synchronization_cmd
);
18267 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18269 /* "router bgp" commands. */
18270 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18272 /* "no router bgp" commands. */
18273 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18275 /* "bgp session-dscp command */
18276 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18277 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18279 /* "bgp router-id" commands. */
18280 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18281 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18283 /* "bgp suppress-fib-pending" command */
18284 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18286 /* "bgp cluster-id" commands. */
18287 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18288 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18290 /* "bgp no-rib" commands. */
18291 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18292 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18294 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18296 /* "bgp confederation" commands. */
18297 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18298 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18300 /* "bgp confederation peers" commands. */
18301 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18302 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18304 /* bgp max-med command */
18305 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18306 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18307 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18308 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18309 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18311 /* "neighbor role" commands. */
18312 install_element(BGP_NODE
, &neighbor_role_cmd
);
18313 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18314 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18316 /* bgp disable-ebgp-connected-nh-check */
18317 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18318 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18320 /* bgp update-delay command */
18321 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18322 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18324 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18325 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18327 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18328 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18330 /* "maximum-paths" commands. */
18331 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18332 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18333 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18334 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18335 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18336 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18337 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18338 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18339 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18340 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18341 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18342 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18343 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18344 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18345 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18347 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18348 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18349 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18350 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18351 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18352 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18353 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18354 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18355 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18356 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18358 /* "timers bgp" commands. */
18359 install_element(BGP_NODE
, &bgp_timers_cmd
);
18360 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18362 /* "minimum-holdtime" commands. */
18363 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18364 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18366 /* route-map delay-timer commands - per instance for backwards compat.
18368 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18369 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18371 /* "bgp client-to-client reflection" commands */
18372 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18373 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18375 /* "bgp always-compare-med" commands */
18376 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18377 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18379 /* bgp ebgp-requires-policy */
18380 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18381 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18383 /* bgp suppress-duplicates */
18384 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18385 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18387 /* bgp reject-as-sets */
18388 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18389 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18391 /* "bgp deterministic-med" commands */
18392 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18393 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18395 /* "bgp graceful-restart" command */
18396 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18397 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18399 /* "bgp graceful-restart-disable" command */
18400 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18401 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18403 /* "neighbor a:b:c:d graceful-restart" command */
18404 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18405 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18407 /* "neighbor a:b:c:d graceful-restart-disable" command */
18408 install_element(BGP_NODE
,
18409 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18410 install_element(BGP_NODE
,
18411 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18413 /* "neighbor a:b:c:d graceful-restart-helper" command */
18414 install_element(BGP_NODE
,
18415 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18416 install_element(BGP_NODE
,
18417 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18419 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18420 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18421 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18422 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18423 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18424 install_element(BGP_NODE
,
18425 &no_bgp_graceful_restart_select_defer_time_cmd
);
18426 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18427 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18428 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18430 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18431 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18432 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18433 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18435 /* "bgp graceful-shutdown" commands */
18436 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18437 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18439 /* "bgp hard-administrative-reset" commands */
18440 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18442 /* "bgp long-lived-graceful-restart" commands */
18443 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18444 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18446 /* "bgp fast-external-failover" commands */
18447 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18448 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18450 /* "bgp bestpath compare-routerid" commands */
18451 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18452 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18454 /* "bgp bestpath as-path ignore" commands */
18455 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18456 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18458 /* "bgp bestpath as-path confed" commands */
18459 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18460 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18462 /* "bgp bestpath as-path multipath-relax" commands */
18463 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18464 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18466 /* "bgp bestpath peer-type multipath-relax" commands */
18467 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18468 install_element(BGP_NODE
,
18469 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18471 /* "bgp log-neighbor-changes" commands */
18472 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18473 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18475 /* "bgp bestpath med" commands */
18476 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18477 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18479 /* "bgp bestpath bandwidth" commands */
18480 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18481 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18483 /* "no bgp default <afi>-<safi>" commands. */
18484 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18486 /* "bgp network import-check" commands. */
18487 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18488 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18489 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18491 /* "bgp default local-preference" commands. */
18492 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18493 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18495 /* bgp default show-hostname */
18496 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18497 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18499 /* bgp default show-nexthop-hostname */
18500 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18501 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18503 /* "bgp default subgroup-pkt-queue-max" commands. */
18504 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18505 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18507 /* bgp ibgp-allow-policy-mods command */
18508 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18509 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18511 /* "bgp listen limit" commands. */
18512 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18513 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18515 /* "bgp listen range" commands. */
18516 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18519 /* "bgp default shutdown" command */
18520 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18522 /* "bgp shutdown" commands */
18523 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18524 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18525 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18526 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18528 /* "neighbor remote-as" commands. */
18529 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18530 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18531 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18532 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18533 install_element(BGP_NODE
,
18534 &neighbor_interface_v6only_config_remote_as_cmd
);
18535 install_element(BGP_NODE
, &no_neighbor_cmd
);
18536 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18538 /* "neighbor peer-group" commands. */
18539 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18540 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18541 install_element(BGP_NODE
,
18542 &no_neighbor_interface_peer_group_remote_as_cmd
);
18544 /* "neighbor local-as" commands. */
18545 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18546 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18547 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18548 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18550 /* "neighbor solo" commands. */
18551 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18552 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18554 /* "neighbor password" commands. */
18555 install_element(BGP_NODE
, &neighbor_password_cmd
);
18556 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18558 /* "neighbor activate" commands. */
18559 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18560 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18561 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18562 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18563 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18564 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18565 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18566 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18567 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18568 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18569 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18570 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18572 /* "no neighbor activate" commands. */
18573 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18574 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18575 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18576 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18577 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18578 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18579 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18580 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18581 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18582 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18583 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18584 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18586 /* "neighbor peer-group" set commands. */
18587 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18588 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18589 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18590 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18591 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18592 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18593 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18594 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18595 install_element(BGP_FLOWSPECV4_NODE
,
18596 &neighbor_set_peer_group_hidden_cmd
);
18597 install_element(BGP_FLOWSPECV6_NODE
,
18598 &neighbor_set_peer_group_hidden_cmd
);
18600 /* "no neighbor peer-group unset" commands. */
18601 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18602 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18603 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18604 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18605 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18606 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18607 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18608 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18609 install_element(BGP_FLOWSPECV4_NODE
,
18610 &no_neighbor_set_peer_group_hidden_cmd
);
18611 install_element(BGP_FLOWSPECV6_NODE
,
18612 &no_neighbor_set_peer_group_hidden_cmd
);
18614 /* "neighbor softreconfiguration inbound" commands.*/
18615 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18616 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18617 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18618 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18619 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18620 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18621 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18622 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18623 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18624 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18625 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18626 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18627 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18628 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18629 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18630 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18631 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18632 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18633 install_element(BGP_FLOWSPECV4_NODE
,
18634 &neighbor_soft_reconfiguration_cmd
);
18635 install_element(BGP_FLOWSPECV4_NODE
,
18636 &no_neighbor_soft_reconfiguration_cmd
);
18637 install_element(BGP_FLOWSPECV6_NODE
,
18638 &neighbor_soft_reconfiguration_cmd
);
18639 install_element(BGP_FLOWSPECV6_NODE
,
18640 &no_neighbor_soft_reconfiguration_cmd
);
18641 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18642 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18644 /* "neighbor attribute-unchanged" commands. */
18645 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18646 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18647 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18648 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18649 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18650 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18651 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18652 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18653 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18654 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18655 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18656 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18657 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18658 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18659 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18660 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18661 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18662 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18664 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18665 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18667 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18668 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18669 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18670 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18672 /* "nexthop-local unchanged" commands */
18673 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18674 install_element(BGP_IPV6_NODE
,
18675 &no_neighbor_nexthop_local_unchanged_cmd
);
18677 /* "neighbor next-hop-self" commands. */
18678 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18679 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18680 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18681 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18682 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18683 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18684 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18685 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18686 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18687 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18688 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18689 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18690 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18691 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18692 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18693 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18694 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18695 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18696 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18697 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18699 /* "neighbor next-hop-self force" commands. */
18700 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18701 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18702 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18703 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18704 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18705 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18706 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18707 install_element(BGP_IPV4_NODE
,
18708 &no_neighbor_nexthop_self_all_hidden_cmd
);
18709 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18710 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18711 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18712 install_element(BGP_IPV4M_NODE
,
18713 &no_neighbor_nexthop_self_all_hidden_cmd
);
18714 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18715 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18716 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18717 install_element(BGP_IPV4L_NODE
,
18718 &no_neighbor_nexthop_self_all_hidden_cmd
);
18719 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18720 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18721 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18722 install_element(BGP_IPV6_NODE
,
18723 &no_neighbor_nexthop_self_all_hidden_cmd
);
18724 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18725 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18726 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18727 install_element(BGP_IPV6M_NODE
,
18728 &no_neighbor_nexthop_self_all_hidden_cmd
);
18729 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18730 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18731 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18732 install_element(BGP_IPV6L_NODE
,
18733 &no_neighbor_nexthop_self_all_hidden_cmd
);
18734 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18735 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18736 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18737 install_element(BGP_VPNV4_NODE
,
18738 &no_neighbor_nexthop_self_all_hidden_cmd
);
18739 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18740 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18741 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18742 install_element(BGP_VPNV6_NODE
,
18743 &no_neighbor_nexthop_self_all_hidden_cmd
);
18744 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18745 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18747 /* "neighbor as-override" commands. */
18748 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18749 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18750 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18751 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18752 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18753 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18754 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18755 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18756 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18757 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18758 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18759 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18760 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18761 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18762 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18763 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18764 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18765 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18767 /* "neighbor remove-private-AS" commands. */
18768 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18769 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18770 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18771 install_element(BGP_NODE
,
18772 &no_neighbor_remove_private_as_all_hidden_cmd
);
18773 install_element(BGP_NODE
,
18774 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18775 install_element(BGP_NODE
,
18776 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18777 install_element(BGP_NODE
,
18778 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18781 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18782 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18783 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18784 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18785 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18786 install_element(BGP_IPV4_NODE
,
18787 &neighbor_remove_private_as_replace_as_cmd
);
18788 install_element(BGP_IPV4_NODE
,
18789 &no_neighbor_remove_private_as_replace_as_cmd
);
18790 install_element(BGP_IPV4_NODE
,
18791 &neighbor_remove_private_as_all_replace_as_cmd
);
18792 install_element(BGP_IPV4_NODE
,
18793 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18794 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18795 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18796 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18797 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18798 install_element(BGP_IPV4M_NODE
,
18799 &neighbor_remove_private_as_replace_as_cmd
);
18800 install_element(BGP_IPV4M_NODE
,
18801 &no_neighbor_remove_private_as_replace_as_cmd
);
18802 install_element(BGP_IPV4M_NODE
,
18803 &neighbor_remove_private_as_all_replace_as_cmd
);
18804 install_element(BGP_IPV4M_NODE
,
18805 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18806 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18807 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18808 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18809 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18810 install_element(BGP_IPV4L_NODE
,
18811 &neighbor_remove_private_as_replace_as_cmd
);
18812 install_element(BGP_IPV4L_NODE
,
18813 &no_neighbor_remove_private_as_replace_as_cmd
);
18814 install_element(BGP_IPV4L_NODE
,
18815 &neighbor_remove_private_as_all_replace_as_cmd
);
18816 install_element(BGP_IPV4L_NODE
,
18817 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18818 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18819 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18820 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18821 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18822 install_element(BGP_IPV6_NODE
,
18823 &neighbor_remove_private_as_replace_as_cmd
);
18824 install_element(BGP_IPV6_NODE
,
18825 &no_neighbor_remove_private_as_replace_as_cmd
);
18826 install_element(BGP_IPV6_NODE
,
18827 &neighbor_remove_private_as_all_replace_as_cmd
);
18828 install_element(BGP_IPV6_NODE
,
18829 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18830 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18831 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18832 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18833 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18834 install_element(BGP_IPV6M_NODE
,
18835 &neighbor_remove_private_as_replace_as_cmd
);
18836 install_element(BGP_IPV6M_NODE
,
18837 &no_neighbor_remove_private_as_replace_as_cmd
);
18838 install_element(BGP_IPV6M_NODE
,
18839 &neighbor_remove_private_as_all_replace_as_cmd
);
18840 install_element(BGP_IPV6M_NODE
,
18841 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18842 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18843 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18844 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18845 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18846 install_element(BGP_IPV6L_NODE
,
18847 &neighbor_remove_private_as_replace_as_cmd
);
18848 install_element(BGP_IPV6L_NODE
,
18849 &no_neighbor_remove_private_as_replace_as_cmd
);
18850 install_element(BGP_IPV6L_NODE
,
18851 &neighbor_remove_private_as_all_replace_as_cmd
);
18852 install_element(BGP_IPV6L_NODE
,
18853 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18854 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18855 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18856 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18857 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18858 install_element(BGP_VPNV4_NODE
,
18859 &neighbor_remove_private_as_replace_as_cmd
);
18860 install_element(BGP_VPNV4_NODE
,
18861 &no_neighbor_remove_private_as_replace_as_cmd
);
18862 install_element(BGP_VPNV4_NODE
,
18863 &neighbor_remove_private_as_all_replace_as_cmd
);
18864 install_element(BGP_VPNV4_NODE
,
18865 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18866 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18867 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18868 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18869 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18870 install_element(BGP_VPNV6_NODE
,
18871 &neighbor_remove_private_as_replace_as_cmd
);
18872 install_element(BGP_VPNV6_NODE
,
18873 &no_neighbor_remove_private_as_replace_as_cmd
);
18874 install_element(BGP_VPNV6_NODE
,
18875 &neighbor_remove_private_as_all_replace_as_cmd
);
18876 install_element(BGP_VPNV6_NODE
,
18877 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18879 /* "neighbor send-community" commands.*/
18880 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18881 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18882 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18883 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18884 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18885 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18886 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18887 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18888 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18889 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18890 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18891 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18892 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18893 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18894 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18895 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18896 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18897 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18898 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18899 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18900 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18901 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18902 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18903 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18904 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18905 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18906 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18907 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18908 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18909 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18910 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18911 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18912 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18913 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18914 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18915 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18917 /* "neighbor route-reflector" commands.*/
18918 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18919 install_element(BGP_NODE
,
18920 &no_neighbor_route_reflector_client_hidden_cmd
);
18921 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18922 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18923 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18924 install_element(BGP_IPV4M_NODE
,
18925 &no_neighbor_route_reflector_client_cmd
);
18926 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18927 install_element(BGP_IPV4L_NODE
,
18928 &no_neighbor_route_reflector_client_cmd
);
18929 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18930 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18931 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18932 install_element(BGP_IPV6M_NODE
,
18933 &no_neighbor_route_reflector_client_cmd
);
18934 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18935 install_element(BGP_IPV6L_NODE
,
18936 &no_neighbor_route_reflector_client_cmd
);
18937 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18938 install_element(BGP_VPNV4_NODE
,
18939 &no_neighbor_route_reflector_client_cmd
);
18940 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18941 install_element(BGP_VPNV6_NODE
,
18942 &no_neighbor_route_reflector_client_cmd
);
18943 install_element(BGP_FLOWSPECV4_NODE
,
18944 &neighbor_route_reflector_client_cmd
);
18945 install_element(BGP_FLOWSPECV4_NODE
,
18946 &no_neighbor_route_reflector_client_cmd
);
18947 install_element(BGP_FLOWSPECV6_NODE
,
18948 &neighbor_route_reflector_client_cmd
);
18949 install_element(BGP_FLOWSPECV6_NODE
,
18950 &no_neighbor_route_reflector_client_cmd
);
18951 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18952 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18954 /* "neighbor route-server" commands.*/
18955 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18956 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18957 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18958 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18959 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18960 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18961 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18962 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18963 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18964 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18965 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18966 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18967 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18968 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18969 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18970 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18971 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18972 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18973 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18974 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18975 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18976 install_element(BGP_FLOWSPECV4_NODE
,
18977 &no_neighbor_route_server_client_cmd
);
18978 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18979 install_element(BGP_FLOWSPECV6_NODE
,
18980 &no_neighbor_route_server_client_cmd
);
18982 /* "neighbor disable-addpath-rx" commands. */
18983 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18984 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18985 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18986 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18987 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18988 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18989 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18990 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18991 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18992 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18993 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18994 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18995 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18996 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18997 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18998 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19000 /* "neighbor addpath-tx-all-paths" commands.*/
19001 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19002 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19003 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19004 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19005 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19006 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19007 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19008 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19009 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19010 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19011 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19012 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19013 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19014 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19015 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19016 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19017 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19018 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19020 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19021 install_element(BGP_NODE
,
19022 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19023 install_element(BGP_NODE
,
19024 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19025 install_element(BGP_IPV4_NODE
,
19026 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19027 install_element(BGP_IPV4_NODE
,
19028 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19029 install_element(BGP_IPV4M_NODE
,
19030 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19031 install_element(BGP_IPV4M_NODE
,
19032 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19033 install_element(BGP_IPV4L_NODE
,
19034 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19035 install_element(BGP_IPV4L_NODE
,
19036 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19037 install_element(BGP_IPV6_NODE
,
19038 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19039 install_element(BGP_IPV6_NODE
,
19040 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19041 install_element(BGP_IPV6M_NODE
,
19042 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19043 install_element(BGP_IPV6M_NODE
,
19044 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19045 install_element(BGP_IPV6L_NODE
,
19046 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19047 install_element(BGP_IPV6L_NODE
,
19048 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19049 install_element(BGP_VPNV4_NODE
,
19050 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19051 install_element(BGP_VPNV4_NODE
,
19052 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19053 install_element(BGP_VPNV6_NODE
,
19054 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19055 install_element(BGP_VPNV6_NODE
,
19056 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19058 /* "neighbor sender-as-path-loop-detection" commands. */
19059 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19060 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19062 /* "neighbor passive" commands. */
19063 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19064 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19067 /* "neighbor shutdown" commands. */
19068 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19069 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19070 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19071 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19072 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19073 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19075 /* "neighbor capability extended-nexthop" commands.*/
19076 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19077 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19079 /* "neighbor capability orf prefix-list" commands.*/
19080 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19081 install_element(BGP_NODE
,
19082 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19083 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19084 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19085 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19086 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19087 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19088 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19089 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19090 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19091 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19092 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19093 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19094 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19096 /* "neighbor capability dynamic" commands.*/
19097 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19098 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19100 /* "neighbor dont-capability-negotiate" commands. */
19101 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19102 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19104 /* "neighbor ebgp-multihop" commands. */
19105 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19106 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19107 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19109 /* "neighbor disable-connected-check" commands. */
19110 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19111 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19113 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19114 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19115 install_element(BGP_NODE
,
19116 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19118 /* "neighbor extended-optional-parameters" commands. */
19119 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19120 install_element(BGP_NODE
,
19121 &no_neighbor_extended_optional_parameters_cmd
);
19123 /* "neighbor enforce-first-as" commands. */
19124 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19125 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19127 /* "neighbor description" commands. */
19128 install_element(BGP_NODE
, &neighbor_description_cmd
);
19129 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19130 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19132 /* "neighbor update-source" commands. "*/
19133 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19134 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19136 /* "neighbor default-originate" commands. */
19137 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19138 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19139 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19140 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19141 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19142 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19143 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19144 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19145 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19146 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19147 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19148 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19149 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19150 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19151 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19152 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19153 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19154 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19155 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19156 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19157 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19159 /* "neighbor port" commands. */
19160 install_element(BGP_NODE
, &neighbor_port_cmd
);
19161 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19163 /* "neighbor weight" commands. */
19164 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19165 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19167 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19168 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19169 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19170 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19171 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19172 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19173 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19174 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19175 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19176 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19177 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19178 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19179 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19180 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19181 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19182 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19184 /* "neighbor override-capability" commands. */
19185 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19186 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19188 /* "neighbor strict-capability-match" commands. */
19189 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19190 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19192 /* "neighbor timers" commands. */
19193 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19194 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19196 /* "neighbor timers connect" commands. */
19197 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19198 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19200 /* "neighbor timers delayopen" commands. */
19201 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19202 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19204 /* "neighbor advertisement-interval" commands. */
19205 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19206 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19208 /* "neighbor interface" commands. */
19209 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19210 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19212 /* "neighbor distribute" commands. */
19213 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19214 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19215 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19216 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19217 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19218 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19219 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19220 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19221 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19222 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19223 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19224 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19225 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19226 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19227 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19228 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19229 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19230 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19232 /* "neighbor prefix-list" commands. */
19233 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19234 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19235 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19236 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19237 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19238 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19239 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19240 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19241 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19242 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19243 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19244 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19245 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19246 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19247 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19248 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19249 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19250 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19251 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19252 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19253 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19254 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19256 /* "neighbor filter-list" commands. */
19257 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19258 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19259 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19260 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19261 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19262 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19263 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19264 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19265 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19266 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19267 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19268 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19269 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19270 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19271 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19272 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19273 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19274 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19275 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19276 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19277 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19278 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19280 /* "neighbor route-map" commands. */
19281 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19282 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19283 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19284 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19285 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19286 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19287 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19288 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19289 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19290 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19291 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19292 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19293 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19294 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19295 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19296 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19297 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19298 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19299 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19300 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19301 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19302 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19303 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19304 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19306 /* "neighbor unsuppress-map" commands. */
19307 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19308 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19309 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19310 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19311 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19312 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19313 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19314 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19315 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19316 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19317 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19318 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19319 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19320 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19321 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19322 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19323 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19324 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19326 /* "neighbor advertise-map" commands. */
19327 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19328 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19329 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19330 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19331 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19332 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19333 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19334 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19335 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19336 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19338 /* neighbor maximum-prefix-out commands. */
19339 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19340 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19341 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19342 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19343 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19344 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19345 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19346 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19347 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19348 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19349 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19350 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19351 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19352 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19353 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19354 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19355 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19356 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19358 /* "neighbor maximum-prefix" commands. */
19359 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19360 install_element(BGP_NODE
,
19361 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19362 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19363 install_element(BGP_NODE
,
19364 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19365 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19366 install_element(BGP_NODE
,
19367 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19368 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19369 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19370 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19371 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19372 install_element(BGP_IPV4_NODE
,
19373 &neighbor_maximum_prefix_threshold_warning_cmd
);
19374 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19375 install_element(BGP_IPV4_NODE
,
19376 &neighbor_maximum_prefix_threshold_restart_cmd
);
19377 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19378 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19379 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19380 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19381 install_element(BGP_IPV4M_NODE
,
19382 &neighbor_maximum_prefix_threshold_warning_cmd
);
19383 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19384 install_element(BGP_IPV4M_NODE
,
19385 &neighbor_maximum_prefix_threshold_restart_cmd
);
19386 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19387 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19388 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19389 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19390 install_element(BGP_IPV4L_NODE
,
19391 &neighbor_maximum_prefix_threshold_warning_cmd
);
19392 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19393 install_element(BGP_IPV4L_NODE
,
19394 &neighbor_maximum_prefix_threshold_restart_cmd
);
19395 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19396 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19397 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19398 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19399 install_element(BGP_IPV6_NODE
,
19400 &neighbor_maximum_prefix_threshold_warning_cmd
);
19401 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19402 install_element(BGP_IPV6_NODE
,
19403 &neighbor_maximum_prefix_threshold_restart_cmd
);
19404 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19405 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19406 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19407 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19408 install_element(BGP_IPV6M_NODE
,
19409 &neighbor_maximum_prefix_threshold_warning_cmd
);
19410 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19411 install_element(BGP_IPV6M_NODE
,
19412 &neighbor_maximum_prefix_threshold_restart_cmd
);
19413 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19414 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19415 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19416 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19417 install_element(BGP_IPV6L_NODE
,
19418 &neighbor_maximum_prefix_threshold_warning_cmd
);
19419 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19420 install_element(BGP_IPV6L_NODE
,
19421 &neighbor_maximum_prefix_threshold_restart_cmd
);
19422 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19423 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19424 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19425 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19426 install_element(BGP_VPNV4_NODE
,
19427 &neighbor_maximum_prefix_threshold_warning_cmd
);
19428 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19429 install_element(BGP_VPNV4_NODE
,
19430 &neighbor_maximum_prefix_threshold_restart_cmd
);
19431 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19432 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19433 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19434 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19435 install_element(BGP_VPNV6_NODE
,
19436 &neighbor_maximum_prefix_threshold_warning_cmd
);
19437 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19438 install_element(BGP_VPNV6_NODE
,
19439 &neighbor_maximum_prefix_threshold_restart_cmd
);
19440 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19442 /* "neighbor allowas-in" */
19443 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19444 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19445 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19446 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19447 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19448 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19449 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19450 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19451 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19452 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19453 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19454 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19455 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19456 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19457 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19458 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19459 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19460 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19461 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19462 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19464 /* "neighbor soo" */
19465 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19466 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19467 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19468 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19469 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19470 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19471 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19472 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19473 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19474 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19475 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19476 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19477 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19478 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19479 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19480 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19481 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19482 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19484 /* address-family commands. */
19485 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19486 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19487 #ifdef KEEP_OLD_VPN_COMMANDS
19488 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19489 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19490 #endif /* KEEP_OLD_VPN_COMMANDS */
19492 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19494 /* "exit-address-family" command. */
19495 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19496 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19497 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19498 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19499 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19500 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19501 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19502 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19503 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19504 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19505 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19507 /* BGP retain all route-target */
19508 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19509 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19511 /* "clear ip bgp commands" */
19512 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19514 /* clear ip bgp prefix */
19515 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19516 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19517 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19519 /* "show [ip] bgp summary" commands. */
19520 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19521 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19522 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19523 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19524 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19525 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19526 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19528 /* "show [ip] bgp neighbors" commands. */
19529 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19531 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19533 /* "show [ip] bgp peer-group" commands. */
19534 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19536 /* "show [ip] bgp paths" commands. */
19537 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19539 /* "show [ip] bgp community" commands. */
19540 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19542 /* "show ip bgp large-community" commands. */
19543 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19544 /* "show [ip] bgp attribute-info" commands. */
19545 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19546 /* "show [ip] bgp route-leak" command */
19547 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19549 /* "redistribute" commands. */
19550 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19551 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19552 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19553 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19554 install_element(BGP_NODE
,
19555 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19556 install_element(BGP_NODE
,
19557 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19558 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19559 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19560 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19561 install_element(BGP_NODE
,
19562 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19563 install_element(BGP_NODE
,
19564 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19565 install_element(BGP_NODE
,
19566 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19567 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19568 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19569 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19570 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19571 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19572 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19573 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19574 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19575 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19576 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19577 install_element(BGP_IPV4_NODE
,
19578 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19579 install_element(BGP_IPV4_NODE
,
19580 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19581 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19582 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19583 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19584 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19585 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19586 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19588 /* import|export vpn [route-map RMAP_NAME] */
19589 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19590 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19592 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19593 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19595 /* ttl_security commands */
19596 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19597 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19599 /* "show [ip] bgp memory" commands. */
19600 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19602 /* "show bgp martian next-hop" */
19603 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19605 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19607 /* "show [ip] bgp views" commands. */
19608 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19610 /* "show [ip] bgp vrfs" commands. */
19611 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19613 /* Community-list. */
19614 community_list_vty();
19616 community_alias_vty();
19618 /* vpn-policy commands */
19619 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19620 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19621 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19622 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19623 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19624 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19625 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19626 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19627 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19628 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19629 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19630 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19632 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19633 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19635 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19636 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19637 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19638 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19639 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19640 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19641 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19642 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19643 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19644 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19646 /* tcp-mss command */
19647 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19648 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19650 /* srv6 commands */
19651 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19652 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19653 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19654 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19655 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19656 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19657 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19662 #include "memory.h"
19663 #include "bgp_regex.h"
19664 #include "bgp_clist.h"
19665 #include "bgp_ecommunity.h"
19667 /* VTY functions. */
19669 /* Direction value to string conversion. */
19670 static const char *community_direct_str(int direct
)
19673 case COMMUNITY_DENY
:
19675 case COMMUNITY_PERMIT
:
19682 /* Display error string. */
19683 static void community_list_perror(struct vty
*vty
, int ret
)
19686 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19687 vty_out(vty
, "%% Can't find community-list\n");
19689 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19690 vty_out(vty
, "%% Malformed community-list value\n");
19692 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19694 "%% Community name conflict, previously defined as standard community\n");
19696 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19698 "%% Community name conflict, previously defined as expanded community\n");
19703 /* "community-list" keyword help string. */
19704 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19706 /*community-list standard */
19707 DEFUN (community_list_standard
,
19708 bgp_community_list_standard_cmd
,
19709 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19712 "Community list number (standard)\n"
19713 "Add an standard community-list entry\n"
19714 "Community list name\n"
19715 "Sequence number of an entry\n"
19716 "Sequence number\n"
19717 "Specify community to reject\n"
19718 "Specify community to accept\n"
19721 char *cl_name_or_number
= NULL
;
19724 int style
= COMMUNITY_LIST_STANDARD
;
19727 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19728 seq
= argv
[idx
]->arg
;
19731 argv_find(argv
, argc
, "(1-99)", &idx
);
19732 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19733 cl_name_or_number
= argv
[idx
]->arg
;
19734 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19736 argv_find(argv
, argc
, "AA:NN", &idx
);
19737 char *str
= argv_concat(argv
, argc
, idx
);
19739 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19742 XFREE(MTYPE_TMP
, str
);
19745 /* Display error string. */
19746 community_list_perror(vty
, ret
);
19747 return CMD_WARNING_CONFIG_FAILED
;
19750 return CMD_SUCCESS
;
19753 DEFUN (no_community_list_standard_all
,
19754 no_bgp_community_list_standard_all_cmd
,
19755 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19759 "Community list number (standard)\n"
19760 "Add an standard community-list entry\n"
19761 "Community list name\n"
19762 "Sequence number of an entry\n"
19763 "Sequence number\n"
19764 "Specify community to reject\n"
19765 "Specify community to accept\n"
19768 char *cl_name_or_number
= NULL
;
19771 int style
= COMMUNITY_LIST_STANDARD
;
19775 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19776 seq
= argv
[idx
]->arg
;
19779 argv_find(argv
, argc
, "permit", &idx
);
19780 argv_find(argv
, argc
, "deny", &idx
);
19783 direct
= argv_find(argv
, argc
, "permit", &idx
)
19788 argv_find(argv
, argc
, "AA:NN", &idx
);
19789 str
= argv_concat(argv
, argc
, idx
);
19793 argv_find(argv
, argc
, "(1-99)", &idx
);
19794 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19795 cl_name_or_number
= argv
[idx
]->arg
;
19797 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19800 XFREE(MTYPE_TMP
, str
);
19803 community_list_perror(vty
, ret
);
19804 return CMD_WARNING_CONFIG_FAILED
;
19807 return CMD_SUCCESS
;
19810 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19811 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19812 NO_STR BGP_STR COMMUNITY_LIST_STR
19813 "Community list number (standard)\n"
19814 "Add an standard community-list entry\n"
19815 "Community list name\n")
19817 /*community-list expanded */
19818 DEFUN (community_list_expanded_all
,
19819 bgp_community_list_expanded_all_cmd
,
19820 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19823 "Community list number (expanded)\n"
19824 "Add an expanded community-list entry\n"
19825 "Community list name\n"
19826 "Sequence number of an entry\n"
19827 "Sequence number\n"
19828 "Specify community to reject\n"
19829 "Specify community to accept\n"
19832 char *cl_name_or_number
= NULL
;
19835 int style
= COMMUNITY_LIST_EXPANDED
;
19838 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19839 seq
= argv
[idx
]->arg
;
19843 argv_find(argv
, argc
, "(100-500)", &idx
);
19844 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19845 cl_name_or_number
= argv
[idx
]->arg
;
19846 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19848 argv_find(argv
, argc
, "AA:NN", &idx
);
19849 char *str
= argv_concat(argv
, argc
, idx
);
19851 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19854 XFREE(MTYPE_TMP
, str
);
19857 /* Display error string. */
19858 community_list_perror(vty
, ret
);
19859 return CMD_WARNING_CONFIG_FAILED
;
19862 return CMD_SUCCESS
;
19865 DEFUN (no_community_list_expanded_all
,
19866 no_bgp_community_list_expanded_all_cmd
,
19867 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19871 "Community list number (expanded)\n"
19872 "Add an expanded community-list entry\n"
19873 "Community list name\n"
19874 "Sequence number of an entry\n"
19875 "Sequence number\n"
19876 "Specify community to reject\n"
19877 "Specify community to accept\n"
19880 char *cl_name_or_number
= NULL
;
19884 int style
= COMMUNITY_LIST_EXPANDED
;
19887 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19888 seq
= argv
[idx
]->arg
;
19891 argv_find(argv
, argc
, "permit", &idx
);
19892 argv_find(argv
, argc
, "deny", &idx
);
19895 direct
= argv_find(argv
, argc
, "permit", &idx
)
19900 argv_find(argv
, argc
, "AA:NN", &idx
);
19901 str
= argv_concat(argv
, argc
, idx
);
19905 argv_find(argv
, argc
, "(100-500)", &idx
);
19906 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19907 cl_name_or_number
= argv
[idx
]->arg
;
19909 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19912 XFREE(MTYPE_TMP
, str
);
19915 community_list_perror(vty
, ret
);
19916 return CMD_WARNING_CONFIG_FAILED
;
19919 return CMD_SUCCESS
;
19922 ALIAS(no_community_list_expanded_all
,
19923 no_bgp_community_list_expanded_all_list_cmd
,
19924 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19925 NO_STR BGP_STR COMMUNITY_LIST_STR
19926 "Community list number (expanded)\n"
19927 "Add an expanded community-list entry\n"
19928 "Community list name\n")
19930 /* Return configuration string of community-list entry. */
19931 static const char *community_list_config_str(struct community_entry
*entry
)
19938 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19939 str
= community_str(entry
->u
.com
, false, false);
19940 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19941 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19943 str
= entry
->config
;
19948 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19950 struct community_entry
*entry
;
19952 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19953 if (entry
== list
->head
) {
19954 if (all_digit(list
->name
))
19955 vty_out(vty
, "Community %s list %s\n",
19956 entry
->style
== COMMUNITY_LIST_STANDARD
19958 : "(expanded) access",
19961 vty_out(vty
, "Named Community %s list %s\n",
19962 entry
->style
== COMMUNITY_LIST_STANDARD
19968 vty_out(vty
, " %s\n",
19969 community_direct_str(entry
->direct
));
19971 vty_out(vty
, " %s %s\n",
19972 community_direct_str(entry
->direct
),
19973 community_list_config_str(entry
));
19977 DEFUN (show_community_list
,
19978 show_bgp_community_list_cmd
,
19979 "show bgp community-list",
19982 "List community-list\n")
19984 struct community_list
*list
;
19985 struct community_list_master
*cm
;
19987 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19989 return CMD_SUCCESS
;
19991 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19992 community_list_show(vty
, list
);
19994 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19995 community_list_show(vty
, list
);
19997 return CMD_SUCCESS
;
20000 DEFUN (show_community_list_arg
,
20001 show_bgp_community_list_arg_cmd
,
20002 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20005 "List community-list\n"
20006 "Community-list number\n"
20007 "Community-list name\n"
20008 "Detailed information on community-list\n")
20010 int idx_comm_list
= 3;
20011 struct community_list
*list
;
20013 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20014 COMMUNITY_LIST_MASTER
);
20016 vty_out(vty
, "%% Can't find community-list\n");
20017 return CMD_WARNING
;
20020 community_list_show(vty
, list
);
20022 return CMD_SUCCESS
;
20026 * Large Community code.
20028 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20029 struct cmd_token
**argv
, int style
,
20030 int reject_all_digit_name
)
20039 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20040 seq
= argv
[idx
]->arg
;
20043 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20046 /* All digit name check. */
20048 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20049 argv_find(argv
, argc
, "(1-99)", &idx
);
20050 argv_find(argv
, argc
, "(100-500)", &idx
);
20051 cl_name
= argv
[idx
]->arg
;
20052 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20053 vty_out(vty
, "%% Community name cannot have all digits\n");
20054 return CMD_WARNING_CONFIG_FAILED
;
20058 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20059 argv_find(argv
, argc
, "LINE", &idx
);
20060 /* Concat community string argument. */
20062 str
= argv_concat(argv
, argc
, idx
);
20066 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20068 /* Free temporary community list string allocated by
20070 XFREE(MTYPE_TMP
, str
);
20073 community_list_perror(vty
, ret
);
20074 return CMD_WARNING_CONFIG_FAILED
;
20076 return CMD_SUCCESS
;
20079 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20080 struct cmd_token
**argv
, int style
)
20088 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20089 seq
= argv
[idx
]->arg
;
20092 argv_find(argv
, argc
, "permit", &idx
);
20093 argv_find(argv
, argc
, "deny", &idx
);
20096 /* Check the list direct. */
20097 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20098 direct
= COMMUNITY_PERMIT
;
20100 direct
= COMMUNITY_DENY
;
20103 argv_find(argv
, argc
, "LINE", &idx
);
20104 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20105 /* Concat community string argument. */
20106 str
= argv_concat(argv
, argc
, idx
);
20110 argv_find(argv
, argc
, "(1-99)", &idx
);
20111 argv_find(argv
, argc
, "(100-500)", &idx
);
20112 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20114 /* Unset community list. */
20115 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20118 /* Free temporary community list string allocated by
20120 XFREE(MTYPE_TMP
, str
);
20123 community_list_perror(vty
, ret
);
20124 return CMD_WARNING_CONFIG_FAILED
;
20127 return CMD_SUCCESS
;
20130 /* "large-community-list" keyword help string. */
20131 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20132 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20134 DEFUN (lcommunity_list_standard
,
20135 bgp_lcommunity_list_standard_cmd
,
20136 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20138 LCOMMUNITY_LIST_STR
20139 "Large Community list number (standard)\n"
20140 "Sequence number of an entry\n"
20141 "Sequence number\n"
20142 "Specify large community to reject\n"
20143 "Specify large community to accept\n"
20144 LCOMMUNITY_VAL_STR
)
20146 return lcommunity_list_set_vty(vty
, argc
, argv
,
20147 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20150 DEFUN (lcommunity_list_expanded
,
20151 bgp_lcommunity_list_expanded_cmd
,
20152 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20154 LCOMMUNITY_LIST_STR
20155 "Large Community list number (expanded)\n"
20156 "Sequence number of an entry\n"
20157 "Sequence number\n"
20158 "Specify large community to reject\n"
20159 "Specify large community to accept\n"
20160 "An ordered list as a regular-expression\n")
20162 return lcommunity_list_set_vty(vty
, argc
, argv
,
20163 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20166 DEFUN (lcommunity_list_name_standard
,
20167 bgp_lcommunity_list_name_standard_cmd
,
20168 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20170 LCOMMUNITY_LIST_STR
20171 "Specify standard large-community-list\n"
20172 "Large Community list name\n"
20173 "Sequence number of an entry\n"
20174 "Sequence number\n"
20175 "Specify large community to reject\n"
20176 "Specify large community to accept\n"
20177 LCOMMUNITY_VAL_STR
)
20179 return lcommunity_list_set_vty(vty
, argc
, argv
,
20180 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20183 DEFUN (lcommunity_list_name_expanded
,
20184 bgp_lcommunity_list_name_expanded_cmd
,
20185 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20187 LCOMMUNITY_LIST_STR
20188 "Specify expanded large-community-list\n"
20189 "Large Community list name\n"
20190 "Sequence number of an entry\n"
20191 "Sequence number\n"
20192 "Specify large community to reject\n"
20193 "Specify large community to accept\n"
20194 "An ordered list as a regular-expression\n")
20196 return lcommunity_list_set_vty(vty
, argc
, argv
,
20197 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20200 DEFUN (no_lcommunity_list_all
,
20201 no_bgp_lcommunity_list_all_cmd
,
20202 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20205 LCOMMUNITY_LIST_STR
20206 "Large Community list number (standard)\n"
20207 "Large Community list number (expanded)\n"
20208 "Large Community list name\n")
20210 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20211 LARGE_COMMUNITY_LIST_STANDARD
);
20214 DEFUN (no_lcommunity_list_name_standard_all
,
20215 no_bgp_lcommunity_list_name_standard_all_cmd
,
20216 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20219 LCOMMUNITY_LIST_STR
20220 "Specify standard large-community-list\n"
20221 "Large Community list name\n")
20223 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20224 LARGE_COMMUNITY_LIST_STANDARD
);
20227 DEFUN (no_lcommunity_list_name_expanded_all
,
20228 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20229 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20232 LCOMMUNITY_LIST_STR
20233 "Specify expanded large-community-list\n"
20234 "Large Community list name\n")
20236 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20237 LARGE_COMMUNITY_LIST_EXPANDED
);
20240 DEFUN (no_lcommunity_list_standard
,
20241 no_bgp_lcommunity_list_standard_cmd
,
20242 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20245 LCOMMUNITY_LIST_STR
20246 "Large Community list number (standard)\n"
20247 "Sequence number of an entry\n"
20248 "Sequence number\n"
20249 "Specify large community to reject\n"
20250 "Specify large community to accept\n"
20251 LCOMMUNITY_VAL_STR
)
20253 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20254 LARGE_COMMUNITY_LIST_STANDARD
);
20257 DEFUN (no_lcommunity_list_expanded
,
20258 no_bgp_lcommunity_list_expanded_cmd
,
20259 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20262 LCOMMUNITY_LIST_STR
20263 "Large Community list number (expanded)\n"
20264 "Sequence number of an entry\n"
20265 "Sequence number\n"
20266 "Specify large community to reject\n"
20267 "Specify large community to accept\n"
20268 "An ordered list as a regular-expression\n")
20270 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20271 LARGE_COMMUNITY_LIST_EXPANDED
);
20274 DEFUN (no_lcommunity_list_name_standard
,
20275 no_bgp_lcommunity_list_name_standard_cmd
,
20276 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20279 LCOMMUNITY_LIST_STR
20280 "Specify standard large-community-list\n"
20281 "Large Community list name\n"
20282 "Sequence number of an entry\n"
20283 "Sequence number\n"
20284 "Specify large community to reject\n"
20285 "Specify large community to accept\n"
20286 LCOMMUNITY_VAL_STR
)
20288 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20289 LARGE_COMMUNITY_LIST_STANDARD
);
20292 DEFUN (no_lcommunity_list_name_expanded
,
20293 no_bgp_lcommunity_list_name_expanded_cmd
,
20294 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20297 LCOMMUNITY_LIST_STR
20298 "Specify expanded large-community-list\n"
20299 "Large community list name\n"
20300 "Sequence number of an entry\n"
20301 "Sequence number\n"
20302 "Specify large community to reject\n"
20303 "Specify large community to accept\n"
20304 "An ordered list as a regular-expression\n")
20306 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20307 LARGE_COMMUNITY_LIST_EXPANDED
);
20310 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20312 struct community_entry
*entry
;
20314 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20315 if (entry
== list
->head
) {
20316 if (all_digit(list
->name
))
20317 vty_out(vty
, "Large community %s list %s\n",
20319 LARGE_COMMUNITY_LIST_STANDARD
20321 : "(expanded) access",
20325 "Named large community %s list %s\n",
20327 LARGE_COMMUNITY_LIST_STANDARD
20333 vty_out(vty
, " %s\n",
20334 community_direct_str(entry
->direct
));
20336 vty_out(vty
, " %s %s\n",
20337 community_direct_str(entry
->direct
),
20338 community_list_config_str(entry
));
20342 DEFUN (show_lcommunity_list
,
20343 show_bgp_lcommunity_list_cmd
,
20344 "show bgp large-community-list",
20347 "List large-community list\n")
20349 struct community_list
*list
;
20350 struct community_list_master
*cm
;
20352 cm
= community_list_master_lookup(bgp_clist
,
20353 LARGE_COMMUNITY_LIST_MASTER
);
20355 return CMD_SUCCESS
;
20357 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20358 lcommunity_list_show(vty
, list
);
20360 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20361 lcommunity_list_show(vty
, list
);
20363 return CMD_SUCCESS
;
20366 DEFUN (show_lcommunity_list_arg
,
20367 show_bgp_lcommunity_list_arg_cmd
,
20368 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20371 "List large-community list\n"
20372 "Large-community-list number\n"
20373 "Large-community-list name\n"
20374 "Detailed information on large-community-list\n")
20376 struct community_list
*list
;
20378 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20379 LARGE_COMMUNITY_LIST_MASTER
);
20381 vty_out(vty
, "%% Can't find large-community-list\n");
20382 return CMD_WARNING
;
20385 lcommunity_list_show(vty
, list
);
20387 return CMD_SUCCESS
;
20390 /* "extcommunity-list" keyword help string. */
20391 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20392 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20394 DEFUN (extcommunity_list_standard
,
20395 bgp_extcommunity_list_standard_cmd
,
20396 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20398 EXTCOMMUNITY_LIST_STR
20399 "Extended Community list number (standard)\n"
20400 "Specify standard extcommunity-list\n"
20401 "Community list name\n"
20402 "Sequence number of an entry\n"
20403 "Sequence number\n"
20404 "Specify community to reject\n"
20405 "Specify community to accept\n"
20406 EXTCOMMUNITY_VAL_STR
)
20408 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20410 char *cl_number_or_name
= NULL
;
20415 argv_find(argv
, argc
, "(1-99)", &idx
);
20416 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20417 cl_number_or_name
= argv
[idx
]->arg
;
20419 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20420 seq
= argv
[idx
]->arg
;
20422 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20424 argv_find(argv
, argc
, "AA:NN", &idx
);
20425 char *str
= argv_concat(argv
, argc
, idx
);
20427 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20430 XFREE(MTYPE_TMP
, str
);
20433 community_list_perror(vty
, ret
);
20434 return CMD_WARNING_CONFIG_FAILED
;
20437 return CMD_SUCCESS
;
20440 DEFUN (extcommunity_list_name_expanded
,
20441 bgp_extcommunity_list_name_expanded_cmd
,
20442 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20444 EXTCOMMUNITY_LIST_STR
20445 "Extended Community list number (expanded)\n"
20446 "Specify expanded extcommunity-list\n"
20447 "Extended Community list name\n"
20448 "Sequence number of an entry\n"
20449 "Sequence number\n"
20450 "Specify community to reject\n"
20451 "Specify community to accept\n"
20452 "An ordered list as a regular-expression\n")
20454 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20456 char *cl_number_or_name
= NULL
;
20460 argv_find(argv
, argc
, "(100-500)", &idx
);
20461 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20462 cl_number_or_name
= argv
[idx
]->arg
;
20464 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20465 seq
= argv
[idx
]->arg
;
20467 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20469 argv_find(argv
, argc
, "LINE", &idx
);
20470 char *str
= argv_concat(argv
, argc
, idx
);
20472 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20475 XFREE(MTYPE_TMP
, str
);
20478 community_list_perror(vty
, ret
);
20479 return CMD_WARNING_CONFIG_FAILED
;
20482 return CMD_SUCCESS
;
20485 DEFUN (no_extcommunity_list_standard_all
,
20486 no_bgp_extcommunity_list_standard_all_cmd
,
20487 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20490 EXTCOMMUNITY_LIST_STR
20491 "Extended Community list number (standard)\n"
20492 "Specify standard extcommunity-list\n"
20493 "Community list name\n"
20494 "Sequence number of an entry\n"
20495 "Sequence number\n"
20496 "Specify community to reject\n"
20497 "Specify community to accept\n"
20498 EXTCOMMUNITY_VAL_STR
)
20500 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20502 char *cl_number_or_name
= NULL
;
20507 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20508 seq
= argv
[idx
]->arg
;
20511 argv_find(argv
, argc
, "permit", &idx
);
20512 argv_find(argv
, argc
, "deny", &idx
);
20514 direct
= argv_find(argv
, argc
, "permit", &idx
)
20519 argv_find(argv
, argc
, "AA:NN", &idx
);
20520 str
= argv_concat(argv
, argc
, idx
);
20524 argv_find(argv
, argc
, "(1-99)", &idx
);
20525 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20526 cl_number_or_name
= argv
[idx
]->arg
;
20528 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20529 seq
, direct
, style
);
20531 XFREE(MTYPE_TMP
, str
);
20534 community_list_perror(vty
, ret
);
20535 return CMD_WARNING_CONFIG_FAILED
;
20538 return CMD_SUCCESS
;
20541 ALIAS(no_extcommunity_list_standard_all
,
20542 no_bgp_extcommunity_list_standard_all_list_cmd
,
20543 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20544 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20545 "Extended Community list number (standard)\n"
20546 "Specify standard extcommunity-list\n"
20547 "Community list name\n")
20549 DEFUN (no_extcommunity_list_expanded_all
,
20550 no_bgp_extcommunity_list_expanded_all_cmd
,
20551 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20554 EXTCOMMUNITY_LIST_STR
20555 "Extended Community list number (expanded)\n"
20556 "Specify expanded extcommunity-list\n"
20557 "Extended Community list name\n"
20558 "Sequence number of an entry\n"
20559 "Sequence number\n"
20560 "Specify community to reject\n"
20561 "Specify community to accept\n"
20562 "An ordered list as a regular-expression\n")
20564 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20566 char *cl_number_or_name
= NULL
;
20571 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20572 seq
= argv
[idx
]->arg
;
20575 argv_find(argv
, argc
, "permit", &idx
);
20576 argv_find(argv
, argc
, "deny", &idx
);
20579 direct
= argv_find(argv
, argc
, "permit", &idx
)
20584 argv_find(argv
, argc
, "LINE", &idx
);
20585 str
= argv_concat(argv
, argc
, idx
);
20589 argv_find(argv
, argc
, "(100-500)", &idx
);
20590 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20591 cl_number_or_name
= argv
[idx
]->arg
;
20593 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20594 seq
, direct
, style
);
20596 XFREE(MTYPE_TMP
, str
);
20599 community_list_perror(vty
, ret
);
20600 return CMD_WARNING_CONFIG_FAILED
;
20603 return CMD_SUCCESS
;
20606 ALIAS(no_extcommunity_list_expanded_all
,
20607 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20608 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20609 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20610 "Extended Community list number (expanded)\n"
20611 "Specify expanded extcommunity-list\n"
20612 "Extended Community list name\n")
20614 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20616 struct community_entry
*entry
;
20618 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20619 if (entry
== list
->head
) {
20620 if (all_digit(list
->name
))
20621 vty_out(vty
, "Extended community %s list %s\n",
20622 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20624 : "(expanded) access",
20628 "Named extended community %s list %s\n",
20629 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20635 vty_out(vty
, " %s\n",
20636 community_direct_str(entry
->direct
));
20638 vty_out(vty
, " %s %s\n",
20639 community_direct_str(entry
->direct
),
20640 community_list_config_str(entry
));
20644 DEFUN (show_extcommunity_list
,
20645 show_bgp_extcommunity_list_cmd
,
20646 "show bgp extcommunity-list",
20649 "List extended-community list\n")
20651 struct community_list
*list
;
20652 struct community_list_master
*cm
;
20654 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20656 return CMD_SUCCESS
;
20658 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20659 extcommunity_list_show(vty
, list
);
20661 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20662 extcommunity_list_show(vty
, list
);
20664 return CMD_SUCCESS
;
20667 DEFUN (show_extcommunity_list_arg
,
20668 show_bgp_extcommunity_list_arg_cmd
,
20669 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20672 "List extended-community list\n"
20673 "Extcommunity-list number\n"
20674 "Extcommunity-list name\n"
20675 "Detailed information on extcommunity-list\n")
20677 int idx_comm_list
= 3;
20678 struct community_list
*list
;
20680 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20681 EXTCOMMUNITY_LIST_MASTER
);
20683 vty_out(vty
, "%% Can't find extcommunity-list\n");
20684 return CMD_WARNING
;
20687 extcommunity_list_show(vty
, list
);
20689 return CMD_SUCCESS
;
20692 /* Display community-list and extcommunity-list configuration. */
20693 static int community_list_config_write(struct vty
*vty
)
20695 struct community_list
*list
;
20696 struct community_entry
*entry
;
20697 struct community_list_master
*cm
;
20700 /* Community-list. */
20701 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20703 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20704 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20706 "bgp community-list %s seq %" PRId64
" %s %s\n",
20707 list
->name
, entry
->seq
,
20708 community_direct_str(entry
->direct
),
20709 community_list_config_str(entry
));
20712 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20713 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20715 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20716 entry
->style
== COMMUNITY_LIST_STANDARD
20719 list
->name
, entry
->seq
,
20720 community_direct_str(entry
->direct
),
20721 community_list_config_str(entry
));
20725 /* Extcommunity-list. */
20726 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20728 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20729 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20731 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20732 list
->name
, entry
->seq
,
20733 community_direct_str(entry
->direct
),
20734 community_list_config_str(entry
));
20737 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20738 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20740 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20741 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20744 list
->name
, entry
->seq
,
20745 community_direct_str(entry
->direct
),
20746 community_list_config_str(entry
));
20751 /* lcommunity-list. */
20752 cm
= community_list_master_lookup(bgp_clist
,
20753 LARGE_COMMUNITY_LIST_MASTER
);
20755 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20756 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20758 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20759 list
->name
, entry
->seq
,
20760 community_direct_str(entry
->direct
),
20761 community_list_config_str(entry
));
20764 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20765 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20767 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20769 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20772 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20773 community_list_config_str(entry
));
20780 static int community_list_config_write(struct vty
*vty
);
20781 static struct cmd_node community_list_node
= {
20782 .name
= "community list",
20783 .node
= COMMUNITY_LIST_NODE
,
20785 .config_write
= community_list_config_write
,
20788 static void community_list_vty(void)
20790 install_node(&community_list_node
);
20792 /* Community-list. */
20793 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20794 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20795 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20796 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20797 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20798 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20799 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20800 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20802 /* Extcommunity-list. */
20803 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20804 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20805 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20806 install_element(CONFIG_NODE
,
20807 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20808 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20809 install_element(CONFIG_NODE
,
20810 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20811 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20812 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20814 /* Large Community List */
20815 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20816 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20817 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20818 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20819 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20820 install_element(CONFIG_NODE
,
20821 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20822 install_element(CONFIG_NODE
,
20823 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20824 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20825 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20826 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20827 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20828 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20829 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20831 bgp_community_list_command_completion_setup();
20834 static struct cmd_node community_alias_node
= {
20835 .name
= "community alias",
20836 .node
= COMMUNITY_ALIAS_NODE
,
20838 .config_write
= bgp_community_alias_write
,
20841 void community_alias_vty(void)
20843 install_node(&community_alias_node
);
20845 /* Community-list. */
20846 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20848 bgp_community_alias_command_completion_setup();